diff --git a/bin/cp/extern.h b/bin/cp/extern.h index f42315f07390..a5b86c12b2f9 100644 --- a/bin/cp/extern.h +++ b/bin/cp/extern.h @@ -1,54 +1,53 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/1/94 - * $FreeBSD$ */ typedef struct { char *p_end; /* pointer to NULL at end of path */ char *target_end; /* pointer to end of target base */ char p_path[PATH_MAX]; /* pointer to the start of a path */ } PATH_T; extern PATH_T to; extern int fflag, iflag, lflag, nflag, pflag, sflag, vflag; extern volatile sig_atomic_t info; __BEGIN_DECLS int copy_fifo(struct stat *, int); int copy_file(const FTSENT *, int); int copy_link(const FTSENT *, int); int copy_special(struct stat *, int); int setfile(struct stat *, int); int preserve_dir_acls(struct stat *, char *, char *); int preserve_fd_acls(int, int); void usage(void) __dead2; __END_DECLS diff --git a/bin/dd/dd.h b/bin/dd/dd.h index ea606f288f3f..ce00412073e3 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -1,115 +1,114 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego and Lance * Visser of Convex Computer Corporation. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)dd.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ */ /* Input/output stream state. */ typedef struct { u_char *db; /* buffer address */ u_char *dbp; /* current buffer I/O address */ ssize_t dbcnt; /* current buffer byte count */ ssize_t dbrcnt; /* last read byte count */ ssize_t dbsz; /* block size */ #define ISCHR 0x01 /* character device (warn on short) */ #define ISPIPE 0x02 /* pipe-like (see position.c) */ #define ISTAPE 0x04 /* tape */ #define ISSEEK 0x08 /* valid to seek on */ #define NOREAD 0x10 /* not readable */ #define ISTRUNC 0x20 /* valid to ftruncate() */ u_int flags; const char *name; /* name */ int fd; /* file descriptor */ off_t offset; /* # of blocks to skip */ off_t seek_offset; /* offset of last seek past output hole */ } IO; typedef struct { uintmax_t in_full; /* # of full input blocks */ uintmax_t in_part; /* # of partial input blocks */ uintmax_t out_full; /* # of full output blocks */ uintmax_t out_part; /* # of partial output blocks */ uintmax_t trunc; /* # of truncated records */ uintmax_t swab; /* # of odd-length swab blocks */ uintmax_t bytes; /* # of bytes written */ struct timespec start; /* start time of dd */ } STAT; /* Flags (in ddflags). */ #define C_ASCII 0x0000000000000001ULL #define C_BLOCK 0x0000000000000002ULL #define C_BS 0x0000000000000004ULL #define C_CBS 0x0000000000000008ULL #define C_COUNT 0x0000000000000010ULL #define C_EBCDIC 0x0000000000000020ULL #define C_FILES 0x0000000000000040ULL #define C_IBS 0x0000000000000080ULL #define C_IF 0x0000000000000100ULL #define C_LCASE 0x0000000000000200ULL #define C_NOERROR 0x0000000000000400ULL #define C_NOTRUNC 0x0000000000000800ULL #define C_OBS 0x0000000000001000ULL #define C_OF 0x0000000000002000ULL #define C_OSYNC 0x0000000000004000ULL #define C_PAREVEN 0x0000000000008000ULL #define C_PARNONE 0x0000000000010000ULL #define C_PARODD 0x0000000000020000ULL #define C_PARSET 0x0000000000040000ULL #define C_SEEK 0x0000000000080000ULL #define C_SKIP 0x0000000000100000ULL #define C_SPARSE 0x0000000000200000ULL #define C_SWAB 0x0000000000400000ULL #define C_SYNC 0x0000000000800000ULL #define C_UCASE 0x0000000001000000ULL #define C_UNBLOCK 0x0000000002000000ULL #define C_FILL 0x0000000004000000ULL #define C_STATUS 0x0000000008000000ULL #define C_NOXFER 0x0000000010000000ULL #define C_NOINFO 0x0000000020000000ULL #define C_PROGRESS 0x0000000040000000ULL #define C_FSYNC 0x0000000080000000ULL #define C_FDATASYNC 0x0000000100000000ULL #define C_OFSYNC 0x0000000200000000ULL #define C_IFULLBLOCK 0x0000000400000000ULL #define C_IDIRECT 0x0000000800000000ULL #define C_ODIRECT 0x0000001000000000ULL #define C_PARITY (C_PAREVEN | C_PARODD | C_PARNONE | C_PARSET) #define BISZERO(p, s) ((s) > 0 && *((const char *)p) == 0 && !memcmp( \ (const void *)(p), (const void *) \ ((const char *)p + 1), (s) - 1)) diff --git a/bin/dd/extern.h b/bin/dd/extern.h index c9de42a152d5..760eecb14b59 100644 --- a/bin/dd/extern.h +++ b/bin/dd/extern.h @@ -1,74 +1,73 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego and Lance * Visser of Convex Computer Corporation. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ */ void block(void); void block_close(void); void dd_out(int); void def(void); void def_close(void); void jcl(char **); void pos_in(void); void pos_out(void); double secs_elapsed(void); void progress(void); void summary(void); void sigalarm_handler(int); void siginfo_handler(int); void prepare_io(void); void before_io(void); void after_io(void); void unblock(void); void unblock_close(void); extern IO in, out; extern STAT st; extern void (*cfunc)(void); extern uintmax_t cpy_cnt; extern size_t cbsz; extern uint64_t ddflags; extern size_t speed; extern uintmax_t files_cnt; extern const u_char *ctab; extern const u_char a2e_32V[], a2e_POSIX[]; extern const u_char e2a_32V[], e2a_POSIX[]; extern const u_char a2ibm_32V[], a2ibm_POSIX[]; extern u_char casetab[]; extern char fill_char; extern volatile sig_atomic_t need_summary; extern volatile sig_atomic_t need_progress; extern volatile sig_atomic_t kill_signal; diff --git a/bin/ed/ed.h b/bin/ed/ed.h index 4dcf5eb36f37..e4562be8d331 100644 --- a/bin/ed/ed.h +++ b/bin/ed/ed.h @@ -1,273 +1,272 @@ /* ed.h: type and constant definitions for the ed editor. */ /*- * Copyright (c) 1993 Andrew Moore * 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. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ed.h,v 1.5 1994/02/01 00:34:39 alm Exp - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #define ERR (-2) #define EMOD (-3) #define FATAL (-4) #define MINBUFSZ 512 /* minimum buffer size - must be > 0 */ #define SE_MAX 30 /* max subexpressions in a regular expression */ #ifdef INT_MAX # define LINECHARS INT_MAX /* max chars per line */ #else # define LINECHARS MAXINT /* max chars per line */ #endif /* gflags */ #define GLB 001 /* global command */ #define GPR 002 /* print after command */ #define GLS 004 /* list after command */ #define GNP 010 /* enumerate after command */ #define GSG 020 /* global substitute */ typedef regex_t pattern_t; /* Line node */ typedef struct line { struct line *q_forw; struct line *q_back; off_t seek; /* address of line in scratch buffer */ int len; /* length of line */ } line_t; typedef struct undo { /* type of undo nodes */ #define UADD 0 #define UDEL 1 #define UMOV 2 #define VMOV 3 int type; /* command type */ line_t *h; /* head of list */ line_t *t; /* tail of list */ } undo_t; #ifndef max # define max(a,b) ((a) > (b) ? (a) : (b)) #endif #ifndef min # define min(a,b) ((a) < (b) ? (a) : (b)) #endif #define INC_MOD(l, k) ((l) + 1 > (k) ? 0 : (l) + 1) #define DEC_MOD(l, k) ((l) - 1 < 0 ? (k) : (l) - 1) /* SPL1: disable some interrupts (requires reliable signals) */ #define SPL1() mutex++ /* SPL0: enable all interrupts; check sigflags (requires reliable signals) */ #define SPL0() \ if (--mutex == 0) { \ if (sigflags & (1 << (SIGHUP - 1))) handle_hup(SIGHUP); \ if (sigflags & (1 << (SIGINT - 1))) handle_int(SIGINT); \ } /* STRTOL: convert a string to long */ #define STRTOL(i, p) { \ if (((i = strtol(p, &p, 10)) == LONG_MIN || i == LONG_MAX) && \ errno == ERANGE) { \ errmsg = "number out of range"; \ i = 0; \ return ERR; \ } \ } #if defined(sun) || defined(NO_REALLOC_NULL) /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ size_t ti = (n); \ char *ts; \ SPL1(); \ if ((b) != NULL) { \ if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \ fprintf(stderr, "%s\n", strerror(errno)); \ errmsg = "out of memory"; \ SPL0(); \ return err; \ } \ } else { \ if ((ts = (char *) malloc(ti += max((i), MINBUFSZ))) == NULL) { \ fprintf(stderr, "%s\n", strerror(errno)); \ errmsg = "out of memory"; \ SPL0(); \ return err; \ } \ } \ (n) = ti; \ (b) = ts; \ SPL0(); \ } #else /* NO_REALLOC_NULL */ /* REALLOC: assure at least a minimum size for buffer b */ #define REALLOC(b,n,i,err) \ if ((i) > (n)) { \ size_t ti = (n); \ char *ts; \ SPL1(); \ if ((ts = (char *) realloc((b), ti += max((i), MINBUFSZ))) == NULL) { \ fprintf(stderr, "%s\n", strerror(errno)); \ errmsg = "out of memory"; \ SPL0(); \ return err; \ } \ (n) = ti; \ (b) = ts; \ SPL0(); \ } #endif /* NO_REALLOC_NULL */ /* REQUE: link pred before succ */ #define REQUE(pred, succ) (pred)->q_forw = (succ), (succ)->q_back = (pred) /* INSQUE: insert elem in circular queue after pred */ #define INSQUE(elem, pred) \ { \ REQUE((elem), (pred)->q_forw); \ REQUE((pred), elem); \ } /* REMQUE: remove_lines elem from circular queue */ #define REMQUE(elem) REQUE((elem)->q_back, (elem)->q_forw); /* NUL_TO_NEWLINE: overwrite ASCII NULs with newlines */ #define NUL_TO_NEWLINE(s, l) translit_text(s, l, '\0', '\n') /* NEWLINE_TO_NUL: overwrite newlines with ASCII NULs */ #define NEWLINE_TO_NUL(s, l) translit_text(s, l, '\n', '\0') /* Local Function Declarations */ void add_line_node(line_t *); int append_lines(long); int apply_subst_template(const char *, regmatch_t *, int, int); int build_active_list(int); int cbc_decode(unsigned char *, FILE *); int cbc_encode(unsigned char *, int, FILE *); int check_addr_range(long, long); void clear_active_list(void); void clear_undo_stack(void); int close_sbuf(void); int copy_lines(long); int delete_lines(long, long); int display_lines(long, long, int); line_t *dup_line_node(line_t *); int exec_command(void); long exec_global(int, int); int extract_addr_range(void); char *extract_pattern(int); int extract_subst_tail(int *, long *); char *extract_subst_template(void); int filter_lines(long, long, char *); line_t *get_addressed_line_node(long); pattern_t *get_compiled_pattern(void); char *get_extended_line(int *, int); char *get_filename(void); int get_keyword(void); long get_line_node_addr(line_t *); long get_matching_node_addr(pattern_t *, int); long get_marked_node_addr(int); char *get_sbuf_line(line_t *); int get_shell_command(void); int get_stream_line(FILE *); int get_tty_line(void); void handle_hup(int); void handle_int(int); void handle_winch(int); int has_trailing_escape(char *, char *); int hex_to_binary(int, int); void init_buffers(void); int is_legal_filename(char *); int join_lines(long, long); int mark_line_node(line_t *, int); int move_lines(long); line_t *next_active_node(void); long next_addr(void); int open_sbuf(void); char *parse_char_class(char *); int pop_undo_stack(void); undo_t *push_undo_stack(int, long, long); const char *put_sbuf_line(const char *); int put_stream_line(FILE *, const char *, int); int put_tty_line(const char *, int, long, int); void quit(int); long read_file(char *, long); long read_stream(FILE *, long); int search_and_replace(pattern_t *, int, int); int set_active_node(line_t *); void signal_hup(int); void signal_int(int); char *strip_escapes(char *); int substitute_matching_text(pattern_t *, line_t *, int, int); char *translit_text(char *, int, int, int); void unmark_line_node(line_t *); void unset_active_nodes(line_t *, line_t *); long write_file(char *, const char *, long, long); long write_stream(FILE *, long, long); /* global buffers */ extern char stdinbuf[]; extern char *ibuf; extern char *ibufp; extern int ibufsz; /* global flags */ extern int isbinary; extern int isglobal; extern int modified; extern int mutex; extern int sigflags; /* global vars */ extern long addr_last; extern long current_addr; extern const char *errmsg; extern long first_addr; extern int lineno; extern long second_addr; extern long u_addr_last; extern long u_current_addr; extern long rows; extern int cols; extern int newline_added; extern int scripted; extern int patlock; diff --git a/bin/ls/extern.h b/bin/ls/extern.h index 0e577a885474..c3a4eafc353d 100644 --- a/bin/ls/extern.h +++ b/bin/ls/extern.h @@ -1,80 +1,79 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)extern.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ #include int acccmp(const FTSENT *, const FTSENT *); int revacccmp(const FTSENT *, const FTSENT *); int birthcmp(const FTSENT *, const FTSENT *); int revbirthcmp(const FTSENT *, const FTSENT *); int modcmp(const FTSENT *, const FTSENT *); int revmodcmp(const FTSENT *, const FTSENT *); int namecmp(const FTSENT *, const FTSENT *); int revnamecmp(const FTSENT *, const FTSENT *); int verscmp(const FTSENT *, const FTSENT *); int revverscmp(const FTSENT *, const FTSENT *); int statcmp(const FTSENT *, const FTSENT *); int revstatcmp(const FTSENT *, const FTSENT *); int sizecmp(const FTSENT *, const FTSENT *); int revsizecmp(const FTSENT *, const FTSENT *); void printcol(const DISPLAY *); void printlong(const DISPLAY *); int printname(const char *); void printscol(const DISPLAY *); void printstream(const DISPLAY *); void usage(void); int prn_normal(const char *); size_t len_octal(const char *, int); int prn_octal(const char *); int prn_printable(const char *); #ifdef COLORLS void parsecolors(const char *cs); void colorquit(int); extern char *ansi_fgcol; extern char *ansi_bgcol; extern char *ansi_coloff; extern char *attrs_off; extern char *enter_bold; extern char *enter_underline; extern int colorflag; extern bool explicitansi; #define COLORFLAG_NEVER 0 #define COLORFLAG_AUTO 1 #define COLORFLAG_ALWAYS 2 #endif extern int termwidth; diff --git a/bin/ls/ls.h b/bin/ls/ls.h index 1f19858720bf..79e917545386 100644 --- a/bin/ls/ls.h +++ b/bin/ls/ls.h @@ -1,90 +1,89 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Michael Fischbein. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)ls.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ #define NO_PRINT 1 #define HUMANVALSTR_LEN 5 extern long blocksize; /* block size units */ extern int f_accesstime; /* use time of last access */ extern int f_birthtime; /* use time of file creation */ extern int f_flags; /* show flags associated with a file */ extern int f_humanval; /* show human-readable file sizes */ extern int f_label; /* show MAC label */ extern int f_inode; /* print inode */ extern int f_longform; /* long listing format */ extern int f_octal; /* print unprintables in octal */ extern int f_octal_escape; /* like f_octal but use C escapes if possible */ extern int f_nonprint; /* show unprintables as ? */ extern int f_samesort; /* sort time and name in same direction */ extern int f_sectime; /* print the real time for all files */ extern int f_size; /* list size in short listing */ extern int f_slash; /* append a '/' if the file is a directory */ extern int f_sortacross; /* sort across rows, not down columns */ extern int f_sowner; /* disable showing the owner's name */ extern int f_statustime; /* use time of last mode change */ extern int f_thousands; /* show file sizes with thousands separators */ extern char *f_timeformat; /* user-specified time format */ extern int f_notabs; /* don't use tab-separated multi-col output */ extern int f_type; /* add type character for non-regular files */ #ifdef COLORLS extern int f_color; /* add type in color for non-regular files */ #endif typedef struct { FTSENT *list; u_long btotal; int entries; int maxlen; u_int s_block; u_int s_flags; u_int s_label; u_int s_group; u_int s_inode; u_int s_nlink; u_int s_size; u_int s_user; } DISPLAY; typedef struct { char *user; char *group; char *flags; char *label; char data[1]; } NAMES; diff --git a/bin/pax/cache.h b/bin/pax/cache.h index 8a7cca9f457a..d2045f51516a 100644 --- a/bin/pax/cache.h +++ b/bin/pax/cache.h @@ -1,73 +1,72 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)cache.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * Constants and data structures used to implement group and password file * caches. Traditional passwd/group cache routines perform quite poorly with * archives. The chances of hitting a valid lookup with an archive is quite a * bit worse than with files already resident on the file system. These misses * create a MAJOR performance cost. To address this problem, these routines * cache both hits and misses. * * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME */ #define UNMLEN 32 /* >= user name found in any protocol */ #define GNMLEN 32 /* >= group name found in any protocol */ #define UID_SZ 317 /* size of user_name/uid cache */ #define UNM_SZ 317 /* size of user_name/uid cache */ #define GID_SZ 251 /* size of gid cache */ #define GNM_SZ 317 /* size of group name cache */ #define VALID 1 /* entry and name are valid */ #define INVALID 2 /* entry valid, name NOT valid */ /* * Node structures used in the user, group, uid, and gid caches. */ typedef struct uidc { int valid; /* is this a valid or a miss entry */ char name[UNMLEN]; /* uid name */ uid_t uid; /* cached uid */ } UIDC; typedef struct gidc { int valid; /* is this a valid or a miss entry */ char name[GNMLEN]; /* gid name */ gid_t gid; /* cached gid */ } GIDC; diff --git a/bin/pax/cpio.h b/bin/pax/cpio.h index e5d61dea36fb..a5976d9b7a63 100644 --- a/bin/pax/cpio.h +++ b/bin/pax/cpio.h @@ -1,150 +1,149 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)cpio.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * Defines common to all versions of cpio */ #define TRAILER "TRAILER!!!" /* name in last archive record */ /* * Header encoding of the different file types */ #define C_ISDIR 040000 /* Directory */ #define C_ISFIFO 010000 /* FIFO */ #define C_ISREG 0100000 /* Regular file */ #define C_ISBLK 060000 /* Block special file */ #define C_ISCHR 020000 /* Character special file */ #define C_ISCTG 0110000 /* Reserved for contiguous files */ #define C_ISLNK 0120000 /* Reserved for symbolic links */ #define C_ISOCK 0140000 /* Reserved for sockets */ #define C_IFMT 0170000 /* type of file */ /* * Data Interchange Format - Extended cpio header format - POSIX 1003.1-1990 */ typedef struct { char c_magic[6]; /* magic cookie */ char c_dev[6]; /* device number */ char c_ino[6]; /* inode number */ char c_mode[6]; /* file type/access */ char c_uid[6]; /* owners uid */ char c_gid[6]; /* owners gid */ char c_nlink[6]; /* # of links at archive creation */ char c_rdev[6]; /* block/char major/minor # */ char c_mtime[11]; /* modification time */ char c_namesize[6]; /* length of pathname */ char c_filesize[11]; /* length of file in bytes */ } HD_CPIO __aligned(1); #define MAGIC 070707 /* transportable archive id */ #ifdef _PAX_ #define AMAGIC "070707" /* ascii equivalent string of MAGIC */ #define CPIO_MASK 0x3ffff /* bits valid in the dev/ino fields */ /* used for dev/inode remaps */ #endif /* _PAX_ */ /* * Binary cpio header structure * * CAUTION! CAUTION! CAUTION! * Each field really represents a 16 bit short (NOT ASCII). Described as * an array of chars in an attempt to improve portability!! */ typedef struct { u_char h_magic[2]; u_char h_dev[2]; u_char h_ino[2]; u_char h_mode[2]; u_char h_uid[2]; u_char h_gid[2]; u_char h_nlink[2]; u_char h_rdev[2]; u_char h_mtime_1[2]; u_char h_mtime_2[2]; u_char h_namesize[2]; u_char h_filesize_1[2]; u_char h_filesize_2[2]; } HD_BCPIO __aligned(1); #ifdef _PAX_ /* * extraction and creation macros for binary cpio */ #define SHRT_EXT(ch) ((((unsigned)(ch)[0])<<8) | (((unsigned)(ch)[1])&0xff)) #define RSHRT_EXT(ch) ((((unsigned)(ch)[1])<<8) | (((unsigned)(ch)[0])&0xff)) #define CHR_WR_0(val) ((char)(((val) >> 24) & 0xff)) #define CHR_WR_1(val) ((char)(((val) >> 16) & 0xff)) #define CHR_WR_2(val) ((char)(((val) >> 8) & 0xff)) #define CHR_WR_3(val) ((char)((val) & 0xff)) /* * binary cpio masks and pads */ #define BCPIO_PAD(x) ((2 - ((x) & 1)) & 1) /* pad to next 2 byte word */ #define BCPIO_MASK 0xffff /* mask for dev/ino fields */ #endif /* _PAX_ */ /* * System VR4 cpio header structure (with/without file data crc) */ typedef struct { char c_magic[6]; /* magic cookie */ char c_ino[8]; /* inode number */ char c_mode[8]; /* file type/access */ char c_uid[8]; /* owners uid */ char c_gid[8]; /* owners gid */ char c_nlink[8]; /* # of links at archive creation */ char c_mtime[8]; /* modification time */ char c_filesize[8]; /* length of file in bytes */ char c_maj[8]; /* block/char major # */ char c_min[8]; /* block/char minor # */ char c_rmaj[8]; /* special file major # */ char c_rmin[8]; /* special file minor # */ char c_namesize[8]; /* length of pathname */ char c_chksum[8]; /* 0 OR CRC of bytes of FILE data */ } HD_VCPIO __aligned(1); #define VMAGIC 070701 /* sVr4 new portable archive id */ #define VCMAGIC 070702 /* sVr4 new portable archive id CRC */ #ifdef _PAX_ #define AVMAGIC "070701" /* ascii string of above */ #define AVCMAGIC "070702" /* ascii string of above */ #define VCPIO_PAD(x) ((4 - ((x) & 3)) & 3) /* pad to next 4 byte word */ #define VCPIO_MASK 0xffffffff /* mask for dev/ino fields */ #endif /* _PAX_ */ diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 12b7fe162a6e..44d0ab0b40fb 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,297 +1,296 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* * External references from each source file */ #include /* * ar_io.c */ extern const char *arcname; extern const char *gzip_program; int ar_open(const char *); void ar_close(void); void ar_drain(void); int ar_set_wr(void); int ar_app_ok(void); int ar_read(char *, int); int ar_write(char *, int); int ar_rdsync(void); int ar_fow(off_t, off_t *); int ar_rev(off_t ); int ar_next(void); /* * ar_subs.c */ extern u_long flcnt; void list(void); void extract(void); void append(void); void archive(void); void copy(void); /* * buf_subs.c */ extern int blksz; extern int wrblksz; extern int maxflt; extern int rdblksz; extern off_t wrlimit; extern off_t rdcnt; extern off_t wrcnt; int wr_start(void); int rd_start(void); void cp_start(void); int appnd_start(off_t); int rd_sync(void); void pback(char *, int); int rd_skip(off_t); void wr_fin(void); int wr_rdbuf(char *, int); int rd_wrbuf(char *, int); int wr_skip(off_t); int wr_rdfile(ARCHD *, int, off_t *); int rd_wrfile(ARCHD *, int, off_t *); void cp_file(ARCHD *, int, int); int buf_fill(void); int buf_flush(int); /* * cache.c */ int uidtb_start(void); int gidtb_start(void); int usrtb_start(void); int grptb_start(void); const char * name_uid(uid_t, int); const char * name_gid(gid_t, int); int uid_name(char *, uid_t *); int gid_name(char *, gid_t *); /* * cpio.c */ int cpio_strd(void); int cpio_trail(ARCHD *); int cpio_endwr(void); int cpio_id(char *, int); int cpio_rd(ARCHD *, char *); off_t cpio_endrd(void); int cpio_stwr(void); int cpio_wr(ARCHD *); int vcpio_id(char *, int); int crc_id(char *, int); int crc_strd(void); int vcpio_rd(ARCHD *, char *); off_t vcpio_endrd(void); int crc_stwr(void); int vcpio_wr(ARCHD *); int bcpio_id(char *, int); int bcpio_rd(ARCHD *, char *); off_t bcpio_endrd(void); int bcpio_wr(ARCHD *); /* * file_subs.c */ int file_creat(ARCHD *); void file_close(ARCHD *, int); int lnk_creat(ARCHD *); int cross_lnk(ARCHD *); int chk_same(ARCHD *); int node_creat(ARCHD *); int unlnk_exist(char *, int); int chk_path(char *, uid_t, gid_t); void set_ftime(char *fnm, time_t mtime, time_t atime, int frc); int set_ids(char *, uid_t, gid_t); int set_lids(char *, uid_t, gid_t); void set_pmode(char *, mode_t); int file_write(int, char *, int, int *, int *, int, char *); void file_flush(int, char *, int); void rdfile_close(ARCHD *, int *); int set_crc(ARCHD *, int); /* * ftree.c */ int ftree_start(void); int ftree_add(char *, int); void ftree_sel(ARCHD *); void ftree_notsel(void); void ftree_chk(void); int next_file(ARCHD *); /* * gen_subs.c */ void ls_list(ARCHD *, time_t, FILE *); void ls_tty(ARCHD *); int l_strncpy(char *, const char *, int); u_long asc_ul(char *, int, int); int ul_asc(u_long, char *, int, int); u_quad_t asc_uqd(char *, int, int); int uqd_asc(u_quad_t, char *, int, int); /* * getoldopt.c */ int getoldopt(int, char **, const char *); /* * options.c */ extern FSUB fsub[]; extern int ford[]; void options(int, char **); OPLIST * opt_next(void); int opt_add(const char *); int bad_opt(void); extern char *chdname; /* * pat_rep.c */ int rep_add(char *); int pat_add(char *, char *); void pat_chk(void); int pat_sel(ARCHD *); int pat_match(ARCHD *); int mod_name(ARCHD *); int set_dest(ARCHD *, char *, int); /* * pax.c */ extern int act; extern FSUB *frmt; extern int cflag; extern int cwdfd; extern int dflag; extern int iflag; extern int kflag; extern int lflag; extern int nflag; extern int tflag; extern int uflag; extern int vflag; extern int Dflag; extern int Hflag; extern int Lflag; extern int Oflag; extern int Xflag; extern int Yflag; extern int Zflag; extern int vfpart; extern int patime; extern int pmtime; extern int nodirs; extern int pmode; extern int pids; extern int rmleadslash; extern int exit_val; extern int docrc; extern char *dirptr; extern const char *argv0; extern sigset_t s_mask; extern FILE *listf; extern char *tempfile; extern char *tempbase; void sig_cleanup(int); /* * sel_subs.c */ int sel_chk(ARCHD *); int grp_add(char *); int usr_add(char *); int trng_add(char *); /* * tables.c */ int lnk_start(void); int chk_lnk(ARCHD *); void purg_lnk(ARCHD *); void lnk_end(void); int ftime_start(void); int chk_ftime(ARCHD *); int name_start(void); int add_name(char *, int, char *); void sub_name(char *, int *, size_t); int dev_start(void); int add_dev(ARCHD *); int map_dev(ARCHD *, u_long, u_long); int atdir_start(void); void atdir_end(void); void add_atdir(char *, dev_t, ino_t, time_t, time_t); int get_atdir(dev_t, ino_t, time_t *, time_t *); int dir_start(void); void add_dir(char *, int, struct stat *, int); void proc_dir(void); u_int st_hash(char *, int, int); /* * tar.c */ int tar_endwr(void); off_t tar_endrd(void); int tar_trail(char *, int, int *); int tar_id(char *, int); int tar_opt(void); int tar_rd(ARCHD *, char *); int tar_wr(ARCHD *); int ustar_strd(void); int ustar_stwr(void); int ustar_id(char *, int); int ustar_rd(ARCHD *, char *); int ustar_wr(ARCHD *); /* * tty_subs.c */ int tty_init(void); void tty_prnt(const char *, ...) __printflike(1, 2); int tty_read(char *, int); void paxwarn(int, const char *, ...) __printflike(2, 3); void syswarn(int, int, const char *, ...) __printflike(3, 4); diff --git a/bin/pax/ftree.h b/bin/pax/ftree.h index 8e0a710e4ca9..39d08afad0a3 100644 --- a/bin/pax/ftree.h +++ b/bin/pax/ftree.h @@ -1,50 +1,49 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ftree.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * Data structure used by the ftree.c routines to store the file args to be * handed to fts(). It keeps a reference count of which args generated a * "selected" member */ typedef struct ftree { char *fname; /* file tree name */ int refcnt; /* has tree had a selected file? */ int chflg; /* change directory flag */ struct ftree *fow; /* pointer to next entry on list */ } FTREE; diff --git a/bin/pax/options.h b/bin/pax/options.h index 973ea0bd5467..637fd4049974 100644 --- a/bin/pax/options.h +++ b/bin/pax/options.h @@ -1,112 +1,111 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)options.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* * argv[0] names. Used for tar and cpio emulation */ #define NM_TAR "tar" #define NM_CPIO "cpio" #define NM_PAX "pax" /* * Constants used to specify the legal sets of flags in pax. For each major * operation mode of pax, a set of illegal flags is defined. If any one of * those illegal flags are found set, we scream and exit */ #define NONE "none" /* * flags (one for each option). */ #define AF 0x00000001 #define BF 0x00000002 #define CF 0x00000004 #define DF 0x00000008 #define FF 0x00000010 #define IF 0x00000020 #define KF 0x00000040 #define LF 0x00000080 #define NF 0x00000100 #define OF 0x00000200 #define PF 0x00000400 #define RF 0x00000800 #define SF 0x00001000 #define TF 0x00002000 #define UF 0x00004000 #define VF 0x00008000 #define WF 0x00010000 #define XF 0x00020000 #define CBF 0x00040000 /* nonstandard extension */ #define CDF 0x00080000 /* nonstandard extension */ #define CEF 0x00100000 /* nonstandard extension */ #define CGF 0x00200000 /* nonstandard extension */ #define CHF 0x00400000 /* nonstandard extension */ #define CLF 0x00800000 /* nonstandard extension */ #define CPF 0x01000000 /* nonstandard extension */ #define CTF 0x02000000 /* nonstandard extension */ #define CUF 0x04000000 /* nonstandard extension */ #define CXF 0x08000000 #define CYF 0x10000000 /* nonstandard extension */ #define CZF 0x20000000 /* nonstandard extension */ /* * ascii string indexed by bit position above (alter the above and you must * alter this string) used to tell the user what flags caused us to complain */ #define FLGCH "abcdfiklnoprstuvwxBDEGHLPTUXYZ" /* * legal pax operation bit patterns */ #define ISLIST(x) (((x) & (RF|WF)) == 0) #define ISEXTRACT(x) (((x) & (RF|WF)) == RF) #define ISARCHIVE(x) (((x) & (AF|RF|WF)) == WF) #define ISAPPND(x) (((x) & (AF|RF|WF)) == (AF|WF)) #define ISCOPY(x) (((x) & (RF|WF)) == (RF|WF)) #define ISWRITE(x) (((x) & (RF|WF)) == WF) /* * Illegal option flag subsets based on pax operation */ #define BDEXTR (AF|BF|LF|TF|WF|XF|CBF|CHF|CLF|CPF|CXF) #define BDARCH (CF|KF|LF|NF|PF|RF|CDF|CEF|CYF|CZF) #define BDCOPY (AF|BF|FF|OF|XF|CBF|CEF) #define BDLIST (AF|BF|IF|KF|LF|OF|PF|RF|TF|UF|WF|XF|CBF|CDF|CHF|CLF|CPF|CXF|CYF|CZF) diff --git a/bin/pax/pat_rep.h b/bin/pax/pat_rep.h index e28064e6a08e..897d50a1a325 100644 --- a/bin/pax/pat_rep.h +++ b/bin/pax/pat_rep.h @@ -1,49 +1,48 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pat_rep.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * data structure for storing user supplied replacement strings (-s) */ typedef struct replace { char *nstr; /* the new string we will substitute with */ regex_t rcmp; /* compiled regular expression used to match */ int flgs; /* print conversions? global in operation? */ #define PRNT 0x1 #define GLOB 0x2 struct replace *fow; /* pointer to next pattern */ } REPLACE; diff --git a/bin/pax/pax.h b/bin/pax/pax.h index 530f8aa0d33d..d48a267fbca1 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -1,247 +1,246 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pax.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* * BSD PAX global data structures and constants. */ #define MAXBLK 64512 /* MAX blocksize supported (posix SPEC) */ /* WARNING: increasing MAXBLK past 32256 */ /* will violate posix spec. */ #define MAXBLK_POSIX 32256 /* MAX blocksize supported as per POSIX */ #define BLKMULT 512 /* blocksize must be even mult of 512 bytes */ /* Don't even think of changing this */ #define DEVBLK 8192 /* default read blksize for devices */ #define FILEBLK 10240 /* default read blksize for files */ #define PAXPATHLEN 3072 /* maximum path length for pax. MUST be */ /* longer than the system PATH_MAX */ /* * Pax modes of operation */ #define LIST 0 /* List the file in an archive */ #define EXTRACT 1 /* extract the files in an archive */ #define ARCHIVE 2 /* write a new archive */ #define APPND 3 /* append to the end of an archive */ #define COPY 4 /* copy files to destination dir */ #define DEFOP LIST /* if no flags default is to LIST */ /* * Device type of the current archive volume */ #define ISREG 0 /* regular file */ #define ISCHR 1 /* character device */ #define ISBLK 2 /* block device */ #define ISTAPE 3 /* tape drive */ #define ISPIPE 4 /* pipe/socket */ typedef struct archd ARCHD; typedef struct fsub FSUB; typedef struct oplist OPLIST; typedef struct pattern PATTERN; /* * Format Specific Routine Table * * The format specific routine table allows new archive formats to be quickly * added. Overall pax operation is independent of the actual format used to * form the archive. Only those routines which deal directly with the archive * are tailored to the oddities of the specific format. All other routines are * independent of the archive format. Data flow in and out of the format * dependent routines pass pointers to ARCHD structure (described below). */ struct fsub { const char *name; /* name of format, this is the name the user */ /* gives to -x option to select it. */ int bsz; /* default block size. used when the user */ /* does not specify a blocksize for writing */ /* Appends continue to with the blocksize */ /* the archive is currently using. */ int hsz; /* Header size in bytes. this is the size of */ /* the smallest header this format supports. */ /* Headers are assumed to fit in a BLKMULT. */ /* If they are bigger, get_head() and */ /* get_arc() must be adjusted */ int udev; /* does append require unique dev/ino? some */ /* formats use the device and inode fields */ /* to specify hard links. when members in */ /* the archive have the same inode/dev they */ /* are assumed to be hard links. During */ /* append we may have to generate unique ids */ /* to avoid creating incorrect hard links */ int hlk; /* does archive store hard links info? if */ /* not, we do not bother to look for them */ /* during archive write operations */ int blkalgn; /* writes must be aligned to blkalgn boundary */ int inhead; /* is the trailer encoded in a valid header? */ /* if not, trailers are assumed to be found */ /* in invalid headers (i.e like tar) */ int (*id)(char *, int); /* checks if a buffer is a valid header */ /* returns 1 if it is, o.w. returns a 0 */ int (*st_rd)(void); /* initialize routine for read. so format */ /* can set up tables etc before it starts */ /* reading an archive */ int (*rd)(ARCHD *, char *); /* read header routine. passed a pointer to */ /* ARCHD. It must extract the info from the */ /* format and store it in the ARCHD struct. */ /* This routine is expected to fill all the */ /* fields in the ARCHD (including stat buf) */ /* 0 is returned when a valid header is */ /* found. -1 when not valid. This routine */ /* set the skip and pad fields so the format */ /* independent routines know the amount of */ /* padding and the number of bytes of data */ /* which follow the header. This info is */ /* used skip to the next file header */ off_t (*end_rd)(void); /* read cleanup. Allows format to clean up */ /* and MUST RETURN THE LENGTH OF THE TRAILER */ /* RECORD (so append knows how many bytes */ /* to move back to rewrite the trailer) */ int (*st_wr)(void); /* initialize routine for write operations */ int (*wr)(ARCHD *); /* write archive header. Passed an ARCHD */ /* filled with the specs on the next file to */ /* archived. Returns a 1 if no file data is */ /* is to be stored; 0 if file data is to be */ /* added. A -1 is returned if a write */ /* operation to the archive failed. this */ /* function sets the skip and pad fields so */ /* the proper padding can be added after */ /* file data. This routine must NEVER write */ /* a flawed archive header. */ int (*end_wr)(void); /* end write. write the trailer and do any */ /* other format specific functions needed */ /* at the end of an archive write */ int (*trail_cpio)(ARCHD *); int (*trail_tar)(char *, int, int *); /* returns 0 if a valid trailer, -1 if not */ /* For formats which encode the trailer */ /* outside of a valid header, a return value */ /* of 1 indicates that the block passed to */ /* it can never contain a valid header (skip */ /* this block, no point in looking at it) */ int (*rd_data)(ARCHD *, int, off_t *); /* read/process file data from the archive */ int (*wr_data)(ARCHD *, int, off_t *); /* write/process file data to the archive */ int (*options)(void); /* process format specific options (-o) */ }; /* * Pattern matching structure * * Used to store command line patterns */ struct pattern { char *pstr; /* pattern to match, user supplied */ char *pend; /* end of a prefix match */ char *chdname; /* the dir to change to if not NULL. */ int plen; /* length of pstr */ int flgs; /* processing/state flags */ #define MTCH 0x1 /* pattern has been matched */ #define DIR_MTCH 0x2 /* pattern matched a directory */ struct pattern *fow; /* next pattern */ }; /* * General Archive Structure (used internal to pax) * * This structure is used to pass information about archive members between * the format independent routines and the format specific routines. When * new archive formats are added, they must accept requests and supply info * encoded in a structure of this type. The name fields are declared statically * here, as there is only ONE of these floating around, size is not a major * consideration. Eventually converting the name fields to a dynamic length * may be required if and when the supporting operating system removes all * restrictions on the length of pathnames it will resolve. */ struct archd { int nlen; /* file name length */ char name[PAXPATHLEN+1]; /* file name */ int ln_nlen; /* link name length */ char ln_name[PAXPATHLEN+1]; /* name to link to (if any) */ char *org_name; /* orig name in file system */ PATTERN *pat; /* ptr to pattern match (if any) */ struct stat sb; /* stat buffer see stat(2) */ off_t pad; /* bytes of padding after file xfer */ off_t skip; /* bytes of real data after header */ /* IMPORTANT. The st_size field does */ /* not always indicate the amount of */ /* data following the header. */ u_long crc; /* file crc */ int type; /* type of file node */ #define PAX_DIR 1 /* directory */ #define PAX_CHR 2 /* character device */ #define PAX_BLK 3 /* block device */ #define PAX_REG 4 /* regular file */ #define PAX_SLK 5 /* symbolic link */ #define PAX_SCK 6 /* socket */ #define PAX_FIF 7 /* fifo */ #define PAX_HLK 8 /* hard link */ #define PAX_HRG 9 /* hard link to a regular file */ #define PAX_CTG 10 /* high performance file */ }; /* * Format Specific Options List * * Used to pass format options to the format options handler */ struct oplist { char *name; /* option variable name e.g. name= */ char *value; /* value for option variable */ struct oplist *fow; /* next option */ }; /* * General Macros */ #ifndef MIN #define MIN(a,b) (((a)<(b))?(a):(b)) #endif #define MAJOR(x) major(x) #define MINOR(x) minor(x) #define TODEV(x, y) makedev((x), (y)) /* * General Defines */ #define HEX 16 #define OCT 8 #define _PAX_ 1 #define _TFILE_BASE "paxXXXXXXXXXX" diff --git a/bin/pax/sel_subs.h b/bin/pax/sel_subs.h index a628e6981b1a..e2ffae52a50a 100644 --- a/bin/pax/sel_subs.h +++ b/bin/pax/sel_subs.h @@ -1,72 +1,71 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)sel_subs.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * data structure for storing uid/grp selects (-U, -G non standard options) */ #define USR_TB_SZ 317 /* user selection table size */ #define GRP_TB_SZ 317 /* user selection table size */ typedef struct usrt { uid_t uid; struct usrt *fow; /* next uid */ } USRT; typedef struct grpt { gid_t gid; struct grpt *fow; /* next gid */ } GRPT; /* * data structure for storing user supplied time ranges (-T option) */ #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; typedef struct time_rng { time_t low_time; /* lower inclusive time limit */ time_t high_time; /* higher inclusive time limit */ int flgs; /* option flags */ #define HASLOW 0x01 /* has lower time limit */ #define HASHIGH 0x02 /* has higher time limit */ #define CMPMTME 0x04 /* compare file modification time */ #define CMPCTME 0x08 /* compare inode change time */ #define CMPBOTH (CMPMTME|CMPCTME) /* compare inode and mod time */ struct time_rng *fow; /* next pattern */ } TIME_RNG; diff --git a/bin/pax/tables.h b/bin/pax/tables.h index fb5bc437b0a0..eaa48066f70d 100644 --- a/bin/pax/tables.h +++ b/bin/pax/tables.h @@ -1,171 +1,170 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)tables.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ /* * data structures and constants used by the different databases kept by pax */ /* * Hash Table Sizes MUST BE PRIME, if set too small performance suffers. * Probably safe to expect 500000 inodes per tape. Assuming good key * distribution (inodes) chains of under 50 long (worse case) is ok. */ #define L_TAB_SZ 2503 /* hard link hash table size */ #define F_TAB_SZ 50503 /* file time hash table size */ #define N_TAB_SZ 541 /* interactive rename hash table */ #define D_TAB_SZ 317 /* unique device mapping table */ #define A_TAB_SZ 317 /* ftree dir access time reset table */ #define MAXKEYLEN 64 /* max number of chars for hash */ /* * file hard link structure (hashed by dev/ino and chained) used to find the * hard links in a file system or with some archive formats (cpio) */ typedef struct hrdlnk { char *name; /* name of first file seen with this ino/dev */ dev_t dev; /* files device number */ ino_t ino; /* files inode number */ u_long nlink; /* expected link count */ struct hrdlnk *fow; } HRDLNK; /* * Archive write update file time table (the -u, -C flag), hashed by filename. * Filenames are stored in a scratch file at seek offset into the file. The * file time (mod time) and the file name length (for a quick check) are * stored in a hash table node. We were forced to use a scratch file because * with -u, the mtime for every node in the archive must always be available * to compare against (and this data can get REALLY large with big archives). * By being careful to read only when we have a good chance of a match, the * performance loss is not measurable (and the size of the archive we can * handle is greatly increased). */ typedef struct ftm { int namelen; /* file name length */ time_t mtime; /* files last modification time */ off_t seek; /* location in scratch file */ struct ftm *fow; } FTM; /* * Interactive rename table (-i flag), hashed by orig filename. * We assume this will not be a large table as this mapping data can only be * obtained through interactive input by the user. Nobody is going to type in * changes for 500000 files? We use chaining to resolve collisions. */ typedef struct namt { char *oname; /* old name */ char *nname; /* new name typed in by the user */ struct namt *fow; } NAMT; /* * Unique device mapping tables. Some protocols (e.g. cpio) require that the * pair will uniquely identify a file in an archive unless they * are links to the same file. Appending to archives can break this. For those * protocols that have this requirement we map c_dev to a unique value not seen * in the archive when we append. We also try to handle inode truncation with * this table. (When the inode field in the archive header are too small, we * remap the dev on writes to remove accidental collisions). * * The list is hashed by device number using chain collision resolution. Off of * each DEVT are linked the various remaps for this device based on those bits * in the inode which were truncated. For example if we are just remapping to * avoid a device number during an update append, off the DEVT we would have * only a single DLIST that has a truncation id of 0 (no inode bits were * stripped for this device so far). When we spot inode truncation we create * a new mapping based on the set of bits in the inode which were stripped off. * so if the top four bits of the inode are stripped and they have a pattern of * 0110...... (where . are those bits not truncated) we would have a mapping * assigned for all inodes that has the same 0110.... pattern (with this dev * number of course). This keeps the mapping sparse and should be able to store * close to the limit of files which can be represented by the optimal * combination of dev and inode bits, and without creating a fouled up archive. * Note we also remap truncated devs in the same way (an exercise for the * dedicated reader; always wanted to say that...:) */ typedef struct devt { dev_t dev; /* the orig device number we now have to map */ struct devt *fow; /* new device map list */ struct dlist *list; /* map list based on inode truncation bits */ } DEVT; typedef struct dlist { ino_t trunc_bits; /* truncation pattern for a specific map */ dev_t dev; /* the new device id we use */ struct dlist *fow; } DLIST; /* * ftree directory access time reset table. When we are done with with a * subtree we reset the access and mod time of the directory when the tflag is * set. Not really explicitly specified in the pax spec, but easy and fast to * do (and this may have even been intended in the spec, it is not clear). * table is hashed by inode with chaining. */ typedef struct atdir { char *name; /* name of directory to reset */ dev_t dev; /* dev and inode for fast lookup */ ino_t ino; time_t mtime; /* access and mod time to reset to */ time_t atime; struct atdir *fow; } ATDIR; /* * created directory time and mode storage entry. After pax is finished during * extraction or copy, we must reset directory access modes and times that * may have been modified after creation (they no longer have the specified * times and/or modes). We must reset time in the reverse order of creation, * because entries are added from the top of the file tree to the bottom. * We MUST reset times from leaf to root (it will not work the other * direction). Entries are recorded into a spool file to make reverse * reading faster. */ typedef struct dirdata { int nlen; /* length of the directory name (includes \0) */ off_t npos; /* position in file where this dir name starts */ mode_t mode; /* file mode to restore */ time_t mtime; /* mtime to set */ time_t atime; /* atime to set */ int frc_mode; /* do we force mode settings? */ } DIRDATA; diff --git a/bin/pax/tar.h b/bin/pax/tar.h index 91c2400e35ca..0b95bddc1fee 100644 --- a/bin/pax/tar.h +++ b/bin/pax/tar.h @@ -1,147 +1,146 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Keith Muller. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)tar.h 8.2 (Berkeley) 4/18/94 - * $FreeBSD$ */ /* * defines and data structures common to all tar formats */ #define CHK_LEN 8 /* length of checksum field */ #define TNMSZ 100 /* size of name field */ #ifdef _PAX_ #define NULLCNT 2 /* number of null blocks in trailer */ #define CHK_OFFSET 148 /* start of checksum field */ #define BLNKSUM 256L /* sum of checksum field using ' ' */ #endif /* _PAX_ */ /* * Values used in typeflag field in all tar formats * (only REGTYPE, LNKTYPE and SYMTYPE are used in old BSD tar headers) */ #define REGTYPE '0' /* Regular File */ #define AREGTYPE '\0' /* Regular File */ #define LNKTYPE '1' /* Link */ #define SYMTYPE '2' /* Symlink */ #define CHRTYPE '3' /* Character Special File */ #define BLKTYPE '4' /* Block Special File */ #define DIRTYPE '5' /* Directory */ #define FIFOTYPE '6' /* FIFO */ #define CONTTYPE '7' /* high perf file */ /* * Mode field encoding of the different file types - values in octal */ #define TSUID 04000 /* Set UID on execution */ #define TSGID 02000 /* Set GID on execution */ #define TSVTX 01000 /* Reserved */ #define TUREAD 00400 /* Read by owner */ #define TUWRITE 00200 /* Write by owner */ #define TUEXEC 00100 /* Execute/Search by owner */ #define TGREAD 00040 /* Read by group */ #define TGWRITE 00020 /* Write by group */ #define TGEXEC 00010 /* Execute/Search by group */ #define TOREAD 00004 /* Read by other */ #define TOWRITE 00002 /* Write by other */ #define TOEXEC 00001 /* Execute/Search by other */ #ifdef _PAX_ /* * Pad with a bit mask, much faster than doing a mod but only works on powers * of 2. Macro below is for block of 512 bytes. */ #define TAR_PAD(x) ((512 - ((x) & 511)) & 511) #endif /* _PAX_ */ /* * structure of an old tar header as it appeared in BSD releases */ typedef struct { char name[TNMSZ]; /* name of entry */ char mode[8]; /* mode */ char uid[8]; /* uid */ char gid[8]; /* gid */ char size[12]; /* size */ char mtime[12]; /* modification time */ char chksum[CHK_LEN]; /* checksum */ char linkflag; /* norm, hard, or sym. */ char linkname[TNMSZ]; /* linked to name */ } HD_TAR __aligned(1); #ifdef _PAX_ /* * -o options for BSD tar to not write directories to the archive */ #define TAR_NODIR "nodir" #define TAR_OPTION "write_opt" /* * default device names */ #define DEV_0 "/dev/rmt0" #define DEV_1 "/dev/rmt1" #define DEV_4 "/dev/rmt4" #define DEV_5 "/dev/rmt5" #define DEV_7 "/dev/rmt7" #define DEV_8 "/dev/rmt8" #endif /* _PAX_ */ /* * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990 */ #define TPFSZ 155 #define TMAGIC "ustar" /* ustar and a null */ #define TMAGLEN 6 #define TVERSION "00" /* 00 and no null */ #define TVERSLEN 2 typedef struct { char name[TNMSZ]; /* name of entry */ char mode[8]; /* mode */ char uid[8]; /* uid */ char gid[8]; /* gid */ char size[12]; /* size */ char mtime[12]; /* modification time */ char chksum[CHK_LEN]; /* checksum */ char typeflag; /* type of file. */ char linkname[TNMSZ]; /* linked to name */ char magic[TMAGLEN]; /* magic cookie */ char version[TVERSLEN]; /* version */ char uname[32]; /* ascii owner name */ char gname[32]; /* ascii group name */ char devmajor[8]; /* major device number */ char devminor[8]; /* minor device number */ char prefix[TPFSZ]; /* linked to name */ } HD_USTAR __aligned(1); diff --git a/bin/ps/extern.h b/bin/ps/extern.h index ea4362eeadd9..6b07a79fbc20 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -1,94 +1,93 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.3 (Berkeley) 4/2/94 - * $FreeBSD$ */ struct kinfo; struct nlist; struct var; struct varent; extern fixpt_t ccpu; extern int cflag, eval, fscale, nlistread, rawcpu; extern unsigned long mempages; extern time_t now; extern int showthreads, sumrusage, termwidth; extern STAILQ_HEAD(velisthead, varent) varlist; __BEGIN_DECLS char *arguments(KINFO *, VARENT *); char *command(KINFO *, VARENT *); char *cputime(KINFO *, VARENT *); char *cpunum(KINFO *, VARENT *); int donlist(void); char *elapsed(KINFO *, VARENT *); char *elapseds(KINFO *, VARENT *); char *emulname(KINFO *, VARENT *); VARENT *find_varentry(VAR *); const char *fmt_argv(char **, char *, char *, size_t); double getpcpu(const KINFO *); char *jailname(KINFO *, VARENT *); char *kvar(KINFO *, VARENT *); char *label(KINFO *, VARENT *); char *loginclass(KINFO *, VARENT *); char *logname(KINFO *, VARENT *); char *longtname(KINFO *, VARENT *); char *lstarted(KINFO *, VARENT *); char *maxrss(KINFO *, VARENT *); char *lockname(KINFO *, VARENT *); char *mwchan(KINFO *, VARENT *); char *nwchan(KINFO *, VARENT *); char *pagein(KINFO *, VARENT *); void parsefmt(const char *, int); char *pcpu(KINFO *, VARENT *); char *pmem(KINFO *, VARENT *); char *pri(KINFO *, VARENT *); void printheader(void); char *priorityr(KINFO *, VARENT *); char *egroupname(KINFO *, VARENT *); char *rgroupname(KINFO *, VARENT *); char *runame(KINFO *, VARENT *); char *rvar(KINFO *, VARENT *); void showkey(void); char *started(KINFO *, VARENT *); char *state(KINFO *, VARENT *); char *systime(KINFO *, VARENT *); char *tdev(KINFO *, VARENT *); char *tdnam(KINFO *, VARENT *); char *tname(KINFO *, VARENT *); char *ucomm(KINFO *, VARENT *); char *username(KINFO *, VARENT *); char *upr(KINFO *, VARENT *); char *usertime(KINFO *, VARENT *); char *vsize(KINFO *, VARENT *); char *wchan(KINFO *, VARENT *); __END_DECLS diff --git a/bin/ps/ps.h b/bin/ps/ps.h index 03e38af9d517..429dff632872 100644 --- a/bin/ps/ps.h +++ b/bin/ps/ps.h @@ -1,90 +1,89 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ps.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ #include #define UNLIMITED 0 /* unlimited terminal width */ enum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR, PGTOK }; typedef struct kinfo_str { STAILQ_ENTRY(kinfo_str) ks_next; char *ks_str; /* formatted string */ } KINFO_STR; typedef struct kinfo { struct kinfo_proc *ki_p; /* kinfo_proc structure */ const char *ki_args; /* exec args */ const char *ki_env; /* environment */ int ki_valid; /* 1 => uarea stuff valid */ double ki_pcpu; /* calculated in main() */ segsz_t ki_memsize; /* calculated in main() */ union { int level; /* used in decendant_sort() */ char *prefix; /* calculated in decendant_sort() */ } ki_d; STAILQ_HEAD(, kinfo_str) ki_ks; } KINFO; /* Variables. */ typedef struct varent { STAILQ_ENTRY(varent) next_ve; const char *header; struct var *var; } VARENT; typedef struct var { const char *name; /* name(s) of variable */ const char *header; /* default header */ const char *alias; /* aliases */ const char *field; /* xo field name */ #define COMM 0x01 /* needs exec arguments and environment (XXX) */ #define LJUST 0x02 /* left adjust on output (trailing blanks) */ #define USER 0x04 /* needs user structure */ #define INF127 0x10 /* values >127 displayed as 127 */ u_int flag; /* output routine */ char *(*oproc)(struct kinfo *, struct varent *); /* * The following (optional) elements are hooks for passing information * to the generic output routine pvar (which prints simple elements * from the well known kinfo_proc structure). */ size_t off; /* offset in structure */ enum type type; /* type of element */ const char *fmt; /* printf format */ short width; /* calculated width */ } VAR; #include "extern.h" diff --git a/bin/sh/alias.h b/bin/sh/alias.h index 92de705bc963..0c6ea99e8b60 100644 --- a/bin/sh/alias.h +++ b/bin/sh/alias.h @@ -1,45 +1,44 @@ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)alias.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #define ALIASINUSE 1 struct alias { struct alias *next; char *name; char *val; int flag; }; struct alias *lookupalias(const char *, int); diff --git a/bin/sh/arith.h b/bin/sh/arith.h index 569d0c58651f..124fd5944a56 100644 --- a/bin/sh/arith.h +++ b/bin/sh/arith.h @@ -1,37 +1,36 @@ /*- * Copyright (c) 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)arith.h 1.1 (Berkeley) 5/4/95 - * $FreeBSD$ */ #include "shell.h" #define DIGITS(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3) arith_t arith(const char *); diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h index 8149895815dd..226d630694b5 100644 --- a/bin/sh/bltin/bltin.h +++ b/bin/sh/bltin/bltin.h @@ -1,81 +1,80 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)bltin.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* * This file is included by programs which are optionally built into the * shell. If SHELL is defined, we try to map the standard UNIX library * routines to ash routines using defines. */ #include "../shell.h" #include "../mystring.h" #ifdef SHELL #include "../error.h" #include "../output.h" #include "builtins.h" #define FILE struct output #undef stdout #define stdout out1 #undef stderr #define stderr out2 #define printf out1fmt #undef putc #define putc(c, file) outc(c, file) #undef putchar #define putchar(c) out1c(c) #define fprintf outfmt #define fputs outstr #define fwrite(ptr, size, nmemb, file) outbin(ptr, (size) * (nmemb), file) #define fflush flushout #define INITARGS(argv) #define warnx warning #define warn(fmt, ...) warning(fmt ": %s", __VA_ARGS__, strerror(errno)) #define errx(exitstatus, ...) error(__VA_ARGS__) #else #undef NULL #include #undef main #define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else #endif #include pointer stalloc(int); int killjob(const char *, int); extern char *commandname; diff --git a/bin/sh/error.h b/bin/sh/error.h index 3a79dec81b9d..c097c529dc01 100644 --- a/bin/sh/error.h +++ b/bin/sh/error.h @@ -1,94 +1,93 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)error.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* * We enclose jmp_buf in a structure so that we can declare pointers to * jump locations. The global variable handler contains the location to * jump to when an exception occurs, and the global variable exception * contains a code identifying the exception. To implement nested * exception handlers, the user should save the value of handler on entry * to an inner scope, set handler to point to a jmploc structure for the * inner scope, and restore handler on exit from the scope. */ #include #include struct jmploc { jmp_buf loc; }; extern struct jmploc *handler; extern volatile sig_atomic_t exception; /* exceptions */ #define EXINT 0 /* SIGINT received */ #define EXERROR 1 /* a generic error with exitstatus */ #define EXEXIT 2 /* call exitshell(exitstatus) */ /* * These macros allow the user to suspend the handling of interrupt signals * over a period of time. This is similar to SIGHOLD to or sigblock, but * much more efficient and portable. (But hacking the kernel is so much * more fun than worrying about efficiency and portability. :-)) */ extern volatile sig_atomic_t suppressint; extern volatile sig_atomic_t intpending; #define INTOFF suppressint++ #define INTON { if (--suppressint == 0 && intpending) onint(); } #define is_int_on() suppressint #define SETINTON(s) do { suppressint = (s); if (suppressint == 0 && intpending) onint(); } while (0) #define FORCEINTON {suppressint = 0; if (intpending) onint();} #define SET_PENDING_INT intpending = 1 #define CLEAR_PENDING_INT intpending = 0 #define int_pending() intpending void exraise(int) __dead2; void onint(void) __dead2; void warning(const char *, ...) __printflike(1, 2); void error(const char *, ...) __printf0like(1, 2) __dead2; void errorwithstatus(int, const char *, ...) __printf0like(2, 3) __dead2; /* * BSD setjmp saves the signal mask, which violates ANSI C and takes time, * so we use _setjmp instead. */ #define setjmp(jmploc) _setjmp(jmploc) #define longjmp(jmploc, val) _longjmp(jmploc, val) diff --git a/bin/sh/eval.h b/bin/sh/eval.h index d8a12eb79c7f..361e0f2ba269 100644 --- a/bin/sh/eval.h +++ b/bin/sh/eval.h @@ -1,70 +1,69 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)eval.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ extern char *commandname; /* currently executing command */ extern int exitstatus; /* exit status of last command */ extern int oexitstatus; /* saved exit status */ extern struct arglist *cmdenviron; /* environment for builtin command */ struct backcmd { /* result of evalbackcmd */ int fd; /* file descriptor to read from */ char *buf; /* buffer */ int nleft; /* number of chars in buffer */ struct job *jp; /* job structure for command */ }; void reseteval(void); /* flags in argument to evaltree/evalstring */ #define EV_EXIT 01 /* exit after evaluating tree */ #define EV_TESTED 02 /* exit status is checked; ignore -e flag */ #define EV_BACKCMD 04 /* command executing within back quotes */ void evalstring(const char *, int); union node; /* BLETCH for ansi C */ void evaltree(union node *, int); void evalbackcmd(union node *, struct backcmd *); /* in_function returns nonzero if we are currently evaluating a function */ #define in_function() funcnest extern int funcnest; extern int evalskip; extern int skipcount; /* reasons for skipping commands (see comment on breakcmd routine) */ #define SKIPBREAK 1 #define SKIPCONT 2 #define SKIPRETURN 3 diff --git a/bin/sh/exec.h b/bin/sh/exec.h index 03e7e6ab0b0c..04d1b97d7386 100644 --- a/bin/sh/exec.h +++ b/bin/sh/exec.h @@ -1,74 +1,73 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)exec.h 8.3 (Berkeley) 6/8/95 - * $FreeBSD$ */ /* values of cmdtype */ #define CMDUNKNOWN -1 /* no entry in table for command */ #define CMDNORMAL 0 /* command is an executable program */ #define CMDBUILTIN 1 /* command is a shell builtin */ #define CMDFUNCTION 2 /* command is a shell function */ /* values for typecmd_impl's third parameter */ enum { TYPECMD_SMALLV, /* command -v */ TYPECMD_BIGV, /* command -V */ TYPECMD_TYPE /* type */ }; union node; struct cmdentry { int cmdtype; union param { int index; struct funcdef *func; } u; int special; }; /* action to find_command() */ #define DO_ERR 0x01 /* prints errors */ #define DO_NOFUNC 0x02 /* don't return shell functions, for command */ void shellexec(char **, char **, const char *, int) __dead2; char *padvance(const char **, const char **, const char *); void find_command(const char *, struct cmdentry *, int, const char *); int find_builtin(const char *, int *); void hashcd(void); void changepath(const char *); void defun(const char *, union node *); int unsetfunc(const char *); int isfunc(const char *); int typecmd_impl(int, char **, int, const char *); void clearcmdentry(void); diff --git a/bin/sh/expand.h b/bin/sh/expand.h index a60ea29514d2..2cf6d2ee0972 100644 --- a/bin/sh/expand.h +++ b/bin/sh/expand.h @@ -1,62 +1,61 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)expand.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ struct arglist { char **args; int count; int capacity; char *smallarg[1]; }; /* * expandarg() flags */ #define EXP_SPLIT 0x1 /* perform word splitting */ #define EXP_TILDE 0x2 /* do normal tilde expansion */ #define EXP_VARTILDE 0x4 /* expand tildes in an assignment */ #define EXP_CASE 0x10 /* keeps quotes around for CASE pattern */ #define EXP_SPLIT_LIT 0x20 /* IFS split literal text ${v+-a b c} */ #define EXP_LIT_QUOTED 0x40 /* for EXP_SPLIT_LIT, start off quoted */ #define EXP_GLOB 0x80 /* perform file globbing */ #define EXP_FULL (EXP_SPLIT | EXP_GLOB) void emptyarglist(struct arglist *); void appendarglist(struct arglist *, char *); union node; void expandarg(union node *, struct arglist *, int); void rmescapes(char *); int casematch(union node *, const char *); diff --git a/bin/sh/input.h b/bin/sh/input.h index edb622b6ec2e..b46e2c021e70 100644 --- a/bin/sh/input.h +++ b/bin/sh/input.h @@ -1,65 +1,64 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)input.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* PEOF (the end of file marker) is defined in syntax.h */ /* * The input line number. Input.c just defines this variable, and saves * and restores it when files are pushed and popped. The user of this * package must set its value. */ extern int plinno; extern int parsenleft; /* number of characters left in input buffer */ extern const char *parsenextc; /* next character in input buffer */ struct alias; struct parsefile; void resetinput(void); int pgetc(void); int preadbuffer(void); int preadateof(void); void pungetc(void); void pushstring(const char *, int, struct alias *); void setinputfile(const char *, int, int); void setinputfd(int, int); void setinputstring(const char *, int); void popfile(void); struct parsefile *getcurrentfile(void); void popfilesupto(struct parsefile *); void popallfiles(void); void closescript(void); #define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer()) diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h index 411d08f27a67..050c86a91ff8 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -1,67 +1,66 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)jobs.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */ #define FORK_FG 0 #define FORK_BG 1 #define FORK_NOJOB 2 #include /* for sig_atomic_t */ struct job; enum { SHOWJOBS_DEFAULT, /* job number, status, command */ SHOWJOBS_VERBOSE, /* job number, PID, status, command */ SHOWJOBS_PIDS, /* PID only */ SHOWJOBS_PGIDS /* PID of the group leader only */ }; extern int job_warning; /* user was warned about stopped jobs */ void setjobctl(int); void showjobs(int, int); struct job *makejob(union node *, int); pid_t forkshell(struct job *, union node *, int); pid_t vforkexecshell(struct job *, char **, char **, const char *, int, int [2]); int waitforjob(struct job *, int *); int stoppedjobs(void); int backgndpidset(void); pid_t backgndpidval(void); char *commandtext(union node *); #if ! JOBS #define setjobctl(on) /* do nothing */ #endif diff --git a/bin/sh/mail.h b/bin/sh/mail.h index 0bb565209c7f..0a52e9f198a1 100644 --- a/bin/sh/mail.h +++ b/bin/sh/mail.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mail.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ void chkmail(int); diff --git a/bin/sh/main.h b/bin/sh/main.h index d12c7ab77fed..38f9b271c309 100644 --- a/bin/sh/main.h +++ b/bin/sh/main.h @@ -1,42 +1,41 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)main.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ extern int rootpid; /* pid of main shell */ extern int rootshell; /* true if we aren't a child of the main shell */ extern struct jmploc main_handler; /* top level exception handler */ void readcmdfile(const char *, int); diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h index 6cb7bd818fb5..038d18173c7b 100644 --- a/bin/sh/memalloc.h +++ b/bin/sh/memalloc.h @@ -1,88 +1,87 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)memalloc.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #include struct stackmark { struct stack_block *stackp; char *stacknxt; int stacknleft; }; extern char *stacknxt; extern int stacknleft; extern char *sstrend; pointer ckmalloc(size_t); pointer ckrealloc(pointer, int); void ckfree(pointer); char *savestr(const char *); pointer stalloc(int); void stunalloc(pointer); char *stsavestr(const char *); void setstackmark(struct stackmark *); void popstackmark(struct stackmark *); char *growstackstr(void); char *makestrspace(int, char *); char *stputbin(const char *data, size_t len, char *p); char *stputs(const char *data, char *p); #define stackblock() stacknxt #define stackblocksize() stacknleft #define grabstackblock(n) stalloc(n) #define STARTSTACKSTR(p) p = stackblock() #define STPUTC(c, p) do { if (p == sstrend) p = growstackstr(); *p++ = (c); } while(0) #define CHECKSTRSPACE(n, p) { if ((size_t)(sstrend - p) < n) p = makestrspace(n, p); } #define USTPUTC(c, p) (*p++ = (c)) /* * STACKSTRNUL's use is where we want to be able to turn a stack * (non-sentinel, character counting string) into a C string, * and later pretend the NUL is not there. * Note: Because of STACKSTRNUL's semantics, STACKSTRNUL cannot be used * on a stack that will grabstackstr()ed. */ #define STACKSTRNUL(p) (p == sstrend ? (p = growstackstr(), *p = '\0') : (*p = '\0')) #define STUNPUTC(p) (--p) #define STTOPC(p) p[-1] #define STADJUST(amount, p) (p += (amount)) #define grabstackstr(p) stalloc((char *)p - stackblock()) #define ungrabstackstr(s, p) stunalloc((s)) #define STPUTBIN(s, len, p) p = stputbin((s), (len), p) #define STPUTS(s, p) p = stputs((s), p) diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index 1f513f0ae206..ef84a90bf5b0 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -1,47 +1,46 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)myhistedit.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #include extern History *hist; extern EditLine *el; extern int displayhist; #include void histedit(void); void sethistsize(const char *); void setterm(const char *); void histload(void); void histsave(void); diff --git a/bin/sh/mystring.h b/bin/sh/mystring.h index ff4384d21c35..dcbdc91cb5d5 100644 --- a/bin/sh/mystring.h +++ b/bin/sh/mystring.h @@ -1,43 +1,42 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mystring.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #include int number(const char *); int is_number(const char *); #define equal(s1, s2) (strcmp(s1, s2) == 0) diff --git a/bin/sh/nodes.c.pat b/bin/sh/nodes.c.pat index 43fa515fe905..9172c544de3d 100644 --- a/bin/sh/nodes.c.pat +++ b/bin/sh/nodes.c.pat @@ -1,193 +1,192 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #include #include #include /* * Routine for dealing with parsed shell commands. */ #include "shell.h" #include "nodes.h" #include "memalloc.h" #include "mystring.h" struct nodesize { int blocksize; /* size of structures in function */ int stringsize; /* size of strings in node */ }; struct nodecopystate { pointer block; /* block to allocate function from */ char *string; /* block to allocate strings from */ }; %SIZES static void calcsize(union node *, struct nodesize *); static void sizenodelist(struct nodelist *, struct nodesize *); static union node *copynode(union node *, struct nodecopystate *); static struct nodelist *copynodelist(struct nodelist *, struct nodecopystate *); static char *nodesavestr(const char *, struct nodecopystate *); struct funcdef { unsigned int refcount; union node n; }; /* * Make a copy of a parse tree. */ struct funcdef * copyfunc(union node *n) { struct nodesize sz; struct nodecopystate st; struct funcdef *fn; if (n == NULL) return NULL; sz.blocksize = offsetof(struct funcdef, n); sz.stringsize = 0; calcsize(n, &sz); fn = ckmalloc(sz.blocksize + sz.stringsize); fn->refcount = 1; st.block = (char *)fn + offsetof(struct funcdef, n); st.string = (char *)fn + sz.blocksize; copynode(n, &st); return fn; } union node * getfuncnode(struct funcdef *fn) { return fn == NULL ? NULL : &fn->n; } static void calcsize(union node *n, struct nodesize *result) { %CALCSIZE } static void sizenodelist(struct nodelist *lp, struct nodesize *result) { while (lp) { result->blocksize += ALIGN(sizeof(struct nodelist)); calcsize(lp->n, result); lp = lp->next; } } static union node * copynode(union node *n, struct nodecopystate *state) { union node *new; %COPY return new; } static struct nodelist * copynodelist(struct nodelist *lp, struct nodecopystate *state) { struct nodelist *start; struct nodelist **lpp; lpp = &start; while (lp) { *lpp = state->block; state->block = (char *)state->block + ALIGN(sizeof(struct nodelist)); (*lpp)->n = copynode(lp->n, state); lp = lp->next; lpp = &(*lpp)->next; } *lpp = NULL; return start; } static char * nodesavestr(const char *s, struct nodecopystate *state) { const char *p = s; char *q = state->string; char *rtn = state->string; while ((*q++ = *p++) != '\0') continue; state->string = q; return rtn; } void reffunc(struct funcdef *fn) { if (fn) fn->refcount++; } /* * Decrement the reference count of a function definition, freeing it * if it falls to 0. */ void unreffunc(struct funcdef *fn) { if (fn) { fn->refcount--; if (fn->refcount > 0) return; ckfree(fn); } } diff --git a/bin/sh/options.h b/bin/sh/options.h index 7c9c4513aa33..9c516b07ad23 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -1,119 +1,118 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)options.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ struct shparam { int nparam; /* # of positional parameters (without $0) */ unsigned char malloc; /* if parameter list dynamically allocated */ unsigned char reset; /* if getopts has been reset */ char **p; /* parameter list */ char **optp; /* parameter list for getopts */ char **optnext; /* next parameter to be processed by getopts */ char *optptr; /* used by getopts */ }; #define eflag optval[0] #define fflag optval[1] #define Iflag optval[2] #define iflag optval[3] #define mflag optval[4] #define nflag optval[5] #define sflag optval[6] #define xflag optval[7] #define vflag optval[8] #define Vflag optval[9] #define Eflag optval[10] #define Cflag optval[11] #define aflag optval[12] #define bflag optval[13] #define uflag optval[14] #define privileged optval[15] #define Tflag optval[16] #define Pflag optval[17] #define hflag optval[18] #define nologflag optval[19] #define pipefailflag optval[20] #define verifyflag optval[21] #define NSHORTOPTS 19 #define NOPTS 22 extern char optval[NOPTS]; extern const char optletter[NSHORTOPTS]; #ifdef DEFINE_OPTIONS char optval[NOPTS]; const char optletter[NSHORTOPTS] = "efIimnsxvVECabupTPh"; static const unsigned char optname[] = "\007errexit" "\006noglob" "\011ignoreeof" "\013interactive" "\007monitor" "\006noexec" "\005stdin" "\006xtrace" "\007verbose" "\002vi" "\005emacs" "\011noclobber" "\011allexport" "\006notify" "\007nounset" "\012privileged" "\012trapsasync" "\010physical" "\010trackall" "\005nolog" "\010pipefail" "\006verify" ; #endif extern char *minusc; /* argument to -c option */ extern char *arg0; /* $0 */ extern struct shparam shellparam; /* $@ */ extern char **argptr; /* argument list for builtin commands */ extern char *shoptarg; /* set by nextopt */ extern char *nextopt_optptr; /* used by nextopt */ void procargs(int, char **); void optschanged(void); void freeparam(struct shparam *); int nextopt(const char *); void getoptsreset(const char *); diff --git a/bin/sh/output.h b/bin/sh/output.h index 62f006d32a36..409cc16df75e 100644 --- a/bin/sh/output.h +++ b/bin/sh/output.h @@ -1,87 +1,86 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)output.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #ifndef OUTPUT_INCL #include #include #include struct output { char *nextc; char *bufend; char *buf; int bufsize; short fd; short flags; }; extern struct output output; /* to fd 1 */ extern struct output errout; /* to fd 2 */ extern struct output memout; extern struct output *out1; /* &memout if backquote, otherwise &output */ extern struct output *out2; /* &memout if backquote with 2>&1, otherwise &errout */ void outcslow(int, struct output *); void out1str(const char *); void out1qstr(const char *); void out2str(const char *); void out2qstr(const char *); void outstr(const char *, struct output *); void outqstr(const char *, struct output *); void outbin(const void *, size_t, struct output *); void emptyoutbuf(struct output *); void flushall(void); void flushout(struct output *); void freestdout(void); int outiserror(struct output *); void outclearerror(struct output *); void outfmt(struct output *, const char *, ...) __printflike(2, 3); void out1fmt(const char *, ...) __printflike(1, 2); void out2fmt_flush(const char *, ...) __printflike(1, 2); void fmtstr(char *, int, const char *, ...) __printflike(3, 4); void doformat(struct output *, const char *, va_list) __printflike(2, 0); FILE *out1fp(void); int xwrite(int, const char *, int); #define outc(c, file) ((file)->nextc == (file)->bufend ? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) #define out1c(c) outc(c, out1); #define out2c(c) outcslow(c, out2); #define OUTPUT_INCL #endif diff --git a/bin/sh/parser.h b/bin/sh/parser.h index aee8244ecf09..5f5249866b0a 100644 --- a/bin/sh/parser.h +++ b/bin/sh/parser.h @@ -1,87 +1,86 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)parser.h 8.3 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* control characters in argument strings */ #define CTLESC '\300' #define CTLVAR '\301' #define CTLENDVAR '\371' #define CTLBACKQ '\372' #define CTLQUOTE 01 /* ored with CTLBACKQ code if in quotes */ /* CTLBACKQ | CTLQUOTE == '\373' */ #define CTLARI '\374' #define CTLENDARI '\375' #define CTLQUOTEMARK '\376' #define CTLQUOTEEND '\377' /* only for ${v+-...} */ /* variable substitution byte (follows CTLVAR) */ #define VSTYPE 0x0f /* type of variable substitution */ #define VSNUL 0x10 /* colon--treat the empty string as unset */ #define VSLINENO 0x20 /* expansion of $LINENO, the line number \ follows immediately */ #define VSQUOTE 0x80 /* inside double quotes--suppress splitting */ /* values of VSTYPE field */ #define VSNORMAL 0x1 /* normal variable: $var or ${var} */ #define VSMINUS 0x2 /* ${var-text} */ #define VSPLUS 0x3 /* ${var+text} */ #define VSQUESTION 0x4 /* ${var?message} */ #define VSASSIGN 0x5 /* ${var=text} */ #define VSTRIMLEFT 0x6 /* ${var#pattern} */ #define VSTRIMLEFTMAX 0x7 /* ${var##pattern} */ #define VSTRIMRIGHT 0x8 /* ${var%pattern} */ #define VSTRIMRIGHTMAX 0x9 /* ${var%%pattern} */ #define VSLENGTH 0xa /* ${#var} */ #define VSERROR 0xb /* Syntax error, issue when expanded */ /* * NEOF is returned by parsecmd when it encounters an end of file. It * must be distinct from NULL. */ #define NEOF ((union node *)-1) extern int whichprompt; /* 1 == PS1, 2 == PS2 */ extern const char *const parsekwd[]; union node *parsecmd(int); union node *parsewordexp(void); void forcealias(void); void fixredir(union node *, const char *, int); int goodname(const char *); int isassignment(const char *); char *getprompt(void *); const char *expandstr(const char *); diff --git a/bin/sh/redir.h b/bin/sh/redir.h index 08c52359c59e..f49d0ddc9a73 100644 --- a/bin/sh/redir.h +++ b/bin/sh/redir.h @@ -1,47 +1,46 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)redir.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* flags passed to redirect */ #define REDIR_PUSH 01 /* save previous values of file descriptors */ #define REDIR_BACKQ 02 /* save the command output in memory */ union node; void redirect(union node *, int); void popredir(void); int fd0_redirected_p(void); void clearredir(void); diff --git a/bin/sh/shell.h b/bin/sh/shell.h index 536efe6ce228..64a2be86b4f7 100644 --- a/bin/sh/shell.h +++ b/bin/sh/shell.h @@ -1,77 +1,76 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)shell.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ #ifndef SHELL_H_ #define SHELL_H_ #include /* * The follow should be set to reflect the type of system you have: * JOBS -> 1 if you have Berkeley job control, 0 otherwise. * define DEBUG=1 to compile in debugging (set global "debug" to turn on) * define DEBUG=2 to compile in and turn on debugging. * * When debugging is on, debugging info will be written to ./trace and * a quit signal will generate a core dump. */ #define JOBS 1 /* #define DEBUG 1 */ /* * Type of used arithmetic. SUSv3 requires us to have at least signed long. */ typedef intmax_t arith_t; #define ARITH_FORMAT_STR "%" PRIdMAX #define ARITH_MIN INTMAX_MIN #define ARITH_MAX INTMAX_MAX typedef void *pointer; #include extern char nullstr[1]; /* null string */ #ifdef DEBUG #define TRACE(param) sh_trace param #else #define TRACE(param) #endif #endif /* !SHELL_H_ */ diff --git a/bin/sh/show.h b/bin/sh/show.h index 790a62e2942c..9dc77c6857d6 100644 --- a/bin/sh/show.h +++ b/bin/sh/show.h @@ -1,44 +1,43 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)show.h 1.1 (Berkeley) 5/4/95 - * $FreeBSD$ */ void showtree(union node *); #ifdef DEBUG void sh_trace(const char *, ...) __printflike(1, 2); void trargs(char **); void trputc(int); void trputs(const char *); void opentrace(void); extern int debug; #endif diff --git a/bin/sh/trap.h b/bin/sh/trap.h index fdc4b7a9683a..f7985e8e70a1 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -1,51 +1,50 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)trap.h 8.3 (Berkeley) 6/5/95 - * $FreeBSD$ */ extern volatile sig_atomic_t pendingsig; extern volatile sig_atomic_t pendingsig_waitcmd; void clear_traps(void); int have_traps(void); void setsignal(int); void ignoresig(int); int issigchldtrapped(void); void onsig(int); void dotrap(void); void trap_init(void); void setinteractive(void); void exitshell(int) __dead2; void exitshell_savedstatus(void) __dead2; diff --git a/bin/sh/var.h b/bin/sh/var.h index eaf4f427f63b..abd2a47c1979 100644 --- a/bin/sh/var.h +++ b/bin/sh/var.h @@ -1,132 +1,131 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Kenneth Almquist. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)var.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD$ */ /* * Shell variables. */ /* flags */ #define VEXPORT 0x01 /* variable is exported */ #define VREADONLY 0x02 /* variable cannot be modified */ #define VSTRFIXED 0x04 /* variable struct is statically allocated */ #define VTEXTFIXED 0x08 /* text is statically allocated */ #define VSTACK 0x10 /* text is allocated on the stack */ #define VUNSET 0x20 /* the variable is not set */ #define VNOFUNC 0x40 /* don't call the callback function */ #define VNOSET 0x80 /* do not set variable - just readonly test */ #define VNOLOCAL 0x100 /* ignore forcelocal */ struct var { struct var *next; /* next entry in hash list */ int flags; /* flags are defined above */ int name_len; /* length of name */ char *text; /* name=value */ void (*func)(const char *); /* function to be called when */ /* the variable gets set/unset */ }; struct localvar { struct localvar *next; /* next local variable in list */ struct var *vp; /* the variable that was made local */ int flags; /* saved flags */ char *text; /* saved text */ }; extern struct localvar *localvars; extern int forcelocal; extern struct var vifs; extern struct var vmail; extern struct var vmpath; extern struct var vpath; extern struct var vps1; extern struct var vps2; extern struct var vps4; extern struct var vdisvfork; #ifndef NO_HISTORY extern struct var vhistsize; extern struct var vterm; #endif extern int localeisutf8; /* The parser uses the locale that was in effect at startup. */ extern int initial_localeisutf8; /* * The following macros access the values of the above variables. * They have to skip over the name. They return the null string * for unset variables. */ #define ifsval() (vifs.text + 4) #define ifsset() ((vifs.flags & VUNSET) == 0) #define mailval() (vmail.text + 5) #define mpathval() (vmpath.text + 9) #define pathval() (vpath.text + 5) #define ps1val() (vps1.text + 4) #define ps2val() (vps2.text + 4) #define ps4val() (vps4.text + 4) #define optindval() (voptind.text + 7) #ifndef NO_HISTORY #define histsizeval() (vhistsize.text + 9) #define termval() (vterm.text + 5) #endif #define mpathset() ((vmpath.flags & VUNSET) == 0) #define disvforkset() ((vdisvfork.flags & VUNSET) == 0) void initvar(void); void setvar(const char *, const char *, int); void setvareq(char *, int); struct arglist; void listsetvar(struct arglist *, int); char *lookupvar(const char *); char *bltinlookup(const char *, int); void bltinsetlocale(void); void bltinunsetlocale(void); void updatecharset(void); void initcharset(void); char **environment(void); int showvarscmd(int, char **); void mklocal(char *); void poplocalvars(void); int unsetvar(const char *); int setvarsafe(const char *, const char *, int); diff --git a/bin/stty/extern.h b/bin/stty/extern.h index 88b58890f7d1..40aa92c35de1 100644 --- a/bin/stty/extern.h +++ b/bin/stty/extern.h @@ -1,45 +1,44 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ int c_cchars(const void *, const void *); int c_modes(const void *, const void *); int csearch(char ***, struct info *); void checkredirect(void); void gprint(struct termios *, struct winsize *, int); void gread(struct termios *, char *); int ksearch(char ***, struct info *); int msearch(char ***, struct info *); void optlist(void); void print(struct termios *, struct winsize *, int, enum FMT); void usage(void) __dead2; extern struct cchar cchars1[], cchars2[]; diff --git a/bin/stty/stty.h b/bin/stty/stty.h index d48ccaa20b6e..d4236b09cb6a 100644 --- a/bin/stty/stty.h +++ b/bin/stty/stty.h @@ -1,55 +1,54 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)stty.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ #include #include struct info { int fd; /* file descriptor */ int ldisc; /* line discipline */ int off; /* turn off */ int set; /* need set */ int wset; /* need window set */ const char *arg; /* argument */ struct termios t; /* terminal info */ struct winsize win; /* window info */ }; struct cchar { const char *name; int sub; u_char def; }; enum FMT { NOTSET, GFLAG, BSD, POSIX }; #define LINELENGTH 72 diff --git a/cddl/compat/opensolaris/include/thread_pool.h b/cddl/compat/opensolaris/include/thread_pool.h index 3bd23a6dd2aa..3f4f74212d78 100644 --- a/cddl/compat/opensolaris/include/thread_pool.h +++ b/cddl/compat/opensolaris/include/thread_pool.h @@ -1,78 +1,77 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* - * $FreeBSD$ */ #ifndef _THREAD_POOL_H_ #define _THREAD_POOL_H_ #pragma ident "%Z%%M% %I% %E% SMI" #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct tpool tpool_t; /* opaque thread pool descriptor */ #if defined(__STDC__) extern tpool_t *tpool_create(uint_t min_threads, uint_t max_threads, uint_t linger, pthread_attr_t *attr); extern int tpool_dispatch(tpool_t *tpool, void (*func)(void *), void *arg); extern void tpool_destroy(tpool_t *tpool); extern void tpool_abandon(tpool_t *tpool); extern void tpool_wait(tpool_t *tpool); extern void tpool_suspend(tpool_t *tpool); extern int tpool_suspended(tpool_t *tpool); extern void tpool_resume(tpool_t *tpool); extern int tpool_member(tpool_t *tpool); #else /* Non ANSI */ extern tpool_t *tpool_create(); extern int tpool_dispatch(); extern void tpool_destroy(); extern void tpool_abandon(); extern void tpool_wait(); extern void tpool_suspend(); extern int tpool_suspended(); extern void tpool_resume(); extern int tpool_member(); #endif /* __STDC__ */ #ifdef __cplusplus } #endif #endif /* _THREAD_POOL_H_ */ diff --git a/include/_ctype.h b/include/_ctype.h index 96fbaeba00d6..91e6b1d14f6b 100644 --- a/include/_ctype.h +++ b/include/_ctype.h @@ -1,189 +1,188 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * From @(#)ctype.h 8.4 (Berkeley) 1/21/94 * From FreeBSD: src/include/ctype.h,v 1.27 2004/06/23 07:11:39 tjr Exp - * $FreeBSD$ */ #ifndef __CTYPE_H_ #define __CTYPE_H_ #include #include #define _CTYPE_A 0x00000100L /* Alpha */ #define _CTYPE_C 0x00000200L /* Control */ #define _CTYPE_D 0x00000400L /* Digit */ #define _CTYPE_G 0x00000800L /* Graph */ #define _CTYPE_L 0x00001000L /* Lower */ #define _CTYPE_P 0x00002000L /* Punct */ #define _CTYPE_S 0x00004000L /* Space */ #define _CTYPE_U 0x00008000L /* Upper */ #define _CTYPE_X 0x00010000L /* X digit */ #define _CTYPE_B 0x00020000L /* Blank */ #define _CTYPE_R 0x00040000L /* Print */ #define _CTYPE_I 0x00080000L /* Ideogram */ #define _CTYPE_T 0x00100000L /* Special */ #define _CTYPE_Q 0x00200000L /* Phonogram */ #define _CTYPE_N 0x00400000L /* Number (superset of digit) */ #define _CTYPE_SW0 0x20000000L /* 0 width character */ #define _CTYPE_SW1 0x40000000L /* 1 width character */ #define _CTYPE_SW2 0x80000000L /* 2 width character */ #define _CTYPE_SW3 0xc0000000L /* 3 width character */ #define _CTYPE_SWM 0xe0000000L /* Mask for screen width data */ #define _CTYPE_SWS 30 /* Bits to shift to get width */ /* See comments in about __ct_rune_t. */ __BEGIN_DECLS unsigned long ___runetype(__ct_rune_t) __pure; __ct_rune_t ___tolower(__ct_rune_t) __pure; __ct_rune_t ___toupper(__ct_rune_t) __pure; __END_DECLS /* * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us * to generate code for extern versions of all our inline functions. */ #ifdef _EXTERNALIZE_CTYPE_INLINES_ #define _USE_CTYPE_INLINE_ #define static #define __inline #endif extern int __mb_sb_limit; /* * Use inline functions if we are allowed to and the compiler supports them. */ #if !defined(_DONT_USE_CTYPE_INLINE_) && \ (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus)) #include static __inline int __maskrune(__ct_rune_t _c, unsigned long _f) { return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) : _CurrentRuneLocale->__runetype[_c]) & _f; } static __inline int __sbmaskrune(__ct_rune_t _c, unsigned long _f) { return (_c < 0 || _c >= __mb_sb_limit) ? 0 : _CurrentRuneLocale->__runetype[_c] & _f; } static __inline int __istype(__ct_rune_t _c, unsigned long _f) { return (!!__maskrune(_c, _f)); } static __inline int __sbistype(__ct_rune_t _c, unsigned long _f) { return (!!__sbmaskrune(_c, _f)); } static __inline int __isctype(__ct_rune_t _c, unsigned long _f) { return (_c < 0 || _c >= 128) ? 0 : !!(_DefaultRuneLocale.__runetype[_c] & _f); } static __inline __ct_rune_t __toupper(__ct_rune_t _c) { return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) : _CurrentRuneLocale->__mapupper[_c]; } static __inline __ct_rune_t __sbtoupper(__ct_rune_t _c) { return (_c < 0 || _c >= __mb_sb_limit) ? _c : _CurrentRuneLocale->__mapupper[_c]; } static __inline __ct_rune_t __tolower(__ct_rune_t _c) { return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) : _CurrentRuneLocale->__maplower[_c]; } static __inline __ct_rune_t __sbtolower(__ct_rune_t _c) { return (_c < 0 || _c >= __mb_sb_limit) ? _c : _CurrentRuneLocale->__maplower[_c]; } static __inline int __wcwidth(__ct_rune_t _c) { unsigned int _x; if (_c == 0) return (0); _x = (unsigned int)__maskrune(_c, _CTYPE_SWM|_CTYPE_R); if ((_x & _CTYPE_SWM) != 0) return ((_x & _CTYPE_SWM) >> _CTYPE_SWS); return ((_x & _CTYPE_R) != 0 ? 1 : -1); } #else /* not using inlines */ __BEGIN_DECLS int __maskrune(__ct_rune_t, unsigned long); int __sbmaskrune(__ct_rune_t, unsigned long); int __istype(__ct_rune_t, unsigned long); int __sbistype(__ct_rune_t, unsigned long); int __isctype(__ct_rune_t, unsigned long); __ct_rune_t __toupper(__ct_rune_t); __ct_rune_t __sbtoupper(__ct_rune_t); __ct_rune_t __tolower(__ct_rune_t); __ct_rune_t __sbtolower(__ct_rune_t); int __wcwidth(__ct_rune_t); __END_DECLS #endif /* using inlines */ #endif /* !__CTYPE_H_ */ diff --git a/include/a.out.h b/include/a.out.h index d532d062cacf..8e0a3c34bfe1 100644 --- a/include/a.out.h +++ b/include/a.out.h @@ -1,47 +1,46 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)a.out.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _AOUT_H_ #define _AOUT_H_ #include #include #include #include #include #define _AOUT_INCLUDE_ #include #endif /* !_AOUT_H_ */ diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 357a444a0d2e..881027a0d63a 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -1,180 +1,179 @@ /*- * SPDX-License-Identifier: (BSD-3-Clause AND ISC) * * ++Copyright++ 1983, 1993 * - * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ /*% * @(#)inet.h 8.1 (Berkeley) 6/2/93 * $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $ - * $FreeBSD$ */ #ifndef _ARPA_INET_H_ #define _ARPA_INET_H_ /* External definitions for functions in inet(3). */ #include #include /* Required for byteorder(3) functions. */ #include #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 #ifndef _UINT16_T_DECLARED typedef __uint16_t uint16_t; #define _UINT16_T_DECLARED #endif #ifndef _UINT32_T_DECLARED typedef __uint32_t uint32_t; #define _UINT32_T_DECLARED #endif #ifndef _IN_ADDR_T_DECLARED typedef uint32_t in_addr_t; #define _IN_ADDR_T_DECLARED #endif #ifndef _IN_PORT_T_DECLARED typedef uint16_t in_port_t; #define _IN_PORT_T_DECLARED #endif #if __BSD_VISIBLE #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #endif /* * XXX socklen_t is used by a POSIX.1-2001 interface, but not required by * POSIX.1-2001. */ #ifndef _SOCKLEN_T_DECLARED typedef __socklen_t socklen_t; #define _SOCKLEN_T_DECLARED #endif #ifndef _STRUCT_IN_ADDR_DECLARED struct in_addr { in_addr_t s_addr; }; #define _STRUCT_IN_ADDR_DECLARED #endif /* XXX all new diversions!! argh!! */ #if __BSD_VISIBLE #define inet_addr __inet_addr #define inet_aton __inet_aton #define inet_lnaof __inet_lnaof #define inet_makeaddr __inet_makeaddr #define inet_neta __inet_neta #define inet_netof __inet_netof #define inet_network __inet_network #define inet_net_ntop __inet_net_ntop #define inet_net_pton __inet_net_pton #define inet_cidr_ntop __inet_cidr_ntop #define inet_cidr_pton __inet_cidr_pton #define inet_ntoa __inet_ntoa #define inet_ntoa_r __inet_ntoa_r #define inet_pton __inet_pton #define inet_ntop __inet_ntop #define inet_nsap_addr __inet_nsap_addr #define inet_nsap_ntoa __inet_nsap_ntoa #endif /* __BSD_VISIBLE */ __BEGIN_DECLS #ifndef _BYTEORDER_PROTOTYPED #define _BYTEORDER_PROTOTYPED uint32_t htonl(uint32_t); uint16_t htons(uint16_t); uint32_t ntohl(uint32_t); uint16_t ntohs(uint16_t); #endif in_addr_t inet_addr(const char *); /*const*/ char *inet_ntoa(struct in_addr); const char *inet_ntop(int, const void * __restrict, char * __restrict, socklen_t); int inet_pton(int, const char * __restrict, void * __restrict); #if __BSD_VISIBLE int inet_aton(const char *, struct in_addr *); in_addr_t inet_lnaof(struct in_addr); struct in_addr inet_makeaddr(in_addr_t, in_addr_t); char * inet_neta(in_addr_t, char *, size_t); in_addr_t inet_netof(struct in_addr); in_addr_t inet_network(const char *); char *inet_net_ntop(int, const void *, int, char *, size_t); int inet_net_pton(int, const char *, void *, size_t); char *inet_ntoa_r(struct in_addr, char *buf, socklen_t size); char *inet_cidr_ntop(int, const void *, int, char *, size_t); int inet_cidr_pton(int, const char *, void *, int *); unsigned inet_nsap_addr(const char *, unsigned char *, int); char *inet_nsap_ntoa(int, const unsigned char *, char *); #endif /* __BSD_VISIBLE */ __END_DECLS #ifndef _BYTEORDER_FUNC_DEFINED #define _BYTEORDER_FUNC_DEFINED #define htonl(x) __htonl(x) #define htons(x) __htons(x) #define ntohl(x) __ntohl(x) #define ntohs(x) __ntohs(x) #endif #endif /* !_ARPA_INET_H_ */ /*! \file */ diff --git a/include/arpa/nameser.h b/include/arpa/nameser.h index 69ec06dd7233..4c4d0788b7df 100644 --- a/include/arpa/nameser.h +++ b/include/arpa/nameser.h @@ -1,642 +1,641 @@ /*- * SPDX-License-Identifier: (ISC AND BSD-3-Clause) * * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1996-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /*- * Copyright (c) 1983, 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * $Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp $ - * $FreeBSD$ */ #ifndef _ARPA_NAMESER_H_ #define _ARPA_NAMESER_H_ /*! \file */ #define BIND_4_COMPAT #include #include #include /*% * Revision information. This is the release date in YYYYMMDD format. * It can change every day so the right thing to do with it is use it * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not * compare for equality; rather, use it to determine whether your libbind.a * contains a new enough lib/nameser/ to support the feature you need. */ #define __NAMESER 20090302 /*%< New interface version stamp. */ /* * Define constants based on RFC0883, RFC1034, RFC 1035 */ #define NS_PACKETSZ 512 /*%< default UDP packet size */ #define NS_MAXDNAME 1025 /*%< maximum domain name (presentation format)*/ #define NS_MAXMSG 65535 /*%< maximum message size */ #define NS_MAXCDNAME 255 /*%< maximum compressed domain name */ #define NS_MAXLABEL 63 /*%< maximum length of domain label */ #define NS_MAXLABELS 128 /*%< theoretical max #/labels per domain name */ #define NS_MAXNNAME 256 /*%< maximum uncompressed (binary) domain name*/ #define NS_MAXPADDR (sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") #define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */ #define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */ #define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */ #define NS_INT32SZ 4 /*%< #/bytes of data in a u_int32_t */ #define NS_INT16SZ 2 /*%< #/bytes of data in a u_int16_t */ #define NS_INT8SZ 1 /*%< #/bytes of data in a u_int8_t */ #define NS_INADDRSZ 4 /*%< IPv4 T_A */ #define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */ #define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */ #define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */ /* * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() * in synch with it. */ typedef enum __ns_sect { ns_s_qd = 0, /*%< Query: Question. */ ns_s_zn = 0, /*%< Update: Zone. */ ns_s_an = 1, /*%< Query: Answer. */ ns_s_pr = 1, /*%< Update: Prerequisites. */ ns_s_ns = 2, /*%< Query: Name servers. */ ns_s_ud = 2, /*%< Update: Update. */ ns_s_ar = 3, /*%< Query|Update: Additional records. */ ns_s_max = 4 } ns_sect; /*% * Network name (compressed or not) type. Equivalent to a pointer when used * in a function prototype. Can be const'd. */ typedef u_char ns_nname[NS_MAXNNAME]; typedef const u_char *ns_nname_ct; typedef u_char *ns_nname_t; struct ns_namemap { ns_nname_ct base; int len; }; typedef struct ns_namemap *ns_namemap_t; typedef const struct ns_namemap *ns_namemap_ct; /*% * This is a message handle. It is caller allocated and has no dynamic data. * This structure is intended to be opaque to all but ns_parse.c, thus the * leading _'s on the member names. Use the accessor functions, not the _'s. */ typedef struct __ns_msg { const u_char *_msg, *_eom; u_int16_t _id, _flags, _counts[ns_s_max]; const u_char *_sections[ns_s_max]; ns_sect _sect; int _rrnum; const u_char *_msg_ptr; } ns_msg; /* Private data structure - do not use from outside library. */ struct _ns_flagdata { int mask, shift; }; extern struct _ns_flagdata _ns_flagdata[]; /* Accessor macros - this is part of the public interface. */ #define ns_msg_id(handle) ((handle)._id + 0) #define ns_msg_base(handle) ((handle)._msg + 0) #define ns_msg_end(handle) ((handle)._eom + 0) #define ns_msg_size(handle) ((handle)._eom - (handle)._msg) #define ns_msg_count(handle, section) ((handle)._counts[section] + 0) /*% * This is a parsed record. It is caller allocated and has no dynamic data. */ typedef struct __ns_rr { char name[NS_MAXDNAME]; u_int16_t type; u_int16_t rr_class; u_int32_t ttl; u_int16_t rdlength; const u_char * rdata; } ns_rr; /* * Same thing, but using uncompressed network binary names, and real C types. */ typedef struct __ns_rr2 { ns_nname nname; size_t nnamel; int type; int rr_class; u_int ttl; int rdlength; const u_char * rdata; } ns_rr2; /* Accessor macros - this is part of the public interface. */ #define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") #define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname) #define ns_rr_nnamel(rr) ((rr).nnamel + 0) #define ns_rr_type(rr) ((ns_type)((rr).type + 0)) #define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) #define ns_rr_ttl(rr) ((rr).ttl + 0) #define ns_rr_rdlen(rr) ((rr).rdlength + 0) #define ns_rr_rdata(rr) ((rr).rdata + 0) /*% * These don't have to be in the same order as in the packet flags word, * and they can even overlap in some cases, but they will need to be kept * in synch with ns_parse.c:ns_flagdata[]. */ typedef enum __ns_flag { ns_f_qr, /*%< Question/Response. */ ns_f_opcode, /*%< Operation code. */ ns_f_aa, /*%< Authoritative Answer. */ ns_f_tc, /*%< Truncation occurred. */ ns_f_rd, /*%< Recursion Desired. */ ns_f_ra, /*%< Recursion Available. */ ns_f_z, /*%< MBZ. */ ns_f_ad, /*%< Authentic Data (DNSSEC). */ ns_f_cd, /*%< Checking Disabled (DNSSEC). */ ns_f_rcode, /*%< Response code. */ ns_f_max } ns_flag; /*% * Currently defined opcodes. */ typedef enum __ns_opcode { ns_o_query = 0, /*%< Standard query. */ ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */ ns_o_status = 2, /*%< Name server status query (unsupported). */ /* Opcode 3 is undefined/reserved. */ ns_o_notify = 4, /*%< Zone change notification. */ ns_o_update = 5, /*%< Zone update message. */ ns_o_max = 6 } ns_opcode; /*% * Currently defined response codes. */ typedef enum __ns_rcode { ns_r_noerror = 0, /*%< No error occurred. */ ns_r_formerr = 1, /*%< Format error. */ ns_r_servfail = 2, /*%< Server failure. */ ns_r_nxdomain = 3, /*%< Name error. */ ns_r_notimpl = 4, /*%< Unimplemented. */ ns_r_refused = 5, /*%< Operation refused. */ /* these are for BIND_UPDATE */ ns_r_yxdomain = 6, /*%< Name exists */ ns_r_yxrrset = 7, /*%< RRset exists */ ns_r_nxrrset = 8, /*%< RRset does not exist */ ns_r_notauth = 9, /*%< Not authoritative for zone */ ns_r_notzone = 10, /*%< Zone of record different from zone section */ ns_r_max = 11, /* The following are EDNS extended rcodes */ ns_r_badvers = 16, /* The following are TSIG errors */ ns_r_badsig = 16, ns_r_badkey = 17, ns_r_badtime = 18 } ns_rcode; /* BIND_UPDATE */ typedef enum __ns_update_operation { ns_uop_delete = 0, ns_uop_add = 1, ns_uop_max = 2 } ns_update_operation; /*% * This structure is used for TSIG authenticated messages */ struct ns_tsig_key { char name[NS_MAXDNAME], alg[NS_MAXDNAME]; unsigned char *data; int len; }; typedef struct ns_tsig_key ns_tsig_key; /*% * This structure is used for TSIG authenticated TCP messages */ struct ns_tcp_tsig_state { int counter; struct dst_key *key; void *ctx; unsigned char sig[NS_PACKETSZ]; int siglen; }; typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; #define NS_TSIG_FUDGE 300 #define NS_TSIG_TCP_COUNT 100 #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" #define NS_TSIG_ERROR_NO_TSIG -10 #define NS_TSIG_ERROR_NO_SPACE -11 #define NS_TSIG_ERROR_FORMERR -12 /*% * Currently defined type values for resources and queries. */ typedef enum __ns_type { ns_t_invalid = 0, /*%< Cookie. */ ns_t_a = 1, /*%< Host address. */ ns_t_ns = 2, /*%< Authoritative server. */ ns_t_md = 3, /*%< Mail destination. */ ns_t_mf = 4, /*%< Mail forwarder. */ ns_t_cname = 5, /*%< Canonical name. */ ns_t_soa = 6, /*%< Start of authority zone. */ ns_t_mb = 7, /*%< Mailbox domain name. */ ns_t_mg = 8, /*%< Mail group member. */ ns_t_mr = 9, /*%< Mail rename name. */ ns_t_null = 10, /*%< Null resource record. */ ns_t_wks = 11, /*%< Well known service. */ ns_t_ptr = 12, /*%< Domain name pointer. */ ns_t_hinfo = 13, /*%< Host information. */ ns_t_minfo = 14, /*%< Mailbox information. */ ns_t_mx = 15, /*%< Mail routing information. */ ns_t_txt = 16, /*%< Text strings. */ ns_t_rp = 17, /*%< Responsible person. */ ns_t_afsdb = 18, /*%< AFS cell database. */ ns_t_x25 = 19, /*%< X_25 calling address. */ ns_t_isdn = 20, /*%< ISDN calling address. */ ns_t_rt = 21, /*%< Router. */ ns_t_nsap = 22, /*%< NSAP address. */ ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */ ns_t_sig = 24, /*%< Security signature. */ ns_t_key = 25, /*%< Security key. */ ns_t_px = 26, /*%< X.400 mail mapping. */ ns_t_gpos = 27, /*%< Geographical position (withdrawn). */ ns_t_aaaa = 28, /*%< IPv6 Address. */ ns_t_loc = 29, /*%< Location Information. */ ns_t_nxt = 30, /*%< Next domain (security). */ ns_t_eid = 31, /*%< Endpoint identifier. */ ns_t_nimloc = 32, /*%< Nimrod Locator. */ ns_t_srv = 33, /*%< Server Selection. */ ns_t_atma = 34, /*%< ATM Address */ ns_t_naptr = 35, /*%< Naming Authority PoinTeR */ ns_t_kx = 36, /*%< Key Exchange */ ns_t_cert = 37, /*%< Certification record */ ns_t_a6 = 38, /*%< IPv6 address (experimental) */ ns_t_dname = 39, /*%< Non-terminal DNAME */ ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */ ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */ ns_t_apl = 42, /*%< Address prefix list (RFC3123) */ ns_t_ds = 43, /*%< Delegation Signer */ ns_t_sshfp = 44, /*%< SSH Fingerprint */ ns_t_ipseckey = 45, /*%< IPSEC Key */ ns_t_rrsig = 46, /*%< RRset Signature */ ns_t_nsec = 47, /*%< Negative security */ ns_t_dnskey = 48, /*%< DNS Key */ ns_t_dhcid = 49, /*%< Dynamic host configuratin identifier */ ns_t_nsec3 = 50, /*%< Negative security type 3 */ ns_t_nsec3param = 51, /*%< Negative security type 3 parameters */ ns_t_hip = 55, /*%< Host Identity Protocol */ ns_t_spf = 99, /*%< Sender Policy Framework */ ns_t_tkey = 249, /*%< Transaction key */ ns_t_tsig = 250, /*%< Transaction signature. */ ns_t_ixfr = 251, /*%< Incremental zone transfer. */ ns_t_axfr = 252, /*%< Transfer zone of authority. */ ns_t_mailb = 253, /*%< Transfer mailbox records. */ ns_t_maila = 254, /*%< Transfer mail agent records. */ ns_t_any = 255, /*%< Wildcard match. */ ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */ ns_t_dlv = 32769, /*%< DNSSEC look-aside validatation. */ ns_t_max = 65536 } ns_type; /* Exclusively a QTYPE? (not also an RTYPE) */ #define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ (t) == ns_t_mailb || (t) == ns_t_maila) /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ #define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ (t) == ns_t_zxfr) /*% * Values for class field */ typedef enum __ns_class { ns_c_invalid = 0, /*%< Cookie. */ ns_c_in = 1, /*%< Internet. */ ns_c_2 = 2, /*%< unallocated/unsupported. */ ns_c_chaos = 3, /*%< MIT Chaos-net. */ ns_c_hs = 4, /*%< MIT Hesiod. */ /* Query class values which do not appear in resource records */ ns_c_none = 254, /*%< for prereq. sections in update requests */ ns_c_any = 255, /*%< Wildcard match. */ ns_c_max = 65536 } ns_class; /* DNSSEC constants. */ typedef enum __ns_key_types { ns_kt_rsa = 1, /*%< key type RSA/MD5 */ ns_kt_dh = 2, /*%< Diffie Hellman */ ns_kt_dsa = 3, /*%< Digital Signature Standard (MANDATORY) */ ns_kt_private = 254 /*%< Private key type starts with OID */ } ns_key_types; typedef enum __ns_cert_types { cert_t_pkix = 1, /*%< PKIX (X.509v3) */ cert_t_spki = 2, /*%< SPKI */ cert_t_pgp = 3, /*%< PGP */ cert_t_url = 253, /*%< URL private type */ cert_t_oid = 254 /*%< OID private type */ } ns_cert_types; /* Flags field of the KEY RR rdata. */ #define NS_KEY_TYPEMASK 0xC000 /*%< Mask for "type" bits */ #define NS_KEY_TYPE_AUTH_CONF 0x0000 /*%< Key usable for both */ #define NS_KEY_TYPE_CONF_ONLY 0x8000 /*%< Key usable for confidentiality */ #define NS_KEY_TYPE_AUTH_ONLY 0x4000 /*%< Key usable for authentication */ #define NS_KEY_TYPE_NO_KEY 0xC000 /*%< No key usable for either; no key */ /* The type bits can also be interpreted independently, as single bits: */ #define NS_KEY_NO_AUTH 0x8000 /*%< Key unusable for authentication */ #define NS_KEY_NO_CONF 0x4000 /*%< Key unusable for confidentiality */ #define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ #define NS_KEY_EXTENDED_FLAGS 0x1000 /*%< reserved - must be zero */ #define NS_KEY_RESERVED4 0x0800 /*%< reserved - must be zero */ #define NS_KEY_RESERVED5 0x0400 /*%< reserved - must be zero */ #define NS_KEY_NAME_TYPE 0x0300 /*%< these bits determine the type */ #define NS_KEY_NAME_USER 0x0000 /*%< key is assoc. with user */ #define NS_KEY_NAME_ENTITY 0x0200 /*%< key is assoc. with entity eg host */ #define NS_KEY_NAME_ZONE 0x0100 /*%< key is zone key */ #define NS_KEY_NAME_RESERVED 0x0300 /*%< reserved meaning */ #define NS_KEY_RESERVED8 0x0080 /*%< reserved - must be zero */ #define NS_KEY_RESERVED9 0x0040 /*%< reserved - must be zero */ #define NS_KEY_RESERVED10 0x0020 /*%< reserved - must be zero */ #define NS_KEY_RESERVED11 0x0010 /*%< reserved - must be zero */ #define NS_KEY_SIGNATORYMASK 0x000F /*%< key can sign RR's of same name */ #define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ NS_KEY_RESERVED4 | \ NS_KEY_RESERVED5 | \ NS_KEY_RESERVED8 | \ NS_KEY_RESERVED9 | \ NS_KEY_RESERVED10 | \ NS_KEY_RESERVED11 ) #define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */ /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ #define NS_ALG_MD5RSA 1 /*%< MD5 with RSA */ #define NS_ALG_DH 2 /*%< Diffie Hellman KEY */ #define NS_ALG_DSA 3 /*%< DSA KEY */ #define NS_ALG_DSS NS_ALG_DSA #define NS_ALG_EXPIRE_ONLY 253 /*%< No alg, no security */ #define NS_ALG_PRIVATE_OID 254 /*%< Key begins with OID giving alg */ /* Protocol values */ /* value 0 is reserved */ #define NS_KEY_PROT_TLS 1 #define NS_KEY_PROT_EMAIL 2 #define NS_KEY_PROT_DNSSEC 3 #define NS_KEY_PROT_IPSEC 4 #define NS_KEY_PROT_ANY 255 /* Signatures */ #define NS_MD5RSA_MIN_BITS 512 /*%< Size of a mod or exp in bits */ #define NS_MD5RSA_MAX_BITS 4096 /* Total of binary mod and exp */ #define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) /* Max length of text sig block */ #define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) #define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) #define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) #define NS_DSA_SIG_SIZE 41 #define NS_DSA_MIN_SIZE 213 #define NS_DSA_MAX_BYTES 405 /* Offsets into SIG record rdata to find various values */ #define NS_SIG_TYPE 0 /*%< Type flags */ #define NS_SIG_ALG 2 /*%< Algorithm */ #define NS_SIG_LABELS 3 /*%< How many labels in name */ #define NS_SIG_OTTL 4 /*%< Original TTL */ #define NS_SIG_EXPIR 8 /*%< Expiration time */ #define NS_SIG_SIGNED 12 /*%< Signature time */ #define NS_SIG_FOOT 16 /*%< Key footprint */ #define NS_SIG_SIGNER 18 /*%< Domain name of who signed it */ /* How RR types are represented as bit-flags in NXT records */ #define NS_NXT_BITS 8 #define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) #define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) #define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) #define NS_NXT_MAX 127 /*% * EDNS0 extended flags and option codes, host order. */ #define NS_OPT_DNSSEC_OK 0x8000U #define NS_OPT_NSID 3 /*% * Inline versions of get/put short/long. Pointer is advanced. */ #define NS_GET16(s, cp) do { \ register const u_char *t_cp = (const u_char *)(cp); \ (s) = ((u_int16_t)t_cp[0] << 8) \ | ((u_int16_t)t_cp[1]) \ ; \ (cp) += NS_INT16SZ; \ } while (0) #define NS_GET32(l, cp) do { \ register const u_char *t_cp = (const u_char *)(cp); \ (l) = ((u_int32_t)t_cp[0] << 24) \ | ((u_int32_t)t_cp[1] << 16) \ | ((u_int32_t)t_cp[2] << 8) \ | ((u_int32_t)t_cp[3]) \ ; \ (cp) += NS_INT32SZ; \ } while (0) #define NS_PUT16(s, cp) do { \ register u_int16_t t_s = (u_int16_t)(s); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ (cp) += NS_INT16SZ; \ } while (0) #define NS_PUT32(l, cp) do { \ register u_int32_t t_l = (u_int32_t)(l); \ register u_char *t_cp = (u_char *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ *t_cp++ = t_l >> 8; \ *t_cp = t_l; \ (cp) += NS_INT32SZ; \ } while (0) /*% * ANSI C identifier hiding for bind's lib/nameser. */ #define ns_msg_getflag __ns_msg_getflag #define ns_get16 __ns_get16 #define ns_get32 __ns_get32 #define ns_put16 __ns_put16 #define ns_put32 __ns_put32 #define ns_initparse __ns_initparse #define ns_skiprr __ns_skiprr #define ns_parserr __ns_parserr #define ns_parserr2 __ns_parserr2 #define ns_sprintrr __ns_sprintrr #define ns_sprintrrf __ns_sprintrrf #define ns_format_ttl __ns_format_ttl #define ns_parse_ttl __ns_parse_ttl #if 0 #define ns_datetosecs __ns_datetosecs #endif #define ns_name_ntol __ns_name_ntol #define ns_name_ntop __ns_name_ntop #define ns_name_pton __ns_name_pton #define ns_name_pton2 __ns_name_pton2 #define ns_name_unpack __ns_name_unpack #define ns_name_unpack2 __ns_name_unpack2 #define ns_name_pack __ns_name_pack #define ns_name_compress __ns_name_compress #define ns_name_uncompress __ns_name_uncompress #define ns_name_skip __ns_name_skip #define ns_name_rollback __ns_name_rollback #define ns_name_length __ns_name_length #define ns_name_eq __ns_name_eq #define ns_name_owned __ns_name_owned #define ns_name_map __ns_name_map #define ns_name_labels __ns_name_labels #if 0 #define ns_sign __ns_sign #define ns_sign2 __ns_sign2 #define ns_sign_tcp __ns_sign_tcp #define ns_sign_tcp2 __ns_sign_tcp2 #define ns_sign_tcp_init __ns_sign_tcp_init #define ns_find_tsig __ns_find_tsig #define ns_verify __ns_verify #define ns_verify_tcp __ns_verify_tcp #define ns_verify_tcp_init __ns_verify_tcp_init #endif #define ns_samedomain __ns_samedomain #if 0 #define ns_subdomain __ns_subdomain #endif #define ns_makecanon __ns_makecanon #define ns_samename __ns_samename __BEGIN_DECLS int ns_msg_getflag(ns_msg, int); u_int ns_get16(const u_char *); u_long ns_get32(const u_char *); void ns_put16(u_int, u_char *); void ns_put32(u_long, u_char *); int ns_initparse(const u_char *, int, ns_msg *); int ns_skiprr(const u_char *, const u_char *, ns_sect, int); int ns_parserr(ns_msg *, ns_sect, int, ns_rr *); int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *); int ns_sprintrr(const ns_msg *, const ns_rr *, const char *, const char *, char *, size_t); int ns_sprintrrf(const u_char *, size_t, const char *, ns_class, ns_type, u_long, const u_char *, size_t, const char *, const char *, char *, size_t); int ns_format_ttl(u_long, char *, size_t); int ns_parse_ttl(const char *, u_long *); #if 0 u_int32_t ns_datetosecs(const char *cp, int *errp); #endif int ns_name_ntol(const u_char *, u_char *, size_t); int ns_name_ntop(const u_char *, char *, size_t); int ns_name_pton(const char *, u_char *, size_t); int ns_name_pton2(const char *, u_char *, size_t, size_t *); int ns_name_unpack(const u_char *, const u_char *, const u_char *, u_char *, size_t); int ns_name_unpack2(const u_char *, const u_char *, const u_char *, u_char *, size_t, size_t *); int ns_name_pack(const u_char *, u_char *, int, const u_char **, const u_char **); int ns_name_uncompress(const u_char *, const u_char *, const u_char *, char *, size_t); int ns_name_compress(const char *, u_char *, size_t, const u_char **, const u_char **); int ns_name_skip(const u_char **, const u_char *); void ns_name_rollback(const u_char *, const u_char **, const u_char **); ssize_t ns_name_length(ns_nname_ct, size_t); int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t); int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int); int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int); int ns_name_labels(ns_nname_ct, size_t); #if 0 int ns_sign(u_char *, int *, int, int, void *, const u_char *, int, u_char *, int *, time_t); int ns_sign2(u_char *, int *, int, int, void *, const u_char *, int, u_char *, int *, time_t, u_char **, u_char **); int ns_sign_tcp(u_char *, int *, int, int, ns_tcp_tsig_state *, int); int ns_sign_tcp2(u_char *, int *, int, int, ns_tcp_tsig_state *, int, u_char **, u_char **); int ns_sign_tcp_init(void *, const u_char *, int, ns_tcp_tsig_state *); u_char *ns_find_tsig(u_char *, u_char *); int ns_verify(u_char *, int *, void *, const u_char *, int, u_char *, int *, time_t *, int); int ns_verify_tcp(u_char *, int *, ns_tcp_tsig_state *, int); int ns_verify_tcp_init(void *, const u_char *, int, ns_tcp_tsig_state *); #endif int ns_samedomain(const char *, const char *); #if 0 int ns_subdomain(const char *, const char *); #endif int ns_makecanon(const char *, char *, size_t); int ns_samename(const char *, const char *); __END_DECLS #ifdef BIND_4_COMPAT #include #endif #endif /* !_ARPA_NAMESER_H_ */ /*! \file */ diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h index d70bc199b823..fd5e397092d6 100644 --- a/include/arpa/nameser_compat.h +++ b/include/arpa/nameser_compat.h @@ -1,221 +1,220 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1989 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /*% * from nameser.h 8.1 (Berkeley) 6/2/93 * $Id: nameser_compat.h,v 1.8 2006/05/19 02:33:40 marka Exp $ - * $FreeBSD$ */ #ifndef _ARPA_NAMESER_COMPAT_ #define _ARPA_NAMESER_COMPAT_ #define __BIND 19950621 /*%< (DEAD) interface version stamp. */ #include #if !defined(_BYTE_ORDER) || \ (_BYTE_ORDER != _BIG_ENDIAN && _BYTE_ORDER != _LITTLE_ENDIAN && \ _BYTE_ORDER != _PDP_ENDIAN) /* you must determine what the correct bit order is for * your compiler - the next line is an intentional error * which will force your compiles to bomb until you fix * the above macros. */ #error "Undefined or invalid _BYTE_ORDER"; #endif /*% * Structure for query header. The order of the fields is machine- and * compiler-dependent, depending on the byte/bit order and the layout * of bit fields. We use bit fields only in int variables, as this * is all ANSI requires. This requires a somewhat confusing rearrangement. */ typedef struct { unsigned id :16; /*%< query identification number */ #if _BYTE_ORDER == _BIG_ENDIAN /* fields in third byte */ unsigned qr: 1; /*%< response flag */ unsigned opcode: 4; /*%< purpose of message */ unsigned aa: 1; /*%< authoritative answer */ unsigned tc: 1; /*%< truncated message */ unsigned rd: 1; /*%< recursion desired */ /* fields in fourth byte */ unsigned ra: 1; /*%< recursion available */ unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ unsigned ad: 1; /*%< authentic data from named */ unsigned cd: 1; /*%< checking disabled by resolver */ unsigned rcode :4; /*%< response code */ #endif #if _BYTE_ORDER == _LITTLE_ENDIAN || _BYTE_ORDER == _PDP_ENDIAN /* fields in third byte */ unsigned rd :1; /*%< recursion desired */ unsigned tc :1; /*%< truncated message */ unsigned aa :1; /*%< authoritative answer */ unsigned opcode :4; /*%< purpose of message */ unsigned qr :1; /*%< response flag */ /* fields in fourth byte */ unsigned rcode :4; /*%< response code */ unsigned cd: 1; /*%< checking disabled by resolver */ unsigned ad: 1; /*%< authentic data from named */ unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ unsigned ra :1; /*%< recursion available */ #endif /* remaining bytes */ unsigned qdcount :16; /*%< number of question entries */ unsigned ancount :16; /*%< number of answer entries */ unsigned nscount :16; /*%< number of authority entries */ unsigned arcount :16; /*%< number of resource entries */ } HEADER; #define PACKETSZ NS_PACKETSZ #define MAXDNAME NS_MAXDNAME #define MAXCDNAME NS_MAXCDNAME #define MAXLABEL NS_MAXLABEL #define HFIXEDSZ NS_HFIXEDSZ #define QFIXEDSZ NS_QFIXEDSZ #define RRFIXEDSZ NS_RRFIXEDSZ #define INT32SZ NS_INT32SZ #define INT16SZ NS_INT16SZ #define INT8SZ NS_INT8SZ #define INADDRSZ NS_INADDRSZ #define IN6ADDRSZ NS_IN6ADDRSZ #define INDIR_MASK NS_CMPRSFLGS #define NAMESERVER_PORT NS_DEFAULTPORT #define S_ZONE ns_s_zn #define S_PREREQ ns_s_pr #define S_UPDATE ns_s_ud #define S_ADDT ns_s_ar #define QUERY ns_o_query #define IQUERY ns_o_iquery #define STATUS ns_o_status #define NS_NOTIFY_OP ns_o_notify #define NS_UPDATE_OP ns_o_update #define NOERROR ns_r_noerror #define FORMERR ns_r_formerr #define SERVFAIL ns_r_servfail #define NXDOMAIN ns_r_nxdomain #define NOTIMP ns_r_notimpl #define REFUSED ns_r_refused #define YXDOMAIN ns_r_yxdomain #define YXRRSET ns_r_yxrrset #define NXRRSET ns_r_nxrrset #define NOTAUTH ns_r_notauth #define NOTZONE ns_r_notzone /*#define BADSIG ns_r_badsig*/ /*#define BADKEY ns_r_badkey*/ /*#define BADTIME ns_r_badtime*/ #define DELETE ns_uop_delete #define ADD ns_uop_add #define T_A ns_t_a #define T_NS ns_t_ns #define T_MD ns_t_md #define T_MF ns_t_mf #define T_CNAME ns_t_cname #define T_SOA ns_t_soa #define T_MB ns_t_mb #define T_MG ns_t_mg #define T_MR ns_t_mr #define T_NULL ns_t_null #define T_WKS ns_t_wks #define T_PTR ns_t_ptr #define T_HINFO ns_t_hinfo #define T_MINFO ns_t_minfo #define T_MX ns_t_mx #define T_TXT ns_t_txt #define T_RP ns_t_rp #define T_AFSDB ns_t_afsdb #define T_X25 ns_t_x25 #define T_ISDN ns_t_isdn #define T_RT ns_t_rt #define T_NSAP ns_t_nsap #define T_NSAP_PTR ns_t_nsap_ptr #define T_SIG ns_t_sig #define T_KEY ns_t_key #define T_PX ns_t_px #define T_GPOS ns_t_gpos #define T_AAAA ns_t_aaaa #define T_LOC ns_t_loc #define T_NXT ns_t_nxt #define T_EID ns_t_eid #define T_NIMLOC ns_t_nimloc #define T_SRV ns_t_srv #define T_ATMA ns_t_atma #define T_NAPTR ns_t_naptr #define T_KX ns_t_kx #define T_CERT ns_t_cert #define T_A6 ns_t_a6 #define T_DNAME ns_t_dname #define T_SINK ns_t_sink #define T_OPT ns_t_opt #define T_APL ns_t_apl #define T_DS ns_t_ds #define T_SSHFP ns_t_sshfp #define T_IPSECKEY ns_t_ipseckey #define T_RRSIG ns_t_rrsig #define T_NSEC ns_t_nsec #define T_DNSKEY ns_t_dnskey #define T_DHCID ns_t_dhcid #define T_NSEC3 ns_t_nsec3 #define T_NSEC3PARAM ns_t_nsec3param #define T_HIP ns_t_hip #define T_SPF ns_t_spf #define T_TKEY ns_t_tkey #define T_TSIG ns_t_tsig #define T_IXFR ns_t_ixfr #define T_AXFR ns_t_axfr #define T_MAILB ns_t_mailb #define T_MAILA ns_t_maila #define T_ANY ns_t_any #define T_ZXFR ns_t_zxfr #define T_DLV ns_t_dlv #define C_IN ns_c_in #define C_CHAOS ns_c_chaos #define C_HS ns_c_hs /* BIND_UPDATE */ #define C_NONE ns_c_none #define C_ANY ns_c_any #define GETSHORT NS_GET16 #define GETLONG NS_GET32 #define PUTSHORT NS_PUT16 #define PUTLONG NS_PUT32 #endif /* _ARPA_NAMESER_COMPAT_ */ /*! \file */ diff --git a/include/arpa/telnet.h b/include/arpa/telnet.h index 855b3d26f9cf..922a06563469 100644 --- a/include/arpa/telnet.h +++ b/include/arpa/telnet.h @@ -1,345 +1,344 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)telnet.h 8.2 (Berkeley) 12/15/93 - * $FreeBSD$ */ #ifndef _ARPA_TELNET_H_ #define _ARPA_TELNET_H_ /* * Definitions for the TELNET protocol. */ #define IAC 255 /* interpret as command: */ #define DONT 254 /* you are not to use option */ #define DO 253 /* please, you use option */ #define WONT 252 /* I won't use option */ #define WILL 251 /* I will use option */ #define SB 250 /* interpret as subnegotiation */ #define GA 249 /* you may reverse the line */ #define EL 248 /* erase the current line */ #define EC 247 /* erase the current character */ #define AYT 246 /* are you there */ #define AO 245 /* abort output--but let prog finish */ #define IP 244 /* interrupt process--permanently */ #define BREAK 243 /* break */ #define DM 242 /* data mark--for connect. cleaning */ #define NOP 241 /* nop */ #define SE 240 /* end sub negotiation */ #define EOR 239 /* end of record (transparent mode) */ #define ABORT 238 /* Abort process */ #define SUSP 237 /* Suspend process */ #define xEOF 236 /* End of file: EOF is already used... */ #define SYNCH 242 /* for telfunc calls */ #ifdef TELCMDS const char *telcmds[] = { "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0 }; #else extern char *telcmds[]; #endif #define TELCMD_FIRST xEOF #define TELCMD_LAST IAC #define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ (unsigned int)(x) >= TELCMD_FIRST) #define TELCMD(x) telcmds[(x)-TELCMD_FIRST] /* telnet options */ #define TELOPT_BINARY 0 /* 8-bit data path */ #define TELOPT_ECHO 1 /* echo */ #define TELOPT_RCP 2 /* prepare to reconnect */ #define TELOPT_SGA 3 /* suppress go ahead */ #define TELOPT_NAMS 4 /* approximate message size */ #define TELOPT_STATUS 5 /* give status */ #define TELOPT_TM 6 /* timing mark */ #define TELOPT_RCTE 7 /* remote controlled transmission and echo */ #define TELOPT_NAOL 8 /* negotiate about output line width */ #define TELOPT_NAOP 9 /* negotiate about output page size */ #define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ #define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ #define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ #define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ #define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ #define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ #define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ #define TELOPT_XASCII 17 /* extended ascic character set */ #define TELOPT_LOGOUT 18 /* force logout */ #define TELOPT_BM 19 /* byte macro */ #define TELOPT_DET 20 /* data entry terminal */ #define TELOPT_SUPDUP 21 /* supdup protocol */ #define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ #define TELOPT_SNDLOC 23 /* send location */ #define TELOPT_TTYPE 24 /* terminal type */ #define TELOPT_EOR 25 /* end or record */ #define TELOPT_TUID 26 /* TACACS user identification */ #define TELOPT_OUTMRK 27 /* output marking */ #define TELOPT_TTYLOC 28 /* terminal location number */ #define TELOPT_3270REGIME 29 /* 3270 regime */ #define TELOPT_X3PAD 30 /* X.3 PAD */ #define TELOPT_NAWS 31 /* window size */ #define TELOPT_TSPEED 32 /* terminal speed */ #define TELOPT_LFLOW 33 /* remote flow control */ #define TELOPT_LINEMODE 34 /* Linemode option */ #define TELOPT_XDISPLOC 35 /* X Display Location */ #define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ #define TELOPT_AUTHENTICATION 37/* Authenticate */ #define TELOPT_ENCRYPT 38 /* Encryption option */ #define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ #define TELOPT_TN3270E 40 /* RFC2355 - TN3270 Enhancements */ #define TELOPT_CHARSET 42 /* RFC2066 - Charset */ #define TELOPT_COMPORT 44 /* RFC2217 - Com Port Control */ #define TELOPT_KERMIT 47 /* RFC2840 - Kermit */ #define TELOPT_EXOPL 255 /* extended-options-list */ #define NTELOPTS (1+TELOPT_KERMIT) #ifdef TELOPTS const char *telopts[NTELOPTS+1] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", "TACACS UID", "OUTPUT MARKING", "TTYLOC", "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON", "TN3270E", "XAUTH", "CHARSET", "RSP", "COM-PORT", "SLE", "STARTTLS", "KERMIT", 0 }; #define TELOPT_FIRST TELOPT_BINARY #define TELOPT_LAST TELOPT_KERMIT #define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) #define TELOPT(x) telopts[(x)-TELOPT_FIRST] #endif /* sub-option qualifiers */ #define TELQUAL_IS 0 /* option is... */ #define TELQUAL_SEND 1 /* send option */ #define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ #define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ #define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ #define LFLOW_OFF 0 /* Disable remote flow control */ #define LFLOW_ON 1 /* Enable remote flow control */ #define LFLOW_RESTART_ANY 2 /* Restart output on any char */ #define LFLOW_RESTART_XON 3 /* Restart output only on XON */ /* * LINEMODE suboptions */ #define LM_MODE 1 #define LM_FORWARDMASK 2 #define LM_SLC 3 #define MODE_EDIT 0x01 #define MODE_TRAPSIG 0x02 #define MODE_ACK 0x04 #define MODE_SOFT_TAB 0x08 #define MODE_LIT_ECHO 0x10 #define MODE_MASK 0x1f /* Not part of protocol, but needed to simplify things... */ #define MODE_FLOW 0x0100 #define MODE_ECHO 0x0200 #define MODE_INBIN 0x0400 #define MODE_OUTBIN 0x0800 #define MODE_FORCE 0x1000 #define SLC_SYNCH 1 #define SLC_BRK 2 #define SLC_IP 3 #define SLC_AO 4 #define SLC_AYT 5 #define SLC_EOR 6 #define SLC_ABORT 7 #define SLC_EOF 8 #define SLC_SUSP 9 #define SLC_EC 10 #define SLC_EL 11 #define SLC_EW 12 #define SLC_RP 13 #define SLC_LNEXT 14 #define SLC_XON 15 #define SLC_XOFF 16 #define SLC_FORW1 17 #define SLC_FORW2 18 #define SLC_MCL 19 #define SLC_MCR 20 #define SLC_MCWL 21 #define SLC_MCWR 22 #define SLC_MCBOL 23 #define SLC_MCEOL 24 #define SLC_INSRT 25 #define SLC_OVER 26 #define SLC_ECR 27 #define SLC_EWR 28 #define SLC_EBOL 29 #define SLC_EEOL 30 #define NSLC 30 /* * For backwards compatibility, we define SLC_NAMES to be the * list of names if SLC_NAMES is not defined. */ #define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \ "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \ "MCEOL", "INSRT", "OVER", "ECR", "EWR", \ "EBOL", "EEOL", \ 0 #ifdef SLC_NAMES const char *slc_names[] = { SLC_NAMELIST }; #else extern char *slc_names[]; #define SLC_NAMES SLC_NAMELIST #endif #define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) #define SLC_NAME(x) slc_names[x] #define SLC_NOSUPPORT 0 #define SLC_CANTCHANGE 1 #define SLC_VARIABLE 2 #define SLC_DEFAULT 3 #define SLC_LEVELBITS 0x03 #define SLC_FUNC 0 #define SLC_FLAGS 1 #define SLC_VALUE 2 #define SLC_ACK 0x80 #define SLC_FLUSHIN 0x40 #define SLC_FLUSHOUT 0x20 #define OLD_ENV_VAR 1 #define OLD_ENV_VALUE 0 #define NEW_ENV_VAR 0 #define NEW_ENV_VALUE 1 #define ENV_ESC 2 #define ENV_USERVAR 3 /* * AUTHENTICATION suboptions */ /* * Who is authenticating who ... */ #define AUTH_WHO_CLIENT 0 /* Client authenticating server */ #define AUTH_WHO_SERVER 1 /* Server authenticating client */ #define AUTH_WHO_MASK 1 /* * amount of authentication done */ #define AUTH_HOW_ONE_WAY 0 #define AUTH_HOW_MUTUAL 2 #define AUTH_HOW_MASK 2 #define AUTHTYPE_NULL 0 #define AUTHTYPE_KERBEROS_V4 1 #define AUTHTYPE_KERBEROS_V5 2 #define AUTHTYPE_SPX 3 #define AUTHTYPE_MINK 4 #define AUTHTYPE_SRA 6 #define AUTHTYPE_CNT 7 #define AUTHTYPE_TEST 99 #ifdef AUTH_NAMES const char *authtype_names[] = { "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA", 0 }; #else extern char *authtype_names[]; #endif #define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) #define AUTHTYPE_NAME(x) authtype_names[x] /* * ENCRYPTion suboptions */ #define ENCRYPT_IS 0 /* I pick encryption type ... */ #define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ #define ENCRYPT_REPLY 2 /* Initial setup response */ #define ENCRYPT_START 3 /* Am starting to send encrypted */ #define ENCRYPT_END 4 /* Am ending encrypted */ #define ENCRYPT_REQSTART 5 /* Request you start encrypting */ #define ENCRYPT_REQEND 6 /* Request you end encrypting */ #define ENCRYPT_ENC_KEYID 7 #define ENCRYPT_DEC_KEYID 8 #define ENCRYPT_CNT 9 #define ENCTYPE_ANY 0 #define ENCTYPE_DES_CFB64 1 #define ENCTYPE_DES_OFB64 2 #define ENCTYPE_CNT 3 #ifdef ENCRYPT_NAMES const char *encrypt_names[] = { "IS", "SUPPORT", "REPLY", "START", "END", "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", 0 }; const char *enctype_names[] = { "ANY", "DES_CFB64", "DES_OFB64", 0 }; #else extern char *encrypt_names[]; extern char *enctype_names[]; #endif #define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) #define ENCRYPT_NAME(x) encrypt_names[x] #define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) #define ENCTYPE_NAME(x) enctype_names[x] #endif /* !_TELNET_H_ */ diff --git a/include/arpa/tftp.h b/include/arpa/tftp.h index 50147137db15..c62429cf16aa 100644 --- a/include/arpa/tftp.h +++ b/include/arpa/tftp.h @@ -1,83 +1,82 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)tftp.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _ARPA_TFTP_H_ #define _ARPA_TFTP_H_ #include /* * Trivial File Transfer Protocol (IEN-133) */ #define SEGSIZE 512 /* data segment size */ /* * Packet types. */ #define RRQ 01 /* read request */ #define WRQ 02 /* write request */ #define DATA 03 /* data packet */ #define ACK 04 /* acknowledgement */ #define ERROR 05 /* error code */ #define OACK 06 /* option acknowledgement */ struct tftphdr { unsigned short th_opcode; /* packet type */ union { unsigned short tu_block; /* block # */ unsigned short tu_code; /* error code */ char tu_stuff[1]; /* request packet stuff */ } __packed th_u; char th_data[1]; /* data or error string */ } __packed; #define th_block th_u.tu_block #define th_code th_u.tu_code #define th_stuff th_u.tu_stuff #define th_msg th_data /* * Error codes. */ #define EUNDEF 0 /* not defined */ #define ENOTFOUND 1 /* file not found */ #define EACCESS 2 /* access violation */ #define ENOSPACE 3 /* disk full or allocation exceeded */ #define EBADOP 4 /* illegal TFTP operation */ #define EBADID 5 /* unknown transfer ID */ #define EEXISTS 6 /* file already exists */ #define ENOUSER 7 /* no such user */ #define EOPTNEG 8 /* option negotiation failed */ #endif /* !_TFTP_H_ */ diff --git a/include/assert.h b/include/assert.h index 702e231603e6..54e1456b9e0d 100644 --- a/include/assert.h +++ b/include/assert.h @@ -1,80 +1,79 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)assert.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #include /* * Unlike other ANSI header files, may usefully be included * multiple times, with and without NDEBUG defined. */ #undef assert #undef _assert #ifdef NDEBUG #define assert(e) ((void)0) #define _assert(e) ((void)0) #else #define _assert(e) assert(e) #define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \ __LINE__, #e)) #endif /* NDEBUG */ #ifndef _ASSERT_H_ #define _ASSERT_H_ /* * Static assertions. In principle we could define static_assert for * C++ older than C++11, but this breaks if _Static_assert is * implemented as a macro. * * C++ template parameters may contain commas, even if not enclosed in * parentheses, causing the _Static_assert macro to be invoked with more * than two parameters. */ #if __ISO_C_VISIBLE >= 2011 && !defined(__cplusplus) #define static_assert _Static_assert #endif __BEGIN_DECLS void __assert(const char *, const char *, int, const char *) __dead2; __END_DECLS #endif /* !_ASSERT_H_ */ diff --git a/include/ctype.h b/include/ctype.h index 13173139777b..46e8f3b23d9e 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -1,137 +1,136 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ctype.h 8.4 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _CTYPE_H_ #define _CTYPE_H_ #include #include #include <_ctype.h> __BEGIN_DECLS int isalnum(int); int isalpha(int); int iscntrl(int); int isdigit(int); int isgraph(int); int islower(int); int isprint(int); int ispunct(int); int isspace(int); int isupper(int); int isxdigit(int); int tolower(int); int toupper(int); #if __XSI_VISIBLE int isascii(int); int toascii(int); #endif #if __ISO_C_VISIBLE >= 1999 int isblank(int); #endif #if __BSD_VISIBLE int digittoint(int); int ishexnumber(int); int isideogram(int); int isnumber(int); int isphonogram(int); int isrune(int); int isspecial(int); #endif #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif __END_DECLS #ifndef __cplusplus #define isalnum(c) __sbistype((c), _CTYPE_A|_CTYPE_D|_CTYPE_N) #define isalpha(c) __sbistype((c), _CTYPE_A) #define iscntrl(c) __sbistype((c), _CTYPE_C) #define isdigit(c) __sbistype((c), _CTYPE_D) #define isgraph(c) __sbistype((c), _CTYPE_G) #define islower(c) __sbistype((c), _CTYPE_L) #define isprint(c) __sbistype((c), _CTYPE_R) #define ispunct(c) __sbistype((c), _CTYPE_P) #define isspace(c) __sbistype((c), _CTYPE_S) #define isupper(c) __sbistype((c), _CTYPE_U) #define isxdigit(c) __sbistype((c), _CTYPE_X) #define tolower(c) __sbtolower(c) #define toupper(c) __sbtoupper(c) #endif /* !__cplusplus */ #if __XSI_VISIBLE /* * POSIX.1-2001 specifies _tolower() and _toupper() to be macros equivalent to * tolower() and toupper() respectively, minus extra checking to ensure that * the argument is a lower or uppercase letter respectively. We've chosen to * implement these macros with the same error checking as tolower() and * toupper() since this doesn't violate the specification itself, only its * intent. We purposely leave _tolower() and _toupper() undocumented to * discourage their use. * * XXX isascii() and toascii() should similarly be undocumented. */ #define _tolower(c) __sbtolower(c) #define _toupper(c) __sbtoupper(c) #define isascii(c) (((c) & ~0x7F) == 0) #define toascii(c) ((c) & 0x7F) #endif #if __ISO_C_VISIBLE >= 1999 && !defined(__cplusplus) #define isblank(c) __sbistype((c), _CTYPE_B) #endif #if __BSD_VISIBLE #define digittoint(c) __sbmaskrune((c), 0xFF) #define ishexnumber(c) __sbistype((c), _CTYPE_X) #define isideogram(c) __sbistype((c), _CTYPE_I) #define isnumber(c) __sbistype((c), _CTYPE_D|_CTYPE_N) #define isphonogram(c) __sbistype((c), _CTYPE_Q) #define isrune(c) __sbistype((c), 0xFFFFFF00L) #define isspecial(c) __sbistype((c), _CTYPE_T) #endif #endif /* !_CTYPE_H_ */ diff --git a/include/db.h b/include/db.h index 13fa91d68048..19db882f8eff 100644 --- a/include/db.h +++ b/include/db.h @@ -1,219 +1,218 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)db.h 8.7 (Berkeley) 6/16/94 - * $FreeBSD$ */ #ifndef _DB_H_ #define _DB_H_ #include #include #include #define RET_ERROR -1 /* Return values. */ #define RET_SUCCESS 0 #define RET_SPECIAL 1 #define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ typedef uint32_t pgno_t; #define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ typedef uint16_t indx_t; #define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ typedef uint32_t recno_t; /* Key/data structure -- a Data-Base Thang. */ typedef struct { void *data; /* data */ size_t size; /* data length */ } DBT; /* Routine flags. */ #define R_CURSOR 1 /* del, put, seq */ #define __R_UNUSED 2 /* UNUSED */ #define R_FIRST 3 /* seq */ #define R_IAFTER 4 /* put (RECNO) */ #define R_IBEFORE 5 /* put (RECNO) */ #define R_LAST 6 /* seq (BTREE, RECNO) */ #define R_NEXT 7 /* seq */ #define R_NOOVERWRITE 8 /* put */ #define R_PREV 9 /* seq (BTREE, RECNO) */ #define R_SETCURSOR 10 /* put (RECNO) */ #define R_RECNOSYNC 11 /* sync (RECNO) */ typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; /* * !!! * The following flags are included in the dbopen(3) call as part of the * open(2) flags. In order to avoid conflicts with the open flags, start * at the top of the 16 or 32-bit number space and work our way down. If * the open flags were significantly expanded in the future, it could be * a problem. Wish I'd left another flags word in the dbopen call. * * !!! * None of this stuff is implemented yet. The only reason that it's here * is so that the access methods can skip copying the key/data pair when * the DB_LOCK flag isn't set. */ #if UINT_MAX > 65535 #define DB_LOCK 0x20000000 /* Do locking. */ #define DB_SHMEM 0x40000000 /* Use shared memory. */ #define DB_TXN 0x80000000 /* Do transactions. */ #else #define DB_LOCK 0x2000 /* Do locking. */ #define DB_SHMEM 0x4000 /* Use shared memory. */ #define DB_TXN 0x8000 /* Do transactions. */ #endif /* Access method description structure. */ typedef struct __db { DBTYPE type; /* Underlying db type. */ int (*close)(struct __db *); int (*del)(const struct __db *, const DBT *, unsigned int); int (*get)(const struct __db *, const DBT *, DBT *, unsigned int); int (*put)(const struct __db *, DBT *, const DBT *, unsigned int); int (*seq)(const struct __db *, DBT *, DBT *, unsigned int); int (*sync)(const struct __db *, unsigned int); void *internal; /* Access method private. */ int (*fd)(const struct __db *); } DB; #define BTREEMAGIC 0x053162 #define BTREEVERSION 3 /* Structure used to pass parameters to the btree routines. */ typedef struct { #define R_DUP 0x01 /* duplicate keys */ unsigned long flags; unsigned int cachesize; /* bytes to cache */ int maxkeypage; /* maximum keys per page */ int minkeypage; /* minimum keys per page */ unsigned int psize; /* page size */ int (*compare) /* comparison function */ (const DBT *, const DBT *); size_t (*prefix) /* prefix function */ (const DBT *, const DBT *); int lorder; /* byte order */ } BTREEINFO; #define HASHMAGIC 0x061561 #define HASHVERSION 2 /* Structure used to pass parameters to the hashing routines. */ typedef struct { unsigned int bsize; /* bucket size */ unsigned int ffactor; /* fill factor */ unsigned int nelem; /* number of elements */ unsigned int cachesize; /* bytes to cache */ uint32_t /* hash function */ (*hash)(const void *, size_t); int lorder; /* byte order */ } HASHINFO; /* Structure used to pass parameters to the record routines. */ typedef struct { #define R_FIXEDLEN 0x01 /* fixed-length records */ #define R_NOKEY 0x02 /* key not required */ #define R_SNAPSHOT 0x04 /* snapshot the input */ unsigned long flags; unsigned int cachesize; /* bytes to cache */ unsigned int psize; /* page size */ int lorder; /* byte order */ size_t reclen; /* record length (fixed-length records) */ unsigned char bval; /* delimiting byte (variable-length records */ char *bfname; /* btree file name */ } RECNOINFO; #ifdef __DBINTERFACE_PRIVATE /* * Little endian <==> big endian 32-bit swap macros. * M_32_SWAP swap a memory location * P_32_SWAP swap a referenced memory location * P_32_COPY swap from one location to another */ #define M_32_SWAP(a) { \ uint32_t _tmp = a; \ ((char *)&a)[0] = ((char *)&_tmp)[3]; \ ((char *)&a)[1] = ((char *)&_tmp)[2]; \ ((char *)&a)[2] = ((char *)&_tmp)[1]; \ ((char *)&a)[3] = ((char *)&_tmp)[0]; \ } #define P_32_SWAP(a) { \ uint32_t _tmp = *(uint32_t *)a; \ ((char *)a)[0] = ((char *)&_tmp)[3]; \ ((char *)a)[1] = ((char *)&_tmp)[2]; \ ((char *)a)[2] = ((char *)&_tmp)[1]; \ ((char *)a)[3] = ((char *)&_tmp)[0]; \ } #define P_32_COPY(a, b) { \ ((char *)&(b))[0] = ((char *)&(a))[3]; \ ((char *)&(b))[1] = ((char *)&(a))[2]; \ ((char *)&(b))[2] = ((char *)&(a))[1]; \ ((char *)&(b))[3] = ((char *)&(a))[0]; \ } /* * Little endian <==> big endian 16-bit swap macros. * M_16_SWAP swap a memory location * P_16_SWAP swap a referenced memory location * P_16_COPY swap from one location to another */ #define M_16_SWAP(a) { \ uint16_t _tmp = a; \ ((char *)&a)[0] = ((char *)&_tmp)[1]; \ ((char *)&a)[1] = ((char *)&_tmp)[0]; \ } #define P_16_SWAP(a) { \ uint16_t _tmp = *(uint16_t *)a; \ ((char *)a)[0] = ((char *)&_tmp)[1]; \ ((char *)a)[1] = ((char *)&_tmp)[0]; \ } #define P_16_COPY(a, b) { \ ((char *)&(b))[0] = ((char *)&(a))[1]; \ ((char *)&(b))[1] = ((char *)&(a))[0]; \ } #endif __BEGIN_DECLS #if __BSD_VISIBLE DB *dbopen(const char *, int, int, DBTYPE, const void *); #endif #ifdef __DBINTERFACE_PRIVATE DB *__bt_open(const char *, int, int, const BTREEINFO *, int); DB *__hash_open(const char *, int, int, const HASHINFO *, int); DB *__rec_open(const char *, int, int, const RECNOINFO *, int); void __dbpanic(DB *dbp); #endif __END_DECLS #endif /* !_DB_H_ */ diff --git a/include/dirent.h b/include/dirent.h index 751a016838c0..5db7fe43b243 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -1,149 +1,148 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)dirent.h 8.2 (Berkeley) 7/28/94 - * $FreeBSD$ */ #ifndef _DIRENT_H_ #define _DIRENT_H_ /* * The kernel defines the format of directory entries returned by * the getdirentries(2) system call. */ #include #include #include #if __BSD_VISIBLE #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif #ifndef _OFF_T_DECLARED typedef __off_t off_t; #define _OFF_T_DECLARED #endif #endif /* __BSD_VISIBLE */ #if __XSI_VISIBLE #ifndef _INO_T_DECLARED typedef __ino_t ino_t; #define _INO_T_DECLARED #endif /* * XXX this is probably illegal in the __XSI_VISIBLE case, but brings us closer * to the specification. */ #define d_ino d_fileno /* backward and XSI compatibility */ #endif /* __XSI_VISIBLE */ #if __BSD_VISIBLE #include /* definitions for library routines operating on directories. */ #define DIRBLKSIZ 1024 struct _dirdesc; typedef struct _dirdesc DIR; /* flags for opendir2 */ #define DTF_HIDEW 0x0001 /* hide whiteout entries */ #define DTF_NODUP 0x0002 /* don't return duplicate names */ #define DTF_REWIND 0x0004 /* rewind after reading union stack */ #define __DTF_READALL 0x0008 /* everything has been read */ #define __DTF_SKIPREAD 0x0010 /* assume internal buffer is populated */ #else /* !__BSD_VISIBLE */ typedef void * DIR; #endif /* __BSD_VISIBLE */ #ifndef _KERNEL __BEGIN_DECLS #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 int alphasort(const struct dirent **, const struct dirent **); int dirfd(DIR *); #endif #if __BSD_VISIBLE int versionsort(const struct dirent **, const struct dirent **); DIR *__opendir2(const char *, int); int fdclosedir(DIR *); ssize_t getdents(int, char *, size_t); ssize_t getdirentries(int, char *, size_t, off_t *); #endif DIR *opendir(const char *); DIR *fdopendir(int); struct dirent * readdir(DIR *); #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 int readdir_r(DIR *, struct dirent *, struct dirent **); #endif void rewinddir(DIR *); #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE >= 700 int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); #ifdef __BLOCKS__ int scandir_b(const char *, struct dirent ***, int (^)(const struct dirent *), int (^)(const struct dirent **, const struct dirent **)); #endif #endif #if __BSD_VISIBLE int scandirat(int, const char *, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); #endif #if __XSI_VISIBLE void seekdir(DIR *, long); long telldir(DIR *); #endif int closedir(DIR *); __END_DECLS #endif /* !_KERNEL */ #endif /* !_DIRENT_H_ */ diff --git a/include/err.h b/include/err.h index 4b67275a3450..85b229a05d28 100644 --- a/include/err.h +++ b/include/err.h @@ -1,69 +1,68 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)err.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _ERR_H_ #define _ERR_H_ /* * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two * places ( and ), so if we include one * of them here we may collide with the utility's includes. It's unreasonable * for utilities to have to include one of them to include err.h, so we get * __va_list from and use it. */ #include #include __NULLABILITY_PRAGMA_PUSH __BEGIN_DECLS void err(int, const char *, ...) __dead2 __printf0like(2, 3); void verr(int, const char *, __va_list) __dead2 __printf0like(2, 0); void errc(int, int, const char *, ...) __dead2 __printf0like(3, 4); void verrc(int, int, const char *, __va_list) __dead2 __printf0like(3, 0); void errx(int, const char *, ...) __dead2 __printf0like(2, 3); void verrx(int, const char *, __va_list) __dead2 __printf0like(2, 0); void warn(const char *, ...) __printf0like(1, 2); void vwarn(const char *, __va_list) __printf0like(1, 0); void warnc(int, const char *, ...) __printf0like(2, 3); void vwarnc(int, const char *, __va_list) __printf0like(2, 0); void warnx(const char *, ...) __printflike(1, 2); void vwarnx(const char *, __va_list) __printf0like(1, 0); void err_set_file(void *); void err_set_exit(void (* _Nullable)(int)); __END_DECLS __NULLABILITY_PRAGMA_POP #endif /* !_ERR_H_ */ diff --git a/include/fstab.h b/include/fstab.h index 364d132bc4c8..e61bb7c6d5d7 100644 --- a/include/fstab.h +++ b/include/fstab.h @@ -1,80 +1,79 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fstab.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _FSTAB_H_ #define _FSTAB_H_ /* * File system table, see fstab(5). * * Used by dump, mount, umount, swapon, fsck, df, ... * * For ufs fs_spec field is the block special name. Programs that want to * use the character special name must create that name by prepending a 'r' * after the right most slash. Quota files are always named "quotas", so * if type is "rq", then use concatenation of fs_file and "quotas" to locate * quota file. */ #define _PATH_FSTAB "/etc/fstab" #define FSTAB "/etc/fstab" /* deprecated */ #define FSTAB_RW "rw" /* read/write device */ #define FSTAB_RQ "rq" /* read/write with quotas */ #define FSTAB_RO "ro" /* read-only device */ #define FSTAB_SW "sw" /* swap device */ #define FSTAB_XX "xx" /* ignore totally */ struct fstab { char *fs_spec; /* block special device name */ char *fs_file; /* file system path prefix */ char *fs_vfstype; /* File system type, ufs, nfs */ char *fs_mntops; /* Mount options ala -o */ char *fs_type; /* FSTAB_* from fs_mntops */ int fs_freq; /* dump frequency, in days */ int fs_passno; /* pass number on parallel fsck */ }; #include __BEGIN_DECLS struct fstab *getfsent(void); struct fstab *getfsspec(const char *); struct fstab *getfsfile(const char *); int setfsent(void); void endfsent(void); void setfstab(const char *); const char *getfstab(void); __END_DECLS #endif /* !_FSTAB_H_ */ diff --git a/include/fts.h b/include/fts.h index 6f4674e4a76e..6c6a30e2d8c5 100644 --- a/include/fts.h +++ b/include/fts.h @@ -1,138 +1,137 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fts.h 8.3 (Berkeley) 8/14/94 - * $FreeBSD$ */ #ifndef _FTS_H_ #define _FTS_H_ #include typedef struct { struct _ftsent *fts_cur; /* current node */ struct _ftsent *fts_child; /* linked list of children */ struct _ftsent **fts_array; /* sort array */ __dev_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ __size_t fts_pathlen; /* sizeof(path) */ __size_t fts_nitems; /* elements in the sort array */ int (*fts_compar) /* compare function */ (const struct _ftsent * const *, const struct _ftsent * const *); #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ #define FTS_LOGICAL 0x002 /* logical walk */ #define FTS_NOCHDIR 0x004 /* don't change directories */ #define FTS_NOSTAT 0x008 /* don't get stat info */ #define FTS_PHYSICAL 0x010 /* physical walk */ #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ #define FTS_XDEV 0x040 /* don't cross devices */ #define FTS_WHITEOUT 0x080 /* return whiteout information */ #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ #define FTS_NAMEONLY 0x100 /* (private) child names only */ #define FTS_STOP 0x200 /* (private) unrecoverable error */ int fts_options; /* fts_open options, global flags */ void *fts_clientptr; /* thunk for sort function */ } FTS; typedef struct _ftsent { struct _ftsent *fts_cycle; /* cycle node */ struct _ftsent *fts_parent; /* parent directory */ struct _ftsent *fts_link; /* next file in directory */ long long fts_number; /* local numeric value */ #define fts_bignum fts_number /* XXX non-std, should go away */ void *fts_pointer; /* local address value */ char *fts_accpath; /* access path */ char *fts_path; /* root path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ __size_t fts_pathlen; /* strlen(fts_path) */ __size_t fts_namelen; /* strlen(fts_name) */ __ino_t fts_ino; /* inode */ __dev_t fts_dev; /* device */ __nlink_t fts_nlink; /* link count */ #define FTS_ROOTPARENTLEVEL -1 #define FTS_ROOTLEVEL 0 long fts_level; /* depth (-1 to N) */ #define FTS_D 1 /* preorder directory */ #define FTS_DC 2 /* directory that causes cycles */ #define FTS_DEFAULT 3 /* none of the above */ #define FTS_DNR 4 /* unreadable directory */ #define FTS_DOT 5 /* dot or dot-dot */ #define FTS_DP 6 /* postorder directory */ #define FTS_ERR 7 /* error; errno is set */ #define FTS_F 8 /* regular file */ #define FTS_INIT 9 /* initialized only */ #define FTS_NS 10 /* stat(2) failed */ #define FTS_NSOK 11 /* no stat(2) requested */ #define FTS_SL 12 /* symbolic link */ #define FTS_SLNONE 13 /* symbolic link without target */ #define FTS_W 14 /* whiteout object */ int fts_info; /* user status for FTSENT structure */ #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ #define FTS_ISW 0x04 /* this is a whiteout object */ unsigned fts_flags; /* private flags for FTSENT structure */ #define FTS_AGAIN 1 /* read node again */ #define FTS_FOLLOW 2 /* follow symbolic link */ #define FTS_NOINSTR 3 /* no instructions */ #define FTS_SKIP 4 /* discard node */ int fts_instr; /* fts_set() instructions */ struct stat *fts_statp; /* stat(2) information */ char *fts_name; /* file name */ FTS *fts_fts; /* back pointer to main FTS */ } FTSENT; #include __BEGIN_DECLS FTSENT *fts_children(FTS *, int); int fts_close(FTS *); void *fts_get_clientptr(FTS *); #define fts_get_clientptr(fts) ((fts)->fts_clientptr) FTS *fts_get_stream(FTSENT *); #define fts_get_stream(ftsent) ((ftsent)->fts_fts) FTS *fts_open(char * const *, int, int (*)(const FTSENT * const *, const FTSENT * const *)); FTSENT *fts_read(FTS *); int fts_set(FTS *, FTSENT *, int); void fts_set_clientptr(FTS *, void *); __END_DECLS #endif /* !_FTS_H_ */ diff --git a/include/glob.h b/include/glob.h index 80d78a219444..c5d17ef65ec7 100644 --- a/include/glob.h +++ b/include/glob.h @@ -1,108 +1,107 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Guido van Rossum. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)glob.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _GLOB_H_ #define _GLOB_H_ #include #include #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif struct stat; typedef struct { size_t gl_pathc; /* Count of total paths so far. */ size_t gl_matchc; /* Count of paths matching pattern. */ size_t gl_offs; /* Reserved at beginning of gl_pathv. */ int gl_flags; /* Copy of flags parameter to glob. */ char **gl_pathv; /* List of paths matching pattern. */ /* Copy of errfunc parameter to glob. */ int (*gl_errfunc)(const char *, int); /* * Alternate filesystem access methods for glob; replacement * versions of closedir(3), readdir(3), opendir(3), stat(2) * and lstat(2). */ void (*gl_closedir)(void *); struct dirent *(*gl_readdir)(void *); void *(*gl_opendir)(const char *); int (*gl_lstat)(const char *, struct stat *); int (*gl_stat)(const char *, struct stat *); } glob_t; #if __POSIX_VISIBLE >= 199209 /* Believed to have been introduced in 1003.2-1992 */ #define GLOB_APPEND 0x0001 /* Append to output from previous call. */ #define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ #define GLOB_ERR 0x0004 /* Return on error. */ #define GLOB_MARK 0x0008 /* Append / to matching directories. */ #define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ #define GLOB_NOSORT 0x0020 /* Don't sort. */ #define GLOB_NOESCAPE 0x2000 /* Disable backslash escaping. */ /* Error values returned by glob(3) */ #define GLOB_NOSPACE (-1) /* Malloc call failed. */ #define GLOB_ABORTED (-2) /* Unignored error. */ #define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK was not set. */ #define GLOB_NOSYS (-4) /* Obsolete: source comptability only. */ #endif /* __POSIX_VISIBLE >= 199209 */ #if __BSD_VISIBLE #define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ #define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ #define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ #define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ #define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ #define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ #define GLOB_LIMIT 0x1000 /* limit number of returned paths */ /* source compatibility, these are the old names */ #define GLOB_MAXPATH GLOB_LIMIT #define GLOB_ABEND GLOB_ABORTED #endif /* __BSD_VISIBLE */ __BEGIN_DECLS int glob(const char * __restrict, int, int (*)(const char *, int), glob_t * __restrict); void globfree(glob_t *); __END_DECLS #endif /* !_GLOB_H_ */ diff --git a/include/grp.h b/include/grp.h index 655bfdc66ec8..3798fd3ea43c 100644 --- a/include/grp.h +++ b/include/grp.h @@ -1,94 +1,93 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)grp.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _GRP_H_ #define _GRP_H_ #include #include #define _PATH_GROUP "/etc/group" #ifndef _GID_T_DECLARED typedef __gid_t gid_t; #define _GID_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ gid_t gr_gid; /* group id */ char **gr_mem; /* group members */ }; __BEGIN_DECLS #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE void endgrent(void); struct group *getgrent(void); #endif struct group *getgrgid(gid_t); struct group *getgrnam(const char *); #if __BSD_VISIBLE const char *group_from_gid(gid_t, int); int gid_from_group(const char *, gid_t *); int pwcache_groupdb(int (*)(int), void (*)(void), struct group * (*)(const char *), struct group * (*)(gid_t)); #endif #if __XSI_VISIBLE void setgrent(void); #endif #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); int getgrnam_r(const char *, struct group *, char *, size_t, struct group **); #endif #if __BSD_VISIBLE int getgrent_r(struct group *, char *, size_t, struct group **); int setgroupent(int); #endif __END_DECLS #endif /* !_GRP_H_ */ diff --git a/include/limits.h b/include/limits.h index fc1470c058cb..73036ca3ad7b 100644 --- a/include/limits.h +++ b/include/limits.h @@ -1,149 +1,148 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _LIMITS_H_ #define _LIMITS_H_ #include #if __POSIX_VISIBLE #define _POSIX_ARG_MAX 4096 #define _POSIX_LINK_MAX 8 #define _POSIX_MAX_CANON 255 #define _POSIX_MAX_INPUT 255 #define _POSIX_NAME_MAX 14 #define _POSIX_PIPE_BUF 512 #define _POSIX_SSIZE_MAX 32767 #define _POSIX_STREAM_MAX 8 #if __POSIX_VISIBLE >= 200112 #define _POSIX_CHILD_MAX 25 #define _POSIX_NGROUPS_MAX 8 #define _POSIX_OPEN_MAX 20 #define _POSIX_PATH_MAX 256 #define _POSIX_TZNAME_MAX 6 #else #define _POSIX_CHILD_MAX 6 #define _POSIX_NGROUPS_MAX 0 #define _POSIX_OPEN_MAX 16 #define _POSIX_PATH_MAX 255 #define _POSIX_TZNAME_MAX 3 #endif #if __POSIX_VISIBLE >= 200112 #define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ #define BC_DIM_MAX 2048 /* max array elements in bc(1) */ #define BC_SCALE_MAX 99 /* max scale value in bc(1) */ #define BC_STRING_MAX 1000 /* max const string length in bc(1) */ #define CHARCLASS_NAME_MAX 14 /* max character class name size */ #define COLL_WEIGHTS_MAX 10 /* max weights for order keyword */ #define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ #define LINE_MAX 2048 /* max bytes in an input line */ #define RE_DUP_MAX 255 /* max RE's in interval notation */ #define _POSIX2_BC_BASE_MAX 99 #define _POSIX2_BC_DIM_MAX 2048 #define _POSIX2_BC_SCALE_MAX 99 #define _POSIX2_BC_STRING_MAX 1000 #define _POSIX2_CHARCLASS_NAME_MAX 14 #define _POSIX2_COLL_WEIGHTS_MAX 2 #define _POSIX2_EQUIV_CLASS_MAX 2 #define _POSIX2_EXPR_NEST_MAX 32 #define _POSIX2_LINE_MAX 2048 #define _POSIX2_RE_DUP_MAX 255 #endif #endif #if __POSIX_VISIBLE >= 199309 #define _POSIX_AIO_LISTIO_MAX 2 #define _POSIX_AIO_MAX 1 #define _POSIX_DELAYTIMER_MAX 32 #define _POSIX_MQ_OPEN_MAX 8 #define _POSIX_MQ_PRIO_MAX 32 #define _POSIX_RTSIG_MAX 8 #define _POSIX_SEM_NSEMS_MAX 256 #define _POSIX_SEM_VALUE_MAX 32767 #define _POSIX_SIGQUEUE_MAX 32 #define _POSIX_TIMER_MAX 32 #define _POSIX_CLOCKRES_MIN 20000000 #endif #if __POSIX_VISIBLE >= 199506 #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 #define _POSIX_THREAD_KEYS_MAX 128 #define _POSIX_THREAD_THREADS_MAX 64 #endif #if __POSIX_VISIBLE >= 200112 #define _POSIX_HOST_NAME_MAX 255 #define _POSIX_LOGIN_NAME_MAX 9 #define _POSIX_SS_REPL_MAX 4 #define _POSIX_SYMLINK_MAX 255 #define _POSIX_SYMLOOP_MAX 8 #define _POSIX_TRACE_EVENT_NAME_MAX 30 #define _POSIX_TRACE_NAME_MAX 8 #define _POSIX_TRACE_SYS_MAX 8 #define _POSIX_TRACE_USER_EVENT_MAX 32 #define _POSIX_TTY_NAME_MAX 9 #define _POSIX_RE_DUP_MAX _POSIX2_RE_DUP_MAX #endif #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809 #define NL_ARGMAX 4096 /* max # of position args for printf */ #define NL_MSGMAX 32767 #define NL_SETMAX 255 #define NL_TEXTMAX 2048 #endif #if __XSI_VISIBLE #define _XOPEN_IOV_MAX 16 #define _XOPEN_NAME_MAX 255 #define _XOPEN_PATH_MAX 1024 #define PASS_MAX 128 /* _PASSWORD_LEN from */ #define NL_LANGMAX 31 /* max LANG name length */ #define NL_NMAX 1 #endif #define MB_LEN_MAX 6 /* 31-bit UTF-8 */ #include #if __POSIX_VISIBLE #include #endif #endif /* !_LIMITS_H_ */ diff --git a/include/locale.h b/include/locale.h index de8e03ade5c8..0e2abc04dcc8 100644 --- a/include/locale.h +++ b/include/locale.h @@ -1,89 +1,88 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)locale.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _LOCALE_H_ #define _LOCALE_H_ #include struct lconv { char *decimal_point; char *thousands_sep; char *grouping; char *int_curr_symbol; char *currency_symbol; char *mon_decimal_point; char *mon_thousands_sep; char *mon_grouping; char *positive_sign; char *negative_sign; char int_frac_digits; char frac_digits; char p_cs_precedes; char p_sep_by_space; char n_cs_precedes; char n_sep_by_space; char p_sign_posn; char n_sign_posn; char int_p_cs_precedes; char int_n_cs_precedes; char int_p_sep_by_space; char int_n_sep_by_space; char int_p_sign_posn; char int_n_sign_posn; }; #define LC_ALL 0 #define LC_COLLATE 1 #define LC_CTYPE 2 #define LC_MONETARY 3 #define LC_NUMERIC 4 #define LC_TIME 5 #define LC_MESSAGES 6 #define _LC_LAST 7 /* marks end */ #include __BEGIN_DECLS struct lconv *localeconv(void); char *setlocale(int, const char *); #if __POSIX_VISIBLE >= 200809 #include #endif __END_DECLS #endif /* _LOCALE_H_ */ diff --git a/include/malloc.h b/include/malloc.h index 75673c72ed85..37cde282bdaa 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -1,6 +1,5 @@ /*- * This file is in the public domain. - * $FreeBSD$ */ #include #include diff --git a/include/mpool.h b/include/mpool.h index 2c6866020e7c..7fc66b62f042 100644 --- a/include/mpool.h +++ b/include/mpool.h @@ -1,111 +1,110 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mpool.h 8.4 (Berkeley) 11/2/95 - * $FreeBSD$ */ #ifndef _MPOOL_H_ #define _MPOOL_H_ #include /* * The memory pool scheme is a simple one. Each in-memory page is referenced * by a bucket which is threaded in up to two of three ways. All active pages * are threaded on a hash chain (hashed by page number) and an lru chain. * Inactive pages are threaded on a free chain. Each reference to a memory * pool is handed an opaque MPOOL cookie which stores all of this information. */ #define HASHSIZE 128 #define HASHKEY(pgno) ((pgno - 1 + HASHSIZE) % HASHSIZE) /* The BKT structures are the elements of the queues. */ typedef struct _bkt { TAILQ_ENTRY(_bkt) hq; /* hash queue */ TAILQ_ENTRY(_bkt) q; /* lru queue */ void *page; /* page */ pgno_t pgno; /* page number */ #define MPOOL_DIRTY 0x01 /* page needs to be written */ #define MPOOL_PINNED 0x02 /* page is pinned into memory */ #define MPOOL_INUSE 0x04 /* page address is valid */ u_int8_t flags; /* flags */ } BKT; typedef struct MPOOL { TAILQ_HEAD(_lqh, _bkt) lqh; /* lru queue head */ /* hash queue array */ TAILQ_HEAD(_hqh, _bkt) hqh[HASHSIZE]; pgno_t curcache; /* current number of cached pages */ pgno_t maxcache; /* max number of cached pages */ pgno_t npages; /* number of pages in the file */ unsigned long pagesize; /* file page size */ int fd; /* file descriptor */ /* page in conversion routine */ void (*pgin)(void *, pgno_t, void *); /* page out conversion routine */ void (*pgout)(void *, pgno_t, void *); void *pgcookie; /* cookie for page in/out routines */ #ifdef STATISTICS unsigned long cachehit; unsigned long cachemiss; unsigned long pagealloc; unsigned long pageflush; unsigned long pageget; unsigned long pagenew; unsigned long pageput; unsigned long pageread; unsigned long pagewrite; #endif } MPOOL; #define MPOOL_IGNOREPIN 0x01 /* Ignore if the page is pinned. */ #define MPOOL_PAGE_REQUEST 0x01 /* Allocate a new page with a specific page number. */ #define MPOOL_PAGE_NEXT 0x02 /* Allocate a new page with the next page number. */ __BEGIN_DECLS MPOOL *mpool_open(void *, int, pgno_t, pgno_t); void mpool_filter(MPOOL *, void (*)(void *, pgno_t, void *), void (*)(void *, pgno_t, void *), void *); void *mpool_new(MPOOL *, pgno_t *, unsigned int); void *mpool_get(MPOOL *, pgno_t, unsigned int); int mpool_delete(MPOOL *, void *); int mpool_put(MPOOL *, void *, unsigned int); int mpool_sync(MPOOL *); int mpool_close(MPOOL *); #ifdef STATISTICS void mpool_stat(MPOOL *); #endif __END_DECLS #endif diff --git a/include/ndbm.h b/include/ndbm.h index f9b0d2b4b0ff..c520999ee8a8 100644 --- a/include/ndbm.h +++ b/include/ndbm.h @@ -1,82 +1,81 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Margo Seltzer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _NDBM_H_ #define _NDBM_H_ #include /* Map dbm interface onto db(3). */ #define DBM_RDONLY O_RDONLY /* Flags to dbm_store(). */ #define DBM_INSERT 0 #define DBM_REPLACE 1 /* * The db(3) support for ndbm always appends this suffix to the * file name to avoid overwriting the user's original database. */ #define DBM_SUFFIX ".db" typedef struct { void *dptr; int dsize; /* XXX Should be size_t according to 1003.1-2008. */ } datum; typedef DB DBM; #define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE __BEGIN_DECLS int dbm_clearerr(DBM *); void dbm_close(DBM *); int dbm_delete(DBM *, datum); int dbm_error(DBM *); datum dbm_fetch(DBM *, datum); datum dbm_firstkey(DBM *); #if __BSD_VISIBLE long dbm_forder(DBM *, datum); #endif datum dbm_nextkey(DBM *); DBM *dbm_open(const char *, int, mode_t); int dbm_store(DBM *, datum, datum, int); #if __BSD_VISIBLE int dbm_dirfno(DBM *); #endif __END_DECLS #endif /* !_NDBM_H_ */ diff --git a/include/netdb.h b/include/netdb.h index 7eba378482a1..0f9e4b41032a 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -1,309 +1,308 @@ /*- * SPDX-License-Identifier: (BSD-3-Clause AND ISC) * * Copyright (c) 1980, 1983, 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. * - * --Copyright-- */ /* * @(#)netdb.h 8.1 (Berkeley) 6/2/93 * From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $ - * $FreeBSD$ */ #ifndef _NETDB_H_ #define _NETDB_H_ #include #include #ifndef _IN_ADDR_T_DECLARED typedef __uint32_t in_addr_t; #define _IN_ADDR_T_DECLARED #endif #ifndef _IN_PORT_T_DECLARED typedef __uint16_t in_port_t; #define _IN_PORT_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _SOCKLEN_T_DECLARED typedef __socklen_t socklen_t; #define _SOCKLEN_T_DECLARED #endif #ifndef _UINT32_T_DECLARED typedef __uint32_t uint32_t; #define _UINT32_T_DECLARED #endif #ifndef _PATH_HEQUIV # define _PATH_HEQUIV "/etc/hosts.equiv" #endif #define _PATH_HOSTS "/etc/hosts" #define _PATH_NETWORKS "/etc/networks" #define _PATH_PROTOCOLS "/etc/protocols" #define _PATH_SERVICES "/etc/services" #define _PATH_SERVICES_DB "/var/db/services.db" #define h_errno (*__h_errno()) /* * Structures returned by network data base library. All addresses are * supplied in host order, and returned in network order (suitable for * use in system calls). */ struct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */ #define h_addr h_addr_list[0] /* address, for backward compatibility */ }; struct netent { char *n_name; /* official name of net */ char **n_aliases; /* alias list */ int n_addrtype; /* net address type */ uint32_t n_net; /* network # */ }; struct servent { char *s_name; /* official service name */ char **s_aliases; /* alias list */ int s_port; /* port # */ char *s_proto; /* protocol to use */ }; struct protoent { char *p_name; /* official protocol name */ char **p_aliases; /* alias list */ int p_proto; /* protocol # */ }; struct addrinfo { int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */ int ai_family; /* AF_xxx */ int ai_socktype; /* SOCK_xxx */ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ socklen_t ai_addrlen; /* length of ai_addr */ char *ai_canonname; /* canonical name for hostname */ struct sockaddr *ai_addr; /* binary address */ struct addrinfo *ai_next; /* next structure in linked list */ }; #define IPPORT_RESERVED 1024 /* * Error return codes from gethostbyname() and gethostbyaddr() * (left in h_errno). */ #define NETDB_INTERNAL -1 /* see errno */ #define NETDB_SUCCESS 0 /* no problem */ #define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */ #define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */ #define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ #define NO_DATA 4 /* Valid name, no data record of requested type */ #define NO_ADDRESS NO_DATA /* no address, look for MX record */ /* * Error return codes from gai_strerror(3), see RFC 3493. */ #if __BSD_VISIBLE /* not in POSIX */ /* EAI_ADDRFAMILY was obsoleted by RFC 3493, used as extension */ #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ #endif #define EAI_AGAIN 2 /* name could not be resolved at this time */ #define EAI_BADFLAGS 3 /* flags parameter had an invalid value */ #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ #define EAI_FAMILY 5 /* address family not recognized */ #define EAI_MEMORY 6 /* memory allocation failure */ #if __BSD_VISIBLE /* not in POSIX */ /* EAI_NODATA was obsoleted by RFC 3493, retained here as extension */ #define EAI_NODATA 7 /* no address associated with hostname */ #endif #define EAI_NONAME 8 /* name does not resolve */ #define EAI_SERVICE 9 /* service not recognized for socket type */ #define EAI_SOCKTYPE 10 /* intended socket type was not recognized */ #define EAI_SYSTEM 11 /* system error returned in errno */ #if __BSD_VISIBLE /* not in POSIX */ /* The following 3 are not in RFC 3493 or POSIX, retained for compatibility */ #define EAI_BADHINTS 12 /* invalid value for hints */ #define EAI_PROTOCOL 13 /* resolved protocol is unknown */ #define EAI_OVERFLOW 14 /* argument buffer overflow */ #endif #define EAI_MAX 15 /* * Flag values for getaddrinfo() */ #define AI_PASSIVE 0x00000001 /* get address to use bind() */ #define AI_CANONNAME 0x00000002 /* fill ai_canonname */ #define AI_NUMERICHOST 0x00000004 /* prevent host name resolution */ #define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */ /* valid flags for addrinfo (not a standard def, apps should not use it) */ #define AI_MASK \ (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \ AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED) #define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ #define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ #define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ #define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ /* special recommended flags for getipnodebyname */ #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) /* * Constants for getnameinfo() */ #define NI_MAXHOST 1025 #define NI_MAXSERV 32 /* * Flag values for getnameinfo() */ #define NI_NOFQDN 0x00000001 #define NI_NUMERICHOST 0x00000002 #define NI_NAMEREQD 0x00000004 #define NI_NUMERICSERV 0x00000008 #define NI_DGRAM 0x00000010 #define NI_NUMERICSCOPE 0x00000020 /* * Scope delimit character */ #define SCOPE_DELIMITER '%' __BEGIN_DECLS void endhostent(void); void endnetent(void); void endprotoent(void); void endservent(void); #if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 200112) struct hostent *gethostbyaddr(const void *, socklen_t, int); struct hostent *gethostbyname(const char *); #endif struct hostent *gethostent(void); struct netent *getnetbyaddr(uint32_t, int); struct netent *getnetbyname(const char *); struct netent *getnetent(void); struct protoent *getprotobyname(const char *); struct protoent *getprotobynumber(int); struct protoent *getprotoent(void); struct servent *getservbyname(const char *, const char *); struct servent *getservbyport(int, const char *); struct servent *getservent(void); void sethostent(int); /* void sethostfile(const char *); */ void setnetent(int); void setprotoent(int); int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int); void freeaddrinfo(struct addrinfo *); const char *gai_strerror(int); void setservent(int); #if __BSD_VISIBLE void endnetgrent(void); void freehostent(struct hostent *); int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, char *, size_t, struct hostent **, int *); int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *); struct hostent *gethostbyname2(const char *, int); int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t, struct hostent **, int *); int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *); struct hostent *getipnodebyaddr(const void *, size_t, int, int *); struct hostent *getipnodebyname(const char *, int, int, int *); int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *); int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *); int getnetent_r(struct netent *, char *, size_t, struct netent **, int *); int getnetgrent(char **, char **, char **); int getnetgrent_r(char **, char **, char **, char *, size_t); int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **); int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **); int getprotoent_r(struct protoent *, char *, size_t, struct protoent **); int getservbyname_r(const char *, const char *, struct servent *, char *, size_t, struct servent **); int getservbyport_r(int, const char *, struct servent *, char *, size_t, struct servent **); int getservent_r(struct servent *, char *, size_t, struct servent **); void herror(const char *); const char *hstrerror(int); int innetgr(const char *, const char *, const char *, const char *); void setnetgrent(const char *); #endif /* * PRIVATE functions specific to the FreeBSD implementation */ /* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */ int * __h_errno(void); __END_DECLS #endif /* !_NETDB_H_ */ diff --git a/include/paths.h b/include/paths.h index a0c3c9de6136..55f7d1175617 100644 --- a/include/paths.h +++ b/include/paths.h @@ -1,151 +1,150 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)paths.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _PATHS_H_ #define _PATHS_H_ #include #define _PATH_LOCALBASE "/usr/local" /* Default search path. */ #define _PATH_DEFPATH "/sbin:/bin:/usr/sbin:/usr/bin:" \ _PATH_LOCALBASE "/sbin:" _PATH_LOCALBASE "/bin" /* All standard utilities path. */ #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" /* Locate system binaries. */ #define _PATH_SYSPATH "/sbin:/usr/sbin" #define _PATH_BSHELL "/bin/sh" #define _PATH_CAPABILITY "/etc/capability" #define _PATH_CAPABILITY_DB "/etc/capability.db" #define _PATH_CONSOLE "/dev/console" #define _PATH_CP "/bin/cp" #define _PATH_CSHELL "/bin/csh" #define _PATH_CSMAPPER "/usr/share/i18n/csmapper" #define _PATH_DEFTAPE "/dev/sa0" #define _PATH_DEVGPIOC "/dev/gpioc" #define _PATH_DEVNULL "/dev/null" #define _PATH_DEVZERO "/dev/zero" #define _PATH_DRUM "/dev/drum" #define _PATH_ESDB "/usr/share/i18n/esdb" #define _PATH_ETC "/etc" #define _PATH_FIRMWARE "/usr/share/firmware" #define _PATH_FTPUSERS "/etc/ftpusers" #define _PATH_FWMEM "/dev/fwmem" #define _PATH_GBDE "/sbin/gbde" #define _PATH_GELI "/sbin/geli" #define _PATH_HALT "/sbin/halt" #ifdef COMPAT_libcompat #define _PATH_I18NMODULE "/usr/lib" COMPAT_libcompat "/i18n" #else #define _PATH_I18NMODULE "/usr/lib/i18n" #endif #define _PATH_IFCONFIG "/sbin/ifconfig" #define _PATH_KMEM "/dev/kmem" #define _PATH_LIBMAP_CONF "/etc/libmap.conf" #define _PATH_LOCALE "/usr/share/locale" #define _PATH_LOGIN "/usr/bin/login" #define _PATH_MAILDIR "/var/mail" #define _PATH_MAN "/usr/share/man" #define _PATH_MDCONFIG "/sbin/mdconfig" #define _PATH_MEM "/dev/mem" #define _PATH_MKSNAP_FFS "/sbin/mksnap_ffs" #define _PATH_MOUNT "/sbin/mount" #define _PATH_NEWFS "/sbin/newfs" #define _PATH_NOLOGIN "/var/run/nologin" #define _PATH_RCP "/bin/rcp" #define _PATH_REBOOT "/sbin/reboot" #define _PATH_RLOGIN "/usr/bin/rlogin" #define _PATH_RM "/bin/rm" #define _PATH_RSH "/usr/bin/rsh" #define _PATH_SENDMAIL "/usr/sbin/sendmail" #define _PATH_SHELLS "/etc/shells" #define _PATH_TTY "/dev/tty" #define _PATH_UNIX "don't use _PATH_UNIX" #define _PATH_UFSSUSPEND "/dev/ufssuspend" #define _PATH_VI "/usr/bin/vi" #define _PATH_WALL "/usr/bin/wall" /* Provide trailing slash, since mostly used for building pathnames. */ #define _PATH_DEV "/dev/" #define _PATH_TMP "/tmp/" #define _PATH_VARDB "/var/db/" #define _PATH_VARRUN "/var/run/" #define _PATH_VARTMP "/var/tmp/" #define _PATH_DEVVMM "/dev/vmm/" #define _PATH_YP "/var/yp/" #define _PATH_UUCPLOCK "/var/spool/lock/" /* How to get the correct name of the kernel. */ __BEGIN_DECLS const char *getbootfile(void); __END_DECLS #ifdef RESCUE #undef _PATH_DEFPATH #define _PATH_DEFPATH "/rescue:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" #undef _PATH_STDPATH #define _PATH_STDPATH "/rescue:/usr/bin:/bin:/usr/sbin:/sbin" #undef _PATH_SYSPATH #define _PATH_SYSPATH "/rescue:/sbin:/usr/sbin" #undef _PATH_BSHELL #define _PATH_BSHELL "/rescue/sh" #undef _PATH_CP #define _PATH_CP "/rescue/cp" #undef _PATH_CSHELL #define _PATH_CSHELL "/rescue/csh" #undef _PATH_HALT #define _PATH_HALT "/rescue/halt" #undef _PATH_IFCONFIG #define _PATH_IFCONFIG "/rescue/ifconfig" #undef _PATH_MDCONFIG #define _PATH_MDCONFIG "/rescue/mdconfig" #undef _PATH_MOUNT #define _PATH_MOUNT "/rescue/mount" #undef _PATH_NEWFS #define _PATH_NEWFS "/rescue/newfs" #undef _PATH_RCP #define _PATH_RCP "/rescue/rcp" #undef _PATH_REBOOT #define _PATH_REBOOT "/rescue/reboot" #undef _PATH_RM #define _PATH_RM "/rescue/rm" #undef _PATH_VI #define _PATH_VI "/rescue/vi" #undef _PATH_WALL #define _PATH_WALL "/rescue/wall" #endif /* RESCUE */ #endif /* !_PATHS_H_ */ diff --git a/include/pwd.h b/include/pwd.h index 1548400b7eb8..6b56e6f9c5ed 100644 --- a/include/pwd.h +++ b/include/pwd.h @@ -1,177 +1,176 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pwd.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _PWD_H_ #define _PWD_H_ #include #include #ifndef _GID_T_DECLARED typedef __gid_t gid_t; #define _GID_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #ifndef _UID_T_DECLARED typedef __uid_t uid_t; #define _UID_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #define _PATH_PWD "/etc" #define _PATH_PASSWD "/etc/passwd" #define _PASSWD "passwd" #define _PATH_MASTERPASSWD "/etc/master.passwd" #define _MASTERPASSWD "master.passwd" #define _PATH_MP_DB "/etc/pwd.db" #define _MP_DB "pwd.db" #define _PATH_SMP_DB "/etc/spwd.db" #define _SMP_DB "spwd.db" #define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb" /* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format * `1 octet tag | key', where the tag is one of the _PW_KEY* values * listed below. These values happen to be ASCII digits. Starting * with FreeBSD 5.1, the tag is now still a single octet, but the * upper 4 bits are interpreted as a version. Pre-FreeBSD 5.1 format * entries are version `3' -- this conveniently results in the same * key values as before. The new, architecture-independent entries * are version `4'. * As it happens, some applications read the database directly. * (Bad app, no cookie!) Thus, we leave the _PW_KEY* symbols at their * old pre-FreeBSD 5.1 values so these apps still work. Consequently * we have to muck around a bit more to get the correct, versioned * tag, and that is what the _PW_VERSIONED macro is about. */ #define _PW_VERSION_MASK '\xF0' #define _PW_VERSIONED(x, v) ((unsigned char)(((x) & 0xCF) | ((v)<<4))) #define _PW_KEYBYNAME '\x31' /* stored by name */ #define _PW_KEYBYNUM '\x32' /* stored by entry in the "file" */ #define _PW_KEYBYUID '\x33' /* stored by uid */ #define _PW_KEYYPENABLED '\x34' /* YP is enabled */ #define _PW_KEYYPBYNUM '\x35' /* special +@netgroup entries */ /* The database also contains a key to indicate the format version of * the entries therein. There may be other, older versioned entries * as well. */ #define _PWD_VERSION_KEY "\xFF" "VERSION" #define _PWD_CURRENT_VERSION '\x04' #define _PASSWORD_EFMT1 '_' /* extended encryption format */ #define _PASSWORD_LEN 128 /* max length, not counting NULL */ struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user access class */ char *pw_gecos; /* Honeywell login info */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ int pw_fields; /* internal: fields filled in */ }; /* Mapping from fields to bits for pw_fields. */ #define _PWF(x) (1 << x) #define _PWF_NAME _PWF(0) #define _PWF_PASSWD _PWF(1) #define _PWF_UID _PWF(2) #define _PWF_GID _PWF(3) #define _PWF_CHANGE _PWF(4) #define _PWF_CLASS _PWF(5) #define _PWF_GECOS _PWF(6) #define _PWF_DIR _PWF(7) #define _PWF_SHELL _PWF(8) #define _PWF_EXPIRE _PWF(9) /* XXX These flags are bogus. With nsswitch, there are many * possible sources and they cannot be represented in a small integer. */ #define _PWF_SOURCE 0x3000 #define _PWF_FILES 0x1000 #define _PWF_NIS 0x2000 #define _PWF_HESIOD 0x3000 __BEGIN_DECLS struct passwd *getpwnam(const char *); struct passwd *getpwuid(uid_t); #if __XSI_VISIBLE >= 500 void endpwent(void); struct passwd *getpwent(void); void setpwent(void); #endif #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); #endif #if __BSD_VISIBLE int getpwent_r(struct passwd *, char *, size_t, struct passwd **); int setpassent(int); const char *user_from_uid(uid_t, int); int uid_from_user(const char *, uid_t *); int pwcache_userdb(int (*)(int), void (*)(void), struct passwd * (*)(const char *), struct passwd * (*)(uid_t)); #endif __END_DECLS #endif /* !_PWD_H_ */ diff --git a/include/regex.h b/include/regex.h index 3bea3df4f3d4..2644040899f0 100644 --- a/include/regex.h +++ b/include/regex.h @@ -1,119 +1,118 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Henry Spencer. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Henry Spencer of the University of Toronto. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)regex.h 8.2 (Berkeley) 1/3/94 - * $FreeBSD$ */ #ifndef _REGEX_H_ #define _REGEX_H_ #include #include /* types */ typedef __off_t regoff_t; #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif typedef struct { int re_magic; size_t re_nsub; /* number of parenthesized subexpressions */ const char *re_endp; /* end pointer for REG_PEND */ struct re_guts *re_g; /* none of your business :-) */ } regex_t; typedef struct { regoff_t rm_so; /* start of match */ regoff_t rm_eo; /* end of match */ } regmatch_t; /* regcomp() flags */ #define REG_BASIC 0000 #define REG_EXTENDED 0001 #define REG_ICASE 0002 #define REG_NOSUB 0004 #define REG_NEWLINE 0010 #define REG_NOSPEC 0020 #define REG_PEND 0040 #define REG_DUMP 0200 #define REG_POSIX 0400 /* only POSIX-compliant regex (libregex) */ /* regerror() flags */ #define REG_ENOSYS (-1) #define REG_NOMATCH 1 #define REG_BADPAT 2 #define REG_ECOLLATE 3 #define REG_ECTYPE 4 #define REG_EESCAPE 5 #define REG_ESUBREG 6 #define REG_EBRACK 7 #define REG_EPAREN 8 #define REG_EBRACE 9 #define REG_BADBR 10 #define REG_ERANGE 11 #define REG_ESPACE 12 #define REG_BADRPT 13 #define REG_EMPTY 14 #define REG_ASSERT 15 #define REG_INVARG 16 #define REG_ILLSEQ 17 #define REG_ATOI 255 /* convert name to number (!) */ #define REG_ITOA 0400 /* convert number to name (!) */ /* regexec() flags */ #define REG_NOTBOL 00001 #define REG_NOTEOL 00002 #define REG_STARTEND 00004 #define REG_TRACE 00400 /* tracing of execution */ #define REG_LARGE 01000 /* force large representation */ #define REG_BACKR 02000 /* force use of backref code */ __BEGIN_DECLS int regcomp(regex_t * __restrict, const char * __restrict, int); size_t regerror(int, const regex_t * __restrict, char * __restrict, size_t); /* * XXX forth parameter should be `regmatch_t [__restrict]', but isn't because * of a bug in GCC 3.2 (when -std=c99 is specified) which perceives this as a * syntax error. */ int regexec(const regex_t * __restrict, const char * __restrict, size_t, regmatch_t * __restrict, int); void regfree(regex_t *); __END_DECLS #endif /* !_REGEX_H_ */ diff --git a/include/res_update.h b/include/res_update.h index 32d363bacfae..9f2d550b7265 100644 --- a/include/res_update.h +++ b/include/res_update.h @@ -1,77 +1,76 @@ /*- * SPDX-License-Identifier: ISC * * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1999 by Internet Software Consortium, Inc. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * $Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp $ - * $FreeBSD$ */ #ifndef __RES_UPDATE_H #define __RES_UPDATE_H /*! \file */ #include #include #include /*% * This RR-like structure is particular to UPDATE. */ struct ns_updrec { struct { struct ns_updrec *prev; struct ns_updrec *next; } r_link, r_glink; ns_sect r_section; /*%< ZONE/PREREQUISITE/UPDATE */ char * r_dname; /*%< owner of the RR */ ns_class r_class; /*%< class number */ ns_type r_type; /*%< type number */ u_int32_t r_ttl; /*%< time to live */ u_char * r_data; /*%< rdata fields as text string */ u_int r_size; /*%< size of r_data field */ int r_opcode; /*%< type of operation */ /* following fields for private use by the resolver/server routines */ struct databuf *r_dp; /*%< databuf to process */ struct databuf *r_deldp; /*%< databuf's deleted/overwritten */ u_int r_zone; /*%< zone number on server */ }; typedef struct ns_updrec ns_updrec; typedef struct { ns_updrec *head; ns_updrec *tail; } ns_updque; #define res_mkupdate __res_mkupdate #define res_update __res_update #define res_mkupdrec __res_mkupdrec #define res_freeupdrec __res_freeupdrec #define res_nmkupdate __res_nmkupdate #define res_nupdate __res_nupdate int res_mkupdate(ns_updrec *, u_char *, int); int res_update(ns_updrec *); ns_updrec * res_mkupdrec(int, const char *, u_int, u_int, u_long); void res_freeupdrec(ns_updrec *); int res_nmkupdate(res_state, ns_updrec *, u_char *, int); int res_nupdate(res_state, ns_updrec *, ns_tsig_key *); #endif /*__RES_UPDATE_H*/ /*! \file */ diff --git a/include/resolv.h b/include/resolv.h index 2226c481c7e6..467648b2aa53 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -1,505 +1,504 @@ /*- * SPDX-License-Identifier: (ISC AND BSD-3-Clause) * * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (C) 1995-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* * Copyright (c) 1983, 1987, 1989 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /*% * @(#)resolv.h 8.1 (Berkeley) 6/2/93 * $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $ - * $FreeBSD$ */ #ifndef _RESOLV_H_ #define _RESOLV_H_ #include #include #include #include #include #include /*% * Revision information. This is the release date in YYYYMMDD format. * It can change every day so the right thing to do with it is use it * in preprocessor commands such as "#if (__RES > 19931104)". Do not * compare for equality; rather, use it to determine whether your resolver * is new enough to contain a certain feature. */ #define __RES 20090302 /*% * This used to be defined in res_query.c, now it's in herror.c. * [XXX no it's not. It's in irs/irs_data.c] * It was * never extern'd by any *.h file before it was placed here. For thread * aware programs, the last h_errno value set is stored in res->h_errno. * * XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO * (and __h_errno_set) to the public via . * XXX: __h_errno_set is really part of IRS, not part of the resolver. * If somebody wants to build and use a resolver that doesn't use IRS, * what do they do? Perhaps something like * #ifdef WANT_IRS * # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) * #else * # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x)) * #endif */ #define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x) struct __res_state; /*%< forward */ __BEGIN_DECLS void __h_errno_set(struct __res_state *, int); __END_DECLS /*% * Resolver configuration file. * Normally not present, but may contain the address of the * initial name server(s) to query and the domain search list. */ #ifndef _PATH_RESCONF #define _PATH_RESCONF "/etc/resolv.conf" #endif typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } res_sendhookact; typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *, const u_char **, int *, u_char *, int, int *); typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *, const u_char *, int, u_char *, int, int *); struct res_sym { int number; /*%< Identifying number, like T_MX */ const char * name; /*%< Its symbolic name, like "MX" */ const char * humanname; /*%< Its fun name, like "mail exchanger" */ }; /*% * Global defines and variables for resolver stub. */ #define MAXNS 3 /*%< max # name servers we'll track */ #define MAXDFLSRCH 3 /*%< # default domain levels to try */ #define MAXDNSRCH 6 /*%< max # domains in search path */ #define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */ #define RES_TIMEOUT 5 /*%< min. seconds between retries */ #define MAXRESOLVSORT 10 /*%< number of net to sort on */ #define RES_MAXNDOTS 15 /*%< should reflect bit field size */ #define RES_MAXRETRANS 30 /*%< only for resolv.conf/RES_OPTIONS */ #define RES_MAXRETRY 5 /*%< only for resolv.conf/RES_OPTIONS */ #define RES_DFLRETRY 2 /*%< Default #/tries. */ #define RES_MAXTIME 65535 /*%< Infinity, in milliseconds. */ struct __res_state_ext; struct __res_state { int retrans; /*%< retransmission time interval */ int retry; /*%< number of times to retransmit */ /* * XXX: If `sun' is defined, `options' and `pfcode' are * defined as u_int in original BIND9 distribution. However, * it breaks binary backward compatibility against FreeBSD's * resolver. So, we changed not to see `sun'. */ #if defined(sun) && 0 u_int options; /*%< option flags - see below. */ #else u_long options; /*%< option flags - see below. */ #endif int nscount; /*%< number of name servers */ struct sockaddr_in nsaddr_list[MAXNS]; /*%< address of name server */ #define nsaddr nsaddr_list[0] /*%< for backward compatibility */ u_short id; /*%< current message id */ char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */ char defdname[256]; /*%< default domain (deprecated) */ #if defined(sun) && 0 u_int pfcode; /*%< RES_PRF_ flags - see below. */ #else u_long pfcode; /*%< RES_PRF_ flags - see below. */ #endif unsigned ndots:4; /*%< threshold for initial abs. query */ unsigned nsort:4; /*%< number of elements in sort_list[] */ char unused[3]; struct { struct in_addr addr; u_int32_t mask; } sort_list[MAXRESOLVSORT]; res_send_qhook qhook; /*%< query hook */ res_send_rhook rhook; /*%< response hook */ int res_h_errno; /*%< last one set for this context */ int _vcsock; /*%< PRIVATE: for res_send VC i/o */ u_int _flags; /*%< PRIVATE: see below */ u_int _pad; /*%< make _u 64 bit aligned */ union { /* On an 32-bit arch this means 512b total. */ char pad[72 - 4*sizeof (int) - 3*sizeof (void *)]; struct { u_int16_t nscount; u_int16_t nstimes[MAXNS]; /*%< ms. */ int nssocks[MAXNS]; struct __res_state_ext *ext; /*%< extension for IPv6 */ } _ext; } _u; u_char *_rnd; /*%< PRIVATE: random state */ }; typedef struct __res_state *res_state; union res_sockaddr_union { struct sockaddr_in sin; #ifdef IN6ADDR_ANY_INIT struct sockaddr_in6 sin6; #endif #ifdef ISC_ALIGN64 int64_t __align64; /*%< 64bit alignment */ #else int32_t __align32; /*%< 32bit alignment */ #endif char __space[128]; /*%< max size */ }; /*% * Resolver flags (used to be discrete per-module statics ints). */ #define RES_F_VC 0x00000001 /*%< socket is TCP */ #define RES_F_CONN 0x00000002 /*%< socket is connected */ #define RES_F_EDNS0ERR 0x00000004 /*%< EDNS0 caused errors */ #define RES_F__UNUSED 0x00000008 /*%< (unused) */ #define RES_F_LASTMASK 0x000000F0 /*%< ordinal server of last res_nsend */ #define RES_F_LASTSHIFT 4 /*%< bit position of LASTMASK "flag" */ #define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT) /* res_findzonecut2() options */ #define RES_EXHAUSTIVE 0x00000001 /*%< always do all queries */ #define RES_IPV4ONLY 0x00000002 /*%< IPv4 only */ #define RES_IPV6ONLY 0x00000004 /*%< IPv6 only */ /*% * Resolver options (keep these in synch with res_debug.c, please) */ #define RES_INIT 0x00000001 /*%< address initialized */ #define RES_DEBUG 0x00000002 /*%< print debug messages */ #define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/ #define RES_USEVC 0x00000008 /*%< use virtual circuit */ #define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */ #define RES_IGNTC 0x00000020 /*%< ignore truncation errors */ #define RES_RECURSE 0x00000040 /*%< recursion desired */ #define RES_DEFNAMES 0x00000080 /*%< use default domain name */ #define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */ #define RES_DNSRCH 0x00000200 /*%< search up local domain tree */ #define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */ #define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */ #define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */ #define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */ #define RES_ROTATE 0x00004000 /*%< rotate ns list after each query */ #define RES_NOCHECKNAME 0x00008000 /*%< do not check names for sanity. */ #define RES_KEEPTSIG 0x00010000 /*%< do not strip TSIG records */ #define RES_BLAST 0x00020000 /*%< blast all recursive servers */ #define RES_NSID 0x00040000 /*%< request name server ID */ #define RES_NOTLDQUERY 0x00100000 /*%< don't unqualified name as a tld */ #define RES_USE_DNSSEC 0x00200000 /*%< use DNSSEC using OK bit in OPT */ /* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */ /* KAME extensions: use higher bit to avoid conflict with ISC use */ #define RES_USE_DNAME 0x10000000 /*%< use DNAME */ #define RES_USE_EDNS0 0x40000000 /*%< use EDNS0 if configured */ #define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */ #define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \ RES_DNSRCH | RES_NO_NIBBLE2) /*% * Resolver "pfcode" values. Used by dig. */ #define RES_PRF_STATS 0x00000001 #define RES_PRF_UPDATE 0x00000002 #define RES_PRF_CLASS 0x00000004 #define RES_PRF_CMD 0x00000008 #define RES_PRF_QUES 0x00000010 #define RES_PRF_ANS 0x00000020 #define RES_PRF_AUTH 0x00000040 #define RES_PRF_ADD 0x00000080 #define RES_PRF_HEAD1 0x00000100 #define RES_PRF_HEAD2 0x00000200 #define RES_PRF_TTLID 0x00000400 #define RES_PRF_HEADX 0x00000800 #define RES_PRF_QUERY 0x00001000 #define RES_PRF_REPLY 0x00002000 #define RES_PRF_INIT 0x00004000 #define RES_PRF_TRUNC 0x00008000 /* 0x00010000 */ /* Things involving an internal (static) resolver context. */ __BEGIN_DECLS extern struct __res_state *__res_state(void); __END_DECLS #define _res (*__res_state()) #ifndef __BIND_NOSTATIC #define fp_nquery __fp_nquery #define fp_query __fp_query #define hostalias __hostalias #define p_query __p_query #define res_close __res_close #define res_init __res_init #define res_isourserver __res_isourserver #define res_mkquery __res_mkquery #define res_opt __res_opt #define res_query __res_query #define res_querydomain __res_querydomain #define res_search __res_search #define res_send __res_send #define res_sendsigned __res_sendsigned __BEGIN_DECLS void fp_nquery(const u_char *, int, FILE *); void fp_query(const u_char *, FILE *); const char * hostalias(const char *); void p_query(const u_char *); void res_close(void); int res_init(void); int res_isourserver(const struct sockaddr_in *); int res_mkquery(int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int); int res_opt(int, u_char *, int, int); int res_query(const char *, int, int, u_char *, int); int res_querydomain(const char *, const char *, int, int, u_char *, int); int res_search(const char *, int, int, u_char *, int); int res_send(const u_char *, int, u_char *, int); int res_sendsigned(const u_char *, int, ns_tsig_key *, u_char *, int); __END_DECLS #endif #if !defined(SHARED_LIBBIND) || defined(LIB) /* * If libbind is a shared object (well, DLL anyway) * these externs break the linker when resolv.h is * included by a lib client (like named) * Make them go away if a client is including this * */ extern const struct res_sym __p_key_syms[]; extern const struct res_sym __p_cert_syms[]; extern const struct res_sym __p_class_syms[]; extern const struct res_sym __p_type_syms[]; extern const struct res_sym __p_rcode_syms[]; #endif /* SHARED_LIBBIND */ #define b64_ntop __b64_ntop #define b64_pton __b64_pton #define dn_comp __dn_comp #define dn_count_labels __dn_count_labels #define dn_expand __dn_expand #define dn_skipname __dn_skipname #define fp_resstat __fp_resstat #define loc_aton __loc_aton #define loc_ntoa __loc_ntoa #define p_cdname __p_cdname #define p_cdnname __p_cdnname #define p_class __p_class #define p_fqname __p_fqname #define p_fqnname __p_fqnname #define p_option __p_option #define p_secstodate __p_secstodate #define p_section __p_section #define p_time __p_time #define p_type __p_type #define p_rcode __p_rcode #define p_sockun __p_sockun #define putlong __putlong #define putshort __putshort #define res_dnok __res_dnok #if 0 #define res_findzonecut __res_findzonecut #endif #define res_findzonecut2 __res_findzonecut2 #define res_hnok __res_hnok #define res_hostalias __res_hostalias #define res_mailok __res_mailok #define res_nameinquery __res_nameinquery #define res_nclose __res_nclose #define res_ninit __res_ninit #define res_nmkquery __res_nmkquery #define res_pquery __res_pquery #define res_nquery __res_nquery #define res_nquerydomain __res_nquerydomain #define res_nsearch __res_nsearch #define res_nsend __res_nsend #if 0 #define res_nsendsigned __res_nsendsigned #endif #define res_nisourserver __res_nisourserver #define res_ownok __res_ownok #define res_queriesmatch __res_queriesmatch #define res_rndinit __res_rndinit #define res_randomid __res_randomid #define res_nrandomid __res_nrandomid #define sym_ntop __sym_ntop #define sym_ntos __sym_ntos #define sym_ston __sym_ston #define res_nopt __res_nopt #define res_nopt_rdata __res_nopt_rdata #define res_ndestroy __res_ndestroy #define res_nametoclass __res_nametoclass #define res_nametotype __res_nametotype #define res_setservers __res_setservers #define res_getservers __res_getservers #if 0 #define res_buildprotolist __res_buildprotolist #define res_destroyprotolist __res_destroyprotolist #define res_destroyservicelist __res_destroyservicelist #define res_get_nibblesuffix __res_get_nibblesuffix #define res_get_nibblesuffix2 __res_get_nibblesuffix2 #endif #define res_ourserver_p __res_ourserver_p #if 0 #define res_protocolname __res_protocolname #define res_protocolnumber __res_protocolnumber #endif #define res_send_setqhook __res_send_setqhook #define res_send_setrhook __res_send_setrhook #if 0 #define res_servicename __res_servicename #define res_servicenumber __res_servicenumber #endif __BEGIN_DECLS int res_hnok(const char *); int res_ownok(const char *); int res_mailok(const char *); int res_dnok(const char *); int sym_ston(const struct res_sym *, const char *, int *); const char * sym_ntos(const struct res_sym *, int, int *); const char * sym_ntop(const struct res_sym *, int, int *); int b64_ntop(u_char const *, size_t, char *, size_t); int b64_pton(char const *, u_char *, size_t); int loc_aton(const char *, u_char *); const char * loc_ntoa(const u_char *, char *); int dn_skipname(const u_char *, const u_char *); void putlong(u_int32_t, u_char *); void putshort(u_int16_t, u_char *); #ifndef __ultrix__ u_int16_t _getshort(const u_char *); u_int32_t _getlong(const u_char *); #endif const char * p_class(int); const char * p_time(u_int32_t); const char * p_type(int); const char * p_rcode(int); const char * p_sockun(union res_sockaddr_union, char *, size_t); const u_char * p_cdnname(const u_char *, const u_char *, int, FILE *); const u_char * p_cdname(const u_char *, const u_char *, FILE *); const u_char * p_fqnname(const u_char *, const u_char *, int, char *, int); const u_char * p_fqname(const u_char *, const u_char *, FILE *); const char * p_option(u_long); char * p_secstodate(u_long); int dn_count_labels(const char *); int dn_comp(const char *, u_char *, int, u_char **, u_char **); int dn_expand(const u_char *, const u_char *, const u_char *, char *, int); void res_rndinit(res_state); u_int res_randomid(void); u_int res_nrandomid(res_state); int res_nameinquery(const char *, int, int, const u_char *, const u_char *); int res_queriesmatch(const u_char *, const u_char *, const u_char *, const u_char *); const char * p_section(int, int); /* Things involving a resolver context. */ int res_ninit(res_state); int res_nisourserver(const res_state, const struct sockaddr_in *); void fp_resstat(const res_state, FILE *); void res_pquery(const res_state, const u_char *, int, FILE *); const char * res_hostalias(const res_state, const char *, char *, size_t); int res_nquery(res_state, const char *, int, int, u_char *, int); int res_nsearch(res_state, const char *, int, int, u_char *, int); int res_nquerydomain(res_state, const char *, const char *, int, int, u_char *, int); int res_nmkquery(res_state, int, const char *, int, int, const u_char *, int, const u_char *, u_char *, int); int res_nsend(res_state, const u_char *, int, u_char *, int); #if 0 int res_nsendsigned(res_state, const u_char *, int, ns_tsig_key *, u_char *, int); int res_findzonecut(res_state, const char *, ns_class, int, char *, size_t, struct in_addr *, int); #endif int res_findzonecut2(res_state, const char *, ns_class, int, char *, size_t, union res_sockaddr_union *, int); void res_nclose(res_state); int res_nopt(res_state, int, u_char *, int, int); int res_nopt_rdata(res_state, int, u_char *, int, u_char *, u_short, u_short, u_char *); void res_send_setqhook(res_send_qhook); void res_send_setrhook(res_send_rhook); int __res_vinit(res_state, int); #if 0 void res_destroyservicelist(void); const char * res_servicename(u_int16_t, const char *); const char * res_protocolname(int); void res_destroyprotolist(void); void res_buildprotolist(void); const char * res_get_nibblesuffix(res_state); const char * res_get_nibblesuffix2(res_state); #endif void res_ndestroy(res_state); u_int16_t res_nametoclass(const char *, int *); u_int16_t res_nametotype(const char *, int *); void res_setservers(res_state, const union res_sockaddr_union *, int); int res_getservers(res_state, union res_sockaddr_union *, int); __END_DECLS #endif /* !_RESOLV_H_ */ /*! \file */ diff --git a/include/rpc/auth.h b/include/rpc/auth.h index 8773e7115d12..a894625ac405 100644 --- a/include/rpc/auth.h +++ b/include/rpc/auth.h @@ -1,371 +1,370 @@ /* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)auth.h 1.17 88/02/08 SMI * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC * from: @(#)auth.h 1.43 98/02/02 SMI - * $FreeBSD$ */ /* * auth.h, Authentication interface. * * Copyright (C) 1984, Sun Microsystems, Inc. * * The data structures are completely opaque to the client. The client * is required to pass an AUTH * to routines that create rpc * "sessions". */ #ifndef _RPC_AUTH_H #define _RPC_AUTH_H #include #include #include #include #define MAX_AUTH_BYTES 400 #define MAXNETNAMELEN 255 /* maximum length of network user's name */ /* * Client side authentication/security data */ typedef struct sec_data { u_int secmod; /* security mode number e.g. in nfssec.conf */ u_int rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ int flags; /* AUTH_F_xxx flags */ caddr_t data; /* opaque data per flavor */ } sec_data_t; #ifdef _SYSCALL32_IMPL struct sec_data32 { uint32_t secmod; /* security mode number e.g. in nfssec.conf */ uint32_t rpcflavor; /* rpc flavors:AUTH_UNIX,AUTH_DES,RPCSEC_GSS */ int32_t flags; /* AUTH_F_xxx flags */ caddr32_t data; /* opaque data per flavor */ }; #endif /* _SYSCALL32_IMPL */ /* * AUTH_DES flavor specific data from sec_data opaque data field. * AUTH_KERB has the same structure. */ typedef struct des_clnt_data { struct netbuf syncaddr; /* time sync addr */ struct knetconfig *knconf; /* knetconfig info that associated */ /* with the syncaddr. */ char *netname; /* server's netname */ int netnamelen; /* server's netname len */ } dh_k4_clntdata_t; #ifdef _SYSCALL32_IMPL struct des_clnt_data32 { struct netbuf32 syncaddr; /* time sync addr */ caddr32_t knconf; /* knetconfig info that associated */ /* with the syncaddr. */ caddr32_t netname; /* server's netname */ int32_t netnamelen; /* server's netname len */ }; #endif /* _SYSCALL32_IMPL */ #ifdef KERBEROS /* * flavor specific data to hold the data for AUTH_DES/AUTH_KERB(v4) * in sec_data->data opaque field. */ typedef struct krb4_svc_data { int window; /* window option value */ } krb4_svcdata_t; typedef struct krb4_svc_data des_svcdata_t; #endif /* KERBEROS */ /* * authentication/security specific flags */ #define AUTH_F_RPCTIMESYNC 0x001 /* use RPC to do time sync */ #define AUTH_F_TRYNONE 0x002 /* allow fall back to AUTH_NONE */ /* * 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 */ #ifdef KERBEROS /* * kerberos errors */ , AUTH_KERB_GENERIC = 8, /* kerberos generic error */ AUTH_TIMEEXPIRE = 9, /* time of credential expired */ AUTH_TKT_FILE = 10, /* something wrong with ticket file */ AUTH_DECODE = 11, /* can't decode authenticator */ AUTH_NET_ADDR = 12, /* wrong net address in ticket */ #endif /* KERBEROS */ /* * RPCSEC_GSS errors */ RPCSEC_GSS_CREDPROBLEM = 13, RPCSEC_GSS_CTXPROBLEM = 14, RPCSEC_GSS_NODISPATCH = 0x8000000 }; union des_block { struct { uint32_t high; uint32_t low; } key; char c[8]; }; typedef union des_block des_block; __BEGIN_DECLS extern bool_t xdr_des_block(XDR *, des_block *); __END_DECLS /* * Authentication info. Opaque to client. */ struct opaque_auth { enum_t oa_flavor; /* flavor of auth */ caddr_t oa_base; /* address of more auth stuff */ u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ }; /* * Auth handle, interface to client side authenticators. */ typedef struct __auth { struct opaque_auth ah_cred; struct opaque_auth ah_verf; union des_block ah_key; struct auth_ops { void (*ah_nextverf) (struct __auth *); /* nextverf & serialize */ int (*ah_marshal) (struct __auth *, XDR *); /* validate verifier */ int (*ah_validate) (struct __auth *, struct opaque_auth *); /* refresh credentials */ int (*ah_refresh) (struct __auth *, void *); /* destroy this structure */ void (*ah_destroy) (struct __auth *); } *ah_ops; void *ah_private; } AUTH; /* * Authentication ops. * The ops and the auth handle provide the interface to the authenticators. * * 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_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_REFRESH(auth, msg) \ ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define auth_refresh(auth, msg) \ ((*((auth)->ah_ops->ah_refresh))(auth, msg)) #define AUTH_DESTROY(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)) #define auth_destroy(auth) \ ((*((auth)->ah_ops->ah_destroy))(auth)) __BEGIN_DECLS extern struct opaque_auth _null_auth; __END_DECLS /* * These are the various implementations of client side authenticators. */ /* * System style authentication * AUTH *authunix_create(machname, uid, gid, len, aup_gids) * char *machname; * u_int uid; * u_int gid; * int len; * u_int *aup_gids; */ __BEGIN_DECLS extern AUTH *authunix_create(char *, u_int, u_int, int, u_int *); extern AUTH *authunix_create_default(void); /* takes no parameters */ extern AUTH *authnone_create(void); /* takes no parameters */ __END_DECLS /* * DES style authentication * AUTH *authsecdes_create(servername, window, timehost, ckey) * char *servername; - network name of server * u_int window; - time to live * const char *timehost; - optional hostname to sync with * des_block *ckey; - optional conversation key to use */ __BEGIN_DECLS extern AUTH *authdes_create (char *, u_int, struct sockaddr *, des_block *); extern AUTH *authdes_seccreate (const char *, const u_int, const char *, const des_block *); __END_DECLS __BEGIN_DECLS extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); __END_DECLS #define authsys_create(c,i1,i2,i3,ip) authunix_create((c),(i1),(i2),(i3),(ip)) #define authsys_create_default() authunix_create_default() /* * Netname manipulation routines. */ __BEGIN_DECLS extern int getnetname(char [MAXNETNAMELEN + 1]); extern int host2netname(char [MAXNETNAMELEN + 1], const char *, const char *); extern int user2netname(char [MAXNETNAMELEN + 1], const uid_t, const char *); extern int netname2user(char [MAXNETNAMELEN + 1], uid_t *, gid_t *, int *, gid_t *); extern int netname2host(char [MAXNETNAMELEN + 1], char *, const int); extern void passwd2des ( char *, char * ); __END_DECLS /* * * These routines interface to the keyserv daemon * */ __BEGIN_DECLS extern int key_decryptsession(const char *, des_block *); extern int key_encryptsession(const char *, des_block *); extern int key_gendes(des_block *); extern int key_setsecret(const char *); extern int key_secretkey_is_set(void); __END_DECLS /* * Publickey routines. */ __BEGIN_DECLS extern int getpublickey (const char *, char *); extern int getpublicandprivatekey (const char *, char *); extern int getsecretkey (char *, char *, char *); __END_DECLS #ifdef KERBEROS /* * Kerberos style authentication * AUTH *authkerb_seccreate(service, srv_inst, realm, window, timehost, status) * const char *service; - service name * const char *srv_inst; - server instance * const char *realm; - server realm * const u_int window; - time to live * const char *timehost; - optional hostname to sync with * int *status; - kerberos status returned */ __BEGIN_DECLS extern AUTH *authkerb_seccreate(const char *, const char *, const char *, const u_int, const char *, int *); __END_DECLS /* * Map a kerberos credential into a unix cred. * * authkerb_getucred(rqst, uid, gid, grouplen, groups) * const struct svc_req *rqst; - request pointer * uid_t *uid; * gid_t *gid; * short *grouplen; * int *groups; * */ __BEGIN_DECLS extern int authkerb_getucred(/* struct svc_req *, uid_t *, gid_t *, short *, int * */); __END_DECLS #endif /* KERBEROS */ __BEGIN_DECLS struct svc_req; struct rpc_msg; enum auth_stat _svcauth_null (struct svc_req *, struct rpc_msg *); enum auth_stat _svcauth_short (struct svc_req *, struct rpc_msg *); enum auth_stat _svcauth_unix (struct svc_req *, struct rpc_msg *); __END_DECLS #define AUTH_NONE 0 /* no authentication */ #define AUTH_NULL 0 /* backward compatibility */ #define AUTH_SYS 1 /* unix style (uid, gids) */ #define AUTH_UNIX AUTH_SYS #define AUTH_SHORT 2 /* short hand unix style */ #define AUTH_DH 3 /* for Diffie-Hellman mechanism */ #define AUTH_DES AUTH_DH /* for backward compatibility */ #define AUTH_KERB 4 /* kerberos style */ #define RPCSEC_GSS 6 /* RPCSEC_GSS */ /* * Pseudo auth flavors for RPCSEC_GSS. */ #define RPCSEC_GSS_KRB5 390003 #define RPCSEC_GSS_KRB5I 390004 #define RPCSEC_GSS_KRB5P 390005 #endif /* !_RPC_AUTH_H */ diff --git a/include/rpc/auth_unix.h b/include/rpc/auth_unix.h index 6d1fc315a18d..6d9d5e0f45e6 100644 --- a/include/rpc/auth_unix.h +++ b/include/rpc/auth_unix.h @@ -1,85 +1,84 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)auth_unix.h 1.8 88/02/08 SMI * from: @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * auth_unix.h, Protocol for UNIX style authentication parameters for RPC * * Copyright (C) 1984, Sun Microsystems, Inc. */ /* * The system is very weak. The client uses no encryption for it * credentials and only sends null verifiers. The server sends backs * null verifiers or optionally a verifier that suggests a new short hand * for the credentials. */ #ifndef _RPC_AUTH_UNIX_H #define _RPC_AUTH_UNIX_H #include /* The machine name is part of a credential; it may not exceed 255 bytes */ #define MAX_MACHINE_NAME 255 /* gids compose part of a credential; there may not be more than 16 of them */ #define NGRPS 16 /* * Unix style credentials. */ struct authunix_parms { u_long aup_time; char *aup_machname; u_int aup_uid; u_int aup_gid; u_int aup_len; u_int *aup_gids; }; #define authsys_parms authunix_parms __BEGIN_DECLS extern bool_t xdr_authunix_parms(XDR *, struct authunix_parms *); __END_DECLS /* * If a response verifier has flavor AUTH_SHORT, * then the body of the response verifier encapsulates the following structure; * again it is serialized in the obvious fashion. */ struct short_hand_verf { struct opaque_auth new_cred; }; #endif /* !_RPC_AUTH_UNIX_H */ diff --git a/include/rpc/clnt.h b/include/rpc/clnt.h index 8d9ce1eccb09..a7112d496f07 100644 --- a/include/rpc/clnt.h +++ b/include/rpc/clnt.h @@ -1,538 +1,537 @@ /* $NetBSD: clnt.h,v 1.14 2000/06/02 22:57:55 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2010, Oracle America, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of the "Oracle America, Inc." 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)clnt.h 1.31 94/04/29 SMI * from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * clnt.h - Client side remote procedure call interface. */ #ifndef _RPC_CLNT_H_ #define _RPC_CLNT_H_ #include #include #include #include /* * Well-known IPV6 RPC broadcast address. */ #define RPCB_MULTICAST_ADDR "ff02::202" /* * the following errors are in general unrecoverable. The caller * should give up rather than retry. */ #define IS_UNRECOVERABLE_RPC(s) (((s) == RPC_AUTHERROR) || \ ((s) == RPC_CANTENCODEARGS) || \ ((s) == RPC_CANTDECODERES) || \ ((s) == RPC_VERSMISMATCH) || \ ((s) == RPC_PROCUNAVAIL) || \ ((s) == RPC_PROGUNAVAIL) || \ ((s) == RPC_PROGVERSMISMATCH) || \ ((s) == RPC_CANTDECODEARGS)) /* * Error info. */ struct rpc_err { enum clnt_stat re_status; union { int RE_errno; /* related system error */ enum auth_stat RE_why; /* why the auth error occurred */ struct { rpcvers_t low; /* lowest version supported */ rpcvers_t high; /* highest version supported */ } RE_vers; struct { /* maybe meaningful if RPC_FAILED */ int32_t s1; int32_t s2; } 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 }; /* * Client rpc handle. * Created by individual implementations * Client is responsible for initializing auth, see e.g. auth_none.c. */ typedef struct __rpc_client { AUTH *cl_auth; /* authenticator */ struct clnt_ops { /* call remote procedure */ enum clnt_stat (*cl_call)(struct __rpc_client *, rpcproc_t, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* abort a call */ void (*cl_abort)(struct __rpc_client *); /* get specific error code */ void (*cl_geterr)(struct __rpc_client *, struct rpc_err *); /* frees results */ bool_t (*cl_freeres)(struct __rpc_client *, xdrproc_t, void *); /* destroy this structure */ void (*cl_destroy)(struct __rpc_client *); /* the ioctl() of rpc */ bool_t (*cl_control)(struct __rpc_client *, u_int, void *); } *cl_ops; void *cl_private; /* private stuff */ char *cl_netid; /* network token */ char *cl_tp; /* device name */ } CLIENT; /* * Timers used for the pseudo-transport protocol when using datagrams */ struct rpc_timers { u_short rt_srtt; /* smoothed round-trip time */ u_short rt_deviate; /* estimated deviation */ u_long rt_rtxcur; /* current (backed-off) rto */ }; /* * Feedback values used for possible congestion and rate control */ #define FEEDBACK_REXMIT1 1 /* first retransmit */ #define FEEDBACK_OK 2 /* no retransmits */ /* Used to set version of portmapper used in broadcast */ #define CLCR_SET_LOWVERS 3 #define CLCR_GET_LOWVERS 4 #define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ /* * client side rpc interface ops * * Parameter types are: * */ /* * enum clnt_stat * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) * CLIENT *rh; * rpcproc_t proc; * xdrproc_t xargs; * void *argsp; * xdrproc_t xres; * void *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)) /* * void * CLNT_ABORT(rh); * CLIENT *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; */ #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; * void *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 * CLNT_CONTROL(cl, request, info) * CLIENT *cl; * u_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)) /* * control operations that apply to both udp and tcp transports */ #define CLSET_TIMEOUT 1 /* set timeout (timeval) */ #define CLGET_TIMEOUT 2 /* get timeout (timeval) */ #define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ #define CLGET_FD 6 /* get connections file descriptor */ #define CLGET_SVC_ADDR 7 /* get server's address (netbuf) */ #define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ #define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy */ #define CLGET_XID 10 /* Get xid */ #define CLSET_XID 11 /* Set xid */ #define CLGET_VERS 12 /* Get version number */ #define CLSET_VERS 13 /* Set version number */ #define CLGET_PROG 14 /* Get program number */ #define CLSET_PROG 15 /* Set program number */ #define CLSET_SVC_ADDR 16 /* get server's address (netbuf) */ #define CLSET_PUSH_TIMOD 17 /* push timod if not already present */ #define CLSET_POP_TIMOD 18 /* pop timod */ /* * Connectionless only control operations */ #define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ #define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ #define CLSET_ASYNC 19 #define CLSET_CONNECT 20 /* Use connect() for UDP. (int) */ /* * void * CLNT_DESTROY(rh); * CLIENT *rh; */ #define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) #define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) /* * RPCTEST is a test program which is accessible on every rpc * transport/port. It is used for testing, performance evaluation, * and network administration. */ #define RPCTEST_PROGRAM ((rpcprog_t)1) #define RPCTEST_VERSION ((rpcvers_t)1) #define RPCTEST_NULL_PROC ((rpcproc_t)2) #define RPCTEST_NULL_BATCH_PROC ((rpcproc_t)3) /* * By convention, procedure 0 takes null arguments and returns them */ #define NULLPROC ((rpcproc_t)0) /* * Below are the client handle creation routines for the various * implementations of client side rpc. They can return NULL if a * creation failure occurs. */ /* * Generic client creation routine. Supported protocols are those that * belong to the nettype namespace (/etc/netconfig). */ __BEGIN_DECLS extern CLIENT *clnt_create(const char *, const rpcprog_t, const rpcvers_t, const char *); /* * * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const char *nettype; -- network type */ /* * Generic client creation routine. Just like clnt_create(), except * it takes an additional timeout parameter. */ extern CLIENT * clnt_create_timed(const char *, const rpcprog_t, const rpcvers_t, const char *, const struct timeval *); /* * * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const char *nettype; -- network type * const struct timeval *tp; -- timeout */ /* * Generic client creation routine. Supported protocols are which belong * to the nettype name space. */ extern CLIENT *clnt_create_vers(const char *, const rpcprog_t, rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *); /* * const char *host; -- hostname * const rpcprog_t prog; -- program number * rpcvers_t *vers_out; -- servers highest available version * const rpcvers_t vers_low; -- low version number * const rpcvers_t vers_high; -- high version number * const char *nettype; -- network type */ /* * Generic client creation routine. Supported protocols are which belong * to the nettype name space. */ extern CLIENT * clnt_create_vers_timed(const char *, const rpcprog_t, rpcvers_t *, const rpcvers_t, const rpcvers_t, const char *, const struct timeval *); /* * const char *host; -- hostname * const rpcprog_t prog; -- program number * rpcvers_t *vers_out; -- servers highest available version * const rpcvers_t vers_low; -- low version number * const rpcvers_t vers_high; -- high version number * const char *nettype; -- network type * const struct timeval *tp -- timeout */ /* * Generic client creation routine. It takes a netconfig structure * instead of nettype */ extern CLIENT *clnt_tp_create(const char *, const rpcprog_t, const rpcvers_t, const struct netconfig *); /* * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const struct netconfig *netconf; -- network config structure */ /* * Generic client creation routine. Just like clnt_tp_create(), except * it takes an additional timeout parameter. */ extern CLIENT * clnt_tp_create_timed(const char *, const rpcprog_t, const rpcvers_t, const struct netconfig *, const struct timeval *); /* * const char *hostname; -- hostname * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const struct netconfig *netconf; -- network config structure * const struct timeval *tp -- timeout */ /* * Generic TLI create routine. Only provided for compatibility. */ extern CLIENT *clnt_tli_create(const int, const struct netconfig *, struct netbuf *, const rpcprog_t, const rpcvers_t, const u_int, const u_int); /* * const register int fd; -- fd * const struct netconfig *nconf; -- netconfig structure * struct netbuf *svcaddr; -- servers address * const u_long prog; -- program number * const u_long vers; -- version number * const u_int sendsz; -- send size * const u_int recvsz; -- recv size */ /* * Low level clnt create routine for connectionful transports, e.g. tcp. */ extern CLIENT *clnt_vc_create(const int, const struct netbuf *, const rpcprog_t, const rpcvers_t, u_int, u_int); /* * Added for compatibility to old rpc 4.0. Obsoleted by clnt_vc_create(). */ extern CLIENT *clntunix_create(struct sockaddr_un *, u_long, u_long, int *, u_int, u_int); /* * const int fd; -- open file descriptor * const struct netbuf *svcaddr; -- servers address * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const u_int sendsz; -- buffer recv size * const u_int recvsz; -- buffer send size */ /* * Low level clnt create routine for connectionless transports, e.g. udp. */ extern CLIENT *clnt_dg_create(const int, const struct netbuf *, const rpcprog_t, const rpcvers_t, const u_int, const u_int); /* * const int fd; -- open file descriptor * const struct netbuf *svcaddr; -- servers address * const rpcprog_t program; -- program number * const rpcvers_t version; -- version number * const u_int sendsz; -- buffer recv size * const u_int recvsz; -- buffer send size */ /* * Memory based rpc (for speed check and testing) * CLIENT * * clnt_raw_create(prog, vers) * u_long prog; * u_long vers; */ extern CLIENT *clnt_raw_create(rpcprog_t, rpcvers_t); __END_DECLS /* * Print why creation failed */ __BEGIN_DECLS extern void clnt_pcreateerror(const char *); /* stderr */ extern char *clnt_spcreateerror(const char *); /* string */ __END_DECLS /* * Like clnt_perror(), but is more verbose in its output */ __BEGIN_DECLS extern void clnt_perrno(enum clnt_stat); /* stderr */ extern char *clnt_sperrno(enum clnt_stat); /* string */ __END_DECLS /* * Print an English error message, given the client error code */ __BEGIN_DECLS extern void clnt_perror(CLIENT *, const char *); /* stderr */ extern char *clnt_sperror(CLIENT *, const char *); /* string */ __END_DECLS /* * If a creation fails, the following allows the user to figure out why. */ struct rpc_createerr { enum clnt_stat cf_stat; struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ }; __BEGIN_DECLS extern struct rpc_createerr *__rpc_createerr(void); __END_DECLS #define rpc_createerr (*(__rpc_createerr())) /* * The simplified interface: * enum clnt_stat * rpc_call(host, prognum, versnum, procnum, inproc, in, outproc, out, nettype) * const char *host; * const rpcprog_t prognum; * const rpcvers_t versnum; * const rpcproc_t procnum; * const xdrproc_t inproc, outproc; * const char *in; * char *out; * const char *nettype; */ __BEGIN_DECLS extern enum clnt_stat rpc_call(const char *, const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, const char *, const xdrproc_t, char *, const char *); __END_DECLS /* * RPC broadcast interface * The call is broadcasted to all locally connected nets. * * extern enum clnt_stat * rpc_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, * eachresult, nettype) * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const rpcproc_t proc; -- procedure number * const xdrproc_t xargs; -- xdr routine for args * caddr_t argsp; -- pointer to args * const xdrproc_t xresults; -- xdr routine for results * caddr_t resultsp; -- pointer to results * const resultproc_t eachresult; -- call with each result * const char *nettype; -- Transport type * * For each valid response received, the procedure eachresult is called. * Its form is: * done = eachresult(resp, raddr, nconf) * bool_t done; * caddr_t resp; * struct netbuf *raddr; * struct netconfig *nconf; * where resp points to the results of the call and raddr is the * address if the responder to the broadcast. nconf is the transport * on which the response was received. * * extern enum clnt_stat * rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, * eachresult, inittime, waittime, nettype) * const rpcprog_t prog; -- program number * const rpcvers_t vers; -- version number * const rpcproc_t proc; -- procedure number * const xdrproc_t xargs; -- xdr routine for args * caddr_t argsp; -- pointer to args * const xdrproc_t xresults; -- xdr routine for results * caddr_t resultsp; -- pointer to results * const resultproc_t eachresult; -- call with each result * const int inittime; -- how long to wait initially * const int waittime; -- maximum time to wait * const char *nettype; -- Transport type */ typedef bool_t (*resultproc_t)(caddr_t, ...); __BEGIN_DECLS extern enum clnt_stat rpc_broadcast(const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, const resultproc_t, const char *); extern enum clnt_stat rpc_broadcast_exp(const rpcprog_t, const rpcvers_t, const rpcproc_t, const xdrproc_t, caddr_t, const xdrproc_t, caddr_t, const resultproc_t, const int, const int, const char *); __END_DECLS /* For backward compatibility */ #include #endif /* !_RPC_CLNT_H_ */ diff --git a/include/rpc/des_crypt.h b/include/rpc/des_crypt.h index ef938c5cc900..0dcd897495d4 100644 --- a/include/rpc/des_crypt.h +++ b/include/rpc/des_crypt.h @@ -1,107 +1,106 @@ /* * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI - * $FreeBSD$ * * des_crypt.h, des library routine interface * Copyright (C) 1986, Sun Microsystems, Inc. */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* * des_crypt.h, des library routine interface */ #ifndef _DES_DES_CRYPT_H #define _DES_DES_CRYPT_H #include #include #define DES_MAXDATA 8192 /* max bytes encrypted in one call */ #define DES_DIRMASK (1 << 0) #define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ #define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ #define DES_DEVMASK (1 << 1) #define DES_HW (0*DES_DEVMASK) /* Use hardware device */ #define DES_SW (1*DES_DEVMASK) /* Use software device */ #define DESERR_NONE 0 /* succeeded */ #define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ #define DESERR_HWERROR 2 /* failed, hardware/driver error */ #define DESERR_BADPARAM 3 /* failed, bad parameter to call */ #define DES_FAILED(err) \ ((err) > DESERR_NOHWDEVICE) /* * cbc_crypt() * ecb_crypt() * * Encrypt (or decrypt) len bytes of a buffer buf. * The length must be a multiple of eight. * The key should have odd parity in the low bit of each byte. * ivec is the input vector, and is updated to the new one (cbc only). * The mode is created by oring together the appropriate parameters. * DESERR_NOHWDEVICE is returned if DES_HW was specified but * there was no hardware to do it on (the data will still be * encrypted though, in software). */ /* * Cipher Block Chaining mode */ __BEGIN_DECLS int cbc_crypt( char *, char *, unsigned int, unsigned int, char *); __END_DECLS /* * Electronic Code Book mode */ __BEGIN_DECLS int ecb_crypt( char *, char *, unsigned int, unsigned int ); __END_DECLS /* * Set des parity for a key. * DES parity is odd and in the low bit of each byte */ __BEGIN_DECLS void des_setparity( char *); __END_DECLS #endif /* _DES_DES_CRYPT_H */ diff --git a/include/rpc/pmap_clnt.h b/include/rpc/pmap_clnt.h index 465cb0c02623..363c283e6764 100644 --- a/include/rpc/pmap_clnt.h +++ b/include/rpc/pmap_clnt.h @@ -1,87 +1,86 @@ /* $NetBSD: pmap_clnt.h,v 1.9 2000/06/02 22:57:55 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI * from: @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * pmap_clnt.h * Supplies C routines to get to portmap services. * * Copyright (C) 1984, Sun Microsystems, Inc. */ /* * Usage: * success = pmap_set(program, version, protocol, port); * success = pmap_unset(program, version); * port = pmap_getport(address, program, version, protocol); * head = pmap_getmaps(address); * clnt_stat = pmap_rmtcall(address, program, version, procedure, * xdrargs, argsp, xdrres, resp, tout, port_ptr) * (works for udp only.) * clnt_stat = clnt_broadcast(program, version, procedure, * xdrargs, argsp, xdrres, resp, eachresult) * (like pmap_rmtcall, except the call is broadcasted to all * locally connected nets. For each valid response received, * the procedure eachresult is called. Its form is: * done = eachresult(resp, raddr) * bool_t done; * caddr_t resp; * struct sockaddr_in raddr; * where resp points to the results of the call and raddr is the * address if the responder to the broadcast. */ #ifndef _RPC_PMAP_CLNT_H_ #define _RPC_PMAP_CLNT_H_ #include __BEGIN_DECLS extern bool_t pmap_set(u_long, u_long, int, int); extern bool_t pmap_unset(u_long, u_long); extern struct pmaplist *pmap_getmaps(struct sockaddr_in *); extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, u_long, u_long, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, struct timeval, u_long *); extern enum clnt_stat clnt_broadcast(u_long, u_long, u_long, xdrproc_t, void *, xdrproc_t, void *, resultproc_t); extern u_short pmap_getport(struct sockaddr_in *, u_long, u_long, u_int); __END_DECLS #endif /* !_RPC_PMAP_CLNT_H_ */ diff --git a/include/rpc/pmap_prot.h b/include/rpc/pmap_prot.h index f69bad9ca1a7..a14518802813 100644 --- a/include/rpc/pmap_prot.h +++ b/include/rpc/pmap_prot.h @@ -1,108 +1,107 @@ /* $NetBSD: pmap_prot.h,v 1.8 2000/06/02 22:57:55 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)pmap_prot.h 1.14 88/02/08 SMI * from: @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * pmap_prot.h * Protocol for the local binder service, or pmap. * * Copyright (C) 1984, Sun Microsystems, Inc. * * The following procedures are supported by the protocol: * * PMAPPROC_NULL() returns () * takes nothing, returns nothing * * PMAPPROC_SET(struct pmap) returns (bool_t) * 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. * * 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! * * PMAPPROC_DUMP() RETURNS (struct pmaplist *) * * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, 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. * * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ #ifndef _RPC_PMAP_PROT_H #define _RPC_PMAP_PROT_H #include #define PMAPPORT ((u_short)111) #define PMAPPROG ((u_long)100000) #define PMAPVERS ((u_long)2) #define PMAPVERS_PROTO ((u_long)2) #define PMAPVERS_ORIG ((u_long)1) #define PMAPPROC_NULL ((u_long)0) #define PMAPPROC_SET ((u_long)1) #define PMAPPROC_UNSET ((u_long)2) #define PMAPPROC_GETPORT ((u_long)3) #define PMAPPROC_DUMP ((u_long)4) #define PMAPPROC_CALLIT ((u_long)5) struct pmap { long unsigned pm_prog; long unsigned pm_vers; long unsigned pm_prot; long unsigned pm_port; }; struct pmaplist { struct pmap pml_map; struct pmaplist *pml_next; }; __BEGIN_DECLS extern bool_t xdr_pmap(XDR *, struct pmap *); extern bool_t xdr_pmaplist(XDR *, struct pmaplist **); extern bool_t xdr_pmaplist_ptr(XDR *, struct pmaplist *); __END_DECLS #endif /* !_RPC_PMAP_PROT_H */ diff --git a/include/rpc/pmap_rmt.h b/include/rpc/pmap_rmt.h index 791b3f486bc2..9a9042a71493 100644 --- a/include/rpc/pmap_rmt.h +++ b/include/rpc/pmap_rmt.h @@ -1,66 +1,65 @@ /* $NetBSD: pmap_rmt.h,v 1.7 1998/02/11 23:01:23 lukem Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI * from: @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * Structures and XDR routines for parameters to and replies from * the portmapper remote-call-service. * * Copyright (C) 1986, Sun Microsystems, Inc. */ #ifndef _RPC_PMAP_RMT_H #define _RPC_PMAP_RMT_H #include struct rmtcallargs { u_long prog, vers, proc, arglen; caddr_t args_ptr; xdrproc_t xdr_args; }; struct rmtcallres { u_long *port_ptr; u_long resultslen; caddr_t results_ptr; xdrproc_t xdr_results; }; __BEGIN_DECLS extern bool_t xdr_rmtcall_args(XDR *, struct rmtcallargs *); extern bool_t xdr_rmtcallres(XDR *, struct rmtcallres *); __END_DECLS #endif /* !_RPC_PMAP_RMT_H */ diff --git a/include/rpc/rpc.h b/include/rpc/rpc.h index 561437c30943..783c84280ae2 100644 --- a/include/rpc/rpc.h +++ b/include/rpc/rpc.h @@ -1,109 +1,108 @@ /* $NetBSD: rpc.h,v 1.13 2000/06/02 22:57:56 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)rpc.h 1.9 88/02/08 SMI * from: @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC - * $FreeBSD$ */ /* * rpc.h, Just includes the billions of rpc header files necessary to * do remote procedure calling. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _RPC_RPC_H #define _RPC_RPC_H #include /* some typedefs */ #include #include /* external data representation interfaces */ #include /* generic (de)serializer */ /* Client side only authentication */ #include /* generic authenticator (client side) */ /* Client side (mostly) remote procedure call */ #include /* generic rpc stuff */ /* semi-private protocol headers */ #include /* protocol for rpc messages */ #include /* protocol for unix style cred */ /* * Uncomment-out the next line if you are building the rpc library with * DES Authentication (see the README file in the secure_rpc/ directory). */ #include /* protocol for des style cred */ /* Server side only remote procedure callee */ #include /* service manager and multiplexer */ #include /* service side authenticator */ /* Portmapper client, server, and protocol headers */ #include #include #ifndef _KERNEL #include /* rpcbind interface functions */ #endif #include __BEGIN_DECLS extern int get_myaddress(struct sockaddr_in *); extern int bindresvport(int, struct sockaddr_in *); extern int registerrpc(int, int, int, char *(*)(char [UDPMSGSIZE]), xdrproc_t, xdrproc_t); extern int callrpc(const char *, int, int, int, xdrproc_t, void *, xdrproc_t , void *); extern int getrpcport(char *, int, int, int); char *taddr2uaddr(const struct netconfig *, const struct netbuf *); struct netbuf *uaddr2taddr(const struct netconfig *, const char *); struct sockaddr; extern int bindresvport_sa(int, struct sockaddr *); __END_DECLS /* * The following are not exported interfaces, they are for internal library * and rpcbind use only. Do not use, they may change without notice. */ __BEGIN_DECLS int __rpc_nconf2fd(const struct netconfig *); int __rpc_nconf2sockinfo(const struct netconfig *, struct __rpc_sockinfo *); int __rpc_fd2sockinfo(int, struct __rpc_sockinfo *); u_int __rpc_get_t_size(int, int, int); __END_DECLS #endif /* !_RPC_RPC_H */ diff --git a/include/rpc/rpc_msg.h b/include/rpc/rpc_msg.h index a384c92606c9..f1bd4935f3c3 100644 --- a/include/rpc/rpc_msg.h +++ b/include/rpc/rpc_msg.h @@ -1,215 +1,214 @@ /* $NetBSD: rpc_msg.h,v 1.11 2000/06/02 22:57:56 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)rpc_msg.h 1.7 86/07/16 SMI * from: @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * rpc_msg.h * rpc message definition * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _RPC_RPC_MSG_H #define _RPC_RPC_MSG_H #define RPC_MSG_VERSION ((u_int32_t) 2) #define RPC_SERVICE_PORT ((u_short) 2048) /* * Bottom up definition of an rpc message. * NOTE: call and reply use the same overall struct but * different parts of unions within it. */ enum msg_type { CALL=0, REPLY=1 }; enum reply_stat { 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 }; enum reject_stat { RPC_MISMATCH=0, AUTH_ERROR=1 }; /* * Reply part of an rpc exchange */ /* * Reply to an rpc request that was accepted by the server. * Note: there could be an error even though the request was * accepted. */ struct accepted_reply { struct opaque_auth ar_verf; enum accept_stat ar_stat; union { struct { rpcvers_t low; rpcvers_t high; } AR_versions; struct { caddr_t 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 { enum reject_stat rj_stat; union { struct { rpcvers_t low; rpcvers_t high; } RJ_versions; enum auth_stat 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 { enum reply_stat 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 { rpcvers_t cb_rpcvers; /* must be equal to two */ rpcprog_t cb_prog; rpcvers_t cb_vers; rpcproc_t cb_proc; struct opaque_auth cb_cred; struct opaque_auth cb_verf; /* protocol specific - provided by client */ }; /* * The rpc message */ struct rpc_msg { u_int32_t rm_xid; enum msg_type 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 __BEGIN_DECLS /* * XDR routine to handle a rpc message. * xdr_callmsg(xdrs, cmsg) * XDR *xdrs; * struct rpc_msg *cmsg; */ extern bool_t xdr_callmsg(XDR *, struct rpc_msg *); /* * XDR routine to pre-serialize the static part of a rpc message. * xdr_callhdr(xdrs, cmsg) * XDR *xdrs; * struct rpc_msg *cmsg; */ extern bool_t xdr_callhdr(XDR *, struct rpc_msg *); /* * XDR routine to handle a rpc reply. * xdr_replymsg(xdrs, rmsg) * XDR *xdrs; * struct rpc_msg *rmsg; */ extern bool_t xdr_replymsg(XDR *, struct rpc_msg *); /* * XDR routine to handle an accepted rpc reply. * xdr_accepted_reply(xdrs, rej) * XDR *xdrs; * struct accepted_reply *rej; */ extern bool_t xdr_accepted_reply(XDR *, struct accepted_reply *); /* * XDR routine to handle a rejected rpc reply. * xdr_rejected_reply(xdrs, rej) * XDR *xdrs; * struct rejected_reply *rej; */ extern bool_t xdr_rejected_reply(XDR *, struct rejected_reply *); /* * Fills in the error part of a reply message. * _seterr_reply(msg, error) * struct rpc_msg *msg; * struct rpc_err *error; */ extern void _seterr_reply(struct rpc_msg *, struct rpc_err *); __END_DECLS #endif /* !_RPC_RPC_MSG_H */ diff --git a/include/rpc/svc.h b/include/rpc/svc.h index 4cffd4070817..cb4b70a64ce7 100644 --- a/include/rpc/svc.h +++ b/include/rpc/svc.h @@ -1,480 +1,479 @@ /* $NetBSD: svc.h,v 1.17 2000/06/02 22:57:56 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)svc.h 1.35 88/12/17 SMI * from: @(#)svc.h 1.27 94/04/25 SMI - * $FreeBSD$ */ /* * svc.h, Server-side remote procedure call interface. * * Copyright (C) 1986-1993 by Sun Microsystems, Inc. */ #ifndef _RPC_SVC_H #define _RPC_SVC_H #include /* * This interface must manage two items concerning remote procedure calling: * * 1) An arbitrary number of transport connections upon which rpc requests * are received. The two most notable transports are TCP and UDP; they are * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; * they in turn call xprt_register and xprt_unregister. * * 2) An arbitrary number of locally registered services. Services are * described by the following four data: program number, version number, * "service dispatch" function, a transport handle, and a boolean that * indicates whether or not the exported program should be registered with a * local binder service; if true the program's number and version and the * port number from the transport handle are registered with the binder. * These data are registered with the rpc svc system via svc_register. * * A service's dispatch function is called whenever an rpc request comes in * on a transport. The request's program and version numbers must match * those of the registered service. The dispatch function is passed two * parameters, struct svc_req * and SVCXPRT *, defined below. */ /* * Service control requests */ #define SVCGET_VERSQUIET 1 #define SVCSET_VERSQUIET 2 #define SVCGET_CONNMAXREC 3 #define SVCSET_CONNMAXREC 4 /* * Operations for rpc_control(). */ #define RPC_SVC_CONNMAXREC_SET 0 /* set max rec size, enable nonblock */ #define RPC_SVC_CONNMAXREC_GET 1 enum xprt_stat { XPRT_DIED, XPRT_MOREREQS, XPRT_IDLE }; /* * Server side transport handle */ typedef struct __rpc_svcxprt { int xp_fd; #define xp_sock xp_fd u_short xp_port; /* associated port number */ const struct xp_ops { /* receive incoming requests */ bool_t (*xp_recv)(struct __rpc_svcxprt *, struct rpc_msg *); /* get transport status */ enum xprt_stat (*xp_stat)(struct __rpc_svcxprt *); /* get arguments */ bool_t (*xp_getargs)(struct __rpc_svcxprt *, xdrproc_t, void *); /* send reply */ bool_t (*xp_reply)(struct __rpc_svcxprt *, struct rpc_msg *); /* free mem allocated for args */ bool_t (*xp_freeargs)(struct __rpc_svcxprt *, xdrproc_t, void *); /* destroy this struct */ void (*xp_destroy)(struct __rpc_svcxprt *); } *xp_ops; int xp_addrlen; /* length of remote address */ struct sockaddr_in xp_raddr; /* remote addr. (backward ABI compat) */ /* XXX - fvdl stick this here for ABI backward compat reasons */ const struct xp_ops2 { /* catch-all function */ bool_t (*xp_control)(struct __rpc_svcxprt *, const u_int, void *); } *xp_ops2; char *xp_tp; /* transport provider device name */ char *xp_netid; /* network token */ struct netbuf xp_ltaddr; /* local transport address */ struct netbuf xp_rtaddr; /* remote transport address */ struct opaque_auth xp_verf; /* raw response verifier */ void *xp_p1; /* private: for use by svc ops */ void *xp_p2; /* private: for use by svc ops */ void *xp_p3; /* private: for use by svc lib */ int xp_type; /* transport type */ } SVCXPRT; /* * Interface to server-side authentication flavors. */ typedef struct __rpc_svcauth { struct svc_auth_ops { int (*svc_ah_wrap)(struct __rpc_svcauth *, XDR *, xdrproc_t, caddr_t); int (*svc_ah_unwrap)(struct __rpc_svcauth *, XDR *, xdrproc_t, caddr_t); } *svc_ah_ops; void *svc_ah_private; } SVCAUTH; /* * Server transport extensions (accessed via xp_p3). */ typedef struct __rpc_svcxprt_ext { int xp_flags; /* versquiet */ SVCAUTH xp_auth; /* interface to auth methods */ } SVCXPRT_EXT; /* * Service request */ struct svc_req { u_int32_t rq_prog; /* service program number */ u_int32_t rq_vers; /* service protocol version */ u_int32_t rq_proc; /* the desired procedure */ struct opaque_auth rq_cred; /* raw creds from the wire */ void *rq_clntcred; /* read only cooked cred */ SVCXPRT *rq_xprt; /* associated transport */ }; /* * Approved way of getting address of caller */ #define svc_getrpccaller(x) (&(x)->xp_rtaddr) /* * Approved way of getting address of callee */ #define svc_getrpccallee(x) (&(x)->xp_ltaddr) /* * Operations defined on an SVCXPRT handle * * SVCXPRT *xprt; * struct rpc_msg *msg; * xdrproc_t xargs; * void * argsp; */ #define SVC_RECV(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define svc_recv(xprt, msg) \ (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) #define SVC_STAT(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define svc_stat(xprt) \ (*(xprt)->xp_ops->xp_stat)(xprt) #define SVC_GETARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define svc_getargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) #define SVC_REPLY(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define svc_reply(xprt, msg) \ (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) #define SVC_FREEARGS(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define svc_freeargs(xprt, xargs, argsp) \ (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) #define SVC_DESTROY(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define svc_destroy(xprt) \ (*(xprt)->xp_ops->xp_destroy)(xprt) #define SVC_CONTROL(xprt, rq, in) \ (*(xprt)->xp_ops2->xp_control)((xprt), (rq), (in)) #define SVC_EXT(xprt) \ ((SVCXPRT_EXT *) xprt->xp_p3) #define SVC_AUTH(xprt) \ (SVC_EXT(xprt)->xp_auth) /* * Operations defined on an SVCAUTH handle */ #define SVCAUTH_WRAP(auth, xdrs, xfunc, xwhere) \ ((auth)->svc_ah_ops->svc_ah_wrap(auth, xdrs, xfunc, xwhere)) #define SVCAUTH_UNWRAP(auth, xdrs, xfunc, xwhere) \ ((auth)->svc_ah_ops->svc_ah_unwrap(auth, xdrs, xfunc, xwhere)) /* * Service registration * * svc_reg(xprt, prog, vers, dispatch, nconf) * const SVCXPRT *xprt; * const rpcprog_t prog; * const rpcvers_t vers; * const void (*dispatch)(struct svc_req *, SVCXPRT *); * const struct netconfig *nconf; */ __BEGIN_DECLS extern bool_t svc_reg(SVCXPRT *, const rpcprog_t, const rpcvers_t, void (*)(struct svc_req *, SVCXPRT *), const struct netconfig *); __END_DECLS /* * Service un-registration * * svc_unreg(prog, vers) * const rpcprog_t prog; * const rpcvers_t vers; */ __BEGIN_DECLS extern void svc_unreg(const rpcprog_t, const rpcvers_t); __END_DECLS /* * Transport registration. * * xprt_register(xprt) * SVCXPRT *xprt; */ __BEGIN_DECLS extern void xprt_register(SVCXPRT *); __END_DECLS /* * Transport un-register * * xprt_unregister(xprt) * SVCXPRT *xprt; */ __BEGIN_DECLS extern void xprt_unregister(SVCXPRT *); __END_DECLS /* * When the service routine is called, it must first check to see if it * knows about the procedure; if not, it should call svcerr_noproc * and return. If so, it should deserialize its arguments via * SVC_GETARGS (defined above). If the deserialization does not work, * svcerr_decode should be called followed by a return. Successful * decoding of the arguments should be followed the execution of the * procedure's code and a call to svc_sendreply. * * Also, if the service refuses to execute the procedure due to too- * weak authentication parameters, svcerr_weakauth should be called. * Note: do not confuse access-control failure with weak authentication! * * NB: In pure implementations of rpc, the caller always waits for a reply * msg. This message is sent when svc_sendreply is called. * Therefore pure service implementations should always call * svc_sendreply even if the function logically returns void; use * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows * for the abuse of pure rpc via batched calling or pipelining. In the * case of a batched call, svc_sendreply should NOT be called since * this would send a return message, which is what batching tries to avoid. * It is the service/protocol writer's responsibility to know which calls are * batched and which are not. Warning: responding to batch calls may * deadlock the caller and server processes! */ __BEGIN_DECLS extern bool_t svc_sendreply(SVCXPRT *, xdrproc_t, void *); extern void svcerr_decode(SVCXPRT *); extern void svcerr_weakauth(SVCXPRT *); extern void svcerr_noproc(SVCXPRT *); extern void svcerr_progvers(SVCXPRT *, rpcvers_t, rpcvers_t); extern void svcerr_auth(SVCXPRT *, enum auth_stat); extern void svcerr_noprog(SVCXPRT *); extern void svcerr_systemerr(SVCXPRT *); extern int rpc_reg(rpcprog_t, rpcvers_t, rpcproc_t, char *(*)(char *), xdrproc_t, xdrproc_t, char *); __END_DECLS /* * Lowest level dispatching -OR- who owns this process anyway. * Somebody has to wait for incoming requests and then call the correct * service routine. The routine svc_run does infinite waiting; i.e., * svc_run never returns. * Since another (co-existent) package may wish to selectively wait for * incoming calls or other events outside of the rpc architecture, the * routine svc_getreq is provided. It must be passed readfds, the * "in-place" results of a select system call (see select, section 2). */ /* * Global keeper of rpc service descriptors in use * dynamic; must be inspected before each call to select */ extern int svc_maxfd; #ifdef FD_SETSIZE extern fd_set svc_fdset; #define svc_fds svc_fdset.fds_bits[0] /* compatibility */ #else extern int svc_fds; #endif /* def FD_SETSIZE */ /* * A set of null auth methods used by any authentication protocols * that don't need to inspect or modify the message body. */ extern SVCAUTH _svc_auth_null; /* * a small program implemented by the svc_rpc implementation itself; * also see clnt.h for protocol numbers. */ __BEGIN_DECLS extern void rpctest_service(void); __END_DECLS __BEGIN_DECLS extern SVCXPRT *svc_xprt_alloc(void); extern void svc_xprt_free(SVCXPRT *); extern void svc_getreq(int); extern void svc_getreqset(fd_set *); extern void svc_getreq_common(int); struct pollfd; extern void svc_getreq_poll(struct pollfd *, int); extern void svc_run(void); extern void svc_exit(void); __END_DECLS /* * Socket to use on svcxxx_create call to get default socket */ #define RPC_ANYSOCK -1 #define RPC_ANYFD RPC_ANYSOCK /* * These are the existing service side transport implementations */ __BEGIN_DECLS /* * Transport independent svc_create routine. */ extern int svc_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const char *); /* * void (*dispatch)(struct svc_req *, SVCXPRT *); * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const char *nettype; -- network type */ /* * Generic server creation routine. It takes a netconfig structure * instead of a nettype. */ extern SVCXPRT *svc_tp_create(void (*)(struct svc_req *, SVCXPRT *), const rpcprog_t, const rpcvers_t, const struct netconfig *); /* * void (*dispatch)(struct svc_req *, SVCXPRT *); * const rpcprog_t prognum; -- program number * const rpcvers_t versnum; -- version number * const struct netconfig *nconf; -- netconfig structure */ /* * Generic TLI create routine */ extern SVCXPRT *svc_tli_create(const int, const struct netconfig *, const struct t_bind *, const u_int, const u_int); /* * const int fd; -- connection end point * const struct netconfig *nconf; -- netconfig structure for network * const struct t_bind *bindaddr; -- local bind address * const u_int sendsz; -- max sendsize * const u_int recvsz; -- max recvsize */ /* * Connectionless and connectionful create routines */ extern SVCXPRT *svc_vc_create(const int, const u_int, const u_int); /* * const int fd; -- open connection end point * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * Added for compatibility to old rpc 4.0. Obsoleted by svc_vc_create(). */ extern SVCXPRT *svcunix_create(int, u_int, u_int, char *); extern SVCXPRT *svc_dg_create(const int, const u_int, const u_int); /* * const int fd; -- open connection * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * the routine takes any *open* connection * descriptor as its first input and is used for open connections. */ extern SVCXPRT *svc_fd_create(const int, const u_int, const u_int); /* * const int fd; -- open connection end point * const u_int sendsize; -- max send size * const u_int recvsize; -- max recv size */ /* * Added for compatibility to old rpc 4.0. Obsoleted by svc_fd_create(). */ extern SVCXPRT *svcunixfd_create(int, u_int, u_int); /* * Memory based rpc (for speed check and testing) */ extern SVCXPRT *svc_raw_create(void); /* * svc_dg_enable_cache() enables the cache on dg transports. */ int svc_dg_enablecache(SVCXPRT *, const u_int); int __rpc_get_local_uid(SVCXPRT *_transp, uid_t *_uid); __END_DECLS /* for backward compatibility */ #include #endif /* !_RPC_SVC_H */ diff --git a/include/rpc/svc_auth.h b/include/rpc/svc_auth.h index e9b6cd4be4f3..6652deff085b 100644 --- a/include/rpc/svc_auth.h +++ b/include/rpc/svc_auth.h @@ -1,58 +1,57 @@ /* $NetBSD: svc_auth.h,v 1.8 2000/06/02 22:57:57 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)svc_auth.h 1.6 86/07/16 SMI * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * svc_auth.h, Service side of rpc authentication. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _RPC_SVC_AUTH_H #define _RPC_SVC_AUTH_H /* * Server side authenticator */ __BEGIN_DECLS extern struct svc_auth_ops svc_auth_null_ops; extern enum auth_stat _authenticate(struct svc_req *, struct rpc_msg *); extern int svc_auth_reg(int, enum auth_stat (*)(struct svc_req *, struct rpc_msg *)); __END_DECLS #endif /* !_RPC_SVC_AUTH_H */ diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h index ad1672cd1db8..624a3c294650 100644 --- a/include/rpc/xdr.h +++ b/include/rpc/xdr.h @@ -1,366 +1,365 @@ /* $NetBSD: xdr.h,v 1.19 2000/07/17 05:00:45 matt Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. * * from: @(#)xdr.h 1.19 87/04/22 SMI * from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC - * $FreeBSD$ */ /* * xdr.h, External Data Representation Serialization Routines. * * Copyright (C) 1984, Sun Microsystems, Inc. */ #ifndef _RPC_XDR_H #define _RPC_XDR_H #include /* * XDR provides a conventional way for converting between C data * types and an external bit-string representation. Library supplied * routines provide for the conversion on built-in C data types. These * routines and utility routines defined here are used to help implement * a type encode/decode routine for each user-defined type. * * Each data type provides a single procedure which takes two arguments: * * bool_t * xdrproc(xdrs, argresp) * XDR *xdrs; * *argresp; * * xdrs is an instance of a XDR handle, to which or from which the data * type is to be converted. argresp is a pointer to the structure to be * converted. The XDR handle contains an operation field which indicates * which of the operations (ENCODE, DECODE * or FREE) is to be performed. * * XDR_DECODE may allocate space if the pointer argresp is null. This * data can be freed with the XDR_FREE operation. * * We write only one procedure per data type to make it easy * to keep the encode and decode procedures for a data type consistent. * In many cases the same code performs all operations on a user defined type, * because all the hard work is done in the component type routines. * decode as a series of calls on the nested data types. */ /* * Xdr operations. XDR_ENCODE causes the type to be encoded into the * stream. XDR_DECODE causes the type to be extracted from the stream. * XDR_FREE can be used to release the space allocated by an XDR_DECODE * request. */ enum xdr_op { XDR_ENCODE=0, XDR_DECODE=1, XDR_FREE=2 }; /* * This is the number of bytes per unit of external data. */ #define BYTES_PER_XDR_UNIT (4) #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ * BYTES_PER_XDR_UNIT) /* * The XDR handle. * Contains operation which is being applied to the stream, * an operations vector for the particular implementation (e.g. see xdr_mem.c), * and two private fields for the use of the particular implementation. */ typedef struct XDR { enum xdr_op x_op; /* operation; fast additional param */ const struct xdr_ops { /* get a long from underlying stream */ bool_t (*x_getlong)(struct XDR *, long *); /* put a long to " */ bool_t (*x_putlong)(struct XDR *, const long *); /* get some bytes from " */ bool_t (*x_getbytes)(struct XDR *, char *, u_int); /* put some bytes to " */ bool_t (*x_putbytes)(struct XDR *, const char *, u_int); /* returns bytes off from beginning */ u_int (*x_getpostn)(struct XDR *); /* lets you reposition the stream */ bool_t (*x_setpostn)(struct XDR *, u_int); /* buf quick ptr to buffered data */ int32_t *(*x_inline)(struct XDR *, u_int); /* free privates of this xdr_stream */ void (*x_destroy)(struct XDR *); bool_t (*x_control)(struct XDR *, int, void *); } *x_ops; char * x_public; /* users' data */ void * x_private; /* pointer to private data */ char * x_base; /* private used for position info */ u_int x_handy; /* extra private word */ } XDR; /* * A xdrproc_t exists for each data type which is to be encoded or decoded. * * The second argument to the xdrproc_t is a pointer to an opaque pointer. * The opaque pointer generally points to a structure of the data type * to be decoded. If this pointer is 0, then the type routines should * allocate dynamic storage of the appropriate size and return it. */ #ifdef _KERNEL typedef bool_t (*xdrproc_t)(XDR *, void *, u_int); #else /* * XXX can't actually prototype it, because some take three args!!! */ typedef bool_t (*xdrproc_t)(XDR *, ...); #endif /* * Operations defined on a XDR handle * * XDR *xdrs; * long *longp; * char * addr; * u_int len; * u_int pos; */ #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) static __inline int xdr_getint32(XDR *xdrs, int32_t *ip) { long l; if (!xdr_getlong(xdrs, &l)) return (FALSE); *ip = (int32_t)l; return (TRUE); } static __inline int xdr_putint32(XDR *xdrs, int32_t *ip) { long l; l = (long)*ip; return xdr_putlong(xdrs, &l); } #define XDR_GETINT32(xdrs, int32p) xdr_getint32(xdrs, int32p) #define XDR_PUTINT32(xdrs, int32p) xdr_putint32(xdrs, int32p) #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) \ if ((xdrs)->x_ops->x_destroy) \ (*(xdrs)->x_ops->x_destroy)(xdrs) #define xdr_destroy(xdrs) \ if ((xdrs)->x_ops->x_destroy) \ (*(xdrs)->x_ops->x_destroy)(xdrs) #define XDR_CONTROL(xdrs, req, op) \ if ((xdrs)->x_ops->x_control) \ (*(xdrs)->x_ops->x_control)(xdrs, req, op) #define xdr_control(xdrs, req, op) XDR_CONTROL(xdrs, req, op) #define xdr_rpcvers(xdrs, versp) xdr_u_int32_t(xdrs, versp) #define xdr_rpcprog(xdrs, progp) xdr_u_int32_t(xdrs, progp) #define xdr_rpcproc(xdrs, procp) xdr_u_int32_t(xdrs, procp) #define xdr_rpcprot(xdrs, protp) xdr_u_int32_t(xdrs, protp) #define xdr_rpcport(xdrs, portp) xdr_u_int32_t(xdrs, portp) /* * Support struct for discriminated unions. * You create an array of xdrdiscrim structures, terminated with * an entry with a null procedure pointer. The xdr_union routine gets * the discriminant value and then searches the array of structures * for a matching value. If a match is found the associated xdr routine * is called to handle that part of the union. If there is * no match, then a default routine may be called. * If there is no match and no default routine it is an error. */ #define NULL_xdrproc_t ((xdrproc_t)0) struct xdr_discrim { int value; xdrproc_t proc; }; /* * In-line routines for fast encode/decode of primitive data types. * Caveat emptor: these use single memory cycles to get the * data from the underlying buffer, and will fail to operate * properly if the data is not aligned. The standard way to use these * is to say: * if ((buf = XDR_INLINE(xdrs, count)) == NULL) * return (FALSE); * <<< macro calls >>> * where ``count'' is the number of bytes of data occupied * by the primitive data types. * * N.B. and frozen for all time: each data type here uses 4 bytes * of external representation. */ #define IXDR_GET_INT32(buf) ((int32_t)__ntohl((u_int32_t)*(buf)++)) #define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v)) #define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf)) #define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) #define IXDR_GET_LONG(buf) ((long)__ntohl((u_int32_t)*(buf)++)) #define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) #define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) #define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) #define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) #define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), (v)) /* * These are the "generic" xdr routines. */ __BEGIN_DECLS extern bool_t xdr_void(void); extern bool_t xdr_int(XDR *, int *); extern bool_t xdr_u_int(XDR *, u_int *); extern bool_t xdr_long(XDR *, long *); extern bool_t xdr_u_long(XDR *, u_long *); extern bool_t xdr_short(XDR *, short *); extern bool_t xdr_u_short(XDR *, u_short *); extern bool_t xdr_int16_t(XDR *, int16_t *); extern bool_t xdr_u_int16_t(XDR *, u_int16_t *); extern bool_t xdr_uint16_t(XDR *, u_int16_t *); extern bool_t xdr_int32_t(XDR *, int32_t *); extern bool_t xdr_u_int32_t(XDR *, u_int32_t *); extern bool_t xdr_uint32_t(XDR *, u_int32_t *); extern bool_t xdr_int64_t(XDR *, int64_t *); extern bool_t xdr_u_int64_t(XDR *, u_int64_t *); extern bool_t xdr_uint64_t(XDR *, u_int64_t *); extern bool_t xdr_bool(XDR *, bool_t *); extern bool_t xdr_enum(XDR *, enum_t *); extern bool_t xdr_array(XDR *, char **, u_int *, u_int, u_int, xdrproc_t); extern bool_t xdr_bytes(XDR *, char **, u_int *, u_int); extern bool_t xdr_opaque(XDR *, char *, u_int); extern bool_t xdr_string(XDR *, char **, u_int); extern bool_t xdr_union(XDR *, enum_t *, char *, const struct xdr_discrim *, xdrproc_t); extern bool_t xdr_char(XDR *, char *); extern bool_t xdr_u_char(XDR *, u_char *); extern bool_t xdr_vector(XDR *, char *, u_int, u_int, xdrproc_t); extern bool_t xdr_float(XDR *, float *); extern bool_t xdr_double(XDR *, double *); extern bool_t xdr_quadruple(XDR *, long double *); extern bool_t xdr_reference(XDR *, char **, u_int, xdrproc_t); extern bool_t xdr_pointer(XDR *, char **, u_int, xdrproc_t); extern bool_t xdr_wrapstring(XDR *, char **); extern void xdr_free(xdrproc_t, void *); extern bool_t xdr_hyper(XDR *, quad_t *); extern bool_t xdr_u_hyper(XDR *, u_quad_t *); extern bool_t xdr_longlong_t(XDR *, quad_t *); extern bool_t xdr_u_longlong_t(XDR *, u_quad_t *); extern unsigned long xdr_sizeof(xdrproc_t, void *); __END_DECLS /* * Common opaque bytes objects used by many rpc protocols; * declared here due to commonality. */ #define MAX_NETOBJ_SZ 1024 struct netobj { u_int n_len; char *n_bytes; }; typedef struct netobj netobj; extern bool_t xdr_netobj(XDR *, struct netobj *); /* * These are the public routines for the various implementations of * xdr streams. */ __BEGIN_DECLS /* XDR using memory buffers */ extern void xdrmem_create(XDR *, char *, u_int, enum xdr_op); /* XDR using stdio library */ #ifdef _STDIO_H_ extern void xdrstdio_create(XDR *, FILE *, enum xdr_op); #endif /* XDR pseudo records for tcp */ extern void xdrrec_create(XDR *, u_int, u_int, void *, int (*)(void *, void *, int), int (*)(void *, void *, int)); /* make end of xdr record */ extern bool_t xdrrec_endofrecord(XDR *, int); /* move to beginning of next record */ extern bool_t xdrrec_skiprecord(XDR *); /* true if no more input */ extern bool_t xdrrec_eof(XDR *); extern u_int xdrrec_readbytes(XDR *, caddr_t, u_int); __END_DECLS #endif /* !_RPC_XDR_H */ diff --git a/include/runetype.h b/include/runetype.h index 93007809dbf8..e0ea07b1ae60 100644 --- a/include/runetype.h +++ b/include/runetype.h @@ -1,106 +1,105 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)runetype.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _RUNETYPE_H_ #define _RUNETYPE_H_ #include #include #define _CACHED_RUNES (1 <<8 ) /* Must be a power of 2 */ #define _CRMASK (~(_CACHED_RUNES - 1)) /* * The lower 8 bits of runetype[] contain the digit value of the rune. */ typedef struct { __rune_t __min; /* First rune of the range */ __rune_t __max; /* Last rune (inclusive) of the range */ __rune_t __map; /* What first maps to in maps */ unsigned long *__types; /* Array of types in range */ } _RuneEntry; typedef struct { int __nranges; /* Number of ranges stored */ _RuneEntry *__ranges; /* Pointer to the ranges */ } _RuneRange; typedef struct { char __magic[8]; /* Magic saying what version we are */ char __encoding[32]; /* ASCII name of this encoding */ __rune_t (*__sgetrune)(const char *, __size_t, char const **); int (*__sputrune)(__rune_t, char *, __size_t, char **); __rune_t __invalid_rune; unsigned long __runetype[_CACHED_RUNES]; __rune_t __maplower[_CACHED_RUNES]; __rune_t __mapupper[_CACHED_RUNES]; /* * The following are to deal with Runes larger than _CACHED_RUNES - 1. * Their data is actually contiguous with this structure so as to make * it easier to read/write from/to disk. */ _RuneRange __runetype_ext; _RuneRange __maplower_ext; _RuneRange __mapupper_ext; void *__variable; /* Data which depends on the encoding */ int __variable_len; /* how long that data is */ } _RuneLocale; #define _RUNE_MAGIC_1 "RuneMagi" /* Indicates version 0 of RuneLocale */ __BEGIN_DECLS extern const _RuneLocale _DefaultRuneLocale; extern const _RuneLocale *_CurrentRuneLocale; #ifdef __RUNETYPE_INTERNAL extern const _RuneLocale *__getCurrentRuneLocale(void); #else extern _Thread_local const _RuneLocale *_ThreadRuneLocale; static __inline const _RuneLocale *__getCurrentRuneLocale(void) { if (_ThreadRuneLocale) return _ThreadRuneLocale; return _CurrentRuneLocale; } #endif /*__RUNETYPE_INTERNAL */ #define _CurrentRuneLocale (__getCurrentRuneLocale()) __END_DECLS #endif /* !_RUNETYPE_H_ */ diff --git a/include/search.h b/include/search.h index 068446fdcb88..0615da2b42ba 100644 --- a/include/search.h +++ b/include/search.h @@ -1,85 +1,84 @@ /*- * Written by J.T. Conklin * Public domain. * * $NetBSD: search.h,v 1.16 2005/02/03 04:39:32 perry Exp $ - * $FreeBSD$ */ #ifndef _SEARCH_H_ #define _SEARCH_H_ #include #include #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif typedef struct entry { char *key; void *data; } ENTRY; typedef enum { FIND, ENTER } ACTION; typedef enum { preorder, postorder, endorder, leaf } VISIT; #ifdef _SEARCH_PRIVATE typedef struct __posix_tnode { void *key; struct __posix_tnode *llink, *rlink; signed char balance; } posix_tnode; struct que_elem { struct que_elem *next; struct que_elem *prev; }; #else typedef void posix_tnode; #endif #if __BSD_VISIBLE struct hsearch_data { struct __hsearch *__hsearch; }; #endif __BEGIN_DECLS int hcreate(size_t); void hdestroy(void); ENTRY *hsearch(ENTRY, ACTION); void insque(void *, void *); void *lfind(const void *, const void *, size_t *, size_t, int (*)(const void *, const void *)); void *lsearch(const void *, void *, size_t *, size_t, int (*)(const void *, const void *)); void remque(void *); void *tdelete(const void * __restrict, posix_tnode ** __restrict, int (*)(const void *, const void *)); posix_tnode * tfind(const void *, posix_tnode * const *, int (*)(const void *, const void *)); posix_tnode * tsearch(const void *, posix_tnode **, int (*)(const void *, const void *)); void twalk(const posix_tnode *, void (*)(const posix_tnode *, VISIT, int)); #if __BSD_VISIBLE int hcreate_r(size_t, struct hsearch_data *); void hdestroy_r(struct hsearch_data *); int hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *); #endif __END_DECLS #endif /* !_SEARCH_H_ */ diff --git a/include/setjmp.h b/include/setjmp.h index 1cc8b7762499..88980df9faa2 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -1,64 +1,63 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)setjmp.h 8.2 (Berkeley) 1/21/94 - * $FreeBSD$ */ #ifndef _SETJMP_H_ #define _SETJMP_H_ #include /* The size of the jmp_buf is machine dependent: */ #include __BEGIN_DECLS #if __XSI_VISIBLE >= 600 void _longjmp(jmp_buf, int) __dead2; int _setjmp(jmp_buf) __returns_twice; #endif void longjmp(jmp_buf, int) __dead2; #if __BSD_VISIBLE void longjmperror(void); #endif int setjmp(jmp_buf) __returns_twice; #if __POSIX_VISIBLE || __XSI_VISIBLE void siglongjmp(sigjmp_buf, int) __dead2; int sigsetjmp(sigjmp_buf, int) __returns_twice; #endif __END_DECLS #endif /* !_SETJMP_H_ */ diff --git a/include/signal.h b/include/signal.h index 3b20875290d6..ee73b8ed492c 100644 --- a/include/signal.h +++ b/include/signal.h @@ -1,137 +1,136 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)signal.h 8.3 (Berkeley) 3/30/94 - * $FreeBSD$ */ #ifndef _SIGNAL_H_ #define _SIGNAL_H_ #include #include #include #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE #include #include #endif __NULLABILITY_PRAGMA_PUSH #if __BSD_VISIBLE /* * XXX should enlarge these, if only to give empty names instead of bounds * errors for large signal numbers. */ extern const char * const sys_signame[NSIG]; extern const char * const sys_siglist[NSIG]; extern const int sys_nsig; #endif #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #endif #if __POSIX_VISIBLE || __XSI_VISIBLE struct pthread; /* XXX */ typedef struct pthread *__pthread_t; #if !defined(_PTHREAD_T_DECLARED) && __POSIX_VISIBLE >= 200809 typedef __pthread_t pthread_t; #define _PTHREAD_T_DECLARED #endif #endif /* __POSIX_VISIBLE || __XSI_VISIBLE */ __BEGIN_DECLS int raise(int); #if __POSIX_VISIBLE || __XSI_VISIBLE int kill(__pid_t, int); int pthread_kill(__pthread_t, int); int pthread_sigmask(int, const __sigset_t * __restrict, __sigset_t * __restrict); int sigaction(int, const struct sigaction * __restrict, struct sigaction * __restrict); int sigaddset(sigset_t *, int); int sigdelset(sigset_t *, int); int sigemptyset(sigset_t *); int sigfillset(sigset_t *); int sigismember(const sigset_t *, int); int sigpending(sigset_t * _Nonnull); int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict); int sigsuspend(const sigset_t * _Nonnull); int sigwait(const sigset_t * _Nonnull __restrict, int * _Nonnull __restrict); #endif #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 600 int sigqueue(__pid_t, int, const union sigval); struct timespec; int sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, const struct timespec * __restrict); int sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict); #endif #if __XSI_VISIBLE int killpg(__pid_t, int); int sigaltstack(const stack_t * __restrict, stack_t * __restrict); int sighold(int); int sigignore(int); int sigpause(int); int sigrelse(int); void (* _Nullable sigset(int, void (* _Nullable)(int)))(int); int xsi_sigpause(int); #endif #if __XSI_VISIBLE >= 600 int siginterrupt(int, int); #endif #if __POSIX_VISIBLE >= 200809 void psignal(int, const char *); #endif #if __BSD_VISIBLE int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right); int sigblock(int); int sigisemptyset(const sigset_t *set); int sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *right); int sigreturn(const struct __ucontext *); int sigsetmask(int); int sigstack(const struct sigstack *, struct sigstack *); int sigvec(int, struct sigvec *, struct sigvec *); #endif __END_DECLS __NULLABILITY_PRAGMA_POP #endif /* !_SIGNAL_H_ */ diff --git a/include/stdio.h b/include/stdio.h index e392bd5eb3e2..b7c412c81da7 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,534 +1,533 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)stdio.h 8.5 (Berkeley) 4/29/95 - * $FreeBSD$ */ #ifndef _STDIO_H_ #define _STDIO_H_ #include #include #include __NULLABILITY_PRAGMA_PUSH typedef __off_t fpos_t; #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _RSIZE_T_DEFINED #define _RSIZE_T_DEFINED typedef size_t rsize_t; #endif #if __POSIX_VISIBLE >= 200809 #ifndef _OFF_T_DECLARED #define _OFF_T_DECLARED typedef __off_t off_t; #endif #ifndef _SSIZE_T_DECLARED #define _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #endif #endif #ifndef _OFF64_T_DECLARED #define _OFF64_T_DECLARED typedef __off64_t off64_t; #endif #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE #ifndef _VA_LIST_DECLARED typedef __va_list va_list; #define _VA_LIST_DECLARED #endif #endif #define _FSTDIO /* Define for new stdio with functions. */ /* * NB: to fit things in six character monocase externals, the stdio * code uses the prefix `__s' for stdio objects, typically followed * by a three-character attempt at a mnemonic. */ /* stdio buffers */ struct __sbuf { unsigned char *_base; int _size; }; /* * stdio state variables. * * The following always hold: * * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), * _lbfsize is -_bf._size, else _lbfsize is 0 * if _flags&__SRD, _w is 0 * if _flags&__SWR, _r is 0 * * This ensures that the getc and putc macros (or inline functions) never * try to write or read from a file that is in `read' or `write' mode. * (Moreover, they can, and do, automatically switch from read mode to * write mode, and back, on "r+" and "w+" files.) * * _lbfsize is used only to make the inline line-buffered output stream * code as compact as possible. * * _ub, _up, and _ur are used when ungetc() pushes back more characters * than fit in the current _bf, or when ungetc() pushes back a character * that does not match the previous one in _bf. When this happens, * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. * * Certain members of __sFILE are accessed directly via macros or * inline functions. To preserve ABI compat, these members must not * be disturbed. These members are marked below with (*). */ struct __sFILE { unsigned char *_p; /* (*) current position in (some) buffer */ int _r; /* (*) read space left for getc() */ int _w; /* (*) write space left for putc() */ short _flags; /* (*) flags, below; this FILE is free if 0 */ short _file; /* (*) fileno, if Unix descriptor, else -1 */ struct __sbuf _bf; /* (*) the buffer (at least 1 byte, if !NULL) */ int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */ /* operations */ void *_cookie; /* (*) cookie passed to io functions */ int (* _Nullable _close)(void *); int (* _Nullable _read)(void *, char *, int); fpos_t (* _Nullable _seek)(void *, fpos_t, int); int (* _Nullable _write)(void *, const char *, int); /* separate buffer for long sequences of ungetc() */ struct __sbuf _ub; /* ungetc buffer */ unsigned char *_up; /* saved _p when _p is doing ungetc data */ int _ur; /* saved _r when _r is counting ungetc data */ /* tricks to meet minimum requirements even when malloc() fails */ unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ unsigned char _nbuf[1]; /* guarantee a getc() buffer */ /* separate buffer for fgetln() when line crosses buffer boundary */ struct __sbuf _lb; /* buffer for fgetln() */ /* Unix stdio files get aligned to block boundaries on fseek() */ int _blksize; /* stat.st_blksize (may be != _bf._size) */ fpos_t _offset; /* current lseek offset */ struct pthread_mutex *_fl_mutex; /* used for MT-safety */ struct pthread *_fl_owner; /* current owner */ int _fl_count; /* recursive lock count */ int _orientation; /* orientation for fwide() */ __mbstate_t _mbstate; /* multibyte conversion state */ int _flags2; /* additional flags */ }; #ifndef _STDFILE_DECLARED #define _STDFILE_DECLARED typedef struct __sFILE FILE; #endif #ifndef _STDSTREAM_DECLARED __BEGIN_DECLS extern FILE *__stdinp; extern FILE *__stdoutp; extern FILE *__stderrp; __END_DECLS #define _STDSTREAM_DECLARED #endif #define __SLBF 0x0001 /* line buffered */ #define __SNBF 0x0002 /* unbuffered */ #define __SRD 0x0004 /* OK to read */ #define __SWR 0x0008 /* OK to write */ /* RD and WR are never simultaneously asserted */ #define __SRW 0x0010 /* open for reading & writing */ #define __SEOF 0x0020 /* found EOF */ #define __SERR 0x0040 /* found error */ #define __SMBF 0x0080 /* _bf._base is from malloc */ #define __SAPP 0x0100 /* fdopen()ed in append mode */ #define __SSTR 0x0200 /* this is an sprintf/snprintf string */ #define __SOPT 0x0400 /* do fseek() optimization */ #define __SNPT 0x0800 /* do not do fseek() optimization */ #define __SOFF 0x1000 /* set iff _offset is in fact correct */ #define __SMOD 0x2000 /* true => fgetln modified _p text */ #define __SALC 0x4000 /* allocate string space dynamically */ #define __SIGN 0x8000 /* ignore this file in _fwalk */ #define __S2OAP 0x0001 /* O_APPEND mode is set */ /* * The following three definitions are for ANSI C, which took them * from System V, which brilliantly took internal interface macros and * made them official arguments to setvbuf(), without renaming them. * Hence, these ugly _IOxxx names are *supposed* to appear in user code. * * Although numbered as their counterparts above, the implementation * does not rely on this. */ #define _IOFBF 0 /* setvbuf should set fully buffered */ #define _IOLBF 1 /* setvbuf should set line buffered */ #define _IONBF 2 /* setvbuf should set unbuffered */ #define BUFSIZ 1024 /* size of buffer used by setbuf */ #define EOF (-1) /* * FOPEN_MAX is a minimum maximum, and is the number of streams that * stdio can provide without attempting to allocate further resources * (which could fail). Do not use this for anything. */ /* must be == _POSIX_STREAM_MAX */ #ifndef FOPEN_MAX #define FOPEN_MAX 20 /* must be <= OPEN_MAX */ #endif #define FILENAME_MAX 1024 /* must be <= PATH_MAX */ /* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ #if __XSI_VISIBLE #define P_tmpdir "/tmp/" #endif #define L_tmpnam 1024 /* XXX must be == PATH_MAX */ #define TMP_MAX 308915776 #ifndef SEEK_SET #define SEEK_SET 0 /* set file offset to offset */ #endif #ifndef SEEK_CUR #define SEEK_CUR 1 /* set file offset to current plus offset */ #endif #ifndef SEEK_END #define SEEK_END 2 /* set file offset to EOF plus offset */ #endif #define stdin __stdinp #define stdout __stdoutp #define stderr __stderrp __BEGIN_DECLS #ifdef _XLOCALE_H_ #include #endif /* * Functions defined in ANSI C standard. */ void clearerr(FILE *); int fclose(FILE *); int feof(FILE *); int ferror(FILE *); int fflush(FILE *); int fgetc(FILE *); int fgetpos(FILE * __restrict, fpos_t * __restrict); char *fgets(char * __restrict, int, FILE * __restrict); FILE *fopen(const char * __restrict, const char * __restrict); int fprintf(FILE * __restrict, const char * __restrict, ...); int fputc(int, FILE *); int fputs(const char * __restrict, FILE * __restrict); size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict); int fscanf(FILE * __restrict, const char * __restrict, ...); int fseek(FILE *, long, int); int fsetpos(FILE *, const fpos_t *); long ftell(FILE *); size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); int getc(FILE *); int getchar(void); #if __EXT1_VISIBLE char *gets_s(char *, rsize_t); #endif void perror(const char *); int printf(const char * __restrict, ...); int putc(int, FILE *); int putchar(int); int puts(const char *); int remove(const char *); int rename(const char *, const char *); void rewind(FILE *); int scanf(const char * __restrict, ...); void setbuf(FILE * __restrict, char * __restrict); int setvbuf(FILE * __restrict, char * __restrict, int, size_t); int sprintf(char * __restrict, const char * __restrict, ...); int sscanf(const char * __restrict, const char * __restrict, ...); FILE *tmpfile(void); char *tmpnam(char *); int ungetc(int, FILE *); int vfprintf(FILE * __restrict, const char * __restrict, __va_list); int vprintf(const char * __restrict, __va_list); int vsprintf(char * __restrict, const char * __restrict, __va_list); #if __ISO_C_VISIBLE >= 1999 || __POSIX_VISIBLE >= 199506 int snprintf(char * __restrict, size_t, const char * __restrict, ...) __printflike(3, 4); int vsnprintf(char * __restrict, size_t, const char * __restrict, __va_list) __printflike(3, 0); #endif #if __ISO_C_VISIBLE >= 1999 int vfscanf(FILE * __restrict, const char * __restrict, __va_list) __scanflike(2, 0); int vscanf(const char * __restrict, __va_list) __scanflike(1, 0); int vsscanf(const char * __restrict, const char * __restrict, __va_list) __scanflike(2, 0); #endif /* * Functions defined in all versions of POSIX 1003.1. */ #if __BSD_VISIBLE || (__POSIX_VISIBLE && __POSIX_VISIBLE <= 199506) #define L_cuserid 17 /* size for cuserid(3); MAXLOGNAME, legacy */ #endif #if __POSIX_VISIBLE #define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */ char *ctermid(char *); FILE *fdopen(int, const char *); int fileno(FILE *); #endif /* __POSIX_VISIBLE */ #if __POSIX_VISIBLE >= 199209 int pclose(FILE *); FILE *popen(const char *, const char *); #endif #if __POSIX_VISIBLE >= 199506 int ftrylockfile(FILE *); void flockfile(FILE *); void funlockfile(FILE *); /* * These are normally used through macros as defined below, but POSIX * requires functions as well. */ int getc_unlocked(FILE *); int getchar_unlocked(void); int putc_unlocked(int, FILE *); int putchar_unlocked(int); #endif #if __BSD_VISIBLE void clearerr_unlocked(FILE *); int feof_unlocked(FILE *); int ferror_unlocked(FILE *); int fflush_unlocked(FILE *); int fileno_unlocked(FILE *); int fputc_unlocked(int, FILE *); int fputs_unlocked(const char * __restrict, FILE * __restrict); size_t fread_unlocked(void * __restrict, size_t, size_t, FILE * __restrict); size_t fwrite_unlocked(const void * __restrict, size_t, size_t, FILE * __restrict); #endif #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500 int fseeko(FILE *, __off_t, int); __off_t ftello(FILE *); #endif #if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 int getw(FILE *); int putw(int, FILE *); #endif /* BSD or X/Open before issue 6 */ #if __XSI_VISIBLE char *tempnam(const char *, const char *); #endif #if __POSIX_VISIBLE >= 200809 FILE *fmemopen(void * __restrict, size_t, const char * __restrict); ssize_t getdelim(char ** __restrict, size_t * __restrict, int, FILE * __restrict); FILE *open_memstream(char **, size_t *); int renameat(int, const char *, int, const char *); int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); /* _WITH_GETLINE to allow pre 11 sources to build on 11+ systems */ ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); int dprintf(int, const char * __restrict, ...) __printflike(2, 3); #endif /* __POSIX_VISIBLE >= 200809 */ /* * Routines that are purely local. */ #if __BSD_VISIBLE int asprintf(char **, const char *, ...) __printflike(2, 3); char *ctermid_r(char *); void fcloseall(void); int fdclose(FILE *, int *); char *fgetln(FILE *, size_t *); const char *fmtcheck(const char *, const char *) __format_arg(2); int fpurge(FILE *); void setbuffer(FILE *, char *, int); int setlinebuf(FILE *); int vasprintf(char **, const char *, __va_list) __printflike(2, 0); /* * The system error table contains messages for the first sys_nerr * positive errno values. Use strerror() or strerror_r() from * instead. */ extern const int sys_nerr; extern const char * const sys_errlist[]; /* * Stdio function-access interface. */ FILE *funopen(const void *, int (* _Nullable)(void *, char *, int), int (* _Nullable)(void *, const char *, int), fpos_t (* _Nullable)(void *, fpos_t, int), int (* _Nullable)(void *)); #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) #define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) typedef __ssize_t cookie_read_function_t(void *, char *, size_t); typedef __ssize_t cookie_write_function_t(void *, const char *, size_t); typedef int cookie_seek_function_t(void *, off64_t *, int); typedef int cookie_close_function_t(void *); typedef struct { cookie_read_function_t *read; cookie_write_function_t *write; cookie_seek_function_t *seek; cookie_close_function_t *close; } cookie_io_functions_t; FILE *fopencookie(void *, const char *, cookie_io_functions_t); /* * Portability hacks. See . */ #ifndef _FTRUNCATE_DECLARED #define _FTRUNCATE_DECLARED int ftruncate(int, __off_t); #endif #ifndef _LSEEK_DECLARED #define _LSEEK_DECLARED __off_t lseek(int, __off_t, int); #endif #ifndef _MMAP_DECLARED #define _MMAP_DECLARED void *mmap(void *, size_t, int, int, int, __off_t); #endif #ifndef _TRUNCATE_DECLARED #define _TRUNCATE_DECLARED int truncate(const char *, __off_t); #endif #endif /* __BSD_VISIBLE */ /* * Functions internal to the implementation. */ int __srget(FILE *); int __swbuf(int, FILE *); /* * The __sfoo macros are here so that we can * define function versions in the C library. */ #define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) #if defined(__GNUC__) && defined(__STDC__) static __inline int __sputc(int _c, FILE *_p) { if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) return (*_p->_p++ = _c); else return (__swbuf(_c, _p)); } #else /* * This has been tuned to generate reasonable code on the vax using pcc. */ #define __sputc(c, p) \ (--(p)->_w < 0 ? \ (p)->_w >= (p)->_lbfsize ? \ (*(p)->_p = (c)), *(p)->_p != '\n' ? \ (int)*(p)->_p++ : \ __swbuf('\n', p) : \ __swbuf((int)(c), p) : \ (*(p)->_p = (c), (int)*(p)->_p++)) #endif #ifndef __LIBC_ISTHREADED_DECLARED #define __LIBC_ISTHREADED_DECLARED extern int __isthreaded; #endif #ifndef __cplusplus #define __sfeof(p) (((p)->_flags & __SEOF) != 0) #define __sferror(p) (((p)->_flags & __SERR) != 0) #define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) #define __sfileno(p) ((p)->_file) #define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p)) #define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) #define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) #if __POSIX_VISIBLE #define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) #endif #define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) #define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) #define getchar() getc(stdin) #define putchar(x) putc(x, stdout) #if __BSD_VISIBLE /* * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12 * B.8.2.7 for the rationale behind the *_unlocked() macros. */ #define clearerr_unlocked(p) __sclearerr(p) #define feof_unlocked(p) __sfeof(p) #define ferror_unlocked(p) __sferror(p) #define fileno_unlocked(p) __sfileno(p) #define fputc_unlocked(s, p) __sputc(s, p) #endif #if __POSIX_VISIBLE >= 199506 #define getc_unlocked(fp) __sgetc(fp) #define putc_unlocked(x, fp) __sputc(x, fp) #define getchar_unlocked() getc_unlocked(stdin) #define putchar_unlocked(x) putc_unlocked(x, stdout) #endif #endif /* __cplusplus */ __END_DECLS __NULLABILITY_PRAGMA_POP #endif /* !_STDIO_H_ */ diff --git a/include/stdlib.h b/include/stdlib.h index 730223e7fd77..67a1cb82761d 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,403 +1,402 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 - * $FreeBSD$ */ #ifndef _STDLIB_H_ #define _STDLIB_H_ #include #include #include __NULLABILITY_PRAGMA_PUSH #if __BSD_VISIBLE #ifndef _RUNE_T_DECLARED typedef __rune_t rune_t; #define _RUNE_T_DECLARED #endif #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef __cplusplus #ifndef _WCHAR_T_DECLARED typedef ___wchar_t wchar_t; #define _WCHAR_T_DECLARED #endif #endif typedef struct { int quot; /* quotient */ int rem; /* remainder */ } div_t; typedef struct { long quot; long rem; } ldiv_t; #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 /* * I.e., INT_MAX; rand(3) returns a signed integer but must produce output in * the range [0, RAND_MAX], so half of the possible output range is unused. */ #define RAND_MAX 0x7fffffff __BEGIN_DECLS #ifdef _XLOCALE_H_ #include #endif extern int __mb_cur_max; extern int ___mb_cur_max(void); #define MB_CUR_MAX ((size_t)___mb_cur_max()) _Noreturn void abort(void); int abs(int) __pure2; int atexit(void (* _Nonnull)(void)); double atof(const char *); int atoi(const char *); long atol(const char *); void *bsearch(const void *, const void *, size_t, size_t, int (*)(const void * _Nonnull, const void *)); void *calloc(size_t, size_t) __malloc_like __result_use_check __alloc_size2(1, 2); div_t div(int, int) __pure2; _Noreturn void exit(int); void free(void *); char *getenv(const char *); long labs(long) __pure2; ldiv_t ldiv(long, long) __pure2; void *malloc(size_t) __malloc_like __result_use_check __alloc_size(1); int mblen(const char *, size_t); size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t); int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); void qsort(void *, size_t, size_t, int (* _Nonnull)(const void *, const void *)); int rand(void); void *realloc(void *, size_t) __result_use_check __alloc_size(2); void srand(unsigned); double strtod(const char * __restrict, char ** __restrict); float strtof(const char * __restrict, char ** __restrict); long strtol(const char * __restrict, char ** __restrict, int); long double strtold(const char * __restrict, char ** __restrict); unsigned long strtoul(const char * __restrict, char ** __restrict, int); int system(const char *); int wctomb(char *, wchar_t); size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); /* * Functions added in C99 which we make conditionally available in the * BSD^C89 namespace if the compiler supports `long long'. * The #if test is more complicated than it ought to be because * __BSD_VISIBLE implies __ISO_C_VISIBLE == 1999 *even if* `long long' * is not supported in the compilation environment (which therefore means * that it can't really be ISO C99). * * (The only other extension made by C99 in this header is _Exit().) */ #if __ISO_C_VISIBLE >= 1999 || defined(__cplusplus) #ifdef __LONG_LONG_SUPPORTED /* LONGLONG */ typedef struct { long long quot; long long rem; } lldiv_t; /* LONGLONG */ long long atoll(const char *); /* LONGLONG */ long long llabs(long long) __pure2; /* LONGLONG */ lldiv_t lldiv(long long, long long) __pure2; /* LONGLONG */ long long strtoll(const char * __restrict, char ** __restrict, int); /* LONGLONG */ unsigned long long strtoull(const char * __restrict, char ** __restrict, int); #endif /* __LONG_LONG_SUPPORTED */ _Noreturn void _Exit(int); #endif /* __ISO_C_VISIBLE >= 1999 */ /* * If we're in a mode greater than C99, expose C11 functions. */ #if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1) __alloc_size(2); int at_quick_exit(void (*)(void)); _Noreturn void quick_exit(int); #endif /* __ISO_C_VISIBLE >= 2011 */ /* * Extensions made by POSIX relative to C. */ #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE char *realpath(const char * __restrict, char * __restrict); #endif #if __POSIX_VISIBLE >= 199506 int rand_r(unsigned *); /* (TSF) */ #endif #if __POSIX_VISIBLE >= 200112 int posix_memalign(void **, size_t, size_t); /* (ADV) */ int setenv(const char *, const char *, int); int unsetenv(const char *); #endif #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE int getsubopt(char **, char *const *, char **); #ifndef _MKDTEMP_DECLARED char *mkdtemp(char *); #define _MKDTEMP_DECLARED #endif #ifndef _MKSTEMP_DECLARED int mkstemp(char *); #define _MKSTEMP_DECLARED #endif #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */ /* * The only changes to the XSI namespace in revision 6 were the deletion * of the ttyslot() and valloc() functions, which FreeBSD never declared * in this header. For revision 7, ecvt(), fcvt(), and gcvt(), which * FreeBSD also does not have, and mktemp(), are to be deleted. */ #if __XSI_VISIBLE /* XXX XSI requires pollution from here. We'd rather not. */ long a64l(const char *); double drand48(void); /* char *ecvt(double, int, int * __restrict, int * __restrict); */ double erand48(unsigned short[3]); /* char *fcvt(double, int, int * __restrict, int * __restrict); */ /* char *gcvt(double, int, int * __restrict, int * __restrict); */ char *initstate(unsigned int, char *, size_t); long jrand48(unsigned short[3]); char *l64a(long); void lcong48(unsigned short[7]); long lrand48(void); #if !defined(_MKTEMP_DECLARED) && (__BSD_VISIBLE || __XSI_VISIBLE <= 600) char *mktemp(char *); #define _MKTEMP_DECLARED #endif long mrand48(void); long nrand48(unsigned short[3]); int putenv(char *); long random(void); unsigned short *seed48(unsigned short[3]); char *setstate(/* const */ char *); void srand48(long); void srandom(unsigned int); #endif /* __XSI_VISIBLE */ #if __XSI_VISIBLE int grantpt(int); int posix_openpt(int); char *ptsname(int); int unlockpt(int); #endif /* __XSI_VISIBLE */ #if __BSD_VISIBLE /* ptsname_r will be included in POSIX issue 8 */ int ptsname_r(int, char *, size_t); #endif #if __BSD_VISIBLE extern const char *malloc_conf; extern void (*malloc_message)(void *, const char *); /* * The alloca() function can't be implemented in C, and on some * platforms it can't be implemented at all as a callable function. * The GNU C compiler provides a built-in alloca() which we can use. * On platforms where alloca() is not in libc, programs which use it * will fail to link when compiled with non-GNU compilers. */ #if __GNUC__ >= 2 #undef alloca /* some GNU bits try to get cute and define this on their own */ #define alloca(sz) __builtin_alloca(sz) #endif void abort2(const char *, int, void **) __dead2; __uint32_t arc4random(void); void arc4random_buf(void *, size_t); __uint32_t arc4random_uniform(__uint32_t); #ifdef __BLOCKS__ int atexit_b(void (^ _Nonnull)(void)); void *bsearch_b(const void *, const void *, size_t, size_t, int (^ _Nonnull)(const void *, const void *)); #endif char *getbsize(int *, long *); /* getcap(3) functions */ char *cgetcap(char *, const char *, int); int cgetclose(void); int cgetent(char **, char **, const char *); int cgetfirst(char **, char **); int cgetmatch(const char *, const char *); int cgetnext(char **, char **); int cgetnum(char *, const char *, long *); int cgetset(const char *); int cgetstr(char *, const char *, char **); int cgetustr(char *, const char *, char **); int clearenv(void); int daemon(int, int); int daemonfd(int, int); char *devname(__dev_t, __mode_t); char *devname_r(__dev_t, __mode_t, char *, int); char *fdevname(int); char *fdevname_r(int, char *, int); int getloadavg(double [], int); const char * getprogname(void); int heapsort(void *, size_t, size_t, int (* _Nonnull)(const void *, const void *)); #ifdef __BLOCKS__ int heapsort_b(void *, size_t, size_t, int (^ _Nonnull)(const void *, const void *)); void qsort_b(void *, size_t, size_t, int (^ _Nonnull)(const void *, const void *)); #endif int l64a_r(long, char *, int); int mergesort(void *, size_t, size_t, int (*)(const void *, const void *)); #ifdef __BLOCKS__ int mergesort_b(void *, size_t, size_t, int (^)(const void *, const void *)); #endif int mkostemp(char *, int); int mkostemps(char *, int, int); int mkostempsat(int, char *, int, int); void qsort_r(void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); int radixsort(const unsigned char **, int, const unsigned char *, unsigned); void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size2(2, 3); void *reallocf(void *, size_t) __result_use_check __alloc_size(2); int rpmatch(const char *); char *secure_getenv(const char *); void setprogname(const char *); int sradixsort(const unsigned char **, int, const unsigned char *, unsigned); void srandomdev(void); long long strtonum(const char *, long long, long long, const char **); /* Deprecated interfaces, to be removed. */ __int64_t strtoq(const char *, char **, int); __uint64_t strtouq(const char *, char **, int); /* * In FreeBSD 14, the prototype of qsort_r() was modified to comply with * POSIX. The standardized qsort_r()'s order of last two parameters was * changed, and the comparator function is now taking thunk as its last * parameter, and both are different from the ones expected by the historical * FreeBSD qsort_r() interface. * * Apply a workaround where we explicitly link against the historical * interface, qsort_r@FBSD_1.0, in case when qsort_r() is called with * the last parameter with a function pointer that exactly matches the * historical FreeBSD qsort_r() comparator signature, so applications * written for the historical interface can continue to work without * modification. */ #if defined(__generic) || defined(__cplusplus) void __qsort_r_compat(void *, size_t, size_t, void *, int (*)(void *, const void *, const void *)); __sym_compat(qsort_r, __qsort_r_compat, FBSD_1.0); #endif #if defined(__generic) && !defined(__cplusplus) #define qsort_r(base, nel, width, arg4, arg5) \ __generic(arg5, int (*)(void *, const void *, const void *), \ __qsort_r_compat, qsort_r)(base, nel, width, arg4, arg5) #elif defined(__cplusplus) __END_DECLS extern "C++" { static inline void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *)) { __qsort_r_compat(base, nmemb, size, thunk, compar); } } __BEGIN_DECLS #endif extern char *suboptarg; /* getsubopt(3) external variable */ #endif /* __BSD_VISIBLE */ #if __EXT1_VISIBLE #ifndef _RSIZE_T_DEFINED #define _RSIZE_T_DEFINED typedef size_t rsize_t; #endif #ifndef _ERRNO_T_DEFINED #define _ERRNO_T_DEFINED typedef int errno_t; #endif /* K.3.6 */ typedef void (*constraint_handler_t)(const char * __restrict, void * __restrict, errno_t); /* K.3.6.1.1 */ constraint_handler_t set_constraint_handler_s(constraint_handler_t handler); /* K.3.6.1.2 */ _Noreturn void abort_handler_s(const char * __restrict, void * __restrict, errno_t); /* K3.6.1.3 */ void ignore_handler_s(const char * __restrict, void * __restrict, errno_t); /* K.3.6.3.2 */ errno_t qsort_s(void *, rsize_t, rsize_t, int (*)(const void *, const void *, void *), void *); #endif /* __EXT1_VISIBLE */ __END_DECLS __NULLABILITY_PRAGMA_POP #endif /* !_STDLIB_H_ */ diff --git a/include/string.h b/include/string.h index dc5756830208..7b0cb9f56524 100644 --- a/include/string.h +++ b/include/string.h @@ -1,174 +1,173 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)string.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _STRING_H_ #define _STRING_H_ #include #include #include /* * Prototype functions which were historically defined in , but * are required by POSIX to be prototyped in . */ #if __BSD_VISIBLE #include #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif __BEGIN_DECLS #if __XSI_VISIBLE >= 600 void *memccpy(void * __restrict, const void * __restrict, int, size_t); #endif void *memchr(const void *, int, size_t) __pure; #if __BSD_VISIBLE void *memrchr(const void *, int, size_t) __pure; #endif int memcmp(const void *, const void *, size_t) __pure; void *memcpy(void * __restrict, const void * __restrict, size_t); #if __BSD_VISIBLE void *memmem(const void *, size_t, const void *, size_t) __pure; #endif void *memmove(void *, const void *, size_t); #if __BSD_VISIBLE void *mempcpy(void * __restrict, const void * __restrict, size_t); #endif void *memset(void *, int, size_t); #if __POSIX_VISIBLE >= 200809 char *stpcpy(char * __restrict, const char * __restrict); char *stpncpy(char * __restrict, const char * __restrict, size_t); #endif #if __BSD_VISIBLE char *strcasestr(const char *, const char *) __pure; #endif char *strcat(char * __restrict, const char * __restrict); char *strchr(const char *, int) __pure; #if __BSD_VISIBLE char *strchrnul(const char*, int) __pure; int strverscmp(const char *, const char *) __pure; #endif int strcmp(const char *, const char *) __pure; int strcoll(const char *, const char *); char *strcpy(char * __restrict, const char * __restrict); size_t strcspn(const char *, const char *) __pure; #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE char *strdup(const char *) __malloc_like; #endif char *strerror(int); #if __POSIX_VISIBLE >= 200112 int strerror_r(int, char *, size_t); #endif #if __BSD_VISIBLE size_t strlcat(char * __restrict, const char * __restrict, size_t); size_t strlcpy(char * __restrict, const char * __restrict, size_t); #endif size_t strlen(const char *) __pure; #if __BSD_VISIBLE #ifndef _MODE_T_DECLARED typedef __mode_t mode_t; #define _MODE_T_DECLARED #endif void strmode(mode_t, char *); #endif char *strncat(char * __restrict, const char * __restrict, size_t); int strncmp(const char *, const char *, size_t) __pure; char *strncpy(char * __restrict, const char * __restrict, size_t); #if __POSIX_VISIBLE >= 200809 char *strndup(const char *, size_t) __malloc_like; size_t strnlen(const char *, size_t) __pure; #endif #if __BSD_VISIBLE char *strnstr(const char *, const char *, size_t) __pure; #endif char *strpbrk(const char *, const char *) __pure; char *strrchr(const char *, int) __pure; #if __BSD_VISIBLE char *strsep(char **, const char *); #endif #if __POSIX_VISIBLE >= 200809 char *strsignal(int); #endif size_t strspn(const char *, const char *) __pure; char *strstr(const char *, const char *) __pure; char *strtok(char * __restrict, const char * __restrict); #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500 char *strtok_r(char *, const char *, char **); #endif size_t strxfrm(char * __restrict, const char * __restrict, size_t); #if __BSD_VISIBLE #ifndef _SWAB_DECLARED #define _SWAB_DECLARED #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif /* _SIZE_T_DECLARED */ void swab(const void * __restrict, void * __restrict, ssize_t); #endif /* _SWAB_DECLARED */ int timingsafe_bcmp(const void *, const void *, size_t); int timingsafe_memcmp(const void *, const void *, size_t); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200112 || defined(_XLOCALE_H_) #include #endif #if __EXT1_VISIBLE #ifndef _RSIZE_T_DEFINED #define _RSIZE_T_DEFINED typedef size_t rsize_t; #endif #ifndef _ERRNO_T_DEFINED #define _ERRNO_T_DEFINED typedef int errno_t; #endif /* ISO/IEC 9899:2011 K.3.7.4.1.1 */ errno_t memset_s(void *, rsize_t, int, rsize_t); #endif /* __EXT1_VISIBLE */ __END_DECLS #endif /* _STRING_H_ */ diff --git a/include/termios.h b/include/termios.h index 9b808329a426..f3f06a54dd24 100644 --- a/include/termios.h +++ b/include/termios.h @@ -1,109 +1,108 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1988, 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)termios.h 8.3 (Berkeley) 3/28/94 - * $FreeBSD$ */ #ifndef _TERMIOS_H_ #define _TERMIOS_H_ #include #include #include #if __BSD_VISIBLE #include #endif #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #if __BSD_VISIBLE #define OXTABS TAB3 #define MDMBUF CCAR_OFLOW #endif #if __BSD_VISIBLE #define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) #endif /* * Commands passed to tcsetattr() for setting the termios structure. */ #define TCSANOW 0 /* make change immediate */ #define TCSADRAIN 1 /* drain output, then change */ #define TCSAFLUSH 2 /* drain output, flush input */ #if __BSD_VISIBLE #define TCSASOFT 0x10 /* flag - don't alter h.w. state */ #endif #define TCIFLUSH 1 #define TCOFLUSH 2 #define TCIOFLUSH 3 #define TCOOFF 1 #define TCOON 2 #define TCIOFF 3 #define TCION 4 __BEGIN_DECLS speed_t cfgetispeed(const struct termios *); speed_t cfgetospeed(const struct termios *); int cfsetispeed(struct termios *, speed_t); int cfsetospeed(struct termios *, speed_t); int tcgetattr(int, struct termios *); int tcsetattr(int, int, const struct termios *); int tcdrain(int); int tcflow(int, int); int tcflush(int, int); int tcsendbreak(int, int); #if __POSIX_VISIBLE >= 200112 pid_t tcgetsid(int); #endif #if __BSD_VISIBLE int tcsetsid(int, pid_t); void cfmakeraw(struct termios *); void cfmakesane(struct termios *); int cfsetspeed(struct termios *, speed_t); int tcgetwinsize(int, struct winsize *); int tcsetwinsize(int, const struct winsize *); #endif __END_DECLS #endif /* !_TERMIOS_H_ */ #if __BSD_VISIBLE #include #include #endif diff --git a/include/time.h b/include/time.h index f8560a285bb0..c6c083316423 100644 --- a/include/time.h +++ b/include/time.h @@ -1,193 +1,192 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)time.h 8.3 (Berkeley) 1/21/94 */ /* - * $FreeBSD$ */ #ifndef _TIME_H_ #define _TIME_H_ #include #include #include #include #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE /* * Frequency of the clock ticks reported by times(). Deprecated - use * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.) */ #define CLK_TCK 128 #endif /* Frequency of the clock ticks reported by clock(). */ #define CLOCKS_PER_SEC 128 #ifndef _CLOCK_T_DECLARED typedef __clock_t clock_t; #define _CLOCK_T_DECLARED #endif #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #if __POSIX_VISIBLE >= 199309 /* * New in POSIX 1003.1b-1993. */ #ifndef _CLOCKID_T_DECLARED typedef __clockid_t clockid_t; #define _CLOCKID_T_DECLARED #endif #ifndef _TIMER_T_DECLARED typedef __timer_t timer_t; #define _TIMER_T_DECLARED #endif #include #endif /* __POSIX_VISIBLE >= 199309 */ #if __POSIX_VISIBLE >= 200112 #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #endif struct tm { int tm_sec; /* seconds after the minute [0-60] */ int tm_min; /* minutes after the hour [0-59] */ int tm_hour; /* hours since midnight [0-23] */ int tm_mday; /* day of the month [1-31] */ int tm_mon; /* months since January [0-11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0-6] */ int tm_yday; /* days since January 1 [0-365] */ int tm_isdst; /* Daylight Savings Time flag */ long tm_gmtoff; /* offset from UTC in seconds */ char *tm_zone; /* timezone abbreviation */ }; #if __POSIX_VISIBLE extern char *tzname[]; #endif __BEGIN_DECLS char *asctime(const struct tm *); clock_t clock(void); char *ctime(const time_t *); #ifndef _STANDALONE double difftime(time_t, time_t); #endif /* XXX missing: getdate() */ struct tm *gmtime(const time_t *); struct tm *localtime(const time_t *); time_t mktime(struct tm *); size_t strftime(char * __restrict, size_t, const char * __restrict, const struct tm * __restrict); time_t time(time_t *); #if __POSIX_VISIBLE >= 200112 struct sigevent; int timer_create(clockid_t, struct sigevent *__restrict, timer_t *__restrict); int timer_delete(timer_t); int timer_gettime(timer_t, struct itimerspec *); int timer_getoverrun(timer_t); int timer_settime(timer_t, int, const struct itimerspec *__restrict, struct itimerspec *__restrict); #endif #if __POSIX_VISIBLE void tzset(void); #endif #if __POSIX_VISIBLE >= 199309 int clock_getres(clockid_t, struct timespec *); int clock_gettime(clockid_t, struct timespec *); int clock_settime(clockid_t, const struct timespec *); int nanosleep(const struct timespec *, struct timespec *); #endif /* __POSIX_VISIBLE >= 199309 */ #if __POSIX_VISIBLE >= 200112 int clock_getcpuclockid(pid_t, clockid_t *); int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); #endif #if __POSIX_VISIBLE >= 199506 char *asctime_r(const struct tm *, char *); char *ctime_r(const time_t *, char *); struct tm *gmtime_r(const time_t *, struct tm *); struct tm *localtime_r(const time_t *, struct tm *); #endif #if __XSI_VISIBLE char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict); #endif #if __BSD_VISIBLE char *timezone(int, int); /* XXX XSI conflict */ time_t timelocal(struct tm * const); time_t timegm(struct tm * const); int timer_oshandle_np(timer_t timerid); time_t time2posix(time_t t); time_t posix2time(time_t t); #endif /* __BSD_VISIBLE */ #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) #include #endif #if defined(__BSD_VISIBLE) || __ISO_C_VISIBLE >= 2011 || \ (defined(__cplusplus) && __cplusplus >= 201703) #include /* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */ #define TIME_UTC 1 /* time elapsed since epoch */ int timespec_get(struct timespec *ts, int base); #endif __END_DECLS #endif /* !_TIME_H_ */ diff --git a/include/timeconv.h b/include/timeconv.h index 1298cc238e57..ebbe112233c6 100644 --- a/include/timeconv.h +++ b/include/timeconv.h @@ -1,63 +1,62 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)time.h 8.3 (Berkeley) 1/21/94 */ /* - * $FreeBSD$ */ #ifndef _TIMECONV_H_ #define _TIMECONV_H_ #include #include #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif time_t _time32_to_time(__int32_t t32); __int32_t _time_to_time32(time_t t); time_t _time64_to_time(__int64_t t64); __int64_t _time_to_time64(time_t t); long _time_to_long(time_t t); time_t _long_to_time(long tlong); int _time_to_int(time_t t); time_t _int_to_time(int tint); #endif /* _TIMECONV_H_ */ diff --git a/include/ttyent.h b/include/ttyent.h index a98fbdffb86f..3060512c87c2 100644 --- a/include/ttyent.h +++ b/include/ttyent.h @@ -1,79 +1,78 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _TTYENT_H_ #define _TTYENT_H_ #define _PATH_TTYS "/etc/ttys" #define _TTYS_OFF "off" #define _TTYS_ON "on" #define _TTYS_ONIFCONSOLE "onifconsole" #define _TTYS_ONIFEXISTS "onifexists" #define _TTYS_SECURE "secure" #define _TTYS_INSECURE "insecure" #define _TTYS_WINDOW "window" #define _TTYS_GROUP "group" #define _TTYS_NOGROUP "none" #define _TTYS_DIALUP "dialup" #define _TTYS_NETWORK "network" struct ttyent { char *ty_name; /* terminal device name */ char *ty_getty; /* command to execute, usually getty */ char *ty_type; /* terminal type for termcap */ #define TTY_ON 0x01 /* enable logins (start ty_getty program) */ #define TTY_SECURE 0x02 /* allow uid of 0 to login */ #define TTY_DIALUP 0x04 /* is a dialup tty */ #define TTY_NETWORK 0x08 /* is a network tty */ #define TTY_IFEXISTS 0x10 /* configured as "onifexists" */ #define TTY_IFCONSOLE 0x20 /* configured as "onifconsole" */ int ty_status; /* status flags */ char *ty_window; /* command to start up window manager */ char *ty_comment; /* comment field */ char *ty_group; /* tty group */ }; #include __BEGIN_DECLS struct ttyent *getttyent(void); struct ttyent *getttynam(const char *); int setttyent(void); int endttyent(void); int isdialuptty(const char *); int isnettty(const char *); __END_DECLS #endif /* !_TTYENT_H_ */ diff --git a/include/unistd.h b/include/unistd.h index 8e44e472c6d6..337f6befd717 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,598 +1,597 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)unistd.h 8.12 (Berkeley) 4/27/95 - * $FreeBSD$ */ #ifndef _UNISTD_H_ #define _UNISTD_H_ #include #include /* XXX adds too much pollution. */ #include #include #include #ifndef _GID_T_DECLARED typedef __gid_t gid_t; #define _GID_T_DECLARED #endif #ifndef _OFF_T_DECLARED typedef __off_t off_t; #define _OFF_T_DECLARED #endif #ifndef _PID_T_DECLARED typedef __pid_t pid_t; #define _PID_T_DECLARED #endif #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif #ifndef _UID_T_DECLARED typedef __uid_t uid_t; #define _UID_T_DECLARED #endif #ifndef _USECONDS_T_DECLARED typedef __useconds_t useconds_t; #define _USECONDS_T_DECLARED #endif #define STDIN_FILENO 0 /* standard input file descriptor */ #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 #define F_ULOCK 0 /* unlock locked section */ #define F_LOCK 1 /* lock a section for exclusive use */ #define F_TLOCK 2 /* test and lock a section for exclusive use */ #define F_TEST 3 /* test a section for locks by other procs */ #endif /* * POSIX options and option groups we unconditionally do or don't * implement. This list includes those options which are exclusively * implemented (or not) in user mode. Please keep this list in * alphabetical order. * * Anything which is defined as zero below **must** have an * implementation for the corresponding sysconf() which is able to * determine conclusively whether or not the feature is supported. * Anything which is defined as other than -1 below **must** have * complete headers, types, and function declarations as specified by * the POSIX standard; however, if the relevant sysconf() function * returns -1, the functions may be stubbed out. */ #define _POSIX_BARRIERS 200112L #define _POSIX_CPUTIME 200112L #define _POSIX_READER_WRITER_LOCKS 200112L #define _POSIX_REGEXP 1 #define _POSIX_SHELL 1 #define _POSIX_SPAWN 200112L #define _POSIX_SPIN_LOCKS 200112L #define _POSIX_THREAD_ATTR_STACKADDR 200112L #define _POSIX_THREAD_ATTR_STACKSIZE 200112L #define _POSIX_THREAD_CPUTIME 200112L #define _POSIX_THREAD_PRIO_INHERIT 200112L #define _POSIX_THREAD_PRIO_PROTECT 200112L #define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L #define _POSIX_THREAD_PROCESS_SHARED 200112L #define _POSIX_THREAD_SAFE_FUNCTIONS -1 #define _POSIX_THREAD_SPORADIC_SERVER -1 #define _POSIX_THREADS 200112L #define _POSIX_TRACE -1 #define _POSIX_TRACE_EVENT_FILTER -1 #define _POSIX_TRACE_INHERIT -1 #define _POSIX_TRACE_LOG -1 #define _POSIX2_C_BIND 200112L /* mandatory */ #define _POSIX2_C_DEV -1 /* need c99 utility */ #define _POSIX2_CHAR_TERM 1 #define _POSIX2_FORT_DEV -1 /* need fort77 utility */ #define _POSIX2_FORT_RUN 200112L #define _POSIX2_LOCALEDEF -1 #define _POSIX2_PBS -1 #define _POSIX2_PBS_ACCOUNTING -1 #define _POSIX2_PBS_CHECKPOINT -1 #define _POSIX2_PBS_LOCATE -1 #define _POSIX2_PBS_MESSAGE -1 #define _POSIX2_PBS_TRACK -1 #define _POSIX2_SW_DEV -1 /* XXX ??? */ #define _POSIX2_UPE 200112L #define _V6_ILP32_OFF32 -1 #define _V6_ILP32_OFFBIG 0 #define _V6_LP64_OFF64 0 #define _V6_LPBIG_OFFBIG -1 #if __XSI_VISIBLE #define _XOPEN_CRYPT -1 /* XXX ??? */ #define _XOPEN_ENH_I18N -1 /* mandatory in XSI */ #define _XOPEN_LEGACY -1 #define _XOPEN_REALTIME -1 #define _XOPEN_REALTIME_THREADS -1 #define _XOPEN_UNIX -1 #endif /* Define the POSIX.2 version we target for compliance. */ #define _POSIX2_VERSION 199212L /* * POSIX-style system configuration variable accessors (for the * sysconf function). The kernel does not directly implement the * sysconf() interface; rather, a C library stub translates references * to sysconf() into calls to sysctl() using a giant switch statement. * Those that are marked `user' are implemented entirely in the C * library and never query the kernel. pathconf() is implemented * directly by the kernel so those are not defined here. */ #define _SC_ARG_MAX 1 #define _SC_CHILD_MAX 2 #define _SC_CLK_TCK 3 #define _SC_NGROUPS_MAX 4 #define _SC_OPEN_MAX 5 #define _SC_JOB_CONTROL 6 #define _SC_SAVED_IDS 7 #define _SC_VERSION 8 #define _SC_BC_BASE_MAX 9 /* user */ #define _SC_BC_DIM_MAX 10 /* user */ #define _SC_BC_SCALE_MAX 11 /* user */ #define _SC_BC_STRING_MAX 12 /* user */ #define _SC_COLL_WEIGHTS_MAX 13 /* user */ #define _SC_EXPR_NEST_MAX 14 /* user */ #define _SC_LINE_MAX 15 /* user */ #define _SC_RE_DUP_MAX 16 /* user */ #define _SC_2_VERSION 17 /* user */ #define _SC_2_C_BIND 18 /* user */ #define _SC_2_C_DEV 19 /* user */ #define _SC_2_CHAR_TERM 20 /* user */ #define _SC_2_FORT_DEV 21 /* user */ #define _SC_2_FORT_RUN 22 /* user */ #define _SC_2_LOCALEDEF 23 /* user */ #define _SC_2_SW_DEV 24 /* user */ #define _SC_2_UPE 25 /* user */ #define _SC_STREAM_MAX 26 /* user */ #define _SC_TZNAME_MAX 27 /* user */ #if __POSIX_VISIBLE >= 199309 #define _SC_ASYNCHRONOUS_IO 28 #define _SC_MAPPED_FILES 29 #define _SC_MEMLOCK 30 #define _SC_MEMLOCK_RANGE 31 #define _SC_MEMORY_PROTECTION 32 #define _SC_MESSAGE_PASSING 33 #define _SC_PRIORITIZED_IO 34 #define _SC_PRIORITY_SCHEDULING 35 #define _SC_REALTIME_SIGNALS 36 #define _SC_SEMAPHORES 37 #define _SC_FSYNC 38 #define _SC_SHARED_MEMORY_OBJECTS 39 #define _SC_SYNCHRONIZED_IO 40 #define _SC_TIMERS 41 #define _SC_AIO_LISTIO_MAX 42 #define _SC_AIO_MAX 43 #define _SC_AIO_PRIO_DELTA_MAX 44 #define _SC_DELAYTIMER_MAX 45 #define _SC_MQ_OPEN_MAX 46 #define _SC_PAGESIZE 47 #define _SC_RTSIG_MAX 48 #define _SC_SEM_NSEMS_MAX 49 #define _SC_SEM_VALUE_MAX 50 #define _SC_SIGQUEUE_MAX 51 #define _SC_TIMER_MAX 52 #endif #if __POSIX_VISIBLE >= 200112 #define _SC_2_PBS 59 /* user */ #define _SC_2_PBS_ACCOUNTING 60 /* user */ #define _SC_2_PBS_CHECKPOINT 61 /* user */ #define _SC_2_PBS_LOCATE 62 /* user */ #define _SC_2_PBS_MESSAGE 63 /* user */ #define _SC_2_PBS_TRACK 64 /* user */ #define _SC_ADVISORY_INFO 65 #define _SC_BARRIERS 66 /* user */ #define _SC_CLOCK_SELECTION 67 #define _SC_CPUTIME 68 #define _SC_FILE_LOCKING 69 #define _SC_GETGR_R_SIZE_MAX 70 /* user */ #define _SC_GETPW_R_SIZE_MAX 71 /* user */ #define _SC_HOST_NAME_MAX 72 #define _SC_LOGIN_NAME_MAX 73 #define _SC_MONOTONIC_CLOCK 74 #define _SC_MQ_PRIO_MAX 75 #define _SC_READER_WRITER_LOCKS 76 /* user */ #define _SC_REGEXP 77 /* user */ #define _SC_SHELL 78 /* user */ #define _SC_SPAWN 79 /* user */ #define _SC_SPIN_LOCKS 80 /* user */ #define _SC_SPORADIC_SERVER 81 #define _SC_THREAD_ATTR_STACKADDR 82 /* user */ #define _SC_THREAD_ATTR_STACKSIZE 83 /* user */ #define _SC_THREAD_CPUTIME 84 /* user */ #define _SC_THREAD_DESTRUCTOR_ITERATIONS 85 /* user */ #define _SC_THREAD_KEYS_MAX 86 /* user */ #define _SC_THREAD_PRIO_INHERIT 87 /* user */ #define _SC_THREAD_PRIO_PROTECT 88 /* user */ #define _SC_THREAD_PRIORITY_SCHEDULING 89 /* user */ #define _SC_THREAD_PROCESS_SHARED 90 /* user */ #define _SC_THREAD_SAFE_FUNCTIONS 91 /* user */ #define _SC_THREAD_SPORADIC_SERVER 92 /* user */ #define _SC_THREAD_STACK_MIN 93 /* user */ #define _SC_THREAD_THREADS_MAX 94 /* user */ #define _SC_TIMEOUTS 95 /* user */ #define _SC_THREADS 96 /* user */ #define _SC_TRACE 97 /* user */ #define _SC_TRACE_EVENT_FILTER 98 /* user */ #define _SC_TRACE_INHERIT 99 /* user */ #define _SC_TRACE_LOG 100 /* user */ #define _SC_TTY_NAME_MAX 101 /* user */ #define _SC_TYPED_MEMORY_OBJECTS 102 #define _SC_V6_ILP32_OFF32 103 /* user */ #define _SC_V6_ILP32_OFFBIG 104 /* user */ #define _SC_V6_LP64_OFF64 105 /* user */ #define _SC_V6_LPBIG_OFFBIG 106 /* user */ #define _SC_IPV6 118 #define _SC_RAW_SOCKETS 119 #define _SC_SYMLOOP_MAX 120 #endif #if __XSI_VISIBLE #define _SC_ATEXIT_MAX 107 /* user */ #define _SC_IOV_MAX 56 #define _SC_PAGE_SIZE _SC_PAGESIZE #define _SC_XOPEN_CRYPT 108 /* user */ #define _SC_XOPEN_ENH_I18N 109 /* user */ #define _SC_XOPEN_LEGACY 110 /* user */ #define _SC_XOPEN_REALTIME 111 #define _SC_XOPEN_REALTIME_THREADS 112 #define _SC_XOPEN_SHM 113 #define _SC_XOPEN_STREAMS 114 #define _SC_XOPEN_UNIX 115 #define _SC_XOPEN_VERSION 116 #define _SC_XOPEN_XCU_VERSION 117 /* user */ #endif #if __BSD_VISIBLE #define _SC_NPROCESSORS_CONF 57 #define _SC_NPROCESSORS_ONLN 58 #define _SC_CPUSET_SIZE 122 #endif /* Extensions found in Solaris and Linux. */ #define _SC_PHYS_PAGES 121 /* Keys for the confstr(3) function. */ #if __POSIX_VISIBLE >= 199209 #define _CS_PATH 1 /* default value of PATH */ #endif #if __POSIX_VISIBLE >= 200112 #define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 2 #define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 3 #define _CS_POSIX_V6_ILP32_OFF32_LIBS 4 #define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 5 #define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 6 #define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 7 #define _CS_POSIX_V6_LP64_OFF64_CFLAGS 8 #define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 9 #define _CS_POSIX_V6_LP64_OFF64_LIBS 10 #define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 11 #define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 12 #define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 13 #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 14 #endif __BEGIN_DECLS /* 1003.1-1990 */ void _exit(int) __dead2; int access(const char *, int); unsigned int alarm(unsigned int); int chdir(const char *); int chown(const char *, uid_t, gid_t); int close(int); void closefrom(int); int dup(int); int dup2(int, int); int execl(const char *, const char *, ...) __null_sentinel; int execle(const char *, const char *, ...); int execlp(const char *, const char *, ...) __null_sentinel; int execv(const char *, char * const *); int execve(const char *, char * const *, char * const *); int execvp(const char *, char * const *); pid_t fork(void); long fpathconf(int, int); char *getcwd(char *, size_t); gid_t getegid(void); uid_t geteuid(void); gid_t getgid(void); int getgroups(int, gid_t []); char *getlogin(void); pid_t getpgrp(void); pid_t getpid(void); pid_t getppid(void); uid_t getuid(void); int isatty(int); int link(const char *, const char *); #ifndef _LSEEK_DECLARED #define _LSEEK_DECLARED off_t lseek(int, off_t, int); #endif long pathconf(const char *, int); int pause(void); int pipe(int *); ssize_t read(int, void *, size_t); int rmdir(const char *); int setgid(gid_t); int setpgid(pid_t, pid_t); pid_t setsid(void); int setuid(uid_t); unsigned int sleep(unsigned int); long sysconf(int); pid_t tcgetpgrp(int); int tcsetpgrp(int, pid_t); char *ttyname(int); int ttyname_r(int, char *, size_t); int unlink(const char *); ssize_t write(int, const void *, size_t); /* 1003.2-1992 */ #if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE size_t confstr(int, char *, size_t); #ifndef _GETOPT_DECLARED #define _GETOPT_DECLARED int getopt(int, char * const [], const char *); extern char *optarg; /* getopt(3) external variables */ extern int optind, opterr, optopt; #endif /* _GETOPT_DECLARED */ #endif /* ISO/IEC 9945-1: 1996 */ #if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE int fsync(int); int fdatasync(int); /* * ftruncate() was in the POSIX Realtime Extension (it's used for shared * memory), but truncate() was not. */ #ifndef _FTRUNCATE_DECLARED #define _FTRUNCATE_DECLARED int ftruncate(int, off_t); #endif #endif #if __POSIX_VISIBLE >= 199506 int getlogin_r(char *, size_t); #endif /* 1003.1-2001 */ #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE int fchown(int, uid_t, gid_t); ssize_t readlink(const char * __restrict, char * __restrict, size_t); #endif #if __POSIX_VISIBLE >= 200112 int gethostname(char *, size_t); int setegid(gid_t); int seteuid(uid_t); #endif /* 1003.1-2008 */ #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE int getsid(pid_t _pid); int fchdir(int); int getpgid(pid_t _pid); int lchown(const char *, uid_t, gid_t); ssize_t pread(int, void *, size_t, off_t); ssize_t pwrite(int, const void *, size_t, off_t); /* See comment at ftruncate() above. */ #ifndef _TRUNCATE_DECLARED #define _TRUNCATE_DECLARED int truncate(const char *, off_t); #endif #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */ #if __POSIX_VISIBLE >= 200809 int faccessat(int, const char *, int, int); int fchownat(int, const char *, uid_t, gid_t, int); int fexecve(int, char *const [], char *const []); int linkat(int, const char *, int, const char *, int); ssize_t readlinkat(int, const char * __restrict, char * __restrict, size_t); int symlinkat(const char *, int, const char *); int unlinkat(int, const char *, int); #endif /* __POSIX_VISIBLE >= 200809 */ /* * symlink() was originally in POSIX.1a, which was withdrawn after * being overtaken by events (1003.1-2001). It was in XPG4.2, and of * course has been in BSD since 4.2. */ #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402 int symlink(const char * __restrict, const char * __restrict); #endif /* X/Open System Interfaces */ #if __XSI_VISIBLE char *crypt(const char *, const char *); long gethostid(void); int lockf(int, int, off_t); int nice(int); int setregid(gid_t, gid_t); int setreuid(uid_t, uid_t); #ifndef _SWAB_DECLARED #define _SWAB_DECLARED void swab(const void * __restrict, void * __restrict, ssize_t); #endif /* _SWAB_DECLARED */ void sync(void); #endif /* __XSI_VISIBLE */ #if (__XSI_VISIBLE && __XSI_VISIBLE <= 500) || __BSD_VISIBLE int brk(const void *); int chroot(const char *); int getdtablesize(void); int getpagesize(void) __pure2; char *getpass(const char *); void *sbrk(intptr_t); #endif #if (__XSI_VISIBLE && __XSI_VISIBLE <= 600) || __BSD_VISIBLE char *getwd(char *); /* obsoleted by getcwd() */ useconds_t ualarm(useconds_t, useconds_t); int usleep(useconds_t); pid_t vfork(void) __returns_twice; #endif #if __BSD_VISIBLE struct timeval; /* select(2) */ struct crypt_data { int initialized; /* For compatibility with glibc. */ char __buf[256]; /* Buffer returned by crypt_r(). */ }; int acct(const char *); int async_daemon(void); int check_utility_compat(const char *); int close_range(unsigned int, unsigned int, int); ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned int); const char * crypt_get_format(void); char *crypt_r(const char *, const char *, struct crypt_data *); int crypt_set_format(const char *); int dup3(int, int, int); int eaccess(const char *, int); void endusershell(void); int exect(const char *, char * const *, char * const *); int execvP(const char *, const char *, char * const *); int feature_present(const char *); char *fflagstostr(u_long); int getdomainname(char *, int); int getentropy(void *, size_t); int getgrouplist(const char *, gid_t, gid_t *, int *); int getloginclass(char *, size_t); mode_t getmode(const void *, mode_t); int getosreldate(void); int getpeereid(int, uid_t *, gid_t *); int getresgid(gid_t *, gid_t *, gid_t *); int getresuid(uid_t *, uid_t *, uid_t *); char *getusershell(void); int initgroups(const char *, gid_t); int iruserok(unsigned long, int, const char *, const char *); int iruserok_sa(const void *, int, int, const char *, const char *); int issetugid(void); void __FreeBSD_libc_enter_restricted_mode(void); long lpathconf(const char *, int); #ifndef _MKDTEMP_DECLARED char *mkdtemp(char *); #define _MKDTEMP_DECLARED #endif #ifndef _MKNOD_DECLARED int mknod(const char *, mode_t, dev_t); #define _MKNOD_DECLARED #endif #ifndef _MKSTEMP_DECLARED int mkstemp(char *); #define _MKSTEMP_DECLARED #endif int mkstemps(char *, int); #ifndef _MKTEMP_DECLARED char *mktemp(char *); #define _MKTEMP_DECLARED #endif int nfssvc(int, void *); int nlm_syscall(int, int, int, char **); int pipe2(int *, int); int profil(char *, size_t, vm_offset_t, int); int rcmd(char **, int, const char *, const char *, const char *, int *); int rcmd_af(char **, int, const char *, const char *, const char *, int *, int); int rcmdsh(char **, int, const char *, const char *, const char *, const char *); char *re_comp(const char *); int re_exec(const char *); int reboot(int); int revoke(const char *); pid_t rfork(int) __returns_twice; pid_t rfork_thread(int, void *, int (*)(void *), void *); int rresvport(int *); int rresvport_af(int *, int); int ruserok(const char *, int, const char *, const char *); #ifndef _SELECT_DECLARED #define _SELECT_DECLARED int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); #endif int setdomainname(const char *, int); int setgroups(int, const gid_t *); void sethostid(long); int sethostname(const char *, int); int setlogin(const char *); int setloginclass(const char *); void *setmode(const char *); int setpgrp(pid_t, pid_t); /* obsoleted by setpgid() */ void setproctitle(const char *_fmt, ...) __printf0like(1, 2); void setproctitle_fast(const char *_fmt, ...) __printf0like(1, 2); int setresgid(gid_t, gid_t, gid_t); int setresuid(uid_t, uid_t, uid_t); int setrgid(gid_t); int setruid(uid_t); void setusershell(void); int strtofflags(char **, u_long *, u_long *); int swapon(const char *); int swapoff(const char *, u_int); int syscall(int, ...); off_t __syscall(quad_t, ...); int undelete(const char *); int unwhiteout(const char *); void *valloc(size_t); /* obsoleted by malloc() */ int funlinkat(int, const char *, int, int); pid_t _Fork(void); #ifndef _OPTRESET_DECLARED #define _OPTRESET_DECLARED extern int optreset; /* getopt(3) external variable */ #endif #endif /* __BSD_VISIBLE */ __END_DECLS #endif /* !_UNISTD_H_ */ diff --git a/include/utime.h b/include/utime.h index ec1d28b93e31..0a9ef00aee8a 100644 --- a/include/utime.h +++ b/include/utime.h @@ -1,55 +1,54 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)utime.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _UTIME_H_ #define _UTIME_H_ #include #include #ifndef _TIME_T_DECLARED typedef __time_t time_t; #define _TIME_T_DECLARED #endif struct utimbuf { time_t actime; /* Access time */ time_t modtime; /* Modification time */ }; __BEGIN_DECLS int utime(const char *, const struct utimbuf *); __END_DECLS #endif /* !_UTIME_H_ */ diff --git a/include/wctype.h b/include/wctype.h index 5882615ce048..d823f97fc84a 100644 --- a/include/wctype.h +++ b/include/wctype.h @@ -1,127 +1,126 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c)1999 Citrus Project, * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp * $NetBSD: wctype.h,v 1.3 2000/12/22 14:16:16 itojun Exp $ - * $FreeBSD$ */ #ifndef _WCTYPE_H_ #define _WCTYPE_H_ #include #include #include <_ctype.h> #ifndef _WCTRANS_T typedef int wctrans_t; #define _WCTRANS_T #endif #ifndef _WCTYPE_T typedef unsigned long wctype_t; #define _WCTYPE_T #endif #ifndef _WINT_T_DECLARED typedef __wint_t wint_t; #define _WINT_T_DECLARED #endif #ifndef WEOF #define WEOF ((wint_t)-1) #endif __BEGIN_DECLS int iswalnum(wint_t); int iswalpha(wint_t); int iswblank(wint_t); int iswcntrl(wint_t); int iswctype(wint_t, wctype_t); int iswdigit(wint_t); int iswgraph(wint_t); int iswlower(wint_t); int iswprint(wint_t); int iswpunct(wint_t); int iswspace(wint_t); int iswupper(wint_t); int iswxdigit(wint_t); wint_t towctrans(wint_t, wctrans_t); wint_t towlower(wint_t); wint_t towupper(wint_t); wctrans_t wctrans(const char *); wctype_t wctype(const char *); #if __BSD_VISIBLE wint_t iswascii(wint_t); wint_t iswhexnumber(wint_t); wint_t iswideogram(wint_t); wint_t iswnumber(wint_t); wint_t iswphonogram(wint_t); wint_t iswrune(wint_t); wint_t iswspecial(wint_t); wint_t nextwctype(wint_t, wctype_t); #endif #if __POSIX_VISIBLE >= 200809 #define _XLOCALE_WCTYPES 1 #include #endif /* __POSIX_VISIBLE >= 200809 */ __END_DECLS #ifndef __cplusplus #define iswalnum(wc) __istype((wc), _CTYPE_A|_CTYPE_D|_CTYPE_N) #define iswalpha(wc) __istype((wc), _CTYPE_A) #define iswblank(wc) __istype((wc), _CTYPE_B) #define iswcntrl(wc) __istype((wc), _CTYPE_C) #define iswctype(wc, charclass) __istype((wc), (charclass)) #define iswdigit(wc) __istype((wc), _CTYPE_D) #define iswgraph(wc) __istype((wc), _CTYPE_G) #define iswlower(wc) __istype((wc), _CTYPE_L) #define iswprint(wc) __istype((wc), _CTYPE_R) #define iswpunct(wc) __istype((wc), _CTYPE_P) #define iswspace(wc) __istype((wc), _CTYPE_S) #define iswupper(wc) __istype((wc), _CTYPE_U) #define iswxdigit(wc) __istype((wc), _CTYPE_X) #define towlower(wc) __tolower(wc) #define towupper(wc) __toupper(wc) #if __BSD_VISIBLE #define iswascii(wc) (((wc) & ~0x7F) == 0) #define iswhexnumber(wc) __istype((wc), _CTYPE_X) /* alias of iswxdigit */ #define iswideogram(wc) __istype((wc), _CTYPE_I) #define iswnumber(wc) __istype((wc), _CTYPE_D|_CTYPE_N) #define iswphonogram(wc) __istype((wc), _CTYPE_Q) #define iswrune(wc) __istype((wc), 0xFFFFFF00L) #define iswspecial(wc) __istype((wc), _CTYPE_T) #endif /* __BSD_VISIBLE */ #endif /* __cplusplus */ #endif /* _WCTYPE_H_ */ diff --git a/lib/libbluetooth/bluetooth.c b/lib/libbluetooth/bluetooth.c index 8bd816d7e561..2f24e0865021 100644 --- a/lib/libbluetooth/bluetooth.c +++ b/lib/libbluetooth/bluetooth.c @@ -1,373 +1,372 @@ /* * bluetooth.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2009 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bluetooth.c,v 1.3 2003/05/20 23:04:30 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #define _PATH_BT_HOSTS "/etc/bluetooth/hosts" #define _PATH_BT_PROTOCOLS "/etc/bluetooth/protocols" #define MAXALIASES 35 static FILE *hostf = NULL; static int host_stayopen = 0; static struct hostent host; static bdaddr_t host_addr; static char *host_addr_ptrs[2]; static char *host_aliases[MAXALIASES]; static FILE *protof = NULL; static int proto_stayopen = 0; static struct protoent proto; static char *proto_aliases[MAXALIASES]; static char buf[BUFSIZ + 1]; static int bt_hex_byte (char const *str); static int bt_hex_nibble (char nibble); struct hostent * bt_gethostbyname(char const *name) { struct hostent *p; char **cp; bt_sethostent(host_stayopen); while ((p = bt_gethostent()) != NULL) { if (strcasecmp(p->h_name, name) == 0) break; for (cp = p->h_aliases; *cp != NULL; cp++) if (strcasecmp(*cp, name) == 0) goto found; } found: bt_endhostent(); return (p); } struct hostent * bt_gethostbyaddr(char const *addr, int len, int type) { struct hostent *p; if (type != AF_BLUETOOTH || len != sizeof(bdaddr_t)) { h_errno = NO_RECOVERY; return (NULL); } bt_sethostent(host_stayopen); while ((p = bt_gethostent()) != NULL) if (p->h_addrtype == type && bcmp(p->h_addr, addr, len) == 0) break; bt_endhostent(); return (p); } struct hostent * bt_gethostent(void) { char *p, *cp, **q; if (hostf == NULL) hostf = fopen(_PATH_BT_HOSTS, "r"); if (hostf == NULL) { h_errno = NETDB_INTERNAL; return (NULL); } again: if ((p = fgets(buf, sizeof(buf), hostf)) == NULL) { h_errno = HOST_NOT_FOUND; return (NULL); } if (*p == '#') goto again; if ((cp = strpbrk(p, "#\n")) == NULL) goto again; *cp = 0; if ((cp = strpbrk(p, " \t")) == NULL) goto again; *cp++ = 0; if (bt_aton(p, &host_addr) == 0) goto again; host_addr_ptrs[0] = (char *) &host_addr; host_addr_ptrs[1] = NULL; host.h_addr_list = host_addr_ptrs; host.h_length = sizeof(host_addr); host.h_addrtype = AF_BLUETOOTH; while (*cp == ' ' || *cp == '\t') cp++; host.h_name = cp; q = host.h_aliases = host_aliases; if ((cp = strpbrk(cp, " \t")) != NULL) *cp++ = 0; while (cp != NULL && *cp != 0) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &host_aliases[MAXALIASES - 1]) *q++ = cp; if ((cp = strpbrk(cp, " \t")) != NULL) *cp++ = 0; } *q = NULL; h_errno = NETDB_SUCCESS; return (&host); } void bt_sethostent(int stayopen) { if (hostf == NULL) hostf = fopen(_PATH_BT_HOSTS, "r"); else rewind(hostf); host_stayopen = stayopen; } void bt_endhostent(void) { if (hostf != NULL && host_stayopen == 0) { (void) fclose(hostf); hostf = NULL; } } struct protoent * bt_getprotobyname(char const *name) { struct protoent *p; char **cp; bt_setprotoent(proto_stayopen); while ((p = bt_getprotoent()) != NULL) { if (strcmp(p->p_name, name) == 0) break; for (cp = p->p_aliases; *cp != NULL; cp++) if (strcmp(*cp, name) == 0) goto found; } found: bt_endprotoent(); return (p); } struct protoent * bt_getprotobynumber(int proto) { struct protoent *p; bt_setprotoent(proto_stayopen); while ((p = bt_getprotoent()) != NULL) if (p->p_proto == proto) break; bt_endprotoent(); return (p); } struct protoent * bt_getprotoent(void) { char *p, *cp, **q; if (protof == NULL) protof = fopen(_PATH_BT_PROTOCOLS, "r"); if (protof == NULL) return (NULL); again: if ((p = fgets(buf, sizeof(buf), protof)) == NULL) return (NULL); if (*p == '#') goto again; if ((cp = strpbrk(p, "#\n")) == NULL) goto again; *cp = '\0'; proto.p_name = p; if ((cp = strpbrk(p, " \t")) == NULL) goto again; *cp++ = '\0'; while (*cp == ' ' || *cp == '\t') cp++; if ((p = strpbrk(cp, " \t")) != NULL) *p++ = '\0'; proto.p_proto = atoi(cp); q = proto.p_aliases = proto_aliases; if (p != NULL) { cp = p; while (cp != NULL && *cp != 0) { if (*cp == ' ' || *cp == '\t') { cp++; continue; } if (q < &proto_aliases[MAXALIASES - 1]) *q++ = cp; if ((cp = strpbrk(cp, " \t")) != NULL) *cp++ = '\0'; } } *q = NULL; return (&proto); } void bt_setprotoent(int stayopen) { if (protof == NULL) protof = fopen(_PATH_BT_PROTOCOLS, "r"); else rewind(protof); proto_stayopen = stayopen; } void bt_endprotoent(void) { if (protof != NULL) { (void) fclose(protof); protof = NULL; } } char const * bt_ntoa(bdaddr_t const *ba, char *str) { static char buffer[24]; if (str == NULL) str = buffer; sprintf(str, "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", ba->b[5], ba->b[4], ba->b[3], ba->b[2], ba->b[1], ba->b[0]); return (str); } int bt_aton(char const *str, bdaddr_t *ba) { int i, b; char *end = NULL; memset(ba, 0, sizeof(*ba)); for (i = 5, end = strchr(str, ':'); i > 0 && *str != '\0' && end != NULL; i --, str = end + 1, end = strchr(str, ':')) { switch (end - str) { case 1: b = bt_hex_nibble(str[0]); break; case 2: b = bt_hex_byte(str); break; default: b = -1; break; } if (b < 0) return (0); ba->b[i] = b; } if (i != 0 || end != NULL || *str == 0) return (0); switch (strlen(str)) { case 1: b = bt_hex_nibble(str[0]); break; case 2: b = bt_hex_byte(str); break; default: b = -1; break; } if (b < 0) return (0); ba->b[i] = b; return (1); } static int bt_hex_byte(char const *str) { int n1, n2; if ((n1 = bt_hex_nibble(str[0])) < 0) return (-1); if ((n2 = bt_hex_nibble(str[1])) < 0) return (-1); return ((((n1 & 0x0f) << 4) | (n2 & 0x0f)) & 0xff); } static int bt_hex_nibble(char nibble) { if ('0' <= nibble && nibble <= '9') return (nibble - '0'); if ('a' <= nibble && nibble <= 'f') return (nibble - 'a' + 0xa); if ('A' <= nibble && nibble <= 'F') return (nibble - 'A' + 0xa); return (-1); } diff --git a/lib/libbluetooth/bluetooth.h b/lib/libbluetooth/bluetooth.h index dee52c18a5de..52f402ce209c 100644 --- a/lib/libbluetooth/bluetooth.h +++ b/lib/libbluetooth/bluetooth.h @@ -1,231 +1,230 @@ /* * bluetooth.h */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2009 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bluetooth.h,v 1.5 2003/09/14 23:28:42 max Exp $ - * $FreeBSD$ */ #ifndef _BLUETOOTH_H_ #define _BLUETOOTH_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include __BEGIN_DECLS /* * Linux BlueZ compatibility */ #define bacmp(ba1, ba2) memcmp((ba1), (ba2), sizeof(bdaddr_t)) #define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t)) #define ba2str(ba, str) bt_ntoa((ba), (str)) #define str2ba(str, ba) (bt_aton((str), (ba)) == 1? 0 : -1) #define htobs(d) htole16(d) #define htobl(d) htole32(d) #define btohs(d) le16toh(d) #define btohl(d) le32toh(d) /* * Interface to the outside world */ struct hostent * bt_gethostbyname (char const *name); struct hostent * bt_gethostbyaddr (char const *addr, int len, int type); struct hostent * bt_gethostent (void); void bt_sethostent (int stayopen); void bt_endhostent (void); struct protoent * bt_getprotobyname (char const *name); struct protoent * bt_getprotobynumber (int proto); struct protoent * bt_getprotoent (void); void bt_setprotoent (int stayopen); void bt_endprotoent (void); char const * bt_ntoa (bdaddr_t const *ba, char *str); int bt_aton (char const *str, bdaddr_t *ba); /* bt_devXXXX() functions (inspired by NetBSD) */ int bt_devaddr (char const *devname, bdaddr_t *addr); int bt_devname (char *devname, bdaddr_t const *addr); /* * Bluetooth HCI functions */ #define HCI_DEVMAX 32 /* arbitrary */ #define HCI_DEVNAME_SIZE NG_NODESIZ #define HCI_DEVFEATURES_SIZE NG_HCI_FEATURES_SIZE struct bt_devinfo { char devname[HCI_DEVNAME_SIZE]; uint32_t state; /* device/implementation specific */ bdaddr_t bdaddr; uint16_t _reserved0; uint8_t features[HCI_DEVFEATURES_SIZE]; /* buffer info */ uint16_t _reserved1; uint16_t cmd_free; uint16_t sco_size; uint16_t sco_pkts; uint16_t sco_free; uint16_t acl_size; uint16_t acl_pkts; uint16_t acl_free; /* stats */ uint32_t cmd_sent; uint32_t evnt_recv; uint32_t acl_recv; uint32_t acl_sent; uint32_t sco_recv; uint32_t sco_sent; uint32_t bytes_recv; uint32_t bytes_sent; /* misc/specific */ uint16_t link_policy_info; uint16_t packet_type_info; uint16_t role_switch_info; uint16_t debug; uint8_t _padding[20]; /* leave space for future additions */ }; struct bt_devreq { uint16_t opcode; uint8_t event; void *cparam; size_t clen; void *rparam; size_t rlen; }; struct bt_devfilter { bitstr_t bit_decl(packet_mask, 8); bitstr_t bit_decl(event_mask, 256); }; struct bt_devinquiry { bdaddr_t bdaddr; uint8_t pscan_rep_mode; uint8_t pscan_period_mode; uint8_t dev_class[3]; uint16_t clock_offset; int8_t rssi; uint8_t data[240]; }; typedef int (bt_devenum_cb_t)(int, struct bt_devinfo const *, void *); int bt_devopen (char const *devname); int bt_devclose(int s); int bt_devsend (int s, uint16_t opcode, void *param, size_t plen); ssize_t bt_devrecv (int s, void *buf, size_t size, time_t to); int bt_devreq (int s, struct bt_devreq *r, time_t to); int bt_devfilter(int s, struct bt_devfilter const *newp, struct bt_devfilter *oldp); void bt_devfilter_pkt_set(struct bt_devfilter *filter, uint8_t type); void bt_devfilter_pkt_clr(struct bt_devfilter *filter, uint8_t type); int bt_devfilter_pkt_tst(struct bt_devfilter const *filter, uint8_t type); void bt_devfilter_evt_set(struct bt_devfilter *filter, uint8_t event); void bt_devfilter_evt_clr(struct bt_devfilter *filter, uint8_t event); int bt_devfilter_evt_tst(struct bt_devfilter const *filter, uint8_t event); int bt_devinquiry(char const *devname, time_t length, int num_rsp, struct bt_devinquiry **ii); char * bt_devremote_name(char const *devname, const bdaddr_t *remote, time_t to, uint16_t clk_off, uint8_t ps_rep_mode, uint8_t ps_mode); int bt_devinfo (struct bt_devinfo *di); int bt_devenum (bt_devenum_cb_t cb, void *arg); static __inline char * bt_devremote_name_gen(char const *btooth_devname, const bdaddr_t *remote) { return (bt_devremote_name(btooth_devname, remote, 0, 0x0000, NG_HCI_SCAN_REP_MODE0, NG_HCI_MANDATORY_PAGE_SCAN_MODE)); } /* * bdaddr utility functions (from NetBSD) */ static __inline int bdaddr_same(const bdaddr_t *a, const bdaddr_t *b) { return (a->b[0] == b->b[0] && a->b[1] == b->b[1] && a->b[2] == b->b[2] && a->b[3] == b->b[3] && a->b[4] == b->b[4] && a->b[5] == b->b[5]); } static __inline int bdaddr_any(const bdaddr_t *a) { return (a->b[0] == 0 && a->b[1] == 0 && a->b[2] == 0 && a->b[3] == 0 && a->b[4] == 0 && a->b[5] == 0); } static __inline void bdaddr_copy(bdaddr_t *d, const bdaddr_t *s) { d->b[0] = s->b[0]; d->b[1] = s->b[1]; d->b[2] = s->b[2]; d->b[3] = s->b[3]; d->b[4] = s->b[4]; d->b[5] = s->b[5]; } __END_DECLS #endif /* ndef _BLUETOOTH_H_ */ diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map index 0a5d8782d3ac..7f5b9ee9b56c 100644 --- a/lib/libc/aarch64/Symbol.map +++ b/lib/libc/aarch64/Symbol.map @@ -1,37 +1,36 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; .mcount; _setjmp; _longjmp; fabs; __flt_rounds; fpgetmask; fpsetmask; __infinity; __nan; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; vfork; makecontext; }; FBSDprivate_1.0 { __makecontext; }; diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h index 3adc0b7fb655..c2c8ef8a56ef 100644 --- a/lib/libc/amd64/SYS.h +++ b/lib/libc/amd64/SYS.h @@ -1,54 +1,53 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * William Jolitz. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $FreeBSD$ */ #include #include #define RSYSCALL(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ mov $SYS_##name,%eax; KERNCALL; \ jb HIDENAME(cerror); ret; \ END(__sys_##name) #define PSEUDO(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ mov $SYS_##name,%eax; KERNCALL; \ jb HIDENAME(cerror); ret; \ END(__sys_##name) #define KERNCALL movq %rcx, %r10; syscall diff --git a/lib/libc/amd64/Symbol.map b/lib/libc/amd64/Symbol.map index 297792eb0e82..39a913bd5e84 100644 --- a/lib/libc/amd64/Symbol.map +++ b/lib/libc/amd64/Symbol.map @@ -1,71 +1,70 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; .mcount; _setjmp; _longjmp; fabs; __flt_rounds; fpgetmask; fpgetprec; fpgetround; fpgetsticky; fpsetmask; fpsetprec; fpsetround; __infinity; __nan; makecontext; rfork_thread; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; amd64_get_fsbase; amd64_get_gsbase; amd64_set_fsbase; amd64_set_gsbase; brk; sbrk; vfork; }; FBSD_1.6 { x86_pkru_get_perm; x86_pkru_set_perm; x86_pkru_protect_range; x86_pkru_unprotect_range; }; /* * * FreeBSD private ABI * */ FBSDprivate_1.0 { /* PSEUDO syscalls */ _getlogin; ___longjmp; __makecontext; __longjmp; __signalcontext; signalcontext; __siglongjmp; _brk; _vfork; }; diff --git a/lib/libc/arm/SYS.h b/lib/libc/arm/SYS.h index 2e88cde8b43c..97e37d6aca7d 100644 --- a/lib/libc/arm/SYS.h +++ b/lib/libc/arm/SYS.h @@ -1,81 +1,80 @@ /* $NetBSD: SYS.h,v 1.8 2003/08/07 16:42:02 agc Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * William Jolitz. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $FreeBSD$ */ #include #include #define SYSTRAP(x) \ mov ip, r7; \ ldr r7, =SYS_ ## x; \ swi 0; \ mov r7, ip #define CERROR _C_LABEL(cerror) #define CURBRK _C_LABEL(curbrk) #define _SYSCALL_NOERROR(x) \ ENTRY(__CONCAT(__sys_, x)); \ .weak _C_LABEL(x); \ .set _C_LABEL(x), _C_LABEL(__CONCAT(__sys_,x)); \ .weak _C_LABEL(__CONCAT(_,x)); \ .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \ SYSTRAP(x) #define _SYSCALL(x) \ _SYSCALL_NOERROR(x); \ it cs; \ bcs PIC_SYM(CERROR, PLT) #define SYSCALL(x) \ _SYSCALL(x) #define PSEUDO(x) \ ENTRY(__CONCAT(__sys_, x)); \ .weak _C_LABEL(__CONCAT(_,x)); \ .set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \ SYSTRAP(x); \ it cs; \ bcs PIC_SYM(CERROR, PLT); \ RET #define RSYSCALL(x) \ _SYSCALL(x); \ RET .globl CERROR diff --git a/lib/libc/arm/Symbol.map b/lib/libc/arm/Symbol.map index 61c7ccc070f2..7b3d173d72ed 100644 --- a/lib/libc/arm/Symbol.map +++ b/lib/libc/arm/Symbol.map @@ -1,65 +1,64 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; __mcount; _setjmp; _longjmp; alloca; fabs; __infinity; __nan; makecontext; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; vfork; brk; sbrk; }; FBSD_1.3 { __flt_rounds; }; FBSD_1.4 { __gnu_Unwind_Find_exidx; dl_unwind_find_exidx; }; FBSD_1.6 { arm_drain_writebuf; arm_sync_icache; }; FBSDprivate_1.0 { /* PSEUDO syscalls */ _getlogin; __aeabi_read_tp; ___longjmp; __makecontext; __longjmp; signalcontext; _signalcontext; __siglongjmp; _vfork; _brk; _sbrk; _libc_arm_fpu_present; }; diff --git a/lib/libc/arm/Symbol_vfp.map b/lib/libc/arm/Symbol_vfp.map index 692b72f544cb..29d2b66af1bc 100644 --- a/lib/libc/arm/Symbol_vfp.map +++ b/lib/libc/arm/Symbol_vfp.map @@ -1,15 +1,14 @@ /* - * $FreeBSD$ */ FBSD_1.0 { fpgetmask; fpgetround; fpsetmask; fpsetround; }; FBSD_1.5 { fpgetsticky; fpsetsticky; }; diff --git a/lib/libc/arm/aeabi/Symbol.map b/lib/libc/arm/aeabi/Symbol.map index 4a08d31d601b..823e4ad0d79d 100644 --- a/lib/libc/arm/aeabi/Symbol.map +++ b/lib/libc/arm/aeabi/Symbol.map @@ -1,79 +1,78 @@ /* - * $FreeBSD$ */ /* * This only needs to contain AEABI symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSDprivate_1.0 { __aeabi_atexit; __aeabi_dcmpeq; __aeabi_dcmplt; __aeabi_dcmple; __aeabi_dcmpge; __aeabi_dcmpgt; __aeabi_dcmpun; __aeabi_cdcmpeq; __aeabi_cdcmple; __aeabi_cdrcmple; __aeabi_d2iz; __aeabi_d2f; __aeabi_dadd; __aeabi_ddiv; __aeabi_dmul; __aeabi_dsub; __aeabi_fcmpeq; __aeabi_fcmplt; __aeabi_fcmple; __aeabi_fcmpge; __aeabi_fcmpgt; __aeabi_fcmpun; __aeabi_cfcmpeq; __aeabi_cfcmple; __aeabi_cfrcmple; __aeabi_f2iz; __aeabi_f2d; __aeabi_fadd; __aeabi_fdiv; __aeabi_fmul; __aeabi_fsub; __aeabi_i2d; __aeabi_i2f; __aeabi_memclr; __aeabi_memclr4; __aeabi_memclr8; __aeabi_memcmp; __aeabi_memcmp4; __aeabi_memcmp8; __aeabi_memcpy; __aeabi_memcpy4; __aeabi_memcpy8; __aeabi_memmove; __aeabi_memmove4; __aeabi_memmove8; __aeabi_memset; __aeabi_memset4; __aeabi_memset8; /* * A workaround for DEFINE_AEABI_FUNCTION_ALIAS() bug. * - see aeabi_int_div.S */ __aeabi_idiv; __aeabi_uidiv; }; diff --git a/lib/libc/capability/Symbol.map b/lib/libc/capability/Symbol.map index c5c18c2f5315..65e112348012 100644 --- a/lib/libc/capability/Symbol.map +++ b/lib/libc/capability/Symbol.map @@ -1,14 +1,13 @@ /* - * $FreeBSD$ */ FBSD_1.3 { __cap_rights_clear; cap_rights_contains; __cap_rights_init; __cap_rights_is_set; cap_rights_is_valid; cap_rights_merge; cap_rights_remove; __cap_rights_set; }; diff --git a/lib/libc/compat-43/Symbol.map b/lib/libc/compat-43/Symbol.map index bd49f99e2df6..588a693dabb7 100644 --- a/lib/libc/compat-43/Symbol.map +++ b/lib/libc/compat-43/Symbol.map @@ -1,31 +1,30 @@ /* - * $FreeBSD$ */ FBSD_1.0 { creat; gethostid; getwd; killpg; sethostid; setpgrp; setrgid; setruid; sigblock; sigpause; sigsetmask; sigvec; }; FBSD_1.2 { sighold; sigignore; sigrelse; sigset; xsi_sigpause; }; FBSDprivate_1.0 { __creat; _creat; }; diff --git a/lib/libc/db/Symbol.map b/lib/libc/db/Symbol.map index 225fd401cb57..cb00d6bd1290 100644 --- a/lib/libc/db/Symbol.map +++ b/lib/libc/db/Symbol.map @@ -1,36 +1,35 @@ /* - * $FreeBSD$ */ FBSD_1.0 { dbopen; dbm_open; dbm_close; dbm_fetch; dbm_firstkey; dbm_nextkey; dbm_delete; dbm_store; dbm_error; dbm_clearerr; dbm_dirfno; mpool_open; mpool_filter; mpool_get; mpool_put; mpool_close; mpool_sync; mpool_stat; }; FBSD_1.1 { mpool_new; mpool_delete; }; FBSDprivate_1.0 { __bt_open; __dbpanic; __hash_open; __rec_open; }; diff --git a/lib/libc/db/btree/btree.h b/lib/libc/db/btree/btree.h index 1db1e3485717..4b167652e37e 100644 --- a/lib/libc/db/btree/btree.h +++ b/lib/libc/db/btree/btree.h @@ -1,382 +1,381 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Mike Olson. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)btree.h 8.11 (Berkeley) 8/17/94 - * $FreeBSD$ */ /* Macros to set/clear/test flags. */ #define F_SET(p, f) (p)->flags |= (f) #define F_CLR(p, f) (p)->flags &= ~(f) #define F_ISSET(p, f) ((p)->flags & (f)) #include #define DEFMINKEYPAGE (2) /* Minimum keys per page */ #define MINCACHE (5) /* Minimum cached pages */ #define MINPSIZE (512) /* Minimum page size */ /* * Page 0 of a btree file contains a copy of the meta-data. This page is also * used as an out-of-band page, i.e. page pointers that point to nowhere point * to page 0. Page 1 is the root of the btree. */ #define P_INVALID 0 /* Invalid tree page number. */ #define P_META 0 /* Tree metadata page number. */ #define P_ROOT 1 /* Tree root page number. */ /* * There are five page layouts in the btree: btree internal pages (BINTERNAL), * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages * (RLEAF) and overflow pages. All five page types have a page header (PAGE). * This implementation requires that values within structures NOT be padded. * (ANSI C permits random padding.) If your compiler pads randomly you'll have * to do some work to get this package to run. */ typedef struct _page { pgno_t pgno; /* this page's page number */ pgno_t prevpg; /* left sibling */ pgno_t nextpg; /* right sibling */ #define P_BINTERNAL 0x01 /* btree internal page */ #define P_BLEAF 0x02 /* leaf page */ #define P_OVERFLOW 0x04 /* overflow page */ #define P_RINTERNAL 0x08 /* recno internal page */ #define P_RLEAF 0x10 /* leaf page */ #define P_TYPE 0x1f /* type mask */ #define P_PRESERVE 0x20 /* never delete this chain of pages */ u_int32_t flags; indx_t lower; /* lower bound of free space on page */ indx_t upper; /* upper bound of free space on page */ indx_t linp[1]; /* indx_t-aligned VAR. LENGTH DATA */ } PAGE; /* First and next index. */ #define BTDATAOFF \ (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t)) #define NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) /* * For pages other than overflow pages, there is an array of offsets into the * rest of the page immediately following the page header. Each offset is to * an item which is unique to the type of page. The h_lower offset is just * past the last filled-in index. The h_upper offset is the first item on the * page. Offsets are from the beginning of the page. * * If an item is too big to store on a single page, a flag is set and the item * is a { page, size } pair such that the page is the first page of an overflow * chain with size bytes of item. Overflow pages are simply bytes without any * external structure. * * The page number and size fields in the items are pgno_t-aligned so they can * be manipulated without copying. (This presumes that 32 bit items can be * manipulated on this system.) */ #define LALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) #define NOVFLSIZE (sizeof(pgno_t) + sizeof(u_int32_t)) /* * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} * pairs, such that the key compares less than or equal to all of the records * on that page. For a tree without duplicate keys, an internal page with two * consecutive keys, a and b, will have all records greater than or equal to a * and less than b stored on the page associated with a. Duplicate keys are * somewhat special and can cause duplicate internal and leaf page records and * some minor modifications of the above rule. */ typedef struct _binternal { u_int32_t ksize; /* key size */ pgno_t pgno; /* page number stored on */ #define P_BIGDATA 0x01 /* overflow data */ #define P_BIGKEY 0x02 /* overflow key */ u_char flags; char bytes[1]; /* data */ } BINTERNAL; /* Get the page's BINTERNAL structure at index indx. */ #define GETBINTERNAL(pg, indx) \ ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx])) /* Get the number of bytes in the entry. */ #define NBINTERNAL(len) \ LALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) /* Copy a BINTERNAL entry to the page. */ #define WR_BINTERNAL(p, size, pgno, flags) { \ *(u_int32_t *)p = size; \ p += sizeof(u_int32_t); \ *(pgno_t *)p = pgno; \ p += sizeof(pgno_t); \ *(u_char *)p = flags; \ p += sizeof(u_char); \ } /* * For the recno internal pages, the item is a page number with the number of * keys found on that page and below. */ typedef struct _rinternal { recno_t nrecs; /* number of records */ pgno_t pgno; /* page number stored below */ } RINTERNAL; /* Get the page's RINTERNAL structure at index indx. */ #define GETRINTERNAL(pg, indx) \ ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx])) /* Get the number of bytes in the entry. */ #define NRINTERNAL \ LALIGN(sizeof(recno_t) + sizeof(pgno_t)) /* Copy a RINTERAL entry to the page. */ #define WR_RINTERNAL(p, nrecs, pgno) { \ *(recno_t *)p = nrecs; \ p += sizeof(recno_t); \ *(pgno_t *)p = pgno; \ } /* For the btree leaf pages, the item is a key and data pair. */ typedef struct _bleaf { u_int32_t ksize; /* size of key */ u_int32_t dsize; /* size of data */ u_char flags; /* P_BIGDATA, P_BIGKEY */ char bytes[1]; /* data */ } BLEAF; /* Get the page's BLEAF structure at index indx. */ #define GETBLEAF(pg, indx) \ ((BLEAF *)((char *)(pg) + (pg)->linp[indx])) /* Get the number of bytes in the entry. */ #define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) /* Get the number of bytes in the user's key/data pair. */ #define NBLEAFDBT(ksize, dsize) \ LALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) + \ (ksize) + (dsize)) /* Copy a BLEAF entry to the page. */ #define WR_BLEAF(p, key, data, flags) { \ *(u_int32_t *)p = key->size; \ p += sizeof(u_int32_t); \ *(u_int32_t *)p = data->size; \ p += sizeof(u_int32_t); \ *(u_char *)p = flags; \ p += sizeof(u_char); \ memmove(p, key->data, key->size); \ p += key->size; \ memmove(p, data->data, data->size); \ } /* For the recno leaf pages, the item is a data entry. */ typedef struct _rleaf { u_int32_t dsize; /* size of data */ u_char flags; /* P_BIGDATA */ char bytes[1]; } RLEAF; /* Get the page's RLEAF structure at index indx. */ #define GETRLEAF(pg, indx) \ ((RLEAF *)((char *)(pg) + (pg)->linp[indx])) /* Get the number of bytes in the entry. */ #define NRLEAF(p) NRLEAFDBT((p)->dsize) /* Get the number of bytes from the user's data. */ #define NRLEAFDBT(dsize) \ LALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize)) /* Copy a RLEAF entry to the page. */ #define WR_RLEAF(p, data, flags) { \ *(u_int32_t *)p = data->size; \ p += sizeof(u_int32_t); \ *(u_char *)p = flags; \ p += sizeof(u_char); \ memmove(p, data->data, data->size); \ } /* * A record in the tree is either a pointer to a page and an index in the page * or a page number and an index. These structures are used as a cursor, stack * entry and search returns as well as to pass records to other routines. * * One comment about searches. Internal page searches must find the largest * record less than key in the tree so that descents work. Leaf page searches * must find the smallest record greater than key so that the returned index * is the record's correct position for insertion. */ typedef struct _epgno { pgno_t pgno; /* the page number */ indx_t index; /* the index on the page */ } EPGNO; typedef struct _epg { PAGE *page; /* the (pinned) page */ indx_t index; /* the index on the page */ } EPG; /* * About cursors. The cursor (and the page that contained the key/data pair * that it referenced) can be deleted, which makes things a bit tricky. If * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set * or there simply aren't any duplicates of the key) we copy the key that it * referenced when it's deleted, and reacquire a new cursor key if the cursor * is used again. If there are duplicates keys, we move to the next/previous * key, and set a flag so that we know what happened. NOTE: if duplicate (to * the cursor) keys are added to the tree during this process, it is undefined * if they will be returned or not in a cursor scan. * * The flags determine the possible states of the cursor: * * CURS_INIT The cursor references *something*. * CURS_ACQUIRE The cursor was deleted, and a key has been saved so that * we can reacquire the right position in the tree. * CURS_AFTER, CURS_BEFORE * The cursor was deleted, and now references a key/data pair * that has not yet been returned, either before or after the * deleted key/data pair. * XXX * This structure is broken out so that we can eventually offer multiple * cursors as part of the DB interface. */ typedef struct _cursor { EPGNO pg; /* B: Saved tree reference. */ DBT key; /* B: Saved key, or key.data == NULL. */ recno_t rcursor; /* R: recno cursor (1-based) */ #define CURS_ACQUIRE 0x01 /* B: Cursor needs to be reacquired. */ #define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ #define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ #define CURS_INIT 0x08 /* RB: Cursor initialized. */ u_int8_t flags; } CURSOR; /* * The metadata of the tree. The nrecs field is used only by the RECNO code. * This is because the btree doesn't really need it and it requires that every * put or delete call modify the metadata. */ typedef struct _btmeta { u_int32_t magic; /* magic number */ u_int32_t version; /* version */ u_int32_t psize; /* page size */ u_int32_t free; /* page number of first free page */ u_int32_t nrecs; /* R: number of records */ #define SAVEMETA (B_NODUPS | R_RECNO) u_int32_t flags; /* bt_flags & SAVEMETA */ } BTMETA; /* The in-memory btree/recno data structure. */ typedef struct _btree { MPOOL *bt_mp; /* memory pool cookie */ DB *bt_dbp; /* pointer to enclosing DB */ EPG bt_cur; /* current (pinned) page */ PAGE *bt_pinned; /* page pinned across calls */ CURSOR bt_cursor; /* cursor */ #define BT_PUSH(t, p, i) { \ t->bt_sp->pgno = p; \ t->bt_sp->index = i; \ ++t->bt_sp; \ } #define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL : --t->bt_sp) #define BT_CLR(t) (t->bt_sp = t->bt_stack) EPGNO bt_stack[50]; /* stack of parent pages */ EPGNO *bt_sp; /* current stack pointer */ DBT bt_rkey; /* returned key */ DBT bt_rdata; /* returned data */ int bt_fd; /* tree file descriptor */ pgno_t bt_free; /* next free page */ u_int32_t bt_psize; /* page size */ indx_t bt_ovflsize; /* cut-off for key/data overflow */ int bt_lorder; /* byte order */ /* sorted order */ enum { NOT, BACK, FORWARD } bt_order; EPGNO bt_last; /* last insert */ /* B: key comparison function */ int (*bt_cmp)(const DBT *, const DBT *); /* B: prefix comparison function */ size_t (*bt_pfx)(const DBT *, const DBT *); /* R: recno input function */ int (*bt_irec)(struct _btree *, recno_t); FILE *bt_rfp; /* R: record FILE pointer */ int bt_rfd; /* R: record file descriptor */ caddr_t bt_cmap; /* R: current point in mapped space */ caddr_t bt_smap; /* R: start of mapped space */ caddr_t bt_emap; /* R: end of mapped space */ size_t bt_msize; /* R: size of mapped region. */ recno_t bt_nrecs; /* R: number of records */ size_t bt_reclen; /* R: fixed record length */ u_char bt_bval; /* R: delimiting byte/pad character */ /* * NB: * B_NODUPS and R_RECNO are stored on disk, and may not be changed. */ #define B_INMEM 0x00001 /* in-memory tree */ #define B_METADIRTY 0x00002 /* need to write metadata */ #define B_MODIFIED 0x00004 /* tree modified */ #define B_NEEDSWAP 0x00008 /* if byte order requires swapping */ #define B_RDONLY 0x00010 /* read-only tree */ #define B_NODUPS 0x00020 /* no duplicate keys permitted */ #define R_RECNO 0x00080 /* record oriented tree */ #define R_CLOSEFP 0x00040 /* opened a file pointer */ #define R_EOF 0x00100 /* end of input file reached. */ #define R_FIXLEN 0x00200 /* fixed length records */ #define R_MEMMAPPED 0x00400 /* memory mapped file. */ #define R_INMEM 0x00800 /* in-memory file */ #define R_MODIFIED 0x01000 /* modified file */ #define R_RDONLY 0x02000 /* read-only file */ #define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ #define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ #define B_DB_TXN 0x10000 /* DB_TXN specified. */ u_int32_t flags; } BTREE; #include "extern.h" diff --git a/lib/libc/db/btree/extern.h b/lib/libc/db/btree/extern.h index 581504cc6833..023d9ffe49bd 100644 --- a/lib/libc/db/btree/extern.h +++ b/lib/libc/db/btree/extern.h @@ -1,69 +1,68 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.10 (Berkeley) 7/20/94 - * $FreeBSD$ */ int __bt_close(DB *); int __bt_cmp(BTREE *, const DBT *, EPG *); int __bt_crsrdel(BTREE *, EPGNO *); int __bt_defcmp(const DBT *, const DBT *); size_t __bt_defpfx(const DBT *, const DBT *); int __bt_delete(const DB *, const DBT *, u_int); int __bt_dleaf(BTREE *, const DBT *, PAGE *, u_int); int __bt_fd(const DB *); int __bt_free(BTREE *, PAGE *); int __bt_get(const DB *, const DBT *, DBT *, u_int); PAGE *__bt_new(BTREE *, pgno_t *); void __bt_pgin(void *, pgno_t, void *); void __bt_pgout(void *, pgno_t, void *); int __bt_push(BTREE *, pgno_t, int); int __bt_put(const DB *dbp, DBT *, const DBT *, u_int); int __bt_ret(BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int); EPG *__bt_search(BTREE *, const DBT *, int *); int __bt_seq(const DB *, DBT *, DBT *, u_int); void __bt_setcur(BTREE *, pgno_t, u_int); int __bt_split(BTREE *, PAGE *, const DBT *, const DBT *, int, size_t, u_int32_t); int __bt_sync(const DB *, u_int); int __ovfl_delete(BTREE *, void *); int __ovfl_get(BTREE *, void *, size_t *, void **, size_t *); int __ovfl_put(BTREE *, const DBT *, pgno_t *); #ifdef DEBUG void __bt_dnpage(DB *, pgno_t); void __bt_dpage(PAGE *); void __bt_dump(DB *); #endif #ifdef STATISTICS void __bt_stat(DB *); #endif diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h index e938f9123914..181b2b80c8a3 100644 --- a/lib/libc/db/hash/extern.h +++ b/lib/libc/db/hash/extern.h @@ -1,64 +1,63 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.4 (Berkeley) 6/16/94 - * $FreeBSD$ */ BUFHEAD *__add_ovflpage(HTAB *, BUFHEAD *); int __addel(HTAB *, BUFHEAD *, const DBT *, const DBT *); int __big_delete(HTAB *, BUFHEAD *); int __big_insert(HTAB *, BUFHEAD *, const DBT *, const DBT *); int __big_keydata(HTAB *, BUFHEAD *, DBT *, DBT *, int); int __big_return(HTAB *, BUFHEAD *, int, DBT *, int); int __big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *, int, u_int32_t, SPLIT_RETURN *); int __buf_free(HTAB *, int, int); void __buf_init(HTAB *, int); u_int32_t __call_hash(HTAB *, char *, int); int __delpair(HTAB *, BUFHEAD *, int); int __expand_table(HTAB *); int __find_bigpair(HTAB *, BUFHEAD *, int, char *, int); u_int16_t __find_last_page(HTAB *, BUFHEAD **); void __free_ovflpage(HTAB *, BUFHEAD *); BUFHEAD *__get_buf(HTAB *, u_int32_t, BUFHEAD *, int); int __get_page(HTAB *, char *, u_int32_t, int, int, int); int __ibitmap(HTAB *, int, int, int); u_int32_t __log2(u_int32_t); int __put_page(HTAB *, char *, u_int32_t, int, int); void __reclaim_buf(HTAB *, BUFHEAD *); int __split_page(HTAB *, u_int32_t, u_int32_t); /* Default hash routine. */ extern u_int32_t (*__default_hash)(const void *, size_t); #ifdef HASH_STATISTICS extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows; #endif diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h index 5d4f8d5e8735..2e77025c56e1 100644 --- a/lib/libc/db/hash/hash.h +++ b/lib/libc/db/hash/hash.h @@ -1,292 +1,291 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Margo Seltzer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)hash.h 8.3 (Berkeley) 5/31/94 - * $FreeBSD$ */ /* Operations */ typedef enum { HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT } ACTION; /* Buffer Management structures */ typedef struct _bufhead BUFHEAD; struct _bufhead { BUFHEAD *prev; /* LRU links */ BUFHEAD *next; /* LRU links */ BUFHEAD *ovfl; /* Overflow page buffer header */ u_int32_t addr; /* Address of this page */ char *page; /* Actual page data */ char flags; #define BUF_MOD 0x0001 #define BUF_DISK 0x0002 #define BUF_BUCKET 0x0004 #define BUF_PIN 0x0008 }; #define IS_BUCKET(X) ((X) & BUF_BUCKET) typedef BUFHEAD **SEGMENT; /* Hash Table Information */ typedef struct hashhdr { /* Disk resident portion */ int32_t magic; /* Magic NO for hash tables */ int32_t version; /* Version ID */ u_int32_t lorder; /* Byte Order */ int32_t bsize; /* Bucket/Page Size */ int32_t bshift; /* Bucket shift */ int32_t dsize; /* Directory Size */ int32_t ssize; /* Segment Size */ int32_t sshift; /* Segment shift */ int32_t ovfl_point; /* Where overflow pages are being * allocated */ int32_t last_freed; /* Last overflow page freed */ u_int32_t max_bucket; /* ID of Maximum bucket in use */ u_int32_t high_mask; /* Mask to modulo into entire table */ u_int32_t low_mask; /* Mask to modulo into lower half of * table */ u_int32_t ffactor; /* Fill factor */ int32_t nkeys; /* Number of keys in hash table */ int32_t hdrpages; /* Size of table header */ int32_t h_charkey; /* value of hash(CHARKEY) */ #define NCACHED 32 /* number of bit maps and spare * points */ int32_t spares[NCACHED];/* spare pages for overflow */ u_int16_t bitmaps[NCACHED]; /* address of overflow page * bitmaps */ } HASHHDR; typedef struct htab { /* Memory resident data structure */ HASHHDR hdr; /* Header */ int nsegs; /* Number of allocated segments */ int exsegs; /* Number of extra allocated * segments */ u_int32_t /* Hash function */ (*hash)(const void *, size_t); int flags; /* Flag values */ int fp; /* File pointer */ char *tmp_buf; /* Temporary Buffer for BIG data */ char *tmp_key; /* Temporary Buffer for BIG keys */ BUFHEAD *cpage; /* Current page */ int cbucket; /* Current bucket */ int cndx; /* Index of next item on cpage */ int error; /* Error Number -- for DBM * compatibility */ int new_file; /* Indicates if fd is backing store * or no */ int save_file; /* Indicates whether we need to flush * file at * exit */ u_int32_t *mapp[NCACHED]; /* Pointers to page maps */ int nmaps; /* Initial number of bitmaps */ int nbufs; /* Number of buffers left to * allocate */ BUFHEAD bufhead; /* Header of buffer lru list */ SEGMENT *dir; /* Hash Bucket directory */ } HTAB; /* * Constants */ #define MAX_BSIZE 32768 /* 2^15 but should be 65536 */ #define MIN_BUFFERS 6 #define MINHDRSIZE 512 #define DEF_BUFSIZE 65536 /* 64 K */ #define DEF_BUCKET_SIZE 4096 #define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */ #define DEF_SEGSIZE 256 #define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ #define DEF_DIRSIZE 256 #define DEF_FFACTOR 65536 #define MIN_FFACTOR 4 #define SPLTMAX 8 #define CHARKEY "%$sniglet^&" #define NUMKEY 1038583 #define BYTE_SHIFT 3 #define INT_TO_BYTE 2 #define INT_BYTE_SHIFT 5 #define ALL_SET ((u_int32_t)0xFFFFFFFF) #define ALL_CLEAR 0 #define PTROF(X) ((BUFHEAD *)((intptr_t)(X)&~0x3)) #define ISMOD(X) ((u_int32_t)(intptr_t)(X)&0x1) #define DOMOD(X) ((X) = (char *)((intptr_t)(X)|0x1)) #define ISDISK(X) ((u_int32_t)(intptr_t)(X)&0x2) #define DODISK(X) ((X) = (char *)((intptr_t)(X)|0x2)) #define BITS_PER_MAP 32 /* Given the address of the beginning of a big map, clear/set the nth bit */ #define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) #define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) #define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) /* Overflow management */ /* * Overflow page numbers are allocated per split point. At each doubling of * the table, we can allocate extra pages. So, an overflow page number has * the top 5 bits indicate which split point and the lower 11 bits indicate * which page at that split point is indicated (pages within split points are * numberered starting with 1). */ #define SPLITSHIFT 11 #define SPLITMASK 0x7FF #define SPLITNUM(N) (((u_int32_t)(N)) >> SPLITSHIFT) #define OPAGENUM(N) ((N) & SPLITMASK) #define OADDR_OF(S,O) ((u_int32_t)((u_int32_t)(S) << SPLITSHIFT) + (O)) #define BUCKET_TO_PAGE(B) \ (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0) #define OADDR_TO_PAGE(B) \ BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); /* * page.h contains a detailed description of the page format. * * Normally, keys and data are accessed from offset tables in the top of * each page which point to the beginning of the key and data. There are * four flag values which may be stored in these offset tables which indicate * the following: * * * OVFLPAGE Rather than a key data pair, this pair contains * the address of an overflow page. The format of * the pair is: * OVERFLOW_PAGE_NUMBER OVFLPAGE * * PARTIAL_KEY This must be the first key/data pair on a page * and implies that page contains only a partial key. * That is, the key is too big to fit on a single page * so it starts on this page and continues on the next. * The format of the page is: * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE * * KEY_OFF -- offset of the beginning of the key * PARTIAL_KEY -- 1 * OVFL_PAGENO - page number of the next overflow page * OVFLPAGE -- 0 * * FULL_KEY This must be the first key/data pair on the page. It * is used in two cases. * * Case 1: * There is a complete key on the page but no data * (because it wouldn't fit). The next page contains * the data. * * Page format it: * KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE * * KEY_OFF -- offset of the beginning of the key * FULL_KEY -- 2 * OVFL_PAGENO - page number of the next overflow page * OVFLPAGE -- 0 * * Case 2: * This page contains no key, but part of a large * data field, which is continued on the next page. * * Page format it: * DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE * * KEY_OFF -- offset of the beginning of the data on * this page * FULL_KEY -- 2 * OVFL_PAGENO - page number of the next overflow page * OVFLPAGE -- 0 * * FULL_KEY_DATA * This must be the first key/data pair on the page. * There are two cases: * * Case 1: * This page contains a key and the beginning of the * data field, but the data field is continued on the * next page. * * Page format is: * KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF * * KEY_OFF -- offset of the beginning of the key * FULL_KEY_DATA -- 3 * OVFL_PAGENO - page number of the next overflow page * DATA_OFF -- offset of the beginning of the data * * Case 2: * This page contains the last page of a big data pair. * There is no key, only the tail end of the data * on this page. * * Page format is: * DATA_OFF FULL_KEY_DATA * * DATA_OFF -- offset of the beginning of the data on * this page * FULL_KEY_DATA -- 3 * OVFL_PAGENO - page number of the next overflow page * OVFLPAGE -- 0 * * OVFL_PAGENO and OVFLPAGE are optional (they are * not present if there is no next page). */ #define OVFLPAGE 0 #define PARTIAL_KEY 1 #define FULL_KEY 2 #define FULL_KEY_DATA 3 #define REAL_KEY 4 /* Short hands for accessing structure */ #define BSIZE hdr.bsize #define BSHIFT hdr.bshift #define DSIZE hdr.dsize #define SGSIZE hdr.ssize #define SSHIFT hdr.sshift #define LORDER hdr.lorder #define OVFL_POINT hdr.ovfl_point #define LAST_FREED hdr.last_freed #define MAX_BUCKET hdr.max_bucket #define FFACTOR hdr.ffactor #define HIGH_MASK hdr.high_mask #define LOW_MASK hdr.low_mask #define NKEYS hdr.nkeys #define HDRPAGES hdr.hdrpages #define SPARES hdr.spares #define BITMAPS hdr.bitmaps #define VERSION hdr.version #define MAGIC hdr.magic #define NEXT_FREE hdr.next_free #define H_CHARKEY hdr.h_charkey diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h index 17070e1ff584..5d9b6fedb6a9 100644 --- a/lib/libc/db/hash/page.h +++ b/lib/libc/db/hash/page.h @@ -1,91 +1,90 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Margo Seltzer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)page.h 8.2 (Berkeley) 5/31/94 - * $FreeBSD$ */ /* * Definitions for hashing page file format. */ /* * routines dealing with a data page * * page format: * +------------------------------+ * p | n | keyoff | datoff | keyoff | * +------------+--------+--------+ * | datoff | free | ptr | --> | * +--------+---------------------+ * | F R E E A R E A | * +--------------+---------------+ * | <---- - - - | data | * +--------+-----+----+----------+ * | key | data | key | * +--------+----------+----------+ * * Pointer to the free space is always: p[p[0] + 2] * Amount of free space on the page is: p[p[0] + 1] */ /* * How many bytes required for this pair? * 2 shorts in the table at the top of the page + room for the * key and room for the data * * We prohibit entering a pair on a page unless there is also room to append * an overflow page. The reason for this it that you can get in a situation * where a single key/data pair fits on a page, but you can't append an * overflow page and later you'd have to split the key/data and handle like * a big pair. * You might as well do this up front. */ #define PAIRSIZE(K,D) (2*sizeof(u_int16_t) + (K)->size + (D)->size) #define BIGOVERHEAD (4*sizeof(u_int16_t)) #define KEYSIZE(K) (4*sizeof(u_int16_t) + (K)->size); #define OVFLSIZE (2*sizeof(u_int16_t)) #define FREESPACE(P) ((P)[(P)[0]+1]) #define OFFSET(P) ((P)[(P)[0]+2]) #define PAIRFITS(P,K,D) \ (((P)[2] >= REAL_KEY) && \ (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) #define PAGE_META(N) (((N)+3) * sizeof(u_int16_t)) typedef struct { BUFHEAD *newp; BUFHEAD *oldp; BUFHEAD *nextp; u_int16_t next_addr; } SPLIT_RETURN; diff --git a/lib/libc/db/recno/extern.h b/lib/libc/db/recno/extern.h index 11e3ca223622..9b61d3c19fec 100644 --- a/lib/libc/db/recno/extern.h +++ b/lib/libc/db/recno/extern.h @@ -1,53 +1,52 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.3 (Berkeley) 6/4/94 - * $FreeBSD$ */ #include "../btree/extern.h" int __rec_close(DB *); int __rec_delete(const DB *, const DBT *, u_int); int __rec_dleaf(BTREE *, PAGE *, u_int32_t); int __rec_fd(const DB *); int __rec_fmap(BTREE *, recno_t); int __rec_fout(BTREE *); int __rec_fpipe(BTREE *, recno_t); int __rec_get(const DB *, const DBT *, DBT *, u_int); int __rec_iput(BTREE *, recno_t, const DBT *, u_int); int __rec_put(const DB *dbp, DBT *, const DBT *, u_int); int __rec_ret(BTREE *, EPG *, recno_t, DBT *, DBT *); EPG *__rec_search(BTREE *, recno_t, enum SRCHOP); int __rec_seq(const DB *, DBT *, DBT *, u_int); int __rec_sync(const DB *, u_int); int __rec_vmap(BTREE *, recno_t); int __rec_vout(BTREE *); int __rec_vpipe(BTREE *, recno_t); diff --git a/lib/libc/db/recno/recno.h b/lib/libc/db/recno/recno.h index ae0eb85cc3ca..a484983c1f81 100644 --- a/lib/libc/db/recno/recno.h +++ b/lib/libc/db/recno/recno.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)recno.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ #include "../btree/btree.h" #include "extern.h" diff --git a/lib/libc/gdtoa/Symbol.map b/lib/libc/gdtoa/Symbol.map index 4483e9a3adff..a3cfd8df6819 100644 --- a/lib/libc/gdtoa/Symbol.map +++ b/lib/libc/gdtoa/Symbol.map @@ -1,19 +1,18 @@ /* - * $FreeBSD$ */ FBSD_1.0 { /* * Standard functions from contrib/gdtoa */ strtod; strtof; /* FreeBSD additions */ strtold; }; FBSDprivate_1.0 { /* used in libm */ __hexnan_D2A; }; diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 84432432f4e6..9dd7334728a4 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -1,577 +1,576 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __xuname; pthread_atfork; pthread_attr_destroy; pthread_attr_get_np; pthread_attr_getdetachstate; pthread_attr_getguardsize; pthread_attr_getinheritsched; pthread_attr_getschedparam; pthread_attr_getschedpolicy; pthread_attr_getscope; pthread_attr_getstackaddr; pthread_attr_getstacksize; pthread_attr_init; pthread_attr_setdetachstate; pthread_attr_setguardsize; pthread_attr_setinheritsched; pthread_attr_setschedparam; pthread_attr_setschedpolicy; pthread_attr_setscope; pthread_attr_setstackaddr; pthread_attr_setstacksize; pthread_cancel; pthread_cleanup_pop; pthread_cleanup_push; pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; pthread_cond_signal; pthread_cond_timedwait; pthread_cond_wait; pthread_detach; pthread_equal; pthread_exit; pthread_getspecific; pthread_join; pthread_key_create; pthread_key_delete; pthread_kill; pthread_main_np; pthread_mutex_destroy; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_trylock; pthread_mutex_unlock; pthread_mutexattr_destroy; pthread_mutexattr_init; pthread_mutexattr_settype; pthread_once; pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock; pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock; pthread_rwlock_unlock; pthread_rwlock_wrlock; pthread_self; pthread_setcancelstate; pthread_setcanceltype; pthread_setspecific; pthread_sigmask; pthread_testcancel; alarm; arc4random; __assert; check_utility_compat; clock; closedir; confstr; ctermid; ctermid_r; daemon; getdiskbyname; dladdr; dlclose; dlerror; dlfunc; dllockinit; dlopen; dlsym; dlvsym; dlinfo; dl_iterate_phdr; drand48; erand48; err_set_file; err_set_exit; err; verr; errc; verrc; errx; verrx; warn; vwarn; warnc; vwarnc; warnx; vwarnx; sys_errlist; sys_nerr; errno; exect; execl; execle; execlp; execv; execvp; execvP; fmtcheck; fmtmsg; fnmatch; __fpclassifyf; __fpclassifyd; __fpclassifyl; frexp; setfstab; getfstab; getfsent; getfsspec; getfsfile; setfsent; endfsent; ftok; getbootfile; getbsize; cgetset; cgetcap; cgetent; cgetmatch; cgetfirst; cgetclose; cgetnext; cgetstr; cgetustr; cgetnum; getcwd; getdomainname; setgrent; setgroupent; endgrent; getgrent_r; getgrnam_r; getgrgid_r; getgrnam; getgrgid; getgrent; /* * Why are __gr_parse_entry() and __gr_match_entry() not static in * gen/getgrent.c? */ getgrouplist; gethostname; getloadavg; getlogin; setnetgrent; getnetgrent; endnetgrent; innetgr; getosreldate; getpagesize; getpeereid; _getprogname; getprogname; setpwent; setpassent; endpwent; getpwent_r; getpwnam_r; getpwuid_r; getpwnam; getpwuid; getpwent; getttynam; getttyent; setttyent; endttyent; isdialuptty; isnettty; getusershell; endusershell; setusershell; getvfsbyname; __isnan; isnan; __isnanf; isnanf; __isinf; isinf; __isinff; __isinfl; isatty; initgroups; jrand48; lcong48; ldexp; lockf; lrand48; modf; mrand48; nice; nlist; nrand48; opendir; pause; posix_madvise; popen; pclose; psignal; raise; readpassphrase; getpass; rewinddir; seed48; seekdir; user_from_uid; group_from_gid; setdomainname; sethostname; longjmperror; getmode; setmode; setproctitle; setprogname; siginterrupt; sys_signame; sys_siglist; sys_nsig; signal; sigaddset; sigdelset; sigemptyset; sigfillset; sigismember; sleep; srand48; fstatvfs; statvfs; sl_init; sl_add; sl_free; sl_find; fflagstostr; strtofflags; sysconf; sysctl; sysctlbyname; sysctlnametomib; syslog; vsyslog; openlog; closelog; setlogmask; ttyname_r; ttyname; timezone; times; time; telldir; tcgetattr; tcsetattr; tcsetpgrp; tcgetpgrp; cfgetospeed; cfgetispeed; cfsetospeed; cfsetispeed; cfsetspeed; cfmakeraw; tcsendbreak; _init_tls; __tls_get_addr; tcdrain; tcflush; tcflow; ualarm; ulimit; uname; strunvis; strunvisx; usleep; utime; valloc; vis; strvis; strvisx; wait; wait3; waitpid; wordexp; wordfree; }; FBSD_1.1 { arc4random_buf; arc4random_uniform; fdevname; fdevname_r; fdopendir; feature_present; posix_spawn; posix_spawn_file_actions_addclose; posix_spawn_file_actions_adddup2; posix_spawn_file_actions_addopen; posix_spawn_file_actions_destroy; posix_spawn_file_actions_init; posix_spawnattr_destroy; posix_spawnattr_getflags; posix_spawnattr_getpgroup; posix_spawnattr_getschedparam; posix_spawnattr_getschedpolicy; posix_spawnattr_getsigdefault; posix_spawnattr_getsigmask; posix_spawnattr_init; posix_spawnattr_setflags; posix_spawnattr_setpgroup; posix_spawnattr_setschedparam; posix_spawnattr_setschedpolicy; posix_spawnattr_setsigdefault; posix_spawnattr_setsigmask; posix_spawnp; semctl; tcgetsid; tcsetsid; __pthread_cleanup_pop_imp; __pthread_cleanup_push_imp; }; FBSD_1.2 { cfmakesane; endutxent; getpagesizes; getutxent; getutxid; getutxline; getutxuser; pthread_getthreadid_np; pututxline; sem_close; sem_destroy; sem_getvalue; sem_init; sem_open; sem_post; sem_timedwait; sem_trywait; sem_unlink; sem_wait; setutxdb; setutxent; }; FBSD_1.3 { clock_getcpuclockid; dirfd; dup3; fdclosedir; fdlopen; __FreeBSD_libc_enter_restricted_mode; getcontextx; gid_from_group; nvis; pwcache_userdb; pwcache_groupdb; snvis; strenvisx; strnunvis; strnunvisx; strnvis; strnvisx; strsenvisx; strsnvis; strsnvisx; strsvis; strsvisx; svis; uid_from_user; unvis; waitid; }; FBSD_1.4 { getnetgrent_r; pthread_mutex_consistent; pthread_mutexattr_getrobust; pthread_mutexattr_setrobust; stravis; }; FBSD_1.5 { alphasort; basename; daemonfd; devname; devname_r; dirname; elf_aux_info; fts_children; fts_close; fts_get_clientptr; fts_get_stream; fts_open; fts_read; fts_set; fts_set_clientptr; ftw; getentropy; getmntinfo; glob; globfree; nftw; readdir; readdir_r; scandir; sem_clockwait_np; setproctitle_fast; timespec_get; }; FBSD_1.6 { eventfd; eventfd_read; eventfd_write; getlogin_r; memalign; scandir_b; sigandset; sigisemptyset; sigorset; tcgetwinsize; tcsetwinsize; }; FBSD_1.7 { kqueue1; posix_spawn_file_actions_addchdir_np; posix_spawn_file_actions_addclosefrom_np; posix_spawn_file_actions_addfchdir_np; scandirat; sched_getaffinity; sched_setaffinity; sched_getcpu; versionsort; __cpuset_alloc; __cpuset_free; }; FBSDprivate_1.0 { /* needed by thread libraries */ __thr_jtable; _pthread_atfork; _pthread_attr_destroy; _pthread_attr_getdetachstate; _pthread_attr_getguardsize; _pthread_attr_getinheritsched; _pthread_attr_getschedparam; _pthread_attr_getschedpolicy; _pthread_attr_getscope; _pthread_attr_getstackaddr; _pthread_attr_getstacksize; _pthread_attr_init; _pthread_attr_setdetachstate; _pthread_attr_setguardsize; _pthread_attr_setinheritsched; _pthread_attr_setschedparam; _pthread_attr_setschedpolicy; _pthread_attr_setscope; _pthread_attr_setstackaddr; _pthread_attr_setstacksize; _pthread_cancel; _pthread_cancel_enter; _pthread_cancel_leave; _pthread_cleanup_pop; _pthread_cleanup_push; _pthread_cond_broadcast; _pthread_cond_destroy; _pthread_cond_init; _pthread_cond_signal; _pthread_cond_timedwait; _pthread_cond_wait; _pthread_detach; _pthread_equal; _pthread_exit; _pthread_getspecific; _pthread_join; _pthread_key_create; _pthread_key_delete; _pthread_kill; _pthread_main_np; _pthread_mutex_destroy; _pthread_mutex_init_calloc_cb; _pthread_mutex_init; _pthread_mutex_lock; _pthread_mutex_trylock; _pthread_mutex_unlock; _pthread_mutexattr_destroy; _pthread_mutexattr_init; _pthread_mutexattr_settype; _pthread_once; _pthread_rwlock_destroy; _pthread_rwlock_init; _pthread_rwlock_rdlock; _pthread_rwlock_tryrdlock; _pthread_rwlock_trywrlock; _pthread_rwlock_unlock; _pthread_rwlock_wrlock; _pthread_self; _pthread_setcancelstate; _pthread_setcanceltype; _pthread_setspecific; _pthread_sigmask; _pthread_testcancel; _spinlock; _spinunlock; _rtld_addr_phdr; _rtld_atfork_pre; _rtld_atfork_post; _rtld_error; /* for private use */ _rtld_get_stack_prot; _rtld_is_dlopened; _rtld_thread_init; /* for private use */ __elf_phdr_match_addr; _err; _warn; __fmtcheck; /* __pw_match_entry; */ /* __pw_parse_entry; */ __fdnlist; /* used by libkvm */ /* __elf_is_okay__; */ /* __elf_fdnlist; */ __opendir2; __pause; _pause; __raise; _raise; __sleep; _sleep; _rtld_allocate_tls; _rtld_free_tls; #if defined(i386) ___libc_tls_get_addr; /* x86 only */ #endif __libc_tls_get_addr; __tcdrain; _tcdrain; __usleep; _usleep; __wait; _wait; __waitpid; _waitpid; _libc_sem_init_compat; _libc_sem_destroy_compat; _libc_sem_open_compat; _libc_sem_close_compat; _libc_sem_unlink_compat; _libc_sem_wait_compat; _libc_sem_trywait_compat; _libc_sem_timedwait_compat; _libc_sem_post_compat; _libc_sem_getvalue_compat; __libc_tcdrain; __elf_aux_vector; __pthread_distribute_static_tls; __pthread_map_stacks_exec; __fillcontextx; __fillcontextx2; __getcontextx_size; }; diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h index 6367ec9ebc4b..f1794fe3264d 100644 --- a/lib/libc/gen/fts-compat.h +++ b/lib/libc/gen/fts-compat.h @@ -1,130 +1,129 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fts.h 8.3 (Berkeley) 8/14/94 - * $FreeBSD$ */ #ifndef _FTS_H_ #define _FTS_H_ typedef struct { struct _ftsent *fts_cur; /* current node */ struct _ftsent *fts_child; /* linked list of children */ struct _ftsent **fts_array; /* sort array */ uint32_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ int fts_pathlen; /* sizeof(path) */ int fts_nitems; /* elements in the sort array */ int (*fts_compar) /* compare function */ (const struct _ftsent * const *, const struct _ftsent * const *); #define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ #define FTS_LOGICAL 0x002 /* logical walk */ #define FTS_NOCHDIR 0x004 /* don't change directories */ #define FTS_NOSTAT 0x008 /* don't get stat info */ #define FTS_PHYSICAL 0x010 /* physical walk */ #define FTS_SEEDOT 0x020 /* return dot and dot-dot */ #define FTS_XDEV 0x040 /* don't cross devices */ #define FTS_WHITEOUT 0x080 /* return whiteout information */ #define FTS_OPTIONMASK 0x0ff /* valid user option mask */ #define FTS_NAMEONLY 0x100 /* (private) child names only */ #define FTS_STOP 0x200 /* (private) unrecoverable error */ int fts_options; /* fts_open options, global flags */ void *fts_clientptr; /* thunk for sort function */ } FTS; typedef struct _ftsent { struct _ftsent *fts_cycle; /* cycle node */ struct _ftsent *fts_parent; /* parent directory */ struct _ftsent *fts_link; /* next file in directory */ union { struct { long __fts_number; /* local numeric value */ void *__fts_pointer; /* local address value */ } __struct_ftsent; int64_t __fts_bignum; } __union_ftsent; #define fts_number __union_ftsent.__struct_ftsent.__fts_number #define fts_pointer __union_ftsent.__struct_ftsent.__fts_pointer #define fts_bignum __union_ftsent.__fts_bignum char *fts_accpath; /* access path */ char *fts_path; /* root path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ u_short fts_pathlen; /* strlen(fts_path) */ u_short fts_namelen; /* strlen(fts_name) */ uint32_t fts_ino; /* inode */ uint32_t fts_dev; /* device */ uint16_t fts_nlink; /* link count */ #define FTS_ROOTPARENTLEVEL -1 #define FTS_ROOTLEVEL 0 short fts_level; /* depth (-1 to N) */ #define FTS_D 1 /* preorder directory */ #define FTS_DC 2 /* directory that causes cycles */ #define FTS_DEFAULT 3 /* none of the above */ #define FTS_DNR 4 /* unreadable directory */ #define FTS_DOT 5 /* dot or dot-dot */ #define FTS_DP 6 /* postorder directory */ #define FTS_ERR 7 /* error; errno is set */ #define FTS_F 8 /* regular file */ #define FTS_INIT 9 /* initialized only */ #define FTS_NS 10 /* stat(2) failed */ #define FTS_NSOK 11 /* no stat(2) requested */ #define FTS_SL 12 /* symbolic link */ #define FTS_SLNONE 13 /* symbolic link without target */ #define FTS_W 14 /* whiteout object */ u_short fts_info; /* user flags for FTSENT structure */ #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ #define FTS_ISW 0x04 /* this is a whiteout object */ u_short fts_flags; /* private flags for FTSENT structure */ #define FTS_AGAIN 1 /* read node again */ #define FTS_FOLLOW 2 /* follow symbolic link */ #define FTS_NOINSTR 3 /* no instructions */ #define FTS_SKIP 4 /* discard node */ u_short fts_instr; /* fts_set() instructions */ struct freebsd11_stat *fts_statp; /* stat(2) information */ char *fts_name; /* file name */ FTS *fts_fts; /* back pointer to main FTS */ } FTSENT; #define fts_get_clientptr(fts) ((fts)->fts_clientptr) #define fts_get_stream(ftsent) ((ftsent)->fts_fts) #endif /* !_FTS_H_ */ diff --git a/lib/libc/gen/fts-compat11.h b/lib/libc/gen/fts-compat11.h index 52c0637395fb..ca77b9e491c0 100644 --- a/lib/libc/gen/fts-compat11.h +++ b/lib/libc/gen/fts-compat11.h @@ -1,95 +1,94 @@ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fts.h 8.3 (Berkeley) 8/14/94 - * $FreeBSD$ */ #ifndef _FTS_COPMAT11_H_ #define _FTS_COPMAT11_H_ typedef struct { struct _ftsent11 *fts_cur; /* current node */ struct _ftsent11 *fts_child; /* linked list of children */ struct _ftsent11 **fts_array; /* sort array */ uint32_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ __size_t fts_pathlen; /* sizeof(path) */ __size_t fts_nitems; /* elements in the sort array */ int (*fts_compar) /* compare function */ (const struct _ftsent11 * const *, const struct _ftsent11 * const *); int fts_options; /* fts_open options, global flags */ void *fts_clientptr; /* thunk for sort function */ } FTS11; typedef struct _ftsent11 { struct _ftsent11 *fts_cycle; /* cycle node */ struct _ftsent11 *fts_parent; /* parent directory */ struct _ftsent11 *fts_link; /* next file in directory */ long long fts_number; /* local numeric value */ void *fts_pointer; /* local address value */ char *fts_accpath; /* access path */ char *fts_path; /* root path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ __size_t fts_pathlen; /* strlen(fts_path) */ __size_t fts_namelen; /* strlen(fts_name) */ uint32_t fts_ino; /* inode */ uint32_t fts_dev; /* device */ uint16_t fts_nlink; /* link count */ long fts_level; /* depth (-1 to N) */ int fts_info; /* user status for FTSENT structure */ unsigned fts_flags; /* private flags for FTSENT structure */ int fts_instr; /* fts_set() instructions */ struct freebsd11_stat *fts_statp; /* stat(2) information */ char *fts_name; /* file name */ FTS11 *fts_fts; /* back pointer to main FTS */ } FTSENT11; FTSENT11 *freebsd11_fts_children(FTS11 *, int); int freebsd11_fts_close(FTS11 *); void *freebsd11_fts_get_clientptr(FTS11 *); #define freebsd11_fts_get_clientptr(fts) ((fts)->fts_clientptr) FTS11 *freebsd11_fts_get_stream(FTSENT11 *); #define freebsd11_fts_get_stream(ftsent) ((ftsent)->fts_fts) FTS11 *freebsd11_fts_open(char * const *, int, int (*)(const FTSENT11 * const *, const FTSENT11 * const *)); FTSENT11 *freebsd11_fts_read(FTS11 *); int freebsd11_fts_set(FTS11 *, FTSENT11 *, int); void freebsd11_fts_set_clientptr(FTS11 *, void *); #endif /* !_FTS_COMPAT11_H_ */ diff --git a/lib/libc/gen/pw_scan.h b/lib/libc/gen/pw_scan.h index b56703677ac0..d3e33454195e 100644 --- a/lib/libc/gen/pw_scan.h +++ b/lib/libc/gen/pw_scan.h @@ -1,39 +1,38 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94 - * $FreeBSD$ */ #define _PWSCAN_MASTER 0x01 #define _PWSCAN_WARN 0x02 extern void __pw_initpwd(struct passwd *); extern int __pw_scan(char *, struct passwd *, int); diff --git a/lib/libc/gmon/Symbol.map b/lib/libc/gmon/Symbol.map index 822789972ebf..9d880afd8841 100644 --- a/lib/libc/gmon/Symbol.map +++ b/lib/libc/gmon/Symbol.map @@ -1,14 +1,13 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _mcleanup; monstartup; moncontrol; mexitcount; }; FBSDprivate_1.0 { _gmonparam; }; diff --git a/lib/libc/i386/SYS.h b/lib/libc/i386/SYS.h index 18bcb102691e..f6966aacf237 100644 --- a/lib/libc/i386/SYS.h +++ b/lib/libc/i386/SYS.h @@ -1,58 +1,57 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * William Jolitz. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $FreeBSD$ */ #include #include #define SYSCALL(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ mov $SYS_##name,%eax; KERNCALL; \ jb HIDENAME(cerror) #define RSYSCALL(name) SYSCALL(name); ret; END(__sys_##name) #define PSEUDO(name) ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ mov $SYS_##name,%eax; KERNCALL; \ jb HIDENAME(cerror); ret; \ END(__sys_##name) /* gas messes up offset -- although we don't currently need it, do for BCS */ #define LCALL(x,y) .byte 0x9a ; .long y; .word x #define KERNCALL int $0x80 diff --git a/lib/libc/i386/Symbol.map b/lib/libc/i386/Symbol.map index b169c3229879..9d6ea7fff9f3 100644 --- a/lib/libc/i386/Symbol.map +++ b/lib/libc/i386/Symbol.map @@ -1,68 +1,67 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; .mcount; _setjmp; _longjmp; alloca; fabs; __flt_rounds; __nan; __infinity; makecontext; rfork_thread; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; vfork; brk; i386_clr_watch; i386_get_fsbase; i386_get_gsbase; i386_get_ioperm; i386_get_ldt; i386_set_fsbase; i386_set_gsbase; i386_set_ioperm; i386_set_ldt; i386_set_watch; i386_vm86; sbrk; ___tls_get_addr; }; FBSD_1.6 { x86_pkru_get_perm; x86_pkru_set_perm; x86_pkru_protect_range; x86_pkru_unprotect_range; }; FBSDprivate_1.0 { /* PSEUDO syscalls */ _getlogin; ___longjmp; __makecontext; __longjmp; __signalcontext; signalcontext; __siglongjmp; _vfork; _brk; }; diff --git a/lib/libc/iconv/Symbol.map b/lib/libc/iconv/Symbol.map index 8a9a75d519ed..f883fe0d3e87 100644 --- a/lib/libc/iconv/Symbol.map +++ b/lib/libc/iconv/Symbol.map @@ -1,104 +1,103 @@ /* - * $FreeBSD$ */ FBSD_1.3 { __bsd___iconv; __bsd___iconv_free_list; __bsd___iconv_get_list; __bsd_iconv; __bsd_iconv_canonicalize; __bsd_iconv_close; __bsd_iconv_open; __bsd_iconv_open_into; __bsd_iconv_set_relocation_prefix; __bsd_iconvctl; __bsd_iconvlist; }; FBSDprivate_1.0 { _citrus_bcs_convert_to_lower; _citrus_bcs_convert_to_upper; _citrus_bcs_isalnum; _citrus_bcs_isalpha; _citrus_bcs_isblank; _citrus_bcs_isdigit; _citrus_bcs_iseol; _citrus_bcs_islower; _citrus_bcs_isspace; _citrus_bcs_isupper; _citrus_bcs_isxdigit; _citrus_bcs_skip_nonws; _citrus_bcs_skip_nonws_len; _citrus_bcs_skip_ws; _citrus_bcs_skip_ws_len; _citrus_bcs_strcasecmp; _citrus_bcs_strncasecmp; _citrus_bcs_strtol; _citrus_bcs_strtoul; _citrus_bcs_tolower; _citrus_bcs_toupper; _citrus_bcs_trunc_rws_len; _citrus_bcs_trunc_ws_len; _citrus_csmapper_open; _citrus_csmapper_close; _citrus_db_factory_add_by_string; _citrus_db_factory_add_string_by_string; _citrus_db_factory_add32_by_string; _citrus_db_factory_calc_size; _citrus_db_factory_create; _citrus_db_factory_serialize; _citrus_db_hash_std; _citrus_db_close; _citrus_db_get_entry; _citrus_db_get_number_of_entries; _citrus_db_lookup; _citrus_db_lookup_by_string; _citrus_db_lookup8_by_string; _citrus_db_lookup16_by_string; _citrus_db_lookup_string_by_string; _citrus_db_open; _citrus_esdb_close; _citrus_esdb_open; _citrus_lookup_factory_convert; _citrus_map_file; _citrus_mapper_close; _citrus_mapper_convert; _citrus_mapper_create_area; _citrus_mapper_get_dst_max; _citrus_mapper_get_src_max; _citrus_mapper_get_state_size; _citrus_mapper_init_state; _citrus_mapper_open; _citrus_mapper_open_direct; _citrus_mapper_set_persistent; _citrus_memory_stream_bind; _citrus_memory_stream_chr; _citrus_memory_stream_getc; _citrus_memory_stream_getln; _citrus_memory_stream_getln_region; _citrus_memory_stream_getregion; _citrus_memory_stream_iseof; _citrus_memory_stream_matchline; _citrus_memory_stream_peek; _citrus_memory_stream_remainder; _citrus_memory_stream_rewind; _citrus_memory_stream_seek; _citrus_memory_stream_skip_ws; _citrus_memory_stream_tell; _citrus_memory_stream_ungetc; _citrus_pivot_factory_convert; _citrus_prop_object_init; _citrus_prop_object_uninit; _citrus_prop_parse_variable; _citrus_prop_read_bool; _citrus_prop_read_character; _citrus_prop_read_character_common; _citrus_prop_read_element; _citrus_prop_read_num; _citrus_prop_read_str; _citrus_prop_read_symbol; _citrus_stdenc_close; _citrus_stdenc_open; _citrus_unmap_file; }; diff --git a/lib/libc/inet/Symbol.map b/lib/libc/inet/Symbol.map index f188b137de94..e26556cd5fe4 100644 --- a/lib/libc/inet/Symbol.map +++ b/lib/libc/inet/Symbol.map @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __inet_addr; __inet_aton; inet_addr; inet_aton; __inet_cidr_ntop; __inet_cidr_pton; __inet_lnaof; inet_lnaof; __inet_makeaddr; inet_makeaddr; __inet_net_ntop; inet_net_ntop; __inet_net_pton; inet_net_pton; __inet_neta; inet_neta; __inet_netof; inet_netof; __inet_network; inet_network; __inet_ntoa; inet_ntoa; __inet_ntoa_r; inet_ntoa_r; __inet_ntop; inet_ntop; __inet_pton; inet_pton; __inet_nsap_addr; __inet_nsap_ntoa; inet_nsap_addr; inet_nsap_ntoa; }; diff --git a/lib/libc/isc/eventlib_p.h b/lib/libc/isc/eventlib_p.h index a56334f0a87d..72b17a7a855b 100644 --- a/lib/libc/isc/eventlib_p.h +++ b/lib/libc/isc/eventlib_p.h @@ -1,291 +1,290 @@ /*- * SPDX-License-Identifier: ISC * * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-1999 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /*! \file * \brief private interfaces for eventlib * \author vix 09sep95 [initial] * * $Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp $ - * $FreeBSD$ */ #ifndef _EVENTLIB_P_H #define _EVENTLIB_P_H #include #include #include #include #define EVENTLIB_DEBUG 1 #include #include #include #include #include #ifndef _LIBC #include #include #include #endif #define EV_MASK_ALL (EV_READ | EV_WRITE | EV_EXCEPT) #define EV_ERR(e) return (errno = (e), -1) #define OK(x) if ((x) < 0) EV_ERR(errno); else (void)NULL #define OKFREE(x, y) if ((x) < 0) { FREE((y)); EV_ERR(errno); } \ else (void)NULL #define NEW(p) if (((p) = memget(sizeof *(p))) != NULL) \ FILL(p); \ else \ (void)NULL; #define OKNEW(p) if (!((p) = memget(sizeof *(p)))) { \ errno = ENOMEM; \ return (-1); \ } else \ FILL(p) #define FREE(p) memput((p), sizeof *(p)) #if EVENTLIB_DEBUG #define FILL(p) memset((p), 0xF5, sizeof *(p)) #else #define FILL(p) #endif #ifdef USE_POLL #ifdef HAVE_STROPTS_H #include #endif #include #endif /* USE_POLL */ typedef struct evConn { evConnFunc func; void * uap; int fd; int flags; #define EV_CONN_LISTEN 0x0001 /*%< Connection is a listener. */ #define EV_CONN_SELECTED 0x0002 /*%< evSelectFD(conn->file). */ #define EV_CONN_BLOCK 0x0004 /*%< Listener fd was blocking. */ evFileID file; struct evConn * prev; struct evConn * next; } evConn; #ifndef _LIBC typedef struct evAccept { int fd; union { struct sockaddr sa; struct sockaddr_in in; #ifndef NO_SOCKADDR_UN struct sockaddr_un un; #endif } la; ISC_SOCKLEN_T lalen; union { struct sockaddr sa; struct sockaddr_in in; #ifndef NO_SOCKADDR_UN struct sockaddr_un un; #endif } ra; ISC_SOCKLEN_T ralen; int ioErrno; evConn * conn; LINK(struct evAccept) link; } evAccept; typedef struct evFile { evFileFunc func; void * uap; int fd; int eventmask; int preemptive; struct evFile * prev; struct evFile * next; struct evFile * fdprev; struct evFile * fdnext; } evFile; typedef struct evStream { evStreamFunc func; void * uap; evFileID file; evTimerID timer; int flags; #define EV_STR_TIMEROK 0x0001 /*%< IFF timer valid. */ int fd; struct iovec * iovOrig; int iovOrigCount; struct iovec * iovCur; int iovCurCount; int ioTotal; int ioDone; int ioErrno; struct evStream *prevDone, *nextDone; struct evStream *prev, *next; } evStream; typedef struct evTimer { evTimerFunc func; void * uap; struct timespec due, inter; int index; int mode; #define EV_TMR_RATE 1 } evTimer; typedef struct evWait { evWaitFunc func; void * uap; const void * tag; struct evWait * next; } evWait; typedef struct evWaitList { evWait * first; evWait * last; struct evWaitList * prev; struct evWaitList * next; } evWaitList; typedef struct evEvent_p { enum { Accept, File, Stream, Timer, Wait, Free, Null } type; union { struct { evAccept *this; } accept; struct { evFile *this; int eventmask; } file; struct { evStream *this; } stream; struct { evTimer *this; } timer; struct { evWait *this; } wait; struct { struct evEvent_p *next; } free; struct { const void *placeholder; } null; } u; } evEvent_p; #endif #ifdef USE_POLL typedef struct { void *ctx; /* pointer to the evContext_p */ uint32_t type; /* READ, WRITE, EXCEPT, nonblk */ uint32_t result; /* 1 => revents, 0 => events */ } __evEmulMask; #define emulMaskInit(ctx, field, ev, lastnext) \ ctx->field.ctx = ctx; \ ctx->field.type = ev; \ ctx->field.result = lastnext; extern short *__fd_eventfield(int fd, __evEmulMask *maskp); extern short __poll_event(__evEmulMask *maskp); extern void __fd_clr(int fd, __evEmulMask *maskp); extern void __fd_set(int fd, __evEmulMask *maskp); #undef FD_ZERO #define FD_ZERO(maskp) #undef FD_SET #define FD_SET(fd, maskp) \ __fd_set(fd, maskp) #undef FD_CLR #define FD_CLR(fd, maskp) \ __fd_clr(fd, maskp) #undef FD_ISSET #define FD_ISSET(fd, maskp) \ ((*__fd_eventfield(fd, maskp) & __poll_event(maskp)) != 0) #endif /* USE_POLL */ #ifndef _LIBC typedef struct { /* Global. */ const evEvent_p *cur; /* Debugging. */ int debug; FILE *output; /* Connections. */ evConn *conns; LIST(evAccept) accepts; /* Files. */ evFile *files, *fdNext; #ifndef USE_POLL fd_set rdLast, rdNext; fd_set wrLast, wrNext; fd_set exLast, exNext; fd_set nonblockBefore; int fdMax, fdCount, highestFD; evFile *fdTable[FD_SETSIZE]; #else struct pollfd *pollfds; /* Allocated as needed */ evFile **fdTable; /* Ditto */ int maxnfds; /* # elements in above */ int firstfd; /* First active fd */ int fdMax; /* Last active fd */ int fdCount; /* # fd:s with I/O */ int highestFD; /* max fd allowed by OS */ __evEmulMask rdLast, rdNext; __evEmulMask wrLast, wrNext; __evEmulMask exLast, exNext; __evEmulMask nonblockBefore; #endif /* USE_POLL */ #ifdef EVENTLIB_TIME_CHECKS struct timespec lastSelectTime; int lastFdCount; #endif /* Streams. */ evStream *streams; evStream *strDone, *strLast; /* Timers. */ struct timespec lastEventTime; heap_context timers; /* Waits. */ evWaitList *waitLists; evWaitList waitDone; } evContext_p; /* eventlib.c */ #define evPrintf __evPrintf void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...) ISC_FORMAT_PRINTF(3, 4); #ifdef USE_POLL extern int evPollfdRealloc(evContext_p *ctx, int pollfd_chunk_size, int fd); #endif /* USE_POLL */ /* ev_timers.c */ #define evCreateTimers __evCreateTimers heap_context evCreateTimers(const evContext_p *); #define evDestroyTimers __evDestroyTimers void evDestroyTimers(const evContext_p *); /* ev_waits.c */ #define evFreeWait __evFreeWait evWait *evFreeWait(evContext_p *ctx, evWait *old); #endif /* Global options */ #ifndef _LIBC extern int __evOptMonoTime; #endif #endif /*_EVENTLIB_P_H*/ diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map index b2f2a35f2fe4..f29e6226855b 100644 --- a/lib/libc/locale/Symbol.map +++ b/lib/libc/locale/Symbol.map @@ -1,217 +1,216 @@ /* - * $FreeBSD$ */ FBSD_1.0 { btowc; digittoint; isalnum; isalpha; isascii; isblank; iscntrl; isdigit; isgraph; ishexnumber; isideogram; islower; isnumber; isphonogram; isprint; ispunct; isrune; isspace; isspecial; isupper; isxdigit; toascii; tolower; toupper; iswalnum; iswalpha; iswascii; iswblank; iswcntrl; iswdigit; iswgraph; iswhexnumber; iswideogram; iswlower; iswnumber; iswphonogram; iswprint; iswpunct; iswrune; iswspace; iswspecial; iswupper; iswxdigit; towlower; towupper; localeconv; mblen; mbrlen; mbrtowc; mbsinit; mbsnrtowcs; mbsrtowcs; mbstowcs; mbtowc; nextwctype; nl_langinfo; __maskrune; __sbmaskrune; __istype; __sbistype; __isctype; __toupper; __sbtoupper; __tolower; __sbtolower; __wcwidth; __mb_cur_max; __mb_sb_limit; rpmatch; ___runetype; setlocale; _DefaultRuneLocale; _CurrentRuneLocale; ___tolower; ___toupper; wcrtomb; wcsftime; wcsnrtombs; wcsrtombs; wcstod; wcstof; wcstoimax; wcstol; wcstold; wcstoll; wcstombs; wcstoul; wcstoull; wcstoumax; wctob; wctomb; towctrans; wctrans; iswctype; wctype; wcwidth; }; FBSD_1.3 { newlocale; duplocale; freelocale; querylocale; uselocale; __getCurrentRuneLocale; btowc_l; localeconv_l; mblen_l; mbrlen_l; mbrtowc_l; mbsinit_l; mbsnrtowcs_l; mbsrtowcs_l; mbstowcs_l; mbtowc_l; nl_langinfo_l; strcoll_l; strfmon_l; strftime_l; strptime_l; strxfrm_l; wcrtomb_l; wcscoll_l; wcsnrtombs_l; wcsrtombs_l; wcstombs_l; wcsxfrm_l; wctob_l; wctomb_l; ___tolower_l; ___toupper_l; ___runetype_l; digittoint_l; isalnum_l; isalpha_l; isblank_l; iscntrl_l; isdigit_l; isgraph_l; ishexnumber_l; isideogram_l; islower_l; isnumber_l; isphonogram_l; isprint_l; ispunct_l; isrune_l; isspace_l; isspecial_l; isupper_l; isxdigit_l; tolower_l; toupper_l; iswalnum_l; iswalpha_l; iswblank_l; iswcntrl_l; iswdigit_l; iswgraph_l; iswhexnumber_l; iswideogram_l; iswlower_l; iswnumber_l; iswphonogram_l; iswprint_l; iswpunct_l; iswrune_l; iswspace_l; iswspecial_l; iswupper_l; iswxdigit_l; towlower_l; towupper_l; iswctype_l; wctype_l; nextwctype_l; ___mb_cur_max; ___mb_cur_max_l; towctrans_l; wctrans_l; wcsftime_l; wcstod_l; wcstof_l; wcstoimax_l; wcstol_l; wcstold_l; wcstoll_l; wcstoul_l; wcstoull_l; wcstoumax_l; __sbistype_l; __maskrune_l; __sbmaskrune_l; __istype_l; __runes_for_locale; _ThreadRuneLocale; c16rtomb; c16rtomb_l; c32rtomb; c32rtomb_l; mbrtoc16; mbrtoc16_l; mbrtoc32; mbrtoc32_l; }; FBSDprivate_1.0 { _PathLocale; __detect_path_locale; __collate_load_error; __collate_range_cmp; }; diff --git a/lib/libc/nameser/Symbol.map b/lib/libc/nameser/Symbol.map index b91977b9a07b..db66ed0951ec 100644 --- a/lib/libc/nameser/Symbol.map +++ b/lib/libc/nameser/Symbol.map @@ -1,42 +1,41 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __ns_makecanon; __ns_msg_getflag; __ns_name_ntol; __ns_name_ntop; __ns_name_pton; __ns_name_unpack; __ns_name_pack; __ns_name_uncompress; __ns_name_compress; __ns_name_rollback; __ns_name_skip; __ns_get16; __ns_get32; __ns_put16; __ns_put32; __ns_initparse; __ns_parserr; _ns_flagdata; __ns_samedomain; __ns_samename; __ns_skiprr; __ns_sprintrr; __ns_sprintrrf; __ns_format_ttl; __ns_parse_ttl; }; FBSD_1.4 { __ns_parserr2; __ns_name_pton2; __ns_name_unpack2; __ns_name_length; __ns_name_eq; __ns_name_owned; __ns_name_map; __ns_name_labels; }; diff --git a/lib/libc/net/Symbol.map b/lib/libc/net/Symbol.map index 01d3bcb888d0..b2ecd4f08735 100644 --- a/lib/libc/net/Symbol.map +++ b/lib/libc/net/Symbol.map @@ -1,174 +1,173 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __b64_ntop; __b64_pton; ether_line; ether_aton; ether_aton_r; ether_ntoa; ether_ntoa_r; ether_ntohost; ether_hostton; eui64_aton; eui64_ntoa; eui64_ntohost; eui64_hostton; gai_strerror; freeaddrinfo; getaddrinfo; gethostent; gethostent_r; gethostbyname; gethostbyname_r; gethostbyname2; gethostbyname2_r; gethostbyaddr; gethostbyaddr_r; sethostent; endhostent; getifaddrs; freeifaddrs; getifmaddrs; freeifmaddrs; getnameinfo; getnetent; getnetent_r; getnetbyname; getnetbyname_r; getnetbyaddr; getnetbyaddr_r; setnetent; endnetent; getprotobynumber; getprotobynumber_r; setprotoent; endprotoent; getprotoent; getprotoent_r; getprotobyname; getprotobyname_r; getservbyname; getservbyname_r; getservbyport; getservbyport_r; setservent; endservent; getservent; getservent_r; hesiod_init; hesiod_end; hesiod_to_bind; hesiod_resolve; hesiod_free_list; hes_init; hes_to_bind; hes_resolve; hes_error; hes_free; if_indextoname; if_nameindex; if_freenameindex; if_nametoindex; inet6_option_space; inet6_option_init; inet6_option_append; inet6_option_alloc; inet6_option_next; inet6_option_find; inet6_opt_init; inet6_opt_append; inet6_opt_finish; inet6_opt_set_val; inet6_opt_next; inet6_opt_find; inet6_opt_get_val; link_addr; link_ntoa; getipnodebyname; getipnodebyaddr; freehostent; __nsdefaultsrc; _nsdbtaddsrc; _nsdbtdump; _nsdbtput; nsdispatch; rcmd; rcmd_af; rresvport; rresvport_af; ruserok; iruserok; iruserok_sa; rcmdsh; recv; inet6_rthdr_space; inet6_rthdr_init; inet6_rthdr_add; inet6_rthdr_lasthop; inet6_rthdr_segments; inet6_rthdr_getaddr; inet6_rthdr_getflags; inet6_rth_space; inet6_rth_init; inet6_rth_add; inet6_rth_reverse; inet6_rth_segments; inet6_rth_getaddr; send; sockatmark; in6addr_any; in6addr_loopback; in6addr_nodelocal_allnodes; in6addr_linklocal_allnodes; sctp_getaddrlen; sctp_getassocid; sctp_bindx; sctp_connectx; sctp_peeloff; sctp_opt_info; sctp_getpaddrs; sctp_freepaddrs; sctp_getladdrs; sctp_freeladdrs; sctp_sendmsg; sctp_sendmsgx; sctp_send; sctp_sendx; sctp_recvmsg; setipv4sourcefilter; getipv4sourcefilter; getsourcefilter; setsourcefilter; }; FBSD_1.3 { sctp_recvv; sctp_sendv; }; FBSDprivate_1.0 { _nsdispatch; _nsyyerror; /* generated from nslexer.l */ _nsyylex; /* generated from nslexer.l */ _nsyyparse; /* generated from nsparser.y */ _nsyylineno; /* generated from nsparser.y */ __dns_getanswer; __ivaliduser; __ivaliduser_af; __ivaliduser_sa; __check_rhosts_file; __rcmd_errstr; __nss_compat_getgrnam_r; __nss_compat_getgrgid_r; __nss_compat_getgrent_r; __nss_compat_setgrent; __nss_compat_endgrent; __nss_compat_getpwnam_r; __nss_compat_getpwuid_r; __nss_compat_getpwent_r; __nss_compat_setpwent; __nss_compat_endpwent; }; diff --git a/lib/libc/nls/Symbol.map b/lib/libc/nls/Symbol.map index 818466e6ffb1..d8ee248d60f0 100644 --- a/lib/libc/nls/Symbol.map +++ b/lib/libc/nls/Symbol.map @@ -1,9 +1,8 @@ /* - * $FreeBSD$ */ FBSD_1.0 { catopen; catgets; catclose; }; diff --git a/lib/libc/posix1e/Symbol.map b/lib/libc/posix1e/Symbol.map index d78691419c90..87e18493d1ec 100644 --- a/lib/libc/posix1e/Symbol.map +++ b/lib/libc/posix1e/Symbol.map @@ -1,95 +1,94 @@ /* - * $FreeBSD$ */ FBSD_1.0 { acl_calc_mask; acl_copy_entry; acl_copy_ext; acl_copy_int; acl_delete_def_file; acl_delete_def_link_np; acl_delete_file_np; acl_delete_link_np; acl_delete_fd_np; acl_delete_entry; acl_create_entry; acl_get_entry; acl_free; acl_from_text; acl_get_file; acl_get_link_np; acl_get_fd; acl_get_fd_np; acl_get_permset; acl_get_qualifier; acl_get_tag_type; acl_init; acl_dup; acl_clear_perms; acl_set_file; acl_set_link_np; acl_set_fd; acl_set_fd_np; acl_set_permset; acl_set_qualifier; acl_set_tag_type; acl_to_text; acl_valid; acl_valid_file_np; acl_valid_link_np; acl_valid_fd_np; extattr_namespace_to_string; extattr_string_to_namespace; mac_reload; mac_free; mac_from_text; mac_to_text; mac_prepare; mac_prepare_type; mac_prepare_ifnet_label; mac_prepare_file_label; mac_prepare_packet_label; mac_prepare_process_label; mac_is_present; mac_execve; mac_get_fd; mac_get_file; mac_get_link; mac_get_peer; mac_get_pid; mac_get_proc; mac_set_fd; mac_set_file; mac_set_link; mac_set_proc; }; FBSD_1.1 { acl_add_flag_np; acl_add_perm; acl_clear_flags_np; acl_create_entry_np; acl_delete_entry_np; acl_delete_flag_np; acl_delete_perm; acl_get_brand_np; acl_get_entry_type_np; acl_get_flag_np; acl_get_flagset_np; acl_get_perm_np; acl_is_trivial_np; acl_set_entry_type_np; acl_set_flagset_np; acl_strip_np; acl_to_text_np; }; FBSD_1.7 { acl_cmp_np; acl_equiv_mode_np; acl_extended_file_np; acl_extended_file_nofollow_np; acl_extended_link_np; acl_from_mode_np; }; diff --git a/lib/libc/powerpc/SYS.h b/lib/libc/powerpc/SYS.h index 8d019144cdd6..7fdf7c734310 100644 --- a/lib/libc/powerpc/SYS.h +++ b/lib/libc/powerpc/SYS.h @@ -1,73 +1,72 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2002 Benno Rice. All rights reserved. * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $ - * $FreeBSD$ */ #include #include #define _SYSCALL(name) \ .text; \ .align 2; \ li 0,(SYS_##name); \ sc #define SYSCALL(name) \ .text; \ .align 2; \ 2: b CNAME(HIDENAME(cerror)); \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bso 2b #define PSEUDO(name) \ .text; \ .align 2; \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bnslr; \ b CNAME(HIDENAME(cerror)); \ END(__sys_##name) #define RSYSCALL(name) \ .text; \ .align 2; \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bnslr; \ b CNAME(HIDENAME(cerror)); \ END(__sys_##name) diff --git a/lib/libc/powerpc/Symbol.map b/lib/libc/powerpc/Symbol.map index 8b4418b8eaae..fb82bcdb27f0 100644 --- a/lib/libc/powerpc/Symbol.map +++ b/lib/libc/powerpc/Symbol.map @@ -1,54 +1,53 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; _mcount; _setjmp; _longjmp; fabs; __flt_rounds; fpgetmask; fpgetround; fpgetsticky; fpsetmask; fpsetround; __infinity; __nan; makecontext; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; brk; sbrk; vfork; }; FBSD_1.3 { __eabi; }; FBSDprivate_1.0 { /* PSEUDO syscalls */ _getlogin; _fpgetsticky; __makecontext; __longjmp; signalcontext; __signalcontext; __syncicache; }; diff --git a/lib/libc/powerpc64/SYS.h b/lib/libc/powerpc64/SYS.h index 9ca5af4b70ed..c364090a5487 100644 --- a/lib/libc/powerpc64/SYS.h +++ b/lib/libc/powerpc64/SYS.h @@ -1,98 +1,97 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2002 Benno Rice. All rights reserved. * Copyright (c) 2002 David E. O'Brien. 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 author nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:56 thorpej Exp $ - * $FreeBSD$ */ #include #include #define _SYSCALL(name) \ .text; \ .align 2; \ li 0,(SYS_##name); \ sc #define SYSCALL(name) \ .text; \ .align 2; \ 2: mflr %r0; \ std %r0,16(%r1); \ stdu %r1,-48(%r1); \ bl CNAME(HIDENAME(cerror)); \ nop; \ addi %r1,%r1,48; \ ld %r0,16(%r1); \ mtlr %r0; \ blr; \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bso 2b #define PSEUDO(name) \ .text; \ .align 2; \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bnslr; \ mflr %r0; \ std %r0,16(%r1); \ stdu %r1,-48(%r1); \ bl CNAME(HIDENAME(cerror)); \ nop; \ addi %r1,%r1,48; \ ld %r0,16(%r1); \ mtlr %r0; \ blr; \ END(__sys_##name) #define RSYSCALL(name) \ .text; \ .align 2; \ ENTRY(__sys_##name); \ WEAK_REFERENCE(__sys_##name, name); \ WEAK_REFERENCE(__sys_##name, _##name); \ _SYSCALL(name); \ bnslr; \ \ mflr %r0; \ std %r0,16(%r1); \ stdu %r1,-48(%r1); \ bl CNAME(HIDENAME(cerror)); \ nop; \ addi %r1,%r1,48; \ ld %r0,16(%r1); \ mtlr %r0; \ blr; \ END(__sys_##name) diff --git a/lib/libc/powerpc64/Symbol.map b/lib/libc/powerpc64/Symbol.map index 57b20a5984c0..7d010fda6693 100644 --- a/lib/libc/powerpc64/Symbol.map +++ b/lib/libc/powerpc64/Symbol.map @@ -1,50 +1,49 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; _mcount; _setjmp; _longjmp; fabs; __flt_rounds; fpgetmask; fpgetround; fpgetsticky; fpsetmask; fpsetround; __infinity; __nan; makecontext; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; brk; sbrk; vfork; }; FBSDprivate_1.0 { /* PSEUDO syscalls */ _getlogin; _fpgetsticky; __makecontext; __longjmp; signalcontext; __signalcontext; __syncicache; }; diff --git a/lib/libc/quad/Symbol.map b/lib/libc/quad/Symbol.map index 82ad9402a9ff..2752be26abb4 100644 --- a/lib/libc/quad/Symbol.map +++ b/lib/libc/quad/Symbol.map @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ FBSD_1.0 { /* * These symbols really shouldn't be exported since they should * be pulled from libgcc, but the build of some applications is * broken and they expect to see them in libc. glibc exports * them, but they do not appear to be exported in Solaris. */ __adddi3; __anddi3; __ashldi3; __ashrdi3; __cmpdi2; __divdi3; __fixdfdi; __fixsfdi; __fixunsdfdi; __fixunssfdi; __floatdidf; __floatdisf; __floatunsdidf; __iordi3; __lshldi3; __lshrdi3; __moddi3; __muldi3; __negdi2; __one_cmpldi2; __qdivrem; __subdi3; __ucmpdi2; __udivdi3; __umoddi3; __xordi3; }; diff --git a/lib/libc/quad/quad.h b/lib/libc/quad/quad.h index a9f84470876e..0bda2b67398b 100644 --- a/lib/libc/quad/quad.h +++ b/lib/libc/quad/quad.h @@ -1,105 +1,104 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and * contributed to Berkeley. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)quad.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ /* * Quad arithmetic. * * This library makes the following assumptions: * * - The type long long (aka quad_t) exists. * * - A quad variable is exactly twice as long as `long'. * * - The machine's arithmetic is two's complement. * * This library can provide 128-bit arithmetic on a machine with 128-bit * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines * with 48-bit longs. */ #include #include /* * Depending on the desired operation, we view a `long long' (aka quad_t) in * one or more of the following formats. */ union uu { quad_t q; /* as a (signed) quad */ quad_t uq; /* as an unsigned quad */ long sl[2]; /* as two signed longs */ u_long ul[2]; /* as two unsigned longs */ }; /* * Define high and low longwords. */ #define H _QUAD_HIGHWORD #define L _QUAD_LOWWORD /* * Total number of bits in a quad_t and in the pieces that make it up. * These are used for shifting, and also below for halfword extraction * and assembly. */ #define QUAD_BITS (sizeof(quad_t) * CHAR_BIT) #define LONG_BITS (sizeof(long) * CHAR_BIT) #define HALF_BITS (sizeof(long) * CHAR_BIT / 2) /* * Extract high and low shortwords from longword, and move low shortword of * longword to upper half of long, i.e., produce the upper longword of * ((quad_t)(x) << (number_of_bits_in_long/2)). (`x' must actually be u_long.) * * These are used in the multiply code, to split a longword into upper * and lower halves, and to reassemble a product as a quad_t, shifted left * (sizeof(long)*CHAR_BIT/2). */ #define HHALF(x) ((x) >> HALF_BITS) #define LHALF(x) ((x) & ((1L << HALF_BITS) - 1)) #define LHUP(x) ((x) << HALF_BITS) int __cmpdi2(quad_t a, quad_t b); quad_t __divdi3(quad_t a, quad_t b); quad_t __moddi3(quad_t a, quad_t b); u_quad_t __qdivrem(u_quad_t u, u_quad_t v, u_quad_t *rem); int __ucmpdi2(u_quad_t a, u_quad_t b); u_quad_t __udivdi3(u_quad_t a, u_quad_t b); u_quad_t __umoddi3(u_quad_t a, u_quad_t b); typedef unsigned int qshift_t; diff --git a/lib/libc/regex/Symbol.map b/lib/libc/regex/Symbol.map index 1da7b81ba11b..3b9072571740 100644 --- a/lib/libc/regex/Symbol.map +++ b/lib/libc/regex/Symbol.map @@ -1,13 +1,12 @@ /* - * $FreeBSD$ */ FBSD_1.0 { regerror; regexec; regfree; }; FBSD_1.6 { regcomp; }; diff --git a/lib/libc/regex/cname.h b/lib/libc/regex/cname.h index 3419181aac97..a50ebbe54cb4 100644 --- a/lib/libc/regex/cname.h +++ b/lib/libc/regex/cname.h @@ -1,140 +1,139 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Henry Spencer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)cname.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* character-name table */ static struct cname { const char *name; char code; } cnames[] = { {"NUL", '\0'}, {"SOH", '\001'}, {"STX", '\002'}, {"ETX", '\003'}, {"EOT", '\004'}, {"ENQ", '\005'}, {"ACK", '\006'}, {"BEL", '\007'}, {"alert", '\007'}, {"BS", '\010'}, {"backspace", '\b'}, {"HT", '\011'}, {"tab", '\t'}, {"LF", '\012'}, {"newline", '\n'}, {"VT", '\013'}, {"vertical-tab", '\v'}, {"FF", '\014'}, {"form-feed", '\f'}, {"CR", '\015'}, {"carriage-return", '\r'}, {"SO", '\016'}, {"SI", '\017'}, {"DLE", '\020'}, {"DC1", '\021'}, {"DC2", '\022'}, {"DC3", '\023'}, {"DC4", '\024'}, {"NAK", '\025'}, {"SYN", '\026'}, {"ETB", '\027'}, {"CAN", '\030'}, {"EM", '\031'}, {"SUB", '\032'}, {"ESC", '\033'}, {"IS4", '\034'}, {"FS", '\034'}, {"IS3", '\035'}, {"GS", '\035'}, {"IS2", '\036'}, {"RS", '\036'}, {"IS1", '\037'}, {"US", '\037'}, {"space", ' '}, {"exclamation-mark", '!'}, {"quotation-mark", '"'}, {"number-sign", '#'}, {"dollar-sign", '$'}, {"percent-sign", '%'}, {"ampersand", '&'}, {"apostrophe", '\''}, {"left-parenthesis", '('}, {"right-parenthesis", ')'}, {"asterisk", '*'}, {"plus-sign", '+'}, {"comma", ','}, {"hyphen", '-'}, {"hyphen-minus", '-'}, {"period", '.'}, {"full-stop", '.'}, {"slash", '/'}, {"solidus", '/'}, {"zero", '0'}, {"one", '1'}, {"two", '2'}, {"three", '3'}, {"four", '4'}, {"five", '5'}, {"six", '6'}, {"seven", '7'}, {"eight", '8'}, {"nine", '9'}, {"colon", ':'}, {"semicolon", ';'}, {"less-than-sign", '<'}, {"equals-sign", '='}, {"greater-than-sign", '>'}, {"question-mark", '?'}, {"commercial-at", '@'}, {"left-square-bracket", '['}, {"backslash", '\\'}, {"reverse-solidus", '\\'}, {"right-square-bracket",']'}, {"circumflex", '^'}, {"circumflex-accent", '^'}, {"underscore", '_'}, {"low-line", '_'}, {"grave-accent", '`'}, {"left-brace", '{'}, {"left-curly-bracket", '{'}, {"vertical-line", '|'}, {"right-brace", '}'}, {"right-curly-bracket", '}'}, {"tilde", '~'}, {"DEL", '\177'}, {NULL, 0} }; diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h index 38bbed90fd8f..369c0231b677 100644 --- a/lib/libc/regex/regex2.h +++ b/lib/libc/regex/regex2.h @@ -1,204 +1,203 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Henry Spencer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)regex2.h 8.4 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* * First, the stuff that ends up in the outside-world include file = typedef off_t regoff_t; = typedef struct { = int re_magic; = size_t re_nsub; // number of parenthesized subexpressions = const char *re_endp; // end pointer for REG_PEND = struct re_guts *re_g; // none of your business :-) = } regex_t; = typedef struct { = regoff_t rm_so; // start of match = regoff_t rm_eo; // end of match = } regmatch_t; */ /* * internals of regex_t */ #define MAGIC1 ((('r'^0200)<<8) | 'e') /* * The internal representation is a *strip*, a sequence of * operators ending with an endmarker. (Some terminology etc. is a * historical relic of earlier versions which used multiple strips.) * Certain oddities in the representation are there to permit running * the machinery backwards; in particular, any deviation from sequential * flow must be marked at both its source and its destination. Some * fine points: * * - OPLUS_ and O_PLUS are *inside* the loop they create. * - OQUEST_ and O_QUEST are *outside* the bypass they create. * - OCH_ and O_CH are *outside* the multi-way branch they create, while * OOR1 and OOR2 are respectively the end and the beginning of one of * the branches. Note that there is an implicit OOR2 following OCH_ * and an implicit OOR1 preceding O_CH. * * In state representations, an operator's bit is on to signify a state * immediately *preceding* "execution" of that operator. */ typedef unsigned long sop; /* strip operator */ typedef unsigned long sopno; #define OPRMASK 0xf8000000L #define OPDMASK 0x07ffffffL #define OPSHIFT ((unsigned)27) #define OP(n) ((n)&OPRMASK) #define OPND(n) ((n)&OPDMASK) #define SOP(op, opnd) ((op)|(opnd)) /* operators meaning operand */ /* (back, fwd are offsets) */ #define OEND (1L<= 0); if (ch < NC) return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^ cs->invert); for (i = 0; i < cs->nwides; i++) { if (cs->icase) { if (ch == towlower(cs->wides[i]) || ch == towupper(cs->wides[i])) return (!cs->invert); } else if (ch == cs->wides[i]) return (!cs->invert); } for (i = 0; i < cs->nranges; i++) if (cs->ranges[i].min <= ch && ch <= cs->ranges[i].max) return (!cs->invert); for (i = 0; i < cs->ntypes; i++) if (iswctype(ch, cs->types[i])) return (!cs->invert); return (cs->invert); } static __inline int CHIN(cset *cs, wint_t ch) { assert(ch >= 0); if (ch < NC) return (((cs->bmp[ch >> 3] & (1 << (ch & 7))) != 0) ^ cs->invert); else if (cs->icase) return (CHIN1(cs, ch) || CHIN1(cs, towlower(ch)) || CHIN1(cs, towupper(ch))); else return (CHIN1(cs, ch)); } /* * main compiled-expression structure */ struct re_guts { int magic; # define MAGIC2 ((('R'^0200)<<8)|'E') sop *strip; /* malloced area for strip */ unsigned int ncsets; /* number of csets in use */ cset *sets; /* -> cset [ncsets] */ int cflags; /* copy of regcomp() cflags argument */ sopno nstates; /* = number of sops */ sopno firststate; /* the initial OEND (normally 0) */ sopno laststate; /* the final OEND */ int iflags; /* internal flags */ # define USEBOL 01 /* used ^ */ # define USEEOL 02 /* used $ */ # define BAD 04 /* something wrong */ int nbol; /* number of ^ used */ int neol; /* number of $ used */ char *must; /* match must contain this string */ int moffset; /* latest point at which must may be located */ int *charjump; /* Boyer-Moore char jump table */ int *matchjump; /* Boyer-Moore match jump table */ int mlen; /* length of must */ size_t nsub; /* copy of re_nsub */ int backrefs; /* does it use back references? */ sopno nplus; /* how deep does it nest +s? */ }; /* misc utilities */ #define OUT (CHAR_MIN - 1) /* a non-character value */ #define IGN (CHAR_MIN - 2) #define ISWORD(c) (iswalnum((uch)(c)) || (c) == '_') diff --git a/lib/libc/regex/utils.h b/lib/libc/regex/utils.h index 72f2286a0260..6a486a9a9b63 100644 --- a/lib/libc/regex/utils.h +++ b/lib/libc/regex/utils.h @@ -1,58 +1,57 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Henry Spencer. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)utils.h 8.3 (Berkeley) 3/20/94 - * $FreeBSD$ */ /* utility definitions */ #define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ #define INFINITY (DUPMAX + 1) #define NC_MAX (CHAR_MAX - CHAR_MIN + 1) #define NC ((MB_CUR_MAX) == 1 ? (NC_MAX) : (128)) typedef unsigned char uch; /* switch off assertions (if not already off) if no REDEBUG */ #ifndef REDEBUG #ifndef NDEBUG #define NDEBUG /* no assertions please */ #endif #endif #include /* for old systems with bcopy() but no memmove() */ #ifdef USEBCOPY #define memmove(d, s, c) bcopy(s, d, c) #endif diff --git a/lib/libc/resolv/Symbol.map b/lib/libc/resolv/Symbol.map index 170333343cf0..c93d8bea6f15 100644 --- a/lib/libc/resolv/Symbol.map +++ b/lib/libc/resolv/Symbol.map @@ -1,112 +1,111 @@ /* - * $FreeBSD$ */ FBSD_1.0 { /* h_nerr; */ /* Why is this not staticized in net/herror.c? */ h_errlist; herror; hstrerror; __dn_expand; __dn_comp; __dn_skipname; __res_hnok; __res_ownok; __res_mailok; __res_dnok; __putlong; __putshort; _getlong; _getshort; dn_comp; dn_expand; __fp_resstat; __p_query; __fp_query; __fp_nquery; __p_cdnname; __p_cdname; __p_fqnname; __p_fqname; __p_cert_syms; __p_class_syms; __p_key_syms; __p_rcode_syms; __p_type_syms; __sym_ston; __sym_ntos; __sym_ntop; __p_rcode; __p_sockun; __p_type; __p_section; __p_class; __p_option; __p_time; __loc_aton; __loc_ntoa; __dn_count_labels; __p_secstodate; fp_resstat; p_query; p_fqnname; sym_ston; sym_ntos; sym_ntop; dn_count_labels; p_secstodate; __res_init; __res_randomid; __h_errno; __h_errno_set; h_errno; res_init; __res_findzonecut2; __res_freeupdrec; __res_mkquery; res_mkquery; __res_mkupdrec; __res_mkupdate; __res_opt; __res_getservers; __res_hostalias; __res_nametoclass; __res_nametotype; __res_nclose; __res_ndestroy; __res_ninit; __res_nmkquery; __res_nmkupdate; __res_nopt; __res_nquery; __res_nquerydomain; __res_nsearch; __res_nsend; __res_nupdate; __res_ourserver_p; __res_pquery; __res_query; __res_search; __res_querydomain; __res_setservers; _res; __res_state; __res_vinit; __hostalias; res_query; res_search; res_querydomain; __res_isourserver; __res_nameinquery; __res_queriesmatch; __res_send; __res_close; _res_close; res_send; __res_update; }; FBSD_1.4 { __res_rndinit; __res_nrandomid; }; diff --git a/lib/libc/riscv/Symbol.map b/lib/libc/riscv/Symbol.map index 4214db12ed5f..c19f7ddf631e 100644 --- a/lib/libc/riscv/Symbol.map +++ b/lib/libc/riscv/Symbol.map @@ -1,36 +1,35 @@ /* - * $FreeBSD$ */ /* * This only needs to contain symbols that are not listed in * symbol maps from other parts of libc (i.e., not found in * stdlib/Symbol.map, string/Symbol.map, sys/Symbol.map, ...). */ FBSD_1.0 { /* PSEUDO syscalls */ _exit; _setjmp; _longjmp; fabs; __flt_rounds; fpgetmask; fpsetmask; __infinity; __nan; setjmp; longjmp; sigsetjmp; siglongjmp; htonl; htons; ntohl; ntohs; vfork; makecontext; }; FBSDprivate_1.0 { __makecontext; }; diff --git a/lib/libc/rpc/Symbol.map b/lib/libc/rpc/Symbol.map index 4f356de99748..89b434ce67db 100644 --- a/lib/libc/rpc/Symbol.map +++ b/lib/libc/rpc/Symbol.map @@ -1,247 +1,246 @@ /* - * $FreeBSD$ */ FBSD_1.0 { /* From crypt_clnt.c (generated by rpcgen - include/rpcsvc/crypt.x) */ des_crypt_1; /* From crypt_xdr.c (generated by rpcgen - include/rpcsvc/crypt.x) */ xdr_des_dir; xdr_des_mode; xdr_desargs; xdr_desresp; /* From yp_xdr.c (generated by rpcgen - include/rpcsvc/yp.x) */ xdr_domainname; xdr_keydat; xdr_mapname; xdr_peername; xdr_valdat; xdr_ypbind_binding; xdr_ypbind_resp; xdr_ypbind_resptype; xdr_ypbind_setdom; xdr_ypmap_parms; xdr_ypmaplist; xdr_yppush_status; xdr_yppushresp_xfr; xdr_ypreq_key; xdr_ypreq_nokey; xdr_ypreq_xfr; xdr_ypreqtype; xdr_yprequest; xdr_ypresp_all; xdr_ypresp_key_val; xdr_ypresp_maplist; xdr_ypresp_master; xdr_ypresp_order; xdr_ypresp_val; xdr_ypresp_xfr; xdr_ypresponse; xdr_ypresptype; xdr_ypstat; xdr_ypxfrstat; authdes_seccreate; authdes_pk_seccreate; authnone_create; authunix_create; authunix_create_default; xdr_authdes_cred; xdr_authdes_verf; xdr_authunix_parms; bindresvport; bindresvport_sa; rpc_broadcast_exp; rpc_broadcast; clnt_dg_create; clnt_create_vers; clnt_create_vers_timed; clnt_create; clnt_create_timed; clnt_tp_create; clnt_tp_create_timed; clnt_tli_create; clnt_sperror; clnt_perror; clnt_sperrno; clnt_perrno; clnt_spcreateerror; clnt_pcreateerror; clnt_raw_create; rpc_call; clnt_vc_create; cbc_crypt; ecb_crypt; des_setparity; setnetconfig; getnetconfig; endnetconfig; getnetconfigent; freenetconfigent; nc_sperror; nc_perror; setnetpath; getnetpath; endnetpath; getpublicandprivatekey; getpublickey; getrpcbynumber; getrpcbyname; setrpcent; endrpcent; getrpcent; getrpcport; key_setsecret; key_secretkey_is_set; key_encryptsession_pk; key_decryptsession_pk; key_encryptsession; key_decryptsession; key_gendes; key_setnet; key_get_conv; xdr_keystatus; xdr_keybuf; xdr_netnamestr; xdr_cryptkeyarg; xdr_cryptkeyarg2; xdr_cryptkeyres; xdr_unixcred; xdr_getcredres; xdr_key_netstarg; xdr_key_netstres; rpc_createerr; __rpc_createerr; getnetname; user2netname; host2netname; netname2user; netname2host; pmap_set; pmap_unset; pmap_getmaps; pmap_getport; xdr_pmap; xdr_pmaplist; xdr_pmaplist_ptr; pmap_rmtcall; xdr_rmtcall_args; xdr_rmtcallres; xdr_callmsg; _null_auth; svc_fdset; svc_maxfd; _rpc_dtablesize; __rpc_get_t_size; __rpc_getconfip; __rpc_setconf; __rpc_getconf; __rpc_endconf; rpc_nullproc; __rpc_fd2sockinfo; __rpc_nconf2sockinfo; __rpc_nconf2fd; taddr2uaddr; uaddr2taddr; xdr_opaque_auth; xdr_des_block; xdr_accepted_reply; xdr_rejected_reply; xdr_replymsg; xdr_callhdr; _seterr_reply; clntudp_bufcreate; clntudp_create; clnttcp_create; clntraw_create; svctcp_create; svcudp_bufcreate; svcfd_create; svcudp_create; svcraw_create; get_myaddress; callrpc; registerrpc; clnt_broadcast; authdes_create; clntunix_create; svcunix_create; svcunixfd_create; rpcb_set; rpcb_unset; rpcb_getaddr; rpcb_getmaps; rpcb_rmtcall; rpcb_gettime; rpcb_taddr2uaddr; rpcb_uaddr2taddr; xdr_rpcb; xdr_rpcblist_ptr; xdr_rpcblist; xdr_rpcb_entry; xdr_rpcb_entry_list_ptr; xdr_rpcb_rmtcallargs; xdr_rpcb_rmtcallres; xdr_netbuf; xdr_rpcbs_addrlist; xdr_rpcbs_rmtcalllist; xdr_rpcbs_proc; xdr_rpcbs_addrlist_ptr; xdr_rpcbs_rmtcalllist_ptr; xdr_rpcb_stat; xdr_rpcb_stat_byvers; rtime; xprt_register; xprt_unregister; svc_reg; svc_unreg; svc_register; svc_unregister; svc_sendreply; svcerr_noproc; svcerr_decode; svcerr_systemerr; svcerr_auth; svcerr_weakauth; svcerr_noprog; svcerr_progvers; svc_getreq; svc_getreqset; svc_getreq_common; svc_getreq_poll; rpc_control; _authenticate; _svcauth_null; svc_auth_reg; _svcauth_des; authdes_getucred; _svcauth_unix; _svcauth_short; svc_dg_create; svc_dg_enablecache; svc_create; svc_tp_create; svc_tli_create; __rpc_rawcombuf; svc_raw_create; svc_run; svc_exit; rpc_reg; svc_vc_create; svc_fd_create; __rpc_get_local_uid; }; FBSDprivate_1.0 { __des_crypt_LOCAL; __key_encryptsession_pk_LOCAL; __key_decryptsession_pk_LOCAL; __key_gendes_LOCAL; __svc_clean_idle; __rpc_gss_unwrap; __rpc_gss_unwrap_stub; __rpc_gss_wrap; __rpc_gss_wrap_stub; }; diff --git a/lib/libc/secure/Symbol.map b/lib/libc/secure/Symbol.map index aaa76c17291a..4f9f34844131 100644 --- a/lib/libc/secure/Symbol.map +++ b/lib/libc/secure/Symbol.map @@ -1,9 +1,8 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __chk_fail; __stack_chk_fail; __stack_chk_guard; }; diff --git a/lib/libc/softfloat/Symbol.map b/lib/libc/softfloat/Symbol.map index c5849d3f1efe..ee6d1b0eac52 100644 --- a/lib/libc/softfloat/Symbol.map +++ b/lib/libc/softfloat/Symbol.map @@ -1,55 +1,54 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _fpgetmask; fpgetmask; _fpgetround; fpgetround; _fpgetsticky; fpgetsticky; _fpsetmask; fpsetmask; _fpsetround; fpsetround; _fpsetsticky; fpsetsticky; }; FBSDprivate_1.0 { __softfloat_float_exception_flags; __softfloat_float_exception_mask; __softfloat_float_rounding_mode; __softfloat_float_raise; __adddf3; __addsf3; __divdf3; __divsf3; __eqdf2; __eqsf2; __extendsfdf2; __fixdfsi; __fixsfsi; __floatsidf; __floatsisf; __gedf2; __gesf2; __gtdf2; __gtsf2; __ledf2; __lesf2; __ltdf2; __ltsf2; __muldf3; __mulsf3; __nedf2; __negdf2; __negsf2; __nesf2; __subdf3; __subsf3; __truncdfsf2; __unorddf2; __unordsf2; }; diff --git a/lib/libc/stdio/Symbol.map b/lib/libc/stdio/Symbol.map index 4926b6f35729..575dc3cd923c 100644 --- a/lib/libc/stdio/Symbol.map +++ b/lib/libc/stdio/Symbol.map @@ -1,221 +1,220 @@ /* - * $FreeBSD$ */ FBSD_1.0 { flockfile; ftrylockfile; funlockfile; asprintf; clearerr; fclose; fcloseall; fdopen; feof; ferror; fflush; fgetc; fgetln; fgetpos; fgets; fgetwc; fgetwln; fgetws; fileno; __sF; __stdinp; __stdoutp; __stderrp; f_prealloc; /* deprecated??? */ fopen; fprintf; fpurge; fputc; fputs; fputwc; fputws; fread; freopen; fscanf; fseek; fseeko; fsetpos; ftell; ftello; funopen; fwide; fwprintf; fwrite; fwscanf; getc; getchar; gets; getw; getwc; getwchar; mkstemps; mkstemp; mkdtemp; mktemp; perror; printf; putc; putchar; puts; putw; putwc; putwchar; remove; rewind; __srget; scanf; setbuf; setbuffer; setlinebuf; setvbuf; snprintf; sprintf; sscanf; swprintf; swscanf; tempnam; tmpfile; tmpnam; ungetc; ungetwc; getchar_unlocked; getc_unlocked; putchar_unlocked; putc_unlocked; feof_unlocked; ferror_unlocked; clearerr_unlocked; fileno_unlocked; vasprintf; vfprintf; vfscanf; vfwprintf; vfwscanf; vprintf; vscanf; vsnprintf; vsprintf; vsscanf; vswprintf; vswscanf; vwprintf; vwscanf; __swbuf; wprintf; wscanf; }; FBSD_1.1 { dprintf; getdelim; getline; vdprintf; }; FBSD_1.3 { asprintf_l; fprintf_l; fwprintf_l; printf_l; snprintf_l; sprintf_l; swprintf_l; vasprintf_l; vfprintf_l; vfwprintf_l; vprintf_l; vsnprintf_l; vsprintf_l; vswprintf_l; vwprintf_l; wprintf_l; fgetwc_l; fputwc_l; ungetwc_l; vfwscanf_l; vswscanf_l; fscanf_l; fwscanf_l; scanf_l; sscanf_l; swscanf_l; vfscanf_l; vscanf_l; vsscanf_l; vwscanf_l; wscanf_l; fgetws_l; fputws_l; getwc_l; getwchar_l; putwc_l; putwchar_l; fmemopen; open_memstream; open_wmemstream; mkostemp; mkostemps; }; FBSD_1.4 { fdclose; fopencookie; }; FBSD_1.5 { gets_s; }; FBSD_1.6 { fflush_unlocked; fputc_unlocked; fputs_unlocked; fread_unlocked; fwrite_unlocked; mkostempsat; }; FBSDprivate_1.0 { _flockfile; _flockfile_debug_stub; _flockfile_debug; _ftrylockfile; _funlockfile; __vfscanf; /* * xprintf support */ __use_xprintf; __lowercase_hex; __uppercase_hex; __printf_flush; __printf_puts; __printf_pad; __printf_out; __xvprintf; register_printf_function; register_printf_render; register_printf_render_std; __printf_arginfo_float; __printf_render_float; __printf_arginfo_hexdump; __printf_render_hexdump; __printf_arginfo_int; __printf_render_int; __printf_arginfo_ptr; __printf_render_ptr; __printf_arginfo_str; __printf_render_str; __printf_arginfo_chr; __printf_render_chr; __printf_arginfo_time; __printf_render_time; __printf_arginfo_vis; __printf_render_vis; }; diff --git a/lib/libc/stdio/floatio.h b/lib/libc/stdio/floatio.h index 00af7eaba561..4abf972f5f40 100644 --- a/lib/libc/stdio/floatio.h +++ b/lib/libc/stdio/floatio.h @@ -1,56 +1,55 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)floatio.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ /* * Floating point scanf/printf (input/output) definitions. */ /* * MAXEXPDIG is the maximum number of decimal digits needed to store a * floating point exponent in the largest supported format. It should * be ceil(log10(LDBL_MAX_10_EXP)) or, if hexadecimal floating point * conversions are supported, ceil(log10(LDBL_MAX_EXP)). But since it * is presently never greater than 5 in practice, we fudge it. */ #define MAXEXPDIG 6 #if LDBL_MAX_EXP > 999999 #error "floating point buffers too small" #endif char *__hdtoa(double, const char *, int, int *, int *, char **); char *__hldtoa(long double, const char *, int, int *, int *, char **); char *__ldtoa(long double *, int, int, int *, int *, char **); diff --git a/lib/libc/stdio/fvwrite.h b/lib/libc/stdio/fvwrite.h index 406f138d7db8..f9e89dfd2454 100644 --- a/lib/libc/stdio/fvwrite.h +++ b/lib/libc/stdio/fvwrite.h @@ -1,51 +1,50 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fvwrite.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ /* * I/O descriptors for __sfvwrite(). */ struct __siov { void *iov_base; size_t iov_len; }; struct __suio { struct __siov *uio_iov; int uio_iovcnt; int uio_resid; }; extern int __sfvwrite(FILE *, struct __suio *); diff --git a/lib/libc/stdio/glue.h b/lib/libc/stdio/glue.h index 6c805e038327..3fcb52316133 100644 --- a/lib/libc/stdio/glue.h +++ b/lib/libc/stdio/glue.h @@ -1,47 +1,46 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)glue.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ /* * The first few FILEs are statically allocated; others are dynamically * allocated and linked in via this glue structure. */ struct glue { struct glue *next; int niobs; FILE *iobs; }; extern struct glue __sglue; diff --git a/lib/libc/stdio/local.h b/lib/libc/stdio/local.h index 64156336f5e3..a5c465bcdcba 100644 --- a/lib/libc/stdio/local.h +++ b/lib/libc/stdio/local.h @@ -1,168 +1,167 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Copyright (c) 2011 The FreeBSD Foundation * * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)local.h 8.3 (Berkeley) 7/3/94 - * $FreeBSD$ */ #ifndef _STDIO_LOCAL_H #define _STDIO_LOCAL_H #include /* for off_t */ #include #include #include #include /* * Information local to this implementation of stdio, * in particular, macros and private variables. */ extern int _sread(FILE *, char *, int); extern int _swrite(FILE *, char const *, int); extern fpos_t _sseek(FILE *, fpos_t, int); extern int _ftello(FILE *, fpos_t *); extern int _fseeko(FILE *, off_t, int, int); extern int __fflush(FILE *fp); extern void __fcloseall(void); extern wint_t __fgetwc_mbs(FILE *, mbstate_t *, int *, locale_t); extern wint_t __fputwc(wchar_t, FILE *, locale_t); extern int __sflush(FILE *); extern FILE *__sfp(void); extern int __slbexpand(FILE *, size_t); extern int __srefill(FILE *); extern int __sread(void *, char *, int); extern int __swrite(void *, char const *, int); extern fpos_t __sseek(void *, fpos_t, int); extern int __sclose(void *); extern void __sinit(void); extern void _cleanup(void); extern void __smakebuf(FILE *); extern int __swhatbuf(FILE *, size_t *, int *); extern int _fwalk(int (*)(FILE *)); extern int __svfscanf(FILE *, locale_t, const char *, __va_list); extern int __swsetup(FILE *); extern int __sflags(const char *, int *); extern int __ungetc(int, FILE *); extern wint_t __ungetwc(wint_t, FILE *, locale_t); extern int __vfprintf(FILE *, locale_t, const char *, __va_list); extern int __vfscanf(FILE *, const char *, __va_list); extern int __vfwprintf(FILE *, locale_t, const wchar_t *, __va_list); extern int __vfwscanf(FILE * __restrict, locale_t, const wchar_t * __restrict, __va_list); extern size_t __fread(void * __restrict buf, size_t size, size_t count, FILE * __restrict fp); extern int __sdidinit; static inline wint_t __fgetwc(FILE *fp, locale_t locale) { int nread; return (__fgetwc_mbs(fp, &fp->_mbstate, &nread, locale)); } /* * Prepare the given FILE for writing, and return 0 iff it * can be written now. Otherwise, return EOF and set errno. */ #define prepwrite(fp) \ ((((fp)->_flags & __SWR) == 0 || \ ((fp)->_bf._base == NULL && ((fp)->_flags & __SSTR) == 0)) && \ __swsetup(fp)) /* * Test whether the given stdio file has an active ungetc buffer; * release such a buffer, without restoring ordinary unread data. */ #define HASUB(fp) ((fp)->_ub._base != NULL) #define FREEUB(fp) { \ if ((fp)->_ub._base != (fp)->_ubuf) \ free((char *)(fp)->_ub._base); \ (fp)->_ub._base = NULL; \ } /* * test for an fgetln() buffer. */ #define HASLB(fp) ((fp)->_lb._base != NULL) #define FREELB(fp) { \ free((char *)(fp)->_lb._base); \ (fp)->_lb._base = NULL; \ } /* * Structure initializations for 'fake' FILE objects. */ #define FAKE_FILE { \ ._file = -1, \ ._fl_mutex = PTHREAD_MUTEX_INITIALIZER, \ } /* * Set the orientation for a stream. If o > 0, the stream has wide- * orientation. If o < 0, the stream has byte-orientation. */ #define ORIENT(fp, o) do { \ if ((fp)->_orientation == 0) \ (fp)->_orientation = (o); \ } while (0) void __stdio_cancel_cleanup(void *); #define FLOCKFILE_CANCELSAFE(fp) \ { \ struct _pthread_cleanup_info __cleanup_info__; \ if (__isthreaded) { \ _FLOCKFILE(fp); \ ___pthread_cleanup_push_imp( \ __stdio_cancel_cleanup, (fp), \ &__cleanup_info__); \ } else { \ ___pthread_cleanup_push_imp( \ __stdio_cancel_cleanup, NULL, \ &__cleanup_info__); \ } \ { #define FUNLOCKFILE_CANCELSAFE() \ (void)0; \ } \ ___pthread_cleanup_pop_imp(1); \ } #endif /* _STDIO_LOCAL_H */ diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map index a105f781734d..e10789ceab1a 100644 --- a/lib/libc/stdlib/Symbol.map +++ b/lib/libc/stdlib/Symbol.map @@ -1,140 +1,139 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _Exit; a64l; abort; abs; atexit; __cxa_atexit; __cxa_finalize; atof; atoi; atol; atoll; bsearch; div; __isthreaded; exit; getenv; opterr; optind; optopt; optreset; optarg; getopt; getopt_long; getopt_long_only; suboptarg; getsubopt; grantpt; ptsname; unlockpt; hcreate; hdestroy; hsearch; heapsort; imaxabs; imaxdiv; insque; l64a; l64a_r; labs; ldiv; llabs; lldiv; lsearch; lfind; mergesort; putenv; qsort; radixsort; sradixsort; rand_r; srandom; srandomdev; initstate; setstate; random; reallocf; realpath; remque; setenv; unsetenv; strfmon; strtoimax; strtol; strtoll; strtonum; strtoq; strtoul; strtoull; strtoumax; strtouq; system; tdelete; tfind; tsearch; twalk; }; FBSD_1.3 { at_quick_exit; atof_l; atoi_l; atol_l; atoll_l; quick_exit; strtod_l; strtof_l; strtoimax_l; strtol_l; strtold_l; strtoll_l; strtoul_l; strtoull_l; strtoumax_l; }; FBSD_1.4 { atexit_b; bsearch_b; heapsort_b; mergesort_b; qsort_b; hcreate_r; hdestroy_r; hsearch_r; reallocarray; }; FBSD_1.5 { __cxa_thread_atexit; __cxa_thread_atexit_impl; abort_handler_s; ignore_handler_s; set_constraint_handler_s; }; FBSD_1.6 { ptsname_r; qsort_s; rand; srand; }; FBSD_1.7 { clearenv; qsort_r; secure_getenv; }; FBSDprivate_1.0 { __system; _system; __libc_system; __cxa_thread_call_dtors; __libc_atexit; }; diff --git a/lib/libc/stdlib/atexit.h b/lib/libc/stdlib/atexit.h index fdf2fc158380..456168325e46 100644 --- a/lib/libc/stdlib/atexit.h +++ b/lib/libc/stdlib/atexit.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)atexit.h 8.2 (Berkeley) 7/3/94 - * $FreeBSD$ */ /* must be at least 32 to guarantee ANSI conformance */ #define ATEXIT_SIZE 32 void __cxa_finalize(void *dso); diff --git a/lib/libc/stdlib/jemalloc/Symbol.map b/lib/libc/stdlib/jemalloc/Symbol.map index 087ca53ff75f..4356337d1c37 100644 --- a/lib/libc/stdlib/jemalloc/Symbol.map +++ b/lib/libc/stdlib/jemalloc/Symbol.map @@ -1,69 +1,68 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _malloc_options; _malloc_message; malloc; posix_memalign; calloc; realloc; free; malloc_usable_size; }; FBSD_1.3 { malloc_conf; malloc_message; aligned_alloc; malloc_stats_print; mallctl; mallctlnametomib; mallctlbymib; mallocx; rallocx; xallocx; sallocx; dallocx; nallocx; allocm; rallocm; sallocm; dallocm; nallocm; __malloc; __calloc; __realloc; __free; __posix_memalign; __malloc_usable_size; __mallocx; __rallocx; __xallocx; __sallocx; __dallocx; __nallocx; __allocm; __rallocm; __sallocm; __dallocm; __nallocm; }; FBSD_1.4 { sdallocx; __sdallocx; __aligned_alloc; __malloc_stats_print; __mallctl; __mallctlnametomib; __mallctlbymib; }; FBSDprivate_1.0 { _malloc_thread_cleanup; _malloc_prefork; _malloc_postfork; _malloc_first_thread; }; diff --git a/lib/libc/stdtime/Symbol.map b/lib/libc/stdtime/Symbol.map index 53aa448204d7..acdd3bbb89b4 100644 --- a/lib/libc/stdtime/Symbol.map +++ b/lib/libc/stdtime/Symbol.map @@ -1,36 +1,35 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _time32_to_time; _time_to_time32; _time64_to_time; _time_to_time64; _time_to_long; _long_to_time; _time_to_int; _int_to_time; strptime; strftime; tzname; tzsetwall; tzset; localtime; localtime_r; gmtime; gmtime_r; offtime; offtime_r; ctime; ctime_r; mktime; timelocal; timegm; timeoff; time2posix; posix2time; difftime; asctime_r; asctime; }; diff --git a/lib/libc/string/Symbol.map b/lib/libc/string/Symbol.map index 4fcd194bafd8..ec4778ff3c24 100644 --- a/lib/libc/string/Symbol.map +++ b/lib/libc/string/Symbol.map @@ -1,125 +1,124 @@ /* - * $FreeBSD$ */ FBSD_1.0 { bcmp; bcopy; memcpy; memmove; ffs; ffsl; fls; flsl; index; strchr; memccpy; memchr; memcmp; memmem; bzero; memset; strrchr; rindex; stpcpy; strcasecmp; strncasecmp; strcasestr; strcat; strcmp; strcoll; strcpy; strcspn; strdup; strerror_r; strerror; strlcat; strlcpy; strlen; strmode; strncat; strncmp; strncpy; strnstr; strpbrk; strsep; strsignal; strspn; strstr; strtok_r; strtok; strxfrm; swab; wcscat; wcschr; wcscmp; wcscoll; wcscpy; wcscspn; wcsdup; wcslcat; wcslcpy; wcslen; wcsncat; wcsncmp; wcsncpy; wcspbrk; wcsrchr; wcsspn; wcsstr; wcstok; wcswidth; wcsxfrm; wmemchr; wmemcmp; wmemcpy; wmemmove; wmemset; }; FBSD_1.1 { ffsll; flsll; memrchr; stpncpy; strndup; strnlen; wcpcpy; wcpncpy; wcscasecmp; wcsncasecmp; wcsnlen; }; FBSD_1.3 { strcasecmp_l; strcasestr_l; strchrnul; strncasecmp_l; wcswidth_l; wcwidth_l; }; FBSD_1.4 { explicit_bzero; }; FBSD_1.5 { memset_s; timingsafe_bcmp; timingsafe_memcmp; }; FBSD_1.6 { strerror_l; }; FBSD_1.7 { mempcpy; strverscmp; wmempcpy; }; FBSDprivate_1.0 { __strtok_r; }; diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index cc90998e83fb..c09c3696c17b 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -1,1052 +1,1051 @@ /* - * $FreeBSD$ */ /* * It'd be nice to automatically generate the syscall symbols, but we * don't know to what version they will eventually belong to, so for now * it has to be manual. */ FBSD_1.0 { __acl_aclcheck_fd; __acl_aclcheck_file; __acl_aclcheck_link; __acl_delete_fd; __acl_delete_file; __acl_delete_link; __acl_get_fd; __acl_get_file; __acl_get_link; __acl_set_fd; __acl_set_file; __acl_set_link; __getcwd; __mac_execve; __mac_get_fd; __mac_get_file; __mac_get_link; __mac_get_pid; __mac_get_proc; __mac_set_fd; __mac_set_file; __mac_set_link; __mac_set_proc; __setugid; __syscall; __sysctl; _umtx_op; abort2; accept; access; acct; adjtime; aio_cancel; aio_error; aio_fsync; aio_read; aio_return; aio_suspend; aio_waitcomplete; aio_write; audit; auditctl; auditon; bind; chdir; chflags; chmod; chown; chroot; clock_getres; clock_gettime; clock_settime; close; connect; dup; dup2; eaccess; execve; extattr_delete_fd; extattr_delete_file; extattr_delete_link; extattr_get_fd; extattr_get_file; extattr_get_link; extattr_list_fd; extattr_list_file; extattr_list_link; extattr_set_fd; extattr_set_file; extattr_set_link; extattrctl; fchdir; fchflags; fchmod; fchown; fcntl; fhopen; flock; fork; fpathconf; fsync; futimes; getaudit; getaudit_addr; getauid; getcontext; getdtablesize; getegid; geteuid; getfh; getgid; getgroups; getitimer; getpeername; getpgid; getpgrp; getpid; getppid; getpriority; getresgid; getresuid; getrlimit; getrusage; getsid; getsockname; getsockopt; gettimeofday; getuid; ioctl; issetugid; jail; jail_attach; kenv; kill; kldfind; kldfirstmod; kldload; kldnext; kldstat; kldsym; kldunload; kldunloadf; kqueue; kmq_notify; /* Do we want these to be public interfaces? */ kmq_open; /* librt uses them to provide mq_xxx. */ kmq_setattr; kmq_timedreceive; kmq_timedsend; kmq_unlink; ksem_close; ksem_destroy; ksem_getvalue; ksem_init; ksem_open; ksem_post; ksem_timedwait; ksem_trywait; ksem_unlink; ksem_wait; ktrace; lchflags; lchmod; lchown; lgetfh; link; lio_listio; listen; lutimes; mac_syscall; madvise; mincore; minherit; mkdir; mkfifo; mlock; mlockall; modfind; modfnext; modnext; modstat; mount; mprotect; msgget; msgrcv; msgsnd; msgsys; msync; munlock; munlockall; munmap; nanosleep; nfssvc; nmount; ntp_adjtime; ntp_gettime; open; pathconf; pipe; poll; posix_openpt; preadv; profil; pselect; ptrace; pwritev; quotactl; read; readlink; readv; reboot; recvfrom; recvmsg; rename; revoke; rfork; rmdir; rtprio; rtprio_thread; sched_get_priority_max; sched_get_priority_min; sched_getparam; sched_getscheduler; sched_rr_get_interval; sched_setparam; sched_setscheduler; sched_yield; select; semget; semop; semsys; sendfile; sendmsg; sendto; setaudit; setaudit_addr; setauid; setegid; seteuid; setgid; setgroups; setitimer; setlogin; setpgid; setpriority; setregid; setresgid; setresuid; setreuid; setrlimit; setsid; setsockopt; settimeofday; setuid; shm_open; shm_unlink; shmat; shmdt; shmget; shmsys; shutdown; sigaction; sigaltstack; sigpending; sigprocmask; sigqueue; sigreturn; sigsuspend; sigtimedwait; sigwait; sigwaitinfo; socket; socketpair; swapon; symlink; sync; sysarch; syscall; thr_create; thr_exit; thr_kill; thr_kill2; thr_new; thr_self; thr_set_name; thr_suspend; thr_wake; ktimer_create; /* Do we want these to be public interfaces? */ ktimer_delete; /* librt uses them to provide timer_xxx. */ ktimer_getoverrun; ktimer_gettime; ktimer_settime; umask; undelete; unlink; unmount; utimes; utrace; uuidgen; vadvise; wait4; write; writev; __error; ftruncate; lseek; mmap; pread; pwrite; truncate; }; FBSD_1.1 { __semctl; closefrom; cpuset; cpuset_getid; cpuset_setid; cpuset_getaffinity; cpuset_setaffinity; faccessat; fchmodat; fchownat; fexecve; futimesat; jail_get; jail_set; jail_remove; linkat; lpathconf; mkdirat; mkfifoat; msgctl; readlinkat; renameat; setfib; shmctl; symlinkat; unlinkat; }; FBSD_1.2 { cap_enter; cap_getmode; getloginclass; pdfork; pdgetpid; pdkill; posix_fallocate; rctl_get_racct; rctl_get_rules; rctl_get_limits; rctl_add_rule; rctl_remove_rule; setloginclass; }; FBSD_1.3 { accept4; aio_mlock; bindat; cap_fcntls_get; cap_fcntls_limit; cap_ioctls_get; cap_ioctls_limit; __cap_rights_get; cap_rights_limit; cap_sandboxed; chflagsat; clock_getcpuclockid2; connectat; ffclock_getcounter; ffclock_getestimate; ffclock_setestimate; pipe2; posix_fadvise; procctl; wait6; }; FBSD_1.4 { futimens; ppoll; utimensat; numa_setaffinity; numa_getaffinity; sendmmsg; recvmmsg; }; FBSD_1.5 { clock_nanosleep; fdatasync; fhstat; fhstatfs; fstat; fstatat; fstatfs; getdents; getdirentries; getfsstat; getrandom; kevent; lstat; mknod; mknodat; stat; statfs; cpuset_getdomain; cpuset_setdomain; }; FBSD_1.6 { __sysctlbyname; aio_readv; aio_writev; close_range; copy_file_range; fhlink; fhlinkat; fhreadlink; getfhat; funlinkat; memfd_create; shm_create_largepage; shm_rename; }; FBSD_1.7 { _Fork; fspacectl; kqueuex; swapoff; }; FBSDprivate_1.0 { ___acl_aclcheck_fd; __sys___acl_aclcheck_fd; ___acl_aclcheck_file; __sys___acl_aclcheck_file; ___acl_aclcheck_link; __sys___acl_aclcheck_link; ___acl_delete_fd; __sys___acl_delete_fd; ___acl_delete_file; __sys___acl_delete_file; ___acl_delete_link; __sys___acl_delete_link; ___acl_get_fd; __sys___acl_get_fd; ___acl_get_file; __sys___acl_get_file; ___acl_get_link; __sys___acl_get_link; ___acl_set_fd; __sys___acl_set_fd; ___acl_set_file; __sys___acl_set_file; ___acl_set_link; __sys___acl_set_link; ___getcwd; __sys___getcwd; ___mac_execve; __sys___mac_execve; ___mac_get_fd; __sys___mac_get_fd; ___mac_get_file; __sys___mac_get_file; ___mac_get_link; __sys___mac_get_link; ___mac_get_pid; __sys___mac_get_pid; ___mac_get_proc; __sys___mac_get_proc; ___mac_set_fd; __sys___mac_set_fd; ___mac_set_file; __sys___mac_set_file; ___mac_set_link; __sys___mac_set_link; ___mac_set_proc; __sys___mac_set_proc; ___semctl; __sys___semctl; ___setugid; __sys___setugid; ___syscall; __sys___syscall; ___sysctl; __sys___sysctl; __umtx_op; __sys__umtx_op; _abort2; __sys_abort2; _accept; __sys_accept; _accept4; __sys_accept4; _access; __sys_access; _acct; __sys_acct; _adjtime; __sys_adjtime; __sys_aio_cancel; __sys_aio_error; __sys_aio_fsync; __sys_aio_read; __sys_aio_readv; __sys_aio_return; __sys_aio_suspend; __sys_aio_waitcomplete; __sys_aio_write; __sys_aio_writev; _audit; __sys_audit; _auditctl; __sys_auditctl; _auditon; __sys_auditon; _bind; __sys_bind; _chdir; __sys_chdir; _chflags; __sys_chflags; _chmod; __sys_chmod; _chown; __sys_chown; _chroot; __sys_chroot; _clock_getcpuclockid2; __sys_clock_getcpuclockid2; _clock_getres; __sys_clock_getres; _clock_gettime; __sys_clock_gettime; __sys_clock_nanosleep; _clock_settime; __sys_clock_settime; _close; __sys_close; _connect; __sys_connect; _cpuset; __sys_cpuset; _cpuset_getid; __sys_cpuset_getid; _cpuset_setid; __sys_cpuset_setid; _cpuset_getaffinity; __sys_cpuset_getaffinity; _cpuset_setaffinity; __sys_cpuset_setaffinity; _dup; __sys_dup; _dup2; __sys_dup2; _eaccess; __sys_eaccess; _execve; __sys_execve; _extattr_delete_fd; __sys_extattr_delete_fd; _extattr_delete_file; __sys_extattr_delete_file; _extattr_delete_link; __sys_extattr_delete_link; _extattr_get_fd; __sys_extattr_get_fd; _extattr_get_file; __sys_extattr_get_file; _extattr_get_link; __sys_extattr_get_link; _extattr_list_fd; __sys_extattr_list_fd; _extattr_list_file; __sys_extattr_list_file; _extattr_list_link; __sys_extattr_list_link; _extattr_set_fd; __sys_extattr_set_fd; _extattr_set_file; __sys_extattr_set_file; _extattr_set_link; __sys_extattr_set_link; _extattrctl; __sys_extattrctl; __sys_sigfastblock; _fchdir; __sys_fchdir; _fchflags; __sys_fchflags; _fchmod; __sys_fchmod; _fchown; __sys_fchown; _fcntl; __sys_fcntl; __fcntl_compat; _fhopen; __sys_fhopen; _fhstat; __sys_fhstat; _fhstatfs; __sys_fhstatfs; _flock; __sys_flock; _fork; __sys_fork; _fpathconf; __sys_fpathconf; _fstat; __sys_fstat; _fstatfs; __sys_fstatfs; _fsync; __sys_fsync; _fdatasync; __sys_fdatasync; _futimes; __sys_futimes; _getaudit; __sys_getaudit; _getaudit_addr; __sys_getaudit_addr; _getauid; __sys_getauid; _getcontext; __sys_getcontext; _getdirentries; __sys_getdirentries; _getdtablesize; __sys_getdtablesize; _getegid; __sys_getegid; _geteuid; __sys_geteuid; _getfh; __sys_getfh; _getfsstat; __sys_getfsstat; _getgid; __sys_getgid; _getgroups; __sys_getgroups; _getitimer; __sys_getitimer; _getpeername; __sys_getpeername; _getpgid; __sys_getpgid; _getpgrp; __sys_getpgrp; _getpid; __sys_getpid; _getppid; __sys_getppid; _getpriority; __sys_getpriority; _getresgid; __sys_getresgid; _getresuid; __sys_getresuid; _getrlimit; __sys_getrlimit; _getrusage; __sys_getrusage; _getsid; __sys_getsid; _getsockname; __sys_getsockname; _getsockopt; __sys_getsockopt; _gettimeofday; __sys_gettimeofday; _getuid; __sys_getuid; _ioctl; __sys_ioctl; _issetugid; __sys_issetugid; _jail; __sys_jail; _jail_attach; __sys_jail_attach; _kenv; __sys_kenv; _kevent; __sys_kevent; _kill; __sys_kill; _kldfind; __sys_kldfind; _kldfirstmod; __sys_kldfirstmod; _kldload; __sys_kldload; _kldnext; __sys_kldnext; _kldstat; __sys_kldstat; _kldsym; __sys_kldsym; _kldunload; __sys_kldunload; _kldunloadf; __sys_kldunloadf; _kmq_notify; __sys_kmq_notify; _kmq_open; __sys_kmq_open; _kmq_setattr; __sys_kmq_setattr; _kmq_timedreceive; __sys_kmq_timedreceive; _kmq_timedsend; __sys_kmq_timedsend; _kmq_unlink; __sys_kmq_unlink; _kqueue; __sys_kqueue; _ksem_close; __sys_ksem_close; _ksem_destroy; __sys_ksem_destroy; _ksem_getvalue; __sys_ksem_getvalue; _ksem_init; __sys_ksem_init; _ksem_open; __sys_ksem_open; _ksem_post; __sys_ksem_post; _ksem_timedwait; __sys_ksem_timedwait; _ksem_trywait; __sys_ksem_trywait; _ksem_unlink; __sys_ksem_unlink; _ksem_wait; __sys_ksem_wait; _ktrace; __sys_ktrace; _lchflags; __sys_lchflags; _lchmod; __sys_lchmod; _lchown; __sys_lchown; _lgetfh; __sys_lgetfh; _link; __sys_link; __sys_lio_listio; _listen; __sys_listen; _lutimes; __sys_lutimes; _mac_syscall; __sys_mac_syscall; _madvise; __sys_madvise; _mincore; __sys_mincore; _minherit; __sys_minherit; _mkdir; __sys_mkdir; _mkfifo; __sys_mkfifo; _mknod; __sys_mknod; _mlock; __sys_mlock; _mlockall; __sys_mlockall; _mmap; __sys_mmap; _modfind; __sys_modfind; _modfnext; __sys_modfnext; _modnext; __sys_modnext; _modstat; __sys_modstat; _mount; __sys_mount; _mprotect; __sys_mprotect; _msgctl; __sys_msgctl; _msgget; __sys_msgget; _msgrcv; __sys_msgrcv; _msgsnd; __sys_msgsnd; _msgsys; __sys_msgsys; _msync; __sys_msync; _munlock; __sys_munlock; _munlockall; __sys_munlockall; _munmap; __sys_munmap; _nanosleep; __sys_nanosleep; _nfssvc; __sys_nfssvc; _nmount; __sys_nmount; _ntp_adjtime; __sys_ntp_adjtime; _ntp_gettime; __sys_ntp_gettime; _open; __sys_open; _openat; __sys_openat; _pathconf; __sys_pathconf; __sys_pdfork; _pipe; __sys_pipe; _poll; __sys_poll; _ppoll; __sys_ppoll; _preadv; __sys_preadv; _procctl; __sys_procctl; _profil; __sys_profil; _pselect; __sys_pselect; _ptrace; __sys_ptrace; _pwritev; __sys_pwritev; _quotactl; __sys_quotactl; _read; __sys_read; _readlink; __sys_readlink; _readv; __sys_readv; _reboot; __sys_reboot; _recvfrom; __sys_recvfrom; _recvmsg; __sys_recvmsg; _rename; __sys_rename; _revoke; __sys_revoke; _rfork; __sys_rfork; _rmdir; __sys_rmdir; _rtprio; __sys_rtprio; _rtprio_thread; __sys_rtprio_thread; _sched_get_priority_max; __sys_sched_get_priority_max; _sched_get_priority_min; __sys_sched_get_priority_min; _sched_getparam; __sys_sched_getparam; _sched_getscheduler; __sys_sched_getscheduler; _sched_rr_get_interval; __sys_sched_rr_get_interval; _sched_setparam; __sys_sched_setparam; _sched_setscheduler; __sys_sched_setscheduler; _sched_yield; __sys_sched_yield; _select; __sys_select; _semget; __sys_semget; _semop; __sys_semop; _semsys; __sys_semsys; _sendfile; __sys_sendfile; _sendmsg; __sys_sendmsg; _sendto; __sys_sendto; _setaudit; __sys_setaudit; _setaudit_addr; __sys_setaudit_addr; _setauid; __sys_setauid; _setcontext; __sys_setcontext; _setegid; __sys_setegid; _seteuid; __sys_seteuid; _setgid; __sys_setgid; _setgroups; __sys_setgroups; _setitimer; __sys_setitimer; _setlogin; __sys_setlogin; _setpgid; __sys_setpgid; _setpriority; __sys_setpriority; _setregid; __sys_setregid; _setresgid; __sys_setresgid; _setresuid; __sys_setresuid; _setreuid; __sys_setreuid; _setrlimit; __sys_setrlimit; _setsid; __sys_setsid; _setsockopt; __sys_setsockopt; _settimeofday; __sys_settimeofday; _setuid; __sys_setuid; _shm_open; __sys_shm_open; __sys_shm_open2; _shm_unlink; __sys_shm_unlink; _shmat; __sys_shmat; _shmctl; __sys_shmctl; _shmdt; __sys_shmdt; _shmget; __sys_shmget; _shmsys; __sys_shmsys; _shutdown; __sys_shutdown; _sigaction; __sys_sigaction; _sigaltstack; __sys_sigaltstack; _sigpending; __sys_sigpending; _sigprocmask; __sys_sigprocmask; _sigqueue; __sys_sigqueue; _sigreturn; __sys_sigreturn; _sigsuspend; __sys_sigsuspend; _sigtimedwait; __sys_sigtimedwait; _sigwait; __sigwait; __sys_sigwait; _sigwaitinfo; __sys_sigwaitinfo; _socket; __sys_socket; _socketpair; __sys_socketpair; _statfs; __sys_statfs; _swapcontext; __sys_swapcontext; _swapoff; __sys_swapoff; _swapon; __sys_swapon; _symlink; __sys_symlink; _sync; __sys_sync; _sysarch; __sys_sysarch; _syscall; __sys_syscall; _thr_create; __sys_thr_create; _thr_exit; __sys_thr_exit; _thr_kill; __sys_thr_kill; _thr_kill2; __sys_thr_kill2; _thr_new; __sys_thr_new; _thr_self; __sys_thr_self; _thr_set_name; __sys_thr_set_name; _thr_suspend; __sys_thr_suspend; _thr_wake; __sys_thr_wake; _ktimer_create; __sys_ktimer_create; _ktimer_delete; __sys_ktimer_delete; _ktimer_getoverrun; __sys_ktimer_getoverrun; _ktimer_gettime; __sys_ktimer_gettime; _ktimer_settime; __sys_ktimer_settime; _umask; __sys_umask; _undelete; __sys_undelete; _unlink; __sys_unlink; _unmount; __sys_unmount; _utimes; __sys_utimes; _utrace; __sys_utrace; _uuidgen; __sys_uuidgen; _wait4; __sys_wait4; _wait6; __sys_wait6; _write; __sys_write; _writev; __sys_writev; __set_error_selector; nlm_syscall; gssd_syscall; __libc_interposing_slot; __libc_sigwait; _cpuset_getdomain; __sys_cpuset_getdomain; _cpuset_setdomain; __sys_cpuset_setdomain; rpctls_syscall; }; diff --git a/lib/libc/uuid/Symbol.map b/lib/libc/uuid/Symbol.map index 10acc781225f..49fb239913d2 100644 --- a/lib/libc/uuid/Symbol.map +++ b/lib/libc/uuid/Symbol.map @@ -1,21 +1,20 @@ /* - * $FreeBSD$ */ FBSD_1.0 { uuid_to_string; uuid_is_nil; uuid_hash; uuid_from_string; uuid_equal; uuid_create_nil; uuid_create; uuid_compare; }; FBSD_1.1 { uuid_enc_le; uuid_dec_le; uuid_enc_be; uuid_dec_be; }; diff --git a/lib/libc/xdr/Symbol.map b/lib/libc/xdr/Symbol.map index a8eb3a101ec4..1ee5afda2425 100644 --- a/lib/libc/xdr/Symbol.map +++ b/lib/libc/xdr/Symbol.map @@ -1,56 +1,55 @@ /* - * $FreeBSD$ */ FBSD_1.0 { xdr_free; xdr_void; xdr_int; xdr_u_int; xdr_long; xdr_u_long; xdr_int32_t; xdr_u_int32_t; xdr_short; xdr_u_short; xdr_int16_t; xdr_u_int16_t; xdr_char; xdr_u_char; xdr_bool; xdr_enum; xdr_opaque; xdr_bytes; xdr_netobj; xdr_union; xdr_string; xdr_wrapstring; xdr_int64_t; xdr_u_int64_t; xdr_hyper; xdr_u_hyper; xdr_longlong_t; xdr_u_longlong_t; xdr_array; xdr_vector; xdr_float; xdr_double; xdrmem_create; xdrrec_create; xdrrec_skiprecord; xdrrec_eof; xdrrec_endofrecord; xdr_reference; xdr_pointer; xdrstdio_create; }; FBSD_1.1 { xdr_uint16_t; xdr_uint32_t; xdr_uint64_t; }; FBSD_1.2 { xdr_sizeof; }; diff --git a/lib/libc/yp/Symbol.map b/lib/libc/yp/Symbol.map index cf2470a2dcb9..ecd17af4a29a 100644 --- a/lib/libc/yp/Symbol.map +++ b/lib/libc/yp/Symbol.map @@ -1,25 +1,24 @@ /* - * $FreeBSD$ */ FBSD_1.0 { xdr_datum; xdr_ypresp_all_seq; ypresp_data; ypresp_allfn; ypbinderr_string; _yp_dobind; yp_bind; yp_unbind; yp_match; yp_get_default_domain; yp_first; yp_next; yp_all; yp_order; yp_master; yp_maplist; yperr_string; ypprot_err; _yp_check; }; diff --git a/lib/libdl/Symbol.map b/lib/libdl/Symbol.map index 82ab6012e121..67d26c1f1dfe 100644 --- a/lib/libdl/Symbol.map +++ b/lib/libdl/Symbol.map @@ -1,20 +1,19 @@ /* - * $FreeBSD$ */ FBSD_1.0 { dladdr; dlclose; dlerror; dlfunc; dlopen; dlsym; dlvsym; dlinfo; dl_iterate_phdr; }; FBSD_1.3 { fdlopen; }; diff --git a/lib/libgcc_s/Symbol.map b/lib/libgcc_s/Symbol.map index 292932198170..72b083c698ba 100644 --- a/lib/libgcc_s/Symbol.map +++ b/lib/libgcc_s/Symbol.map @@ -1,181 +1,180 @@ /* - * $FreeBSD$ */ GCC_3.0 { __absvdi2; __absvsi2; __addvdi3; __addvsi3; __ashldi3; __ashlti3; __ashrdi3; __ashrti3; __clear_cache; __cmpdi2; __cmpti2; __deregister_frame; __deregister_frame_info; __deregister_frame_info_bases; __divdi3; __divti3; __ffsdi2; __ffsti2; __fixdfdi; __fixdfti; __fixsfdi; __fixsfti; __fixunsdfdi; __fixunsdfsi; __fixunsdfti; __fixunssfdi; __fixunssfsi; __fixunssfti; __fixunsxfdi; __fixunsxfsi; __fixunsxfti; __fixxfdi; __fixxfti; __floatdidf; __floatdisf; __floatdixf; __floattidf; __floattisf; __floattixf; __lshrdi3; __lshrti3; __moddi3; __modti3; __muldi3; __multi3; __mulvdi3; __mulvsi3; __negdi2; __negti2; __negvdi2; __negvsi2; __register_frame; __register_frame_info; __register_frame_info_bases; __register_frame_info_table; __register_frame_info_table_bases; __register_frame_table; __subvdi3; __subvsi3; __ucmpdi2; __ucmpti2; __udivdi3; __udivmoddi4; __udivmodti4; __udivti3; __umoddi3; __umodti3; _Unwind_DeleteException; _Unwind_Find_FDE; _Unwind_ForcedUnwind; _Unwind_GetDataRelBase; _Unwind_GetGR; _Unwind_GetIP; _Unwind_GetLanguageSpecificData; _Unwind_GetRegionStart; _Unwind_GetTextRelBase; _Unwind_RaiseException; _Unwind_Resume; _Unwind_SetGR; _Unwind_SetIP; }; GCC_3.3 { _Unwind_FindEnclosingFunction; _Unwind_GetCFA; _Unwind_Resume_or_Rethrow; }; GCC_3.3.1 { __gcc_personality_v0; }; GCC_3.4 { __clzdi2; __clzsi2; __clzti2; __ctzdi2; __ctzsi2; __ctzti2; __paritydi2; __paritysi2; __parityti2; __popcountdi2; __popcountsi2; __popcountti2; }; GCC_3.4.2 { __enable_execute_stack; }; GCC_3.4.4 { __absvti2; __addvti3; __mulvti3; __negvti2; __subvti3; }; GCC_4.0.0 { __divdc3; __divsc3; __divxc3; __muldc3; __mulsc3; __mulxc3; __powidf2; __powisf2; __powixf2; }; GCC_4.2.0 { __floatundidf; __floatundisf; __floatundixf; __floatuntidf; __floatuntisf; __floatuntixf; _Unwind_GetIPInfo; }; GCC_4.3.0 { __bswapdi2; __bswapsi2; }; GCC_4.6.0 { __addtf3; __cmptf2; __divtf3; __eqtf2; __extenddftf2; __extendsftf2; __fixtfdi; __fixtfsi; __fixtfti; __fixunstfdi; __fixunstfsi; __fixunstfti; __floatditf; __floatsitf; __floattitf; __floatunditf; __floatunsitf; __floatuntitf; __getf2; __gttf2; __letf2; __lttf2; __multf3; __netf2; __subtf3; __trunctfdf2; __trunctfsf2; __unordtf2; }; diff --git a/lib/libgcc_s/SymbolDefault.map b/lib/libgcc_s/SymbolDefault.map index b3da3a8688bf..8563b26efa18 100644 --- a/lib/libgcc_s/SymbolDefault.map +++ b/lib/libgcc_s/SymbolDefault.map @@ -1,7 +1,6 @@ /* - * $FreeBSD$ */ /* _Unwind_Backtrace should be exported with different version on ARM */ GCC_3.3 { _Unwind_Backtrace; }; diff --git a/lib/libgcc_s/arm/Symbol.map b/lib/libgcc_s/arm/Symbol.map index c431bd464f55..92b54761d810 100644 --- a/lib/libgcc_s/arm/Symbol.map +++ b/lib/libgcc_s/arm/Symbol.map @@ -1,18 +1,17 @@ /* - * $FreeBSD$ */ GCC_3.5 { _Unwind_Complete; _Unwind_VRS_Get; _Unwind_VRS_Set; _Unwind_VRS_Pop; __aeabi_unwind_cpp_pr0; __aeabi_unwind_cpp_pr1; __aeabi_unwind_cpp_pr2; __gnu_unwind_frame; }; GCC_4.3.0 { _Unwind_Backtrace; }; diff --git a/lib/libgssapi/Symbol.map b/lib/libgssapi/Symbol.map index f90b7ab92ab7..ef0d7f86f6f0 100644 --- a/lib/libgssapi/Symbol.map +++ b/lib/libgssapi/Symbol.map @@ -1,77 +1,76 @@ /* - * $FreeBSD$ */ FBSD_1.1 { GSS_C_NT_ANONYMOUS; GSS_C_NT_EXPORT_NAME; GSS_C_NT_HOSTBASED_SERVICE; GSS_C_NT_HOSTBASED_SERVICE_X; GSS_C_NT_MACHINE_UID_NAME; GSS_C_NT_STRING_UID_NAME; GSS_C_NT_USER_NAME; GSS_KRB5_NT_MACHINE_UID_NAME; GSS_KRB5_NT_PRINCIPAL_NAME; GSS_KRB5_NT_STRING_UID_NAME; GSS_KRB5_NT_USER_NAME; gss_accept_sec_context; gss_acquire_cred; gss_add_buffer_set_member; gss_add_cred; gss_add_oid_set_member; gss_canonicalize_name; gss_compare_name; gss_context_time; gss_create_empty_buffer_set; gss_create_empty_oid_set; gss_decapsulate_token; gss_delete_sec_context; gss_display_name; gss_display_status; gss_duplicate_name; gss_duplicate_oid; gss_encapsulate_token; gss_export_name; gss_export_sec_context; gss_get_mic; gss_import_name; gss_import_sec_context; gss_indicate_mechs; gss_init_sec_context; gss_inquire_context; gss_inquire_cred; gss_inquire_cred_by_mech; gss_inquire_cred_by_oid; gss_inquire_mechs_for_name; gss_inquire_names_for_mech; gss_inquire_sec_context_by_oid; gss_oid_equal; gss_oid_to_str; gss_pname_to_uid; gss_process_context_token; gss_pseudo_random; gss_release_buffer; gss_release_buffer_set; gss_release_cred; gss_release_name; gss_release_oid; gss_release_oid_set; gss_seal; gss_set_cred_option; gss_set_sec_context_option; gss_sign; gss_test_oid_set_member; gss_unseal; gss_unwrap; gss_verify; gss_verify_mic; gss_wrap; gss_wrap_size_limit; }; FBSDprivate_1.0 { _gss_copy_oid; _gss_copy_buffer; _gss_free_oid; _gss_mg_collect_error; }; diff --git a/lib/libkvm/kvm.h b/lib/libkvm/kvm.h index e6dd767c9193..6e56f73f4657 100644 --- a/lib/libkvm/kvm.h +++ b/lib/libkvm/kvm.h @@ -1,133 +1,132 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)kvm.h 8.1 (Berkeley) 6/2/93 - * $FreeBSD$ */ #ifndef _KVM_H_ #define _KVM_H_ #include #include #include /* * Including vm/vm.h causes namespace pollution issues. For the * most part, only things using kvm_walk_pages() need to #include it. */ #ifndef VM_H typedef u_char vm_prot_t; #endif /* Default version symbol. */ #define VRS_SYM "_version" #define VRS_KEY "VERSION" #ifndef _SIZE_T_DECLARED typedef __size_t size_t; #define _SIZE_T_DECLARED #endif #ifndef _SSIZE_T_DECLARED typedef __ssize_t ssize_t; #define _SSIZE_T_DECLARED #endif struct kvm_nlist { const char *n_name; unsigned char n_type; kvaddr_t n_value; }; typedef struct __kvm kvm_t; struct kinfo_proc; struct proc; struct kvm_swap { char ksw_devname[32]; u_int ksw_used; u_int ksw_total; int ksw_flags; u_int ksw_reserved1; u_int ksw_reserved2; }; struct kvm_page { u_int kp_version; kpaddr_t kp_paddr; kvaddr_t kp_kmap_vaddr; kvaddr_t kp_dmap_vaddr; vm_prot_t kp_prot; off_t kp_offset; size_t kp_len; /* end of version 2 */ }; #define SWIF_DEV_PREFIX 0x0002 #define LIBKVM_WALK_PAGES_VERSION 2 __BEGIN_DECLS int kvm_close(kvm_t *); int kvm_dpcpu_setcpu(kvm_t *, unsigned int); char **kvm_getargv(kvm_t *, const struct kinfo_proc *, int); int kvm_getcptime(kvm_t *, long *); char **kvm_getenvv(kvm_t *, const struct kinfo_proc *, int); char *kvm_geterr(kvm_t *); int kvm_getloadavg(kvm_t *, double [], int); int kvm_getmaxcpu(kvm_t *); int kvm_getncpus(kvm_t *); void *kvm_getpcpu(kvm_t *, int); uint64_t kvm_counter_u64_fetch(kvm_t *, u_long); struct kinfo_proc * kvm_getprocs(kvm_t *, int, int, int *); int kvm_getswapinfo(kvm_t *, struct kvm_swap *, int, int); int kvm_native(kvm_t *); int kvm_nlist(kvm_t *, struct nlist *); int kvm_nlist2(kvm_t *, struct kvm_nlist *); kvm_t *kvm_open (const char *, const char *, const char *, int, const char *); kvm_t *kvm_openfiles (const char *, const char *, const char *, int, char *); kvm_t *kvm_open2 (const char *, const char *, int, char *, int (*)(const char *, kvaddr_t *)); ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t); ssize_t kvm_read_zpcpu(kvm_t *, unsigned long, void *, size_t, int); ssize_t kvm_read2(kvm_t *, kvaddr_t, void *, size_t); ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t); kssize_t kvm_kerndisp(kvm_t *); typedef int kvm_walk_pages_cb_t(struct kvm_page *, void *); int kvm_walk_pages(kvm_t *, kvm_walk_pages_cb_t *, void *); __END_DECLS #endif /* !_KVM_H_ */ diff --git a/lib/libkvm/kvm_private.h b/lib/libkvm/kvm_private.h index d4ec1ff1837b..86e9a16bb7c5 100644 --- a/lib/libkvm/kvm_private.h +++ b/lib/libkvm/kvm_private.h @@ -1,198 +1,197 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software developed by the Computer Systems * Engineering group at Lawrence Berkeley Laboratory under DARPA contract * BG 91-66 and contributed to Berkeley. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)kvm_private.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #include #include #include struct kvm_arch { int (*ka_probe)(kvm_t *); int (*ka_initvtop)(kvm_t *); void (*ka_freevtop)(kvm_t *); int (*ka_kvatop)(kvm_t *, kvaddr_t, off_t *); int (*ka_native)(kvm_t *); int (*ka_walk_pages)(kvm_t *, kvm_walk_pages_cb_t *, void *); kssize_t (*ka_kerndisp)(kvm_t *); }; #define KVM_ARCH(ka) DATA_SET(kvm_arch, ka) struct __kvm { struct kvm_arch *arch; /* * a string to be prepended to error messages * provided for compatibility with sun's interface * if this value is null, errors are saved in errbuf[] */ const char *program; char *errp; /* XXX this can probably go away */ char errbuf[_POSIX2_LINE_MAX]; #define ISALIVE(kd) ((kd)->vmfd >= 0) int pmfd; /* physical memory file (or crashdump) */ int vmfd; /* virtual memory file (-1 if crashdump) */ int nlfd; /* namelist file (e.g., /kernel) */ GElf_Ehdr nlehdr; /* ELF file header for namelist file */ int (*resolve_symbol)(const char *, kvaddr_t *); struct kinfo_proc *procbase; char *argspc; /* (dynamic) storage for argv strings */ int arglen; /* length of the above */ char **argv; /* (dynamic) storage for argv pointers */ int argc; /* length of above (not actual # present) */ char *argbuf; /* (dynamic) temporary storage */ /* * Kernel virtual address translation state. This only gets filled * in for dead kernels; otherwise, the running kernel (i.e. kmem) * will do the translations for us. It could be big, so we * only allocate it if necessary. */ struct vmstate *vmst; int rawdump; /* raw dump format */ int writable; /* physical memory is writable */ int vnet_initialized; /* vnet fields set up */ kvaddr_t vnet_start; /* start of kernel's vnet region */ kvaddr_t vnet_stop; /* stop of kernel's vnet region */ kvaddr_t vnet_current; /* vnet we're working with */ kvaddr_t vnet_base; /* vnet base of current vnet */ /* * Dynamic per-CPU kernel memory. We translate symbols, on-demand, * to the data associated with dpcpu_curcpu, set with * kvm_dpcpu_setcpu(). */ int dpcpu_initialized; /* dpcpu fields set up */ kvaddr_t dpcpu_start; /* start of kernel's dpcpu region */ kvaddr_t dpcpu_stop; /* stop of kernel's dpcpu region */ u_int dpcpu_maxcpus; /* size of base array */ uintptr_t *dpcpu_off; /* base array, indexed by CPU ID */ u_int dpcpu_curcpu; /* CPU we're currently working with */ kvaddr_t dpcpu_curoff; /* dpcpu base of current CPU */ /* Page table lookup structures. */ uint64_t *pt_map; size_t pt_map_size; uint64_t *dump_avail; /* actually word sized */ size_t dump_avail_size; off_t pt_sparse_off; uint64_t pt_sparse_size; uint32_t *pt_popcounts; unsigned int pt_page_size; /* Page & sparse map structures. */ void *page_map; uint32_t page_map_size; off_t page_map_off; void *sparse_map; }; struct kvm_bitmap { uint8_t *map; u_long size; }; /* Page table lookup constants. */ #define POPCOUNT_BITS 1024 #define BITS_IN(v) (sizeof(v) * NBBY) #define POPCOUNTS_IN(v) (POPCOUNT_BITS / BITS_IN(v)) /* * Functions used internally by kvm, but across kvm modules. */ static inline uint16_t _kvm16toh(kvm_t *kd, uint16_t val) { if (kd->nlehdr.e_ident[EI_DATA] == ELFDATA2LSB) return (le16toh(val)); else return (be16toh(val)); } static inline uint32_t _kvm32toh(kvm_t *kd, uint32_t val) { if (kd->nlehdr.e_ident[EI_DATA] == ELFDATA2LSB) return (le32toh(val)); else return (be32toh(val)); } static inline uint64_t _kvm64toh(kvm_t *kd, uint64_t val) { if (kd->nlehdr.e_ident[EI_DATA] == ELFDATA2LSB) return (le64toh(val)); else return (be64toh(val)); } uint64_t _kvm_pa_bit_id(kvm_t *kd, uint64_t pa, unsigned int page_size); uint64_t _kvm_bit_id_pa(kvm_t *kd, uint64_t bit_id, unsigned int page_size); #define _KVM_PA_INVALID ULONG_MAX #define _KVM_BIT_ID_INVALID ULONG_MAX int _kvm_bitmap_init(struct kvm_bitmap *, u_long, u_long *); void _kvm_bitmap_set(struct kvm_bitmap *, u_long); int _kvm_bitmap_next(struct kvm_bitmap *, u_long *); void _kvm_bitmap_deinit(struct kvm_bitmap *); void _kvm_err(kvm_t *kd, const char *program, const char *fmt, ...) __printflike(3, 4); void _kvm_freeprocs(kvm_t *kd); void *_kvm_malloc(kvm_t *kd, size_t); int _kvm_nlist(kvm_t *, struct kvm_nlist *, int); void *_kvm_realloc(kvm_t *kd, void *, size_t); void _kvm_syserr (kvm_t *kd, const char *program, const char *fmt, ...) __printflike(3, 4); int _kvm_vnet_selectpid(kvm_t *, pid_t); int _kvm_vnet_initialized(kvm_t *, int); kvaddr_t _kvm_vnet_validaddr(kvm_t *, kvaddr_t); int _kvm_dpcpu_initialized(kvm_t *, int); kvaddr_t _kvm_dpcpu_validaddr(kvm_t *, kvaddr_t); int _kvm_probe_elf_kernel(kvm_t *, int, int); int _kvm_is_minidump(kvm_t *); int _kvm_read_core_phdrs(kvm_t *, size_t *, GElf_Phdr **); int _kvm_pt_init(kvm_t *, size_t, off_t, size_t, off_t, off_t, int); off_t _kvm_pt_find(kvm_t *, uint64_t, unsigned int); int _kvm_visit_cb(kvm_t *, kvm_walk_pages_cb_t *, void *, u_long, u_long, u_long, vm_prot_t, size_t, unsigned int); int _kvm_pmap_init(kvm_t *, uint32_t, off_t); void * _kvm_pmap_get(kvm_t *, u_long, size_t); void * _kvm_map_get(kvm_t *, u_long, unsigned int); diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h index c05c690f80e1..f8d762dbec27 100644 --- a/lib/libmd/md4.h +++ b/lib/libmd/md4.h @@ -1,87 +1,86 @@ /* MD4.H - header file for MD4C.C - * $FreeBSD$ */ /*- SPDX-License-Identifier: RSA-MD Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #ifndef _MD4_H_ #define _MD4_H_ /* MD4 context. */ typedef struct MD4Context { u_int32_t state[4]; /* state (ABCD) */ u_int32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD4_CTX; #include __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef MD4Init #define MD4Init _libmd_MD4Init #endif #ifndef MD4Update #define MD4Update _libmd_MD4Update #endif #ifndef MD4Pad #define MD4Pad _libmd_MD4Pad #endif #ifndef MD4Final #define MD4Final _libmd_MD4Final #endif #ifndef MD4End #define MD4End _libmd_MD4End #endif #ifndef MD4Fd #define MD4Fd _libmd_MD4Fd #endif #ifndef MD4FdChunk #define MD4FdChunk _libmd_MD4FdChunk #endif #ifndef MD4File #define MD4File _libmd_MD4File #endif #ifndef MD4FileChunk #define MD4FileChunk _libmd_MD4FileChunk #endif #ifndef MD4Data #define MD4Data _libmd_MD4Data #endif void MD4Init(MD4_CTX *); void MD4Update(MD4_CTX *, const void *, unsigned int); void MD4Pad(MD4_CTX *); void MD4Final(unsigned char [16], MD4_CTX *); char * MD4End(MD4_CTX *, char *); char * MD4Fd(int, char *); char * MD4FdChunk(int, char *, off_t, off_t); char * MD4File(const char *, char *); char * MD4FileChunk(const char *, char *, off_t, off_t); char * MD4Data(const void *, unsigned int, char *); __END_DECLS #endif /* _MD4_H_ */ diff --git a/lib/libmd/ripemd.h b/lib/libmd/ripemd.h index 8f202a53ed84..337f0f6e4669 100644 --- a/lib/libmd/ripemd.h +++ b/lib/libmd/ripemd.h @@ -1,137 +1,136 @@ /* crypto/ripemd/ripemd.h */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * * This package is an SSL implementation written * by Eric Young (eay@cryptsoft.com). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson (tjh@cryptsoft.com). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * 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 copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young (eay@cryptsoft.com)" * The word 'cryptographic' can be left out if the routines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* - * $FreeBSD$ */ #ifndef HEADER_RIPEMD_H #define HEADER_RIPEMD_H #include #include /* XXX switch to machine/ansi.h and __ types */ #define RIPEMD160_CBLOCK 64 #define RIPEMD160_LBLOCK 16 #define RIPEMD160_BLOCK 16 #define RIPEMD160_LAST_BLOCK 56 #define RIPEMD160_LENGTH_BLOCK 8 #define RIPEMD160_DIGEST_LENGTH 20 typedef struct RIPEMD160state_st { u_int32_t A,B,C,D,E; u_int32_t Nl,Nh; u_int32_t data[RIPEMD160_LBLOCK]; int num; } RIPEMD160_CTX; __BEGIN_DECLS /* Ensure libmd symbols do not clash with libcrypto */ #ifndef RIPEMD160_Init #define RIPEMD160_Init _libmd_RIPEMD160_Init #endif #ifndef RIPEMD160_Update #define RIPEMD160_Update _libmd_RIPEMD160_Update #endif #ifndef RIPEMD160_Final #define RIPEMD160_Final _libmd_RIPEMD160_Final #endif #ifndef RIPEMD160_End #define RIPEMD160_End _libmd_RIPEMD160_End #endif #ifndef RIPEMD160_Fd #define RIPEMD160_Fd _libmd_RIPEMD160_Fd #endif #ifndef RIPEMD160_FdChunk #define RIPEMD160_FdChunk _libmd_RIPEMD160_FdChunk #endif #ifndef RIPEMD160_File #define RIPEMD160_File _libmd_RIPEMD160_File #endif #ifndef RIPEMD160_FileChunk #define RIPEMD160_FileChunk _libmd_RIPEMD160_FileChunk #endif #ifndef RIPEMD160_Data #define RIPEMD160_Data _libmd_RIPEMD160_Data #endif #ifndef RIPEMD160_Transform #define RIPEMD160_Transform _libmd_RIPEMD160_Transform #endif #ifndef RMD160_version #define RMD160_version _libmd_RMD160_version #endif #ifndef ripemd160_block #define ripemd160_block _libmd_ripemd160_block #endif void RIPEMD160_Init(RIPEMD160_CTX *c); void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); char *RIPEMD160_End(RIPEMD160_CTX *, char *); char *RIPEMD160_Fd(int, char *); char *RIPEMD160_FdChunk(int, char *, off_t, off_t); char *RIPEMD160_File(const char *, char *); char *RIPEMD160_FileChunk(const char *, char *, off_t, off_t); char *RIPEMD160_Data(const void *, unsigned int, char *); __END_DECLS #endif diff --git a/lib/libmixer/Symbol.map b/lib/libmixer/Symbol.map index cee4e3bdbc18..f16e13d66e4c 100644 --- a/lib/libmixer/Symbol.map +++ b/lib/libmixer/Symbol.map @@ -1,22 +1,21 @@ /* - * $FreeBSD$ */ FBSD_1.7 { mixer_open; mixer_close; mixer_get_dev; mixer_get_dev_byname; mixer_add_ctl; mixer_add_ctl_s; mixer_remove_ctl; mixer_get_ctl; mixer_get_ctl_byname; mixer_set_vol; mixer_set_mute; mixer_mod_recsrc; mixer_get_dunit; mixer_set_dunit; mixer_get_mode; mixer_get_nmixers; }; diff --git a/lib/libmp/Symbol.map b/lib/libmp/Symbol.map index df040986e53f..f00906af6337 100644 --- a/lib/libmp/Symbol.map +++ b/lib/libmp/Symbol.map @@ -1,23 +1,22 @@ /* - * $FreeBSD$ */ FBSD_1.1 { mp_gcd; mp_itom; mp_madd; mp_mcmp; mp_mdiv; mp_mfree; mp_min; mp_mout; mp_move; mp_msqrt; mp_msub; mp_mtox; mp_mult; mp_pow; mp_rpow; mp_sdiv; mp_xtom; }; diff --git a/lib/libnetbsd/sys/event.h b/lib/libnetbsd/sys/event.h index ed52135ee859..7b5b11e1934f 100644 --- a/lib/libnetbsd/sys/event.h +++ b/lib/libnetbsd/sys/event.h @@ -1,42 +1,41 @@ /*- * Copyright (c) 2017 Dell, Inc. * 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. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ * */ #ifndef _LIBNETBSD_SYS_EVENT_H_ #define _LIBNETBSD_SYS_EVENT_H_ /* * kqueue on FreeBSD requires sys/event.h, which in turn uses uintptr_t * (defined in sys/types.h), so in order to accommodate their requirements, * pull in sys/types.h as part of event.h. */ #include #include_next #endif diff --git a/lib/libnetbsd/sys/types.h b/lib/libnetbsd/sys/types.h index e14dd498fe4b..97040b5cdec2 100644 --- a/lib/libnetbsd/sys/types.h +++ b/lib/libnetbsd/sys/types.h @@ -1,37 +1,36 @@ /*- * Copyright (c) 2017 Dell, Inc. * 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. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ * */ #ifndef _LIBNETBSD_SYS_TYPES_H_ #define _LIBNETBSD_SYS_TYPES_H_ #include_next #include /* For NBBY */ #endif diff --git a/lib/libnetbsd/sys/wait.h b/lib/libnetbsd/sys/wait.h index a9369808d8e5..5227efbfb486 100644 --- a/lib/libnetbsd/sys/wait.h +++ b/lib/libnetbsd/sys/wait.h @@ -1,37 +1,36 @@ /*- * Copyright (c) 2017 Dell, Inc. * 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. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ * */ #ifndef _LIBNETBSD_SYS_WAIT_H_ #define _LIBNETBSD_SYS_WAIT_H_ #include_next #define wrusage __wrusage #endif diff --git a/lib/libnetmap/libnetmap.h b/lib/libnetmap/libnetmap.h index 72a171f6fd0a..280132035acc 100644 --- a/lib/libnetmap/libnetmap.h +++ b/lib/libnetmap/libnetmap.h @@ -1,717 +1,716 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 2018 Universita` di Pisa * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * $FreeBSD$ */ #ifndef LIBNETMAP_H_ #define LIBNETMAP_H_ /* if thread-safety is not needed, define LIBNETMAP_NOTHREADSAFE before including * this file. */ /* NOTE: we include net/netmap_user.h without defining NETMAP_WITH_LIBS, which * is deprecated. If you still need it, please define NETMAP_WITH_LIBS and * include net/netmap_user.h before including this file. */ #include struct nmctx; struct nmport_d; struct nmem_d; /* * A port open specification (portspec for brevity) has the following syntax * (square brackets delimit optional parts): * * subsystem:vpname[mode][options] * * The "subsystem" is denoted by a prefix, possibly followed by an identifier. * There can be several kinds of subsystems, each one selected by a unique * prefix. Currently defined subsystems are: * * netmap (no id allowed) * the standard subsystem * * vale (followed by a possibly empty id) * the vpname is connected to a VALE switch identified by * the id (an empty id selects the default switch) * * The "vpname" has the following syntax: * * identifier or * identifier1{identifier2 or * identifier1}identifier2 * * Identifiers are sequences of alphanumeric characters. The part that begins * with either '{' or '}', when present, denotes a netmap pipe opened in the * same memory region as the subsystem:indentifier1 port. * * The "mode" can be one of the following: * * ^ bind all host (sw) ring pairs * ^NN bind individual host ring pair * * bind host and NIC ring pairs * -NN bind individual NIC ring pair * @NN open the port in the NN memory region * a suffix starting with / and the following flags, * in any order: * x exclusive access * z zero copy monitor (both tx and rx) * t monitor tx side (copy monitor) * r monitor rx side (copy monitor) * R bind only RX ring(s) * T bind only TX ring(s) * * The "options" start at the first '@' character not followed by a number. * Each option starts with '@' and has the following syntax: * * option (flag option) * option=value (single key option) * option:key1=value1,key2=value2,... (multi-key option) * * For multi-key options, the keys can be assigned in any order, but they * cannot be assigned more than once. It is not necessary to assign all the * option keys: unmentioned keys will receive default values. Some multi-key * options define a default key and also accept the single-key syntax, by * assigning the value to this key. * * NOTE: Options may be silently ignored if the port is already open by some * other process. * * The currently available options are (default keys, when defined, are marked * with '*'): * * share (single-key) * open the port in the same memory region used by the * given port name (the port name must be given in * subsystem:vpname form) * * conf (multi-key) * specify the rings/slots numbers (effective only on * ports that are created by the open operation itself, * and ignored otherwise). * * The keys are: * * *rings number of tx and rx rings * tx-rings number of tx rings * rx-rings number of rx rings * host-rings number of tx and rx host rings * host-tx-rings number of host tx rings * host-rx-rings number of host rx rings * slots number of slots in each tx and rx * ring * tx-slots number of slots in each tx ring * rx-slots number of slots in each rx ring * * (more specific keys override the less specific ones) * All keys default to zero if not assigned, and the * corresponding value will be chosen by netmap. * * extmem (multi-key) * open the port in the memory region obtained by * mmap()ing the given file. * * The keys are: * * *file the file to mmap * if-num number of pre-allocated netmap_if's * if-size size of each netmap_if * ring-num number of pre-allocated netmap_ring's * ring-size size of each netmap_ring * buf-num number of pre-allocated buffers * buf-size size of each buffer * * file must be assigned. The other keys default to zero, * causing netmap to take the corresponding values from * the priv_{if,ring,buf}_{num,size} sysctls. * * offset (multi-key) * reserve (part of) the ptr fields as an offset field * and write an initial offset into them. * * The keys are: * * bits number of bits of ptr to use * *initial initial offset value * * initial must be assigned. If bits is omitted, it * defaults to the entire ptr field. The max offset is set * at the same value as the initial offset. Note that the * actual values may be increased by the kernel. * * This option is disabled by default (see * nmport_enable_option() below) */ /* nmport manipulation */ /* struct nmport_d - describes a netmap port */ struct nmport_d { /* see net/netmap.h for the definition of these fields */ struct nmreq_header hdr; struct nmreq_register reg; /* all the fields below should be considered read-only */ /* if the same context is used throughout the program, d1->mem == * d2->mem iff d1 and d2 are using the memory region (i.e., zero * copy is possible between the two ports) */ struct nmem_d *mem; /* the nmctx used when this nmport_d was created */ struct nmctx *ctx; int register_done; /* nmport_register() has been called */ int mmap_done; /* nmport_mmap() has been called */ /* pointer to the extmem option contained in the hdr options, if any */ struct nmreq_opt_extmem *extmem; /* the fields below are compatible with nm_open() */ int fd; /* "/dev/netmap", -1 if not open */ struct netmap_if *nifp; /* pointer to the netmap_if */ uint16_t first_tx_ring; uint16_t last_tx_ring; uint16_t first_rx_ring; uint16_t last_rx_ring; uint16_t cur_tx_ring; /* used by nmport_inject */ uint16_t cur_rx_ring; /* LIFO list of cleanup functions (used internally) */ struct nmport_cleanup_d *clist; }; /* nmport_open - opens a port from a portspec * @portspec the port opening specification * * If successful, the function returns a new nmport_d describing a netmap * port, opened according to the port specification, ready to be used for rx * and/or tx. * * The rings available for tx are in the [first_tx_ring, last_tx_ring] * interval, and similarly for rx. One or both intervals may be empty. * * When done using it, the nmport_d descriptor must be closed using * nmport_close(). * * In case of error, NULL is returned, errno is set to some error, and an * error message is sent through the error() method of the current context. */ struct nmport_d * nmport_open(const char *portspec); /* nport_close - close a netmap port * @d the port we want to close * * Undoes the actions performed by the nmport_open that created d, then * frees the descriptor. */ void nmport_close(struct nmport_d *d); /* nmport_inject - sends a packet * @d the port through which we want to send * @buf base address of the packet * @size its size in bytes * * Sends a packet using the cur_tx_ring and updates the index * to use all available tx rings in turn. Note: the packet is copied. * * Returns 0 on success an -1 on error. */ int nmport_inject(struct nmport_d *d, const void *buf, size_t size); /* * the functions below can be used to split the functionality of * nmport_open when special features (e.g., extra buffers) are needed * * The relation among the functions is as follows: * * |nmport_new * |nmport_prepare = | * | |nmport_parse * nmport_open =| * | |nmport_register * |nmport_open_desc =| * |nmport_mmap * */ /* nmport_new - create a new nmport_d * * Creates a new nmport_d using the malloc() method of the current default * context. Returns NULL on error, setting errno to an error value. */ struct nmport_d *nmport_new(void); /* nmport_parse - fills the nmport_d netmap-register request * @d the nmport to be filled * @portspec the port opening specification * * This function parses the portspec and initizalizes the @d->hdr and @d->reg * fields. It may need to allocate a list of options. If an extmem option is * found, it may also mmap() the corresponding file. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_parse(struct nmport_d *d, const char *portspec); /* nmport_register - registers the port with netmap * @d the nmport to be registered * * This function obtains a netmap file descriptor and registers the port with * netmap. The @d->hdr and @d->reg data structures must have been previously * initialized (via nmport_parse() or otherwise). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_register(struct nmport_d *); /* nmport_mmap - maps the port resources into the process memory * @d the nmport to be mapped * * The port must have been previously been registered using nmport_register. * * Note that if extmem is used (either via an option or by calling an * nmport_extmem_* function before nmport_register()), no new mmap() is issued. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_mmap(struct nmport_d *); /* the following functions undo the actions of nmport_new(), nmport_parse(), * nmport_register() and nmport_mmap(), respectively. */ void nmport_delete(struct nmport_d *); void nmport_undo_parse(struct nmport_d *); void nmport_undo_register(struct nmport_d *); void nmport_undo_mmap(struct nmport_d *); /* nmport_prepare - create a port descriptor, but do not open it * @portspec the port opening specification * * This functions creates a new nmport_d and initializes it according to * @portspec. It is equivalent to nmport_new() followed by nmport_parse(). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ struct nmport_d *nmport_prepare(const char *portspec); /* nmport_open_desc - open an initialized port descriptor * @d the descriptor we want to open * * Registers the port with netmap and maps the rings and buffers into the * process memory. It is equivalent to nmport_register() followed by * nmport_mmap(). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_open_desc(struct nmport_d *d); /* the following functions undo the actions of nmport_prepare() * and nmport_open_desc(), respectively. */ void nmport_undo_prepare(struct nmport_d *); void nmport_undo_open_desc(struct nmport_d *); /* nmport_clone - copy an nmport_d * @d the nmport_d we want to copy * * Copying an nmport_d by hand should be avoided, since adjustments are needed * and some part of the state cannot be easily duplicated. This function * creates a copy of @d in a safe way. The returned nmport_d contains * nmreq_header and nmreq_register structures equivalent to those contained in * @d, except for the option list, which is ignored. The returned nmport_d is * already nmport_prepare()d, but it must still be nmport_open_desc()ed. The * new nmport_d uses the same nmctx as @d. * * If extmem was used for @d, then @d cannot be nmport_clone()d until it has * been nmport_register()ed. * * In case of error, the function returns NULL, sets errno to an error value * and sends an error message to the nmctx error() method. */ struct nmport_d *nmport_clone(struct nmport_d *); /* nmport_extmem - use extmem for this port * @d the port we want to use the extmem for * @base the base address of the extmem region * @size the size in bytes of the extmem region * * the memory that contains the netmap ifs, rings and buffers is usually * allocated by netmap and later mmap()ed by the applications. It is sometimes * useful to reverse this process, by having the applications allocate some * memory (through mmap() or otherwise) and then let netmap use it. The extmem * option can be used to implement this latter strategy. The option can be * passed through the portspec using the '@extmem:...' syntax, or * programmatically by calling nmport_extmem() or nmport_extmem_from_file() * between nmport_parse() and nmport_register() (or between nmport_prepare() * and nmport_open_desc()). * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_extmem(struct nmport_d *d, void *base, size_t size); /* nmport_extmem_from_file - use the extmem obtained by mapping a file * @d the port we want to use the extmem for * @fname path of the file we want to map * * This works like nmport_extmem, but the extmem memory is obtained by * mmap()ping @fname. nmport_close() will also automatically munmap() the file. * * It returns 0 on success. On failure it returns -1, sets errno to an error * value and sends an error message to the error() method of the context used * when @d was created. Moreover, *@d is left unchanged. */ int nmport_extmem_from_file(struct nmport_d *d, const char *fname); /* nmport_extmem_getinfo - opbtai a pointer to the extmem configuration * @d the port we want to obtain the pointer from * * Returns a pointer to the nmreq_pools_info structure containing the * configuration of the extmem attached to port @d, or NULL if no extmem * is attached. This can be used to set the desired configuration before * registering the port, or to read the actual configuration after * registration. */ struct nmreq_pools_info* nmport_extmem_getinfo(struct nmport_d *d); /* nmport_offset - use offsets for this port * @initial the initial offset for all the slots * @maxoff the maximum offset * @bits the number of bits of slot->ptr to use for the offsets * @mingap the minimum gap between offsets (in shared buffers) * * With this option the lower @bits bits of the ptr field in the netmap_slot * can be used to specify an offset into the buffer. All offsets will be set * to the @initial value by netmap. * * The offset field can be read and updated using the bitmask found in * ring->offset_mask after a successful register. netmap_user.h contains * some helper macros (NETMAP_ROFFSET, NETMAP_WOFFSET and NETMAP_BUF_OFFSET). * * For RX rings, the user writes the offset o in an empty slot before passing * it to netmap; then, netmap will write the incoming packet at an offset o' >= * o in the buffer. o' may be larger than o because of, e.g., alignment * constrains. If o' > o netmap will also update the offset field in the slot. * Note that large offsets may cause the port to split the packet over several * slots, setting the NS_MOREFRAG flag accordingly. * * For TX rings, the user may prepare the packet to send at an offset o into * the buffer and write o in the offset field. Netmap will send the packets * starting o bytes in the buffer. Note that the address of the packet must * comply with any alignment constraints that the port may have, or the result * will be undefined. The user may read the alignment constraint in the new * ring->buf_align field. It is also possible that empty slots already come * with a non-zero offset o specified in the offset field. In this case, the * user will have to write the packet at an offset o' >= o. * * The user must also declare the @maxoff offset that she is going to use. Any * offset larger than this will be truncated. * * The user may also declare a @mingap (ignored if zero) if she plans to use * offsets to share the same buffer among several slots. Netmap will guarantee * that it will never write more than @mingap bytes for each slot, irrespective * of the buffer length. */ int nmport_offset(struct nmport_d *d, uint64_t initial, uint64_t maxoff, uint64_t bits, uint64_t mingap); /* enable/disable options * * These functions can be used to disable options that the application cannot * or doesn't want to handle, or to enable options that require special support * from the application and are, therefore, disabled by default. Disabled * options will cause an error if encountered during option parsing. * * If the option is unknown, nmport_disable_option is a NOP, while * nmport_enable_option returns -1 and sets errno to EOPNOTSUPP. * * These functions are not threadsafe and are meant to be used at the beginning * of the program. */ void nmport_disable_option(const char *opt); int nmport_enable_option(const char *opt); /* nmreq manipulation * * nmreq_header_init - initialize an nmreq_header * @hdr the nmreq_header to initialize * @reqtype the kind of netmap request * @body the body of the request * * Initialize the nr_version, nr_reqtype and nr_body fields of *@hdr. * The other fields are set to zero. */ void nmreq_header_init(struct nmreq_header *hdr, uint16_t reqtype, void *body); /* * These functions allow for finer grained parsing of portspecs. They are used * internally by nmport_parse(). */ /* nmreq_header_decode - initialize an nmreq_header * @ppspec: (in/out) pointer to a pointer to the portspec * @hdr: pointer to the nmreq_header to be initialized * @ctx: pointer to the nmctx to use (for errors) * * This function fills the @hdr the nr_name field with the port name extracted * from *@pifname. The other fields of *@hdr are unchanged. The @pifname is * updated to point at the first char past the port name. * * Returns 0 on success. In case of error, -1 is returned with errno set to * EINVAL, @pifname is unchanged, *@hdr is also unchanged, and an error message * is sent through @ctx->error(). */ int nmreq_header_decode(const char **ppspec, struct nmreq_header *hdr, struct nmctx *ctx); /* nmreq_regiter_decode - initialize an nmreq_register * @pmode: (in/out) pointer to a pointer to an opening mode * @reg: pointer to the nmreq_register to be initialized * @ctx: pointer to the nmctx to use (for errors) * * This function fills the nr_mode, nr_ringid, nr_flags and nr_mem_id fields of * the structure pointed by @reg, according to the opening mode specified by * *@pmode. The other fields of *@reg are unchanged. The @pmode is updated to * point at the first char past the opening mode. * * If a '@' is encountered followed by something which is not a number, parsing * stops (without error) and @pmode is left pointing at the '@' char. The * nr_mode, nr_ringid and nr_flags fields are still updated, but nr_mem_id is * not touched and the interpretation of the '@' field is left to the caller. * * Returns 0 on success. In case of error, -1 is returned with errno set to * EINVAL, @pmode is unchanged, *@reg is also unchanged, and an error message * is sent through @ctx->error(). */ int nmreq_register_decode(const char **pmode, struct nmreq_register *reg, struct nmctx *ctx); /* nmreq_options_decode - parse the "options" part of the portspec * @opt: pointer to the option list * @parsers: list of option parsers * @token: token to pass to each parser * @ctx: pointer to the nmctx to use (for errors and malloc/free) * * This function parses each option in @opt. Each option is matched (based on * the "option" prefix) to a corresponding parser in @parsers. The function * checks that the syntax is appropriate for the parser and it assigns all the * keys mentioned in the option. It then passes control to the parser, to * interpret the keys values. * * Returns 0 on success. In case of error, -1 is returned, errno is set to an * error value and a message is sent to @ctx->error(). The effects of partially * interpreted options may not be undone. */ struct nmreq_opt_parser; int nmreq_options_decode(const char *opt, struct nmreq_opt_parser *parsers, void *token, struct nmctx *ctx); struct nmreq_parse_ctx; /* type of the option-parsers callbacks */ typedef int (*nmreq_opt_parser_cb)(struct nmreq_parse_ctx *); #define NMREQ_OPT_MAXKEYS 16 /* max nr of recognized keys per option */ /* struct nmreq_opt_key - describes an option key */ struct nmreq_opt_key { const char *key; /* the key name */ int id; /* its position in the parse context */ unsigned int flags; #define NMREQ_OPTK_ALLOWEMPTY (1U << 0) /* =value may be omitted */ #define NMREQ_OPTK_MUSTSET (1U << 1) /* the key is mandatory */ #define NMREQ_OPTK_DEFAULT (1U << 2) /* this is the default key */ }; /* struct nmreq_opt_parser - describes an option parser */ struct nmreq_opt_parser { const char *prefix; /* matches one option prefix */ nmreq_opt_parser_cb parse; /* the parse callback */ int default_key; /* which option is the default if the parser is multi-key (-1 if none) */ int nr_keys; unsigned int flags; #define NMREQ_OPTF_DISABLED (1U << 0) #define NMREQ_OPTF_ALLOWEMPTY (1U << 1) /* =value can be omitted */ struct nmreq_opt_parser *next; /* list of options */ /* recognized keys */ struct nmreq_opt_key keys[NMREQ_OPT_MAXKEYS]; } __attribute__((aligned(16))); /* struct nmreq_parse_ctx - the parse context received by the parse callback */ struct nmreq_parse_ctx { struct nmctx *ctx; /* the nmctx for errors and malloc/free */ void *token; /* the token passed to nmreq_options_parse */ /* the value (i.e., the part after the = sign) of each recognized key * is assigned to the corresponding entry in this array, based on the * key id. Unassigned keys are left at NULL. */ const char *keys[NMREQ_OPT_MAXKEYS]; }; /* nmreq_get_mem_id - get the mem_id of the given port * @portname pointer to a pointer to the portname * @ctx pointer to the nmctx to use (for errors) * * *@portname must point to a substem:vpname porname, possibly followed by * something else. * * If successful, returns the mem_id of *@portname and moves @portname past the * subsystem:vpname part of the input. In case of error it returns -1, sets * errno to an error value and sends an error message to ctx->error(). */ int32_t nmreq_get_mem_id(const char **portname, struct nmctx *ctx); /* option list manipulation */ void nmreq_push_option(struct nmreq_header *, struct nmreq_option *); void nmreq_remove_option(struct nmreq_header *, struct nmreq_option *); struct nmreq_option *nmreq_find_option(struct nmreq_header *, uint32_t); void nmreq_free_options(struct nmreq_header *); const char* nmreq_option_name(uint32_t); #define nmreq_foreach_option(h_, o_) \ for ((o_) = (struct nmreq_option *)((uintptr_t)((h_)->nr_options));\ (o_) != NULL;\ (o_) = (struct nmreq_option *)((uintptr_t)((o_)->nro_next))) /* nmctx manipulation */ /* the nmctx serves a few purposes: * * - maintain a list of all memory regions open by the program, so that two * ports that are using the same region (as identified by the mem_id) will * point to the same nmem_d instance. * * - allow the user to specify how to lock accesses to the above list, if * needed (lock() callback) * * - allow the user to specify how error messages should be delivered (error() * callback) * * - select the verbosity of the library (verbose field); if verbose==0, no * errors are sent to the error() callback * * - allow the user to override the malloc/free functions used by the library * (malloc() and free() callbacks) * */ typedef void (*nmctx_error_cb)(struct nmctx *, const char *); typedef void *(*nmctx_malloc_cb)(struct nmctx *,size_t); typedef void (*nmctx_free_cb)(struct nmctx *,void *); typedef void (*nmctx_lock_cb)(struct nmctx *, int); struct nmctx { int verbose; nmctx_error_cb error; nmctx_malloc_cb malloc; nmctx_free_cb free; nmctx_lock_cb lock; struct nmem_d *mem_descs; }; /* nmctx_get - obtain a pointer to the current default context */ struct nmctx *nmctx_get(void); /* nmctx_set_default - change the default context * @ctx pointer to the new context * * Returns a pointer to the previous default context. */ struct nmctx *nmctx_set_default(struct nmctx *ctx); /* internal functions and data structures */ /* struct nmem_d - describes a memory region currently used */ struct nmem_d { uint16_t mem_id; /* the region netmap identifier */ int refcount; /* how many nmport_d's point here */ void *mem; /* memory region base address */ size_t size; /* memory region size */ int is_extmem; /* was it obtained via extmem? */ /* pointers for the circular list implementation. * The list head is the mem_descs filed in the nmctx */ struct nmem_d *next; struct nmem_d *prev; }; /* a trick to force the inclusion of libpthread only if requested. If * LIBNETMAP_NOTHREADSAFE is defined, no pthread symbol is imported. * * There is no need to actually call this function: the ((used)) attribute is * sufficient to include it in the image. */ static __attribute__((used)) void libnetmap_init(void) { #ifndef LIBNETMAP_NOTHREADSAFE extern int nmctx_threadsafe; /* dummy assignment to link-in the nmctx-pthread.o object. The proper * inizialization is performed only once in the library constructor * defined there. */ nmctx_threadsafe = 1; #endif /* LIBNETMAP_NOTHREADSAFE */ } /* nmctx_set_threadsafe - install a threadsafe default context * * called by the constructor in nmctx-pthread.o to initialize a lock and install * the lock() callback in the default context. */ void nmctx_set_threadsafe(void); /* nmctx_ferror - format and send an error message */ void nmctx_ferror(struct nmctx *, const char *, ...); /* nmctx_malloc - allocate memory */ void *nmctx_malloc(struct nmctx *, size_t); /* nmctx_free - free memory allocated via nmctx_malloc */ void nmctx_free(struct nmctx *, void *); /* nmctx_lock - lock the list of nmem_d */ void nmctx_lock(struct nmctx *); /* nmctx_unlock - unlock the list of nmem_d */ void nmctx_unlock(struct nmctx *); #endif /* LIBNETMAP_H_ */ diff --git a/lib/libpmc/pmu-events/pmu-events.h b/lib/libpmc/pmu-events/pmu-events.h index 654f33c7fa42..d9edbfba7ceb 100644 --- a/lib/libpmc/pmu-events/pmu-events.h +++ b/lib/libpmc/pmu-events/pmu-events.h @@ -1,62 +1,61 @@ /* - * $FreeBSD$ */ #ifndef PMU_EVENTS_H #define PMU_EVENTS_H enum aggr_mode_class { PerChip = 1, PerCore }; /* * Describe each PMU event. Each CPU has a table of PMU events. */ struct pmu_event { const char *name; const char *compat; const char *event; const char *desc; const char *topic; const char *long_desc; const char *pmu; const char *unit; const char *perpkg; const char *aggr_mode; const char *metric_expr; const char *metric_name; const char *metric_group; const char *deprecated; const char *metric_constraint; }; /* * * Map a CPU to its table of PMU events. The CPU is identified by the * cpuid field, which is an arch-specific identifier for the CPU. * The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile * must match the get_cpuid_str() in tools/perf/arch/xxx/util/header.c) * * The cpuid can contain any character other than the comma. */ struct pmu_events_map { const char *cpuid; const char *version; const char *type; /* core, uncore etc */ const struct pmu_event *table; }; struct pmu_sys_events { const char *name; const struct pmu_event *table; }; /* * Global table mapping each known CPU for the architecture to its * table of PMU events. */ extern const struct pmu_events_map pmu_events_map[]; extern const struct pmu_sys_events pmu_sys_event_tables[]; #endif diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map index 3d0f37b5981e..4c8a0c7edefb 100644 --- a/lib/libprocstat/Symbol.map +++ b/lib/libprocstat/Symbol.map @@ -1,51 +1,50 @@ /* - * $FreeBSD$ */ FBSD_1.2 { procstat_close; procstat_freefiles; procstat_freeprocs; procstat_get_pipe_info; procstat_getfiles; procstat_getprocs; procstat_open_kvm; procstat_open_sysctl; }; FBSD_1.3 { procstat_freeargv; procstat_freeauxv; procstat_freeenvv; procstat_freegroups; procstat_freekstack; procstat_freevmmap; procstat_getargv; procstat_getauxv; procstat_getenvv; procstat_getgroups; procstat_getkstack; procstat_getosrel; procstat_getpathname; procstat_getrlimit; procstat_getumask; procstat_getvmmap; procstat_open_core; }; FBSD_1.5 { procstat_freeptlwpinfo; procstat_getptlwpinfo; procstat_get_sem_info; procstat_get_shm_info; procstat_get_socket_info; }; FBSD_1.6 { procstat_get_pts_info; procstat_get_vnode_info; }; FBSD_1.7 { procstat_getadvlock; procstat_freeadvlock; }; \ No newline at end of file diff --git a/lib/libregex/Symbol.map b/lib/libregex/Symbol.map index 09cd21183723..0aa63b86ae0e 100644 --- a/lib/libregex/Symbol.map +++ b/lib/libregex/Symbol.map @@ -1,16 +1,15 @@ /* - * $FreeBSD$ */ /* * libregex uses a different version name because its symbols are not strictly * compatible with those provided by libc. Re-using the version name from libc * could cause linking headaches and make debugging more difficult than it needs * to be. */ LIBREGEX_1.0 { regcomp; regerror; regexec; regfree; }; diff --git a/lib/librpcsec_gss/Symbol.map b/lib/librpcsec_gss/Symbol.map index 7f69c98e8af4..28f66eefd8ea 100644 --- a/lib/librpcsec_gss/Symbol.map +++ b/lib/librpcsec_gss/Symbol.map @@ -1,28 +1,27 @@ /* - * $FreeBSD$ */ FBSD_1.1 { rpc_gss_seccreate; rpc_gss_set_defaults; rpc_gss_max_data_length; rpc_gss_get_error; rpc_gss_mesh_to_oid; rpc_gss_oid_to_mech; rpc_gss_qop_to_num; rpc_gss_get_mechanisms; rpc_gss_get_mech_info; rpc_gss_get_versions; rpc_gss_is_installed; rpc_gss_set_svc_name; rpc_gss_getcred; rpc_gss_set_callback; rpc_gss_get_principal_name; rpc_gss_svc_max_data_length; }; FBSDprivate_1.0 { __rpc_gss_unwrap; __rpc_gss_unwrap_stub; __rpc_gss_wrap; __rpc_gss_wrap_stub; }; diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map index b8fde3dd33b8..1c1ed4c5e817 100644 --- a/lib/librt/Symbol.map +++ b/lib/librt/Symbol.map @@ -1,70 +1,69 @@ /* - * $FreeBSD$ */ FBSD_1.0 { aio_read; aio_write; aio_return; aio_waitcomplete; aio_fsync; mq_open; mq_close; mq_notify; mq_getattr; mq_setattr; mq_timedreceive; mq_timedsend; mq_unlink; mq_send; mq_receive; timer_create; timer_delete; timer_gettime; timer_settime; timer_getoverrun; }; FBSD_1.5 { lio_listio; mq_getfd_np; timer_oshandle_np; }; FBSD_1.6 { aio_readv; aio_writev; }; FBSDprivate_1.0 { _mq_open; _mq_close; _mq_notify; _mq_getattr; _mq_setattr; _mq_timedreceive; _mq_timedsend; _mq_unlink; _mq_send; _mq_receive; __mq_open; __mq_close; __mq_notify; __mq_getattr; __mq_setattr; __mq_timedreceive; __mq_timedsend; __mq_unlink; __mq_send; __mq_receive; _timer_create; _timer_delete; _timer_gettime; _timer_settime; _timer_getoverrun; __timer_create; __timer_delete; __timer_gettime; __timer_settime; __timer_getoverrun; }; diff --git a/lib/libsbuf/Symbol.map b/lib/libsbuf/Symbol.map index 3efd20bdf5c5..1db91383e9d2 100644 --- a/lib/libsbuf/Symbol.map +++ b/lib/libsbuf/Symbol.map @@ -1,45 +1,44 @@ /* - * $FreeBSD$ */ FBSD_1.2 { sbuf_new; sbuf_clear; sbuf_setpos; sbuf_bcat; sbuf_bcpy; sbuf_cat; sbuf_cpy; sbuf_printf; sbuf_vprintf; sbuf_putc; sbuf_set_drain; sbuf_trim; sbuf_error; sbuf_finish; sbuf_data; sbuf_len; sbuf_done; sbuf_delete; sbuf_clear_flags; sbuf_get_flags; sbuf_set_flags; }; FBSD_1.3 { sbuf_start_section; sbuf_end_section; }; FBSD_1.4 { sbuf_hexdump; }; FBSD_1.5 { sbuf_putbuf; }; /* Added in FreeBSD 13.x */ FBSD_1.6 { sbuf_printf_drain; }; diff --git a/lib/libsdp/sdp-int.h b/lib/libsdp/sdp-int.h index acf0469d3a70..c260582af331 100644 --- a/lib/libsdp/sdp-int.h +++ b/lib/libsdp/sdp-int.h @@ -1,64 +1,63 @@ /*- * sdp-int.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sdp-int.h,v 1.1 2003/09/01 23:01:07 max Exp $ - * $FreeBSD$ */ #ifndef _SDP_INT_H_ #define _SDP_INT_H_ __BEGIN_DECLS /* * SDP session */ struct sdp_session { uint16_t flags; #define SDP_SESSION_LOCAL (1 << 0) uint16_t tid; /* current session transaction ID (tid) */ uint16_t omtu; /* outgoing MTU (req buffer size) */ uint16_t imtu; /* incoming MTU (rsp buffer size) */ uint8_t *req; /* request buffer (start) */ uint8_t *req_e; /* request buffer (end) */ uint8_t *rsp; /* response buffer (start) */ uint8_t *rsp_e; /* response buffer (end) */ uint32_t cslen; /* continuation state length */ uint8_t cs[16];/* continuation state */ int32_t s; /* L2CAP socket */ int32_t error; /* last error code */ }; typedef struct sdp_session sdp_session_t; typedef struct sdp_session * sdp_session_p; __END_DECLS #endif /* ndef _SDP_INT_H_ */ diff --git a/lib/libsdp/sdp.h b/lib/libsdp/sdp.h index 87c18a308224..faad36aefca6 100644 --- a/lib/libsdp/sdp.h +++ b/lib/libsdp/sdp.h @@ -1,715 +1,714 @@ /*- * sdp.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sdp.h,v 1.3 2003/09/05 00:33:59 max Exp $ - * $FreeBSD$ */ #ifndef _SDP_H_ #define _SDP_H_ __BEGIN_DECLS /* * Data representation (page 349) */ /* Nil, the null type */ #define SDP_DATA_NIL 0x00 /* Unsigned integer */ #define SDP_DATA_UINT8 0x08 #define SDP_DATA_UINT16 0x09 #define SDP_DATA_UINT32 0x0A #define SDP_DATA_UINT64 0x0B #define SDP_DATA_UINT128 0x0C /* Signed two's-complement integer */ #define SDP_DATA_INT8 0x10 #define SDP_DATA_INT16 0x11 #define SDP_DATA_INT32 0x12 #define SDP_DATA_INT64 0x13 #define SDP_DATA_INT128 0x14 /* UUID, a universally unique identifier */ #define SDP_DATA_UUID16 0x19 #define SDP_DATA_UUID32 0x1A #define SDP_DATA_UUID128 0x1C /* Text string */ #define SDP_DATA_STR8 0x25 #define SDP_DATA_STR16 0x26 #define SDP_DATA_STR32 0x27 /* Boolean */ #define SDP_DATA_BOOL 0x28 /* * Data element sequence. * A data element whose data field is a sequence of data elements */ #define SDP_DATA_SEQ8 0x35 #define SDP_DATA_SEQ16 0x36 #define SDP_DATA_SEQ32 0x37 /* * Data element alternative. * A data element whose data field is a sequence of data elements from * which one data element is to be selected. */ #define SDP_DATA_ALT8 0x3D #define SDP_DATA_ALT16 0x3E #define SDP_DATA_ALT32 0x3F /* URL, a uniform resource locator */ #define SDP_DATA_URL8 0x45 #define SDP_DATA_URL16 0x46 #define SDP_DATA_URL32 0x47 /* * Protocols UUID (short) https://www.bluetooth.org/assigned-numbers/service_discovery.php * BASE UUID 00000000-0000-1000-8000-00805F9B34FB */ #define SDP_UUID_PROTOCOL_SDP 0x0001 #define SDP_UUID_PROTOCOL_UDP 0x0002 #define SDP_UUID_PROTOCOL_RFCOMM 0x0003 #define SDP_UUID_PROTOCOL_TCP 0x0004 #define SDP_UUID_PROTOCOL_TCS_BIN 0x0005 #define SDP_UUID_PROTOCOL_TCS_AT 0x0006 #define SDP_UUID_PROTOCOL_OBEX 0x0008 #define SDP_UUID_PROTOCOL_IP 0x0009 #define SDP_UUID_PROTOCOL_FTP 0x000A #define SDP_UUID_PROTOCOL_HTTP 0x000C #define SDP_UUID_PROTOCOL_WSP 0x000E #define SDP_UUID_PROTOCOL_BNEP 0x000F #define SDP_UUID_PROTOCOL_UPNP 0x0010 #define SDP_UUID_PROTOCOL_HIDP 0x0011 #define SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL 0x0012 #define SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL 0x0014 #define SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION 0x0016 #define SDP_UUID_PROTOCOL_AVCTP 0x0017 #define SDP_UUID_PROTOCOL_AVDTP 0x0019 #define SDP_UUID_PROTOCOL_CMPT 0x001B #define SDP_UUID_PROTOCOL_UDI_C_PLANE 0x001D #define SDP_UUID_PROTOCOL_L2CAP 0x0100 /* * Service class IDs https://www.bluetooth.org/assigned-numbers/service_discovery.php */ #define SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER 0x1000 #define SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR 0x1001 #define SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP 0x1002 #define SDP_SERVICE_CLASS_SERIAL_PORT 0x1101 #define SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP 0x1102 #define SDP_SERVICE_CLASS_DIALUP_NETWORKING 0x1103 #define SDP_SERVICE_CLASS_IR_MC_SYNC 0x1104 #define SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH 0x1105 #define SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER 0x1106 #define SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND 0x1107 #define SDP_SERVICE_CLASS_HEADSET 0x1108 #define SDP_SERVICE_CLASS_CORDLESS_TELEPHONY 0x1109 #define SDP_SERVICE_CLASS_AUDIO_SOURCE 0x110A #define SDP_SERVICE_CLASS_AUDIO_SINK 0x110B #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET 0x110C #define SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION 0x110D #define SDP_SERVICE_CLASS_AV_REMOTE_CONTROL 0x110E #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING 0x110F #define SDP_SERVICE_CLASS_INTERCOM 0x1110 #define SDP_SERVICE_CLASS_FAX 0x1111 #define SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY 0x1112 #define SDP_SERVICE_CLASS_WAP 0x1113 #define SDP_SERVICE_CLASS_WAP_CLIENT 0x1114 #define SDP_SERVICE_CLASS_PANU 0x1115 #define SDP_SERVICE_CLASS_NAP 0x1116 #define SDP_SERVICE_CLASS_GN 0x1117 #define SDP_SERVICE_CLASS_DIRECT_PRINTING 0x1118 #define SDP_SERVICE_CLASS_REFERENCE_PRINTING 0x1119 #define SDP_SERVICE_CLASS_IMAGING 0x111A #define SDP_SERVICE_CLASS_IMAGING_RESPONDER 0x111B #define SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE 0x111C #define SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS 0x111D #define SDP_SERVICE_CLASS_HANDSFREE 0x111E #define SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY 0x111F #define SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS 0x1120 #define SDP_SERVICE_CLASS_REFLECTED_UI 0x1121 #define SDP_SERVICE_CLASS_BASIC_PRINTING 0x1122 #define SDP_SERVICE_CLASS_PRINTING_STATUS 0x1123 #define SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE 0x1124 #define SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT 0x1125 #define SDP_SERVICE_CLASS_HCR_PRINT 0x1126 #define SDP_SERVICE_CLASS_HCR_SCAN 0x1127 #define SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS 0x1128 #define SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW 0x1129 #define SDP_SERVICE_CLASS_UDI_MT 0x112A #define SDP_SERVICE_CLASS_UDI_TA 0x112B #define SDP_SERVICE_CLASS_AUDIO_VIDEO 0x112C #define SDP_SERVICE_CLASS_SIM_ACCESS 0x112D #define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PCE 0x112E #define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PSE 0x112F #define SDP_SERVICE_CLASS_PHONEBOOK_ACCESS 0x1130 #define SDP_SERVICE_CLASS_PNP_INFORMATION 0x1200 #define SDP_SERVICE_CLASS_GENERIC_NETWORKING 0x1201 #define SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER 0x1202 #define SDP_SERVICE_CLASS_GENERIC_AUDIO 0x1203 #define SDP_SERVICE_CLASS_GENERIC_TELEPHONY 0x1204 #define SDP_SERVICE_CLASS_UPNP 0x1205 #define SDP_SERVICE_CLASS_UPNP_IP 0x1206 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN 0x1300 #define SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP 0x1301 #define SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP 0x1302 #define SDP_SERVICE_CLASS_VIDEO_SOURCE 0x1303 #define SDP_SERVICE_CLASS_VIDEO_SINK 0x1304 #define SDP_SERVICE_CLASS_VIDEO_DISTRIBUTION 0x1305 /* * Universal attribute definitions (page 366) and * https://www.bluetooth.org/assigned-numbers/service_discovery.php */ #define SDP_ATTR_RANGE(lo, hi) \ (uint32_t)(((uint16_t)(lo) << 16) | ((uint16_t)(hi))) #define SDP_ATTR_SERVICE_RECORD_HANDLE 0x0000 #define SDP_ATTR_SERVICE_CLASS_ID_LIST 0x0001 #define SDP_ATTR_SERVICE_RECORD_STATE 0x0002 #define SDP_ATTR_SERVICE_ID 0x0003 #define SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST 0x0004 #define SDP_ATTR_BROWSE_GROUP_LIST 0x0005 #define SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST 0x0006 #define SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE 0x0007 #define SDP_ATTR_SERVICE_AVAILABILITY 0x0008 #define SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST 0x0009 #define SDP_ATTR_DOCUMENTATION_URL 0x000A #define SDP_ATTR_CLIENT_EXECUTABLE_URL 0x000B #define SDP_ATTR_ICON_URL 0x000C #define SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS 0x000D #define SDP_ATTR_GROUP_ID 0x0200 #define SDP_ATTR_IP_SUBNET 0x0200 #define SDP_ATTR_VERSION_NUMBER_LIST 0x0200 #define SDP_ATTR_SERVICE_DATABASE_STATE 0x0201 #define SDP_ATTR_SERVICE_VERSION 0x0300 #define SDP_ATTR_EXTERNAL_NETWORK 0x0301 #define SDP_ATTR_NETWORK 0x0301 #define SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301 #define SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302 #define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302 #define SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303 #define SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303 #define SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304 #define SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305 #define SDP_ATTR_NETWORK_ADDRESS 0x0306 #define SDP_ATTR_WAP_GATEWAY 0x0307 #define SDP_ATTR_HOME_PAGE_URL 0x0308 #define SDP_ATTR_WAP_STACK_TYPE 0x0309 #define SDP_ATTR_SECURITY_DESCRIPTION 0x030A #define SDP_ATTR_NET_ACCESS_TYPE 0x030B #define SDP_ATTR_MAX_NET_ACCESS_RATE 0x030C #define SDP_ATTR_IPV4_SUBNET 0x030D #define SDP_ATTR_IPV6_SUBNET 0x030E #define SDP_ATTR_SUPPORTED_CAPABALITIES 0x0310 #define SDP_ATTR_SUPPORTED_FEATURES 0x0311 #define SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312 #define SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313 #define SDP_ATTR_SUPPORTED_REPOSITORIES 0x0314 /* * The offset must be added to the attribute ID base (contained in the * LANGUAGE_BASE_ATTRIBUTE_ID_LIST attribute) in order to compute the * attribute ID for these attributes. */ #define SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID 0x0100 #define SDP_ATTR_SERVICE_NAME_OFFSET 0x0000 #define SDP_ATTR_SERVICE_DESCRIPTION_OFFSET 0x0001 #define SDP_ATTR_PROVIDER_NAME_OFFSET 0x0002 /* * Protocol data unit (PDU) format (page 352) */ #define SDP_PDU_ERROR_RESPONSE 0x01 #define SDP_PDU_SERVICE_SEARCH_REQUEST 0x02 #define SDP_PDU_SERVICE_SEARCH_RESPONSE 0x03 #define SDP_PDU_SERVICE_ATTRIBUTE_REQUEST 0x04 #define SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE 0x05 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST 0x06 #define SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE 0x07 struct sdp_pdu { uint8_t pid; /* PDU ID - SDP_PDU_xxx */ uint16_t tid; /* transaction ID */ uint16_t len; /* parameters length (in bytes) */ } __attribute__ ((packed)); typedef struct sdp_pdu sdp_pdu_t; typedef struct sdp_pdu * sdp_pdu_p; /* * Error codes for SDP_PDU_ERROR_RESPONSE */ #define SDP_ERROR_CODE_INVALID_SDP_VERSION 0x0001 #define SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE 0x0002 #define SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX 0x0003 #define SDP_ERROR_CODE_INVALID_PDU_SIZE 0x0004 #define SDP_ERROR_CODE_INVALID_CONTINUATION_STATE 0x0005 #define SDP_ERROR_CODE_INSUFFICIENT_RESOURCES 0x0006 /* * SDP int128/uint128 parameter */ struct int128 { int8_t b[16]; }; typedef struct int128 int128_t; typedef struct int128 uint128_t; /* * SDP attribute */ struct sdp_attr { uint16_t flags; #define SDP_ATTR_OK (0 << 0) #define SDP_ATTR_INVALID (1 << 0) #define SDP_ATTR_TRUNCATED (1 << 1) uint16_t attr; /* SDP_ATTR_xxx */ uint32_t vlen; /* length of the value[] in bytes */ uint8_t *value; /* base pointer */ }; typedef struct sdp_attr sdp_attr_t; typedef struct sdp_attr * sdp_attr_p; /****************************************************************************** * User interface *****************************************************************************/ /* Inline versions of get/put byte/short/long. Pointer is advanced */ #define SDP_GET8(b, cp) { \ const uint8_t *t_cp = (const uint8_t *)(cp); \ (b) = *t_cp; \ (cp) ++; \ } #define SDP_GET16(s, cp) { \ const uint8_t *t_cp = (const uint8_t *)(cp); \ (s) = ((uint16_t)t_cp[0] << 8) \ | ((uint16_t)t_cp[1]) \ ; \ (cp) += 2; \ } #define SDP_GET32(l, cp) { \ const uint8_t *t_cp = (const uint8_t *)(cp); \ (l) = ((uint32_t)t_cp[0] << 24) \ | ((uint32_t)t_cp[1] << 16) \ | ((uint32_t)t_cp[2] << 8) \ | ((uint32_t)t_cp[3]) \ ; \ (cp) += 4; \ } #define SDP_GET64(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ (l) = ((uint64_t)t_cp[0] << 56) \ | ((uint64_t)t_cp[1] << 48) \ | ((uint64_t)t_cp[2] << 40) \ | ((uint64_t)t_cp[3] << 32) \ | ((uint64_t)t_cp[4] << 24) \ | ((uint64_t)t_cp[5] << 16) \ | ((uint64_t)t_cp[6] << 8) \ | ((uint64_t)t_cp[7]) \ ; \ (cp) += 8; \ } #if BYTE_ORDER == LITTLE_ENDIAN #define SDP_GET128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ (l)->b[15] = *t_cp++; \ (l)->b[14] = *t_cp++; \ (l)->b[13] = *t_cp++; \ (l)->b[12] = *t_cp++; \ (l)->b[11] = *t_cp++; \ (l)->b[10] = *t_cp++; \ (l)->b[9] = *t_cp++; \ (l)->b[8] = *t_cp++; \ (l)->b[7] = *t_cp++; \ (l)->b[6] = *t_cp++; \ (l)->b[5] = *t_cp++; \ (l)->b[4] = *t_cp++; \ (l)->b[3] = *t_cp++; \ (l)->b[2] = *t_cp++; \ (l)->b[1] = *t_cp++; \ (l)->b[0] = *t_cp++; \ (cp) += 16; \ } #define SDP_GET_UUID128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ (l)->b[0] = *t_cp++; \ (l)->b[1] = *t_cp++; \ (l)->b[2] = *t_cp++; \ (l)->b[3] = *t_cp++; \ (l)->b[4] = *t_cp++; \ (l)->b[5] = *t_cp++; \ (l)->b[6] = *t_cp++; \ (l)->b[7] = *t_cp++; \ (l)->b[8] = *t_cp++; \ (l)->b[9] = *t_cp++; \ (l)->b[10] = *t_cp++; \ (l)->b[11] = *t_cp++; \ (l)->b[12] = *t_cp++; \ (l)->b[13] = *t_cp++; \ (l)->b[14] = *t_cp++; \ (l)->b[15] = *t_cp++; \ (cp) += 16; \ } #elif BYTE_ORDER == BIG_ENDIAN #define SDP_GET128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ (l)->b[0] = *t_cp++; \ (l)->b[1] = *t_cp++; \ (l)->b[2] = *t_cp++; \ (l)->b[3] = *t_cp++; \ (l)->b[4] = *t_cp++; \ (l)->b[5] = *t_cp++; \ (l)->b[6] = *t_cp++; \ (l)->b[7] = *t_cp++; \ (l)->b[8] = *t_cp++; \ (l)->b[9] = *t_cp++; \ (l)->b[10] = *t_cp++; \ (l)->b[11] = *t_cp++; \ (l)->b[12] = *t_cp++; \ (l)->b[13] = *t_cp++; \ (l)->b[14] = *t_cp++; \ (l)->b[15] = *t_cp++; \ (cp) += 16; \ } #define SDP_GET_UUID128(l, cp) SDP_GET128(l, cp) #else #error "Unsupported BYTE_ORDER" #endif /* BYTE_ORDER */ #define SDP_PUT8(b, cp) { \ register uint8_t t_b = (uint8_t)(b); \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp = t_b; \ (cp) ++; \ } #define SDP_PUT16(s, cp) { \ register uint16_t t_s = (uint16_t)(s); \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = t_s >> 8; \ *t_cp = t_s; \ (cp) += 2; \ } #define SDP_PUT32(l, cp) { \ register uint32_t t_l = (uint32_t)(l); \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ *t_cp++ = t_l >> 8; \ *t_cp = t_l; \ (cp) += 4; \ } #define SDP_PUT64(l, cp) { \ register uint64_t t_l = (uint64_t)(l); \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = t_l >> 56; \ *t_cp++ = t_l >> 48; \ *t_cp++ = t_l >> 40; \ *t_cp++ = t_l >> 32; \ *t_cp++ = t_l >> 24; \ *t_cp++ = t_l >> 16; \ *t_cp++ = t_l >> 8; \ *t_cp = t_l; \ (cp) += 8; \ } #if BYTE_ORDER == LITTLE_ENDIAN #define SDP_PUT128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = (l)->b[15]; \ *t_cp++ = (l)->b[14]; \ *t_cp++ = (l)->b[13]; \ *t_cp++ = (l)->b[12]; \ *t_cp++ = (l)->b[11]; \ *t_cp++ = (l)->b[10]; \ *t_cp++ = (l)->b[9]; \ *t_cp++ = (l)->b[8]; \ *t_cp++ = (l)->b[7]; \ *t_cp++ = (l)->b[6]; \ *t_cp++ = (l)->b[5]; \ *t_cp++ = (l)->b[4]; \ *t_cp++ = (l)->b[3]; \ *t_cp++ = (l)->b[2]; \ *t_cp++ = (l)->b[1]; \ *t_cp = (l)->b[0]; \ (cp) += 16; \ } #define SDP_PUT_UUID128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = (l)->b[0]; \ *t_cp++ = (l)->b[1]; \ *t_cp++ = (l)->b[2]; \ *t_cp++ = (l)->b[3]; \ *t_cp++ = (l)->b[4]; \ *t_cp++ = (l)->b[5]; \ *t_cp++ = (l)->b[6]; \ *t_cp++ = (l)->b[7]; \ *t_cp++ = (l)->b[8]; \ *t_cp++ = (l)->b[9]; \ *t_cp++ = (l)->b[10]; \ *t_cp++ = (l)->b[11]; \ *t_cp++ = (l)->b[12]; \ *t_cp++ = (l)->b[13]; \ *t_cp++ = (l)->b[14]; \ *t_cp = (l)->b[15]; \ (cp) += 16; \ } #elif BYTE_ORDER == BIG_ENDIAN #define SDP_PUT128(l, cp) { \ register uint8_t *t_cp = (uint8_t *)(cp); \ *t_cp++ = (l)->b[0]; \ *t_cp++ = (l)->b[1]; \ *t_cp++ = (l)->b[2]; \ *t_cp++ = (l)->b[3]; \ *t_cp++ = (l)->b[4]; \ *t_cp++ = (l)->b[5]; \ *t_cp++ = (l)->b[6]; \ *t_cp++ = (l)->b[7]; \ *t_cp++ = (l)->b[8]; \ *t_cp++ = (l)->b[9]; \ *t_cp++ = (l)->b[10]; \ *t_cp++ = (l)->b[11]; \ *t_cp++ = (l)->b[12]; \ *t_cp++ = (l)->b[13]; \ *t_cp++ = (l)->b[14]; \ *t_cp = (l)->b[15]; \ (cp) += 16; \ } #define SDP_PUT_UUID128(l, cp) SDP_PUT128(l, cp) #else #error "Unsupported BYTE_ORDER" #endif /* BYTE_ORDER */ void * sdp_open (bdaddr_t const *l, bdaddr_t const *r); void * sdp_open_local (char const *control); int32_t sdp_close (void *xs); int32_t sdp_error (void *xs); int32_t sdp_get_lcaddr (void *xs, bdaddr_t *l); int32_t sdp_search (void *xs, uint32_t plen, uint16_t const *pp, uint32_t alen, uint32_t const *ap, uint32_t vlen, sdp_attr_t *vp); char const * sdp_attr2desc (uint16_t attr); char const * sdp_uuid2desc (uint16_t uuid); void sdp_print (uint32_t level, uint8_t const *start, uint8_t const *end); /****************************************************************************** * sdpd interface and Bluetooth profiles data *****************************************************************************/ #define SDP_LOCAL_PATH "/var/run/sdp" #define SDP_LOCAL_MTU 4096 /* * These are NOT defined in spec and only accepted on control sockets. * The response to these request always will be SDP_PDU_ERROR_RESPONSE. * The first 2 bytes (after PDU header) is an error code (in network * byte order). The rest of the data (pdu->len - 2) is a response data * and depend on the request. * * SDP_PDU_SERVICE_REGISTER_REQUEST * pdu_header_t hdr; * u_int16_t uuid; service class UUID (network byte order) * bdaddr_t bdaddr; local BD_ADDR (or ANY) * profile data[pdu->len - sizeof(uuid) - sizeof(bdaddr)] * * in successful response additional data will contain 4 bytes record handle * * * SDP_PDU_SERVICE_UNREGISTER_REQUEST * pdu_header_t hdr; * u_int32_t record_handle; (network byte order) * * no additional data in response. * * * SDP_PDU_SERVICE_CHANGE_REQUEST * pdu_header_t hdr; * u_int32_t record_handle; (network byte order) * profile data[pdu->len - sizeof(record_handle)] * * no additional data in response. */ #define SDP_PDU_SERVICE_REGISTER_REQUEST 0x81 #define SDP_PDU_SERVICE_UNREGISTER_REQUEST 0x82 #define SDP_PDU_SERVICE_CHANGE_REQUEST 0x83 struct sdp_audio_sink_profile { uint16_t psm; uint16_t protover; uint16_t features; }; typedef struct sdp_audio_sink_profile sdp_audio_sink_profile_t; typedef struct sdp_audio_sink_profile *sdp_audio_sink_profile_p; struct sdp_audio_source_profile { uint16_t psm; uint16_t protover; uint16_t features; }; typedef struct sdp_audio_source_profile sdp_audio_source_profile_t; typedef struct sdp_audio_source_profile *sdp_audio_source_profile_p; struct sdp_dun_profile { uint8_t server_channel; uint8_t audio_feedback_support; uint8_t reserved[2]; }; typedef struct sdp_dun_profile sdp_dun_profile_t; typedef struct sdp_dun_profile * sdp_dun_profile_p; struct sdp_ftrn_profile { uint8_t server_channel; uint8_t reserved[3]; }; typedef struct sdp_ftrn_profile sdp_ftrn_profile_t; typedef struct sdp_ftrn_profile * sdp_ftrn_profile_p; /* Keep this in sync with sdp_opush_profile */ struct sdp_irmc_profile { uint8_t server_channel; uint8_t supported_formats_size; uint8_t supported_formats[30]; }; typedef struct sdp_irmc_profile sdp_irmc_profile_t; typedef struct sdp_irmc_profile * sdp_irmc_profile_p; struct sdp_irmc_command_profile { uint8_t server_channel; uint8_t reserved[3]; }; typedef struct sdp_irmc_command_profile sdp_irmc_command_profile_t; typedef struct sdp_irmc_command_profile * sdp_irmc_command_profile_p; struct sdp_lan_profile { uint8_t server_channel; uint8_t load_factor; uint8_t reserved; uint8_t ip_subnet_radius; uint32_t ip_subnet; }; typedef struct sdp_lan_profile sdp_lan_profile_t; typedef struct sdp_lan_profile * sdp_lan_profile_p; /* Keep this in sync with sdp_irmc_profile */ struct sdp_opush_profile { uint8_t server_channel; uint8_t supported_formats_size; uint8_t supported_formats[30]; }; typedef struct sdp_opush_profile sdp_opush_profile_t; typedef struct sdp_opush_profile * sdp_opush_profile_p; struct sdp_sp_profile { uint8_t server_channel; uint8_t reserved[3]; }; typedef struct sdp_sp_profile sdp_sp_profile_t; typedef struct sdp_sp_profile * sdp_sp_profile_p; struct sdp_nap_profile { uint8_t reserved; uint8_t load_factor; uint16_t psm; /* HBO */ uint16_t security_description; /* HBO */ uint16_t net_access_type; /* HBO */ uint32_t max_net_access_rate; /* HBO */ }; typedef struct sdp_nap_profile sdp_nap_profile_t; typedef struct sdp_nap_profile * sdp_nap_profile_p; struct sdp_gn_profile { uint8_t reserved; uint8_t load_factor; uint16_t psm; /* HBO */ uint16_t security_description; /* HBO */ uint16_t reserved2; }; typedef struct sdp_gn_profile sdp_gn_profile_t; typedef struct sdp_gn_profile * sdp_gn_profile_p; struct sdp_panu_profile { uint8_t reserved; uint8_t load_factor; uint16_t psm; /* HBO */ uint16_t security_description; /* HBO */ uint16_t reserved2; }; typedef struct sdp_panu_profile sdp_panu_profile_t; typedef struct sdp_panu_profile * sdp_panu_profile_p; int32_t sdp_register_service (void *xss, uint16_t uuid, bdaddr_p const bdaddr, uint8_t const *data, uint32_t datalen, uint32_t *handle); int32_t sdp_unregister_service (void *xss, uint32_t handle); int32_t sdp_change_service (void *xss, uint32_t handle, uint8_t const *data, uint32_t datalen); __END_DECLS #endif /* ndef _SDP_H_ */ diff --git a/lib/libsdp/search.c b/lib/libsdp/search.c index 1ccf55339522..eeed5c89ab65 100644 --- a/lib/libsdp/search.c +++ b/lib/libsdp/search.c @@ -1,424 +1,423 @@ /*- * search.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: search.c,v 1.2 2003/09/04 22:12:13 max Exp $ - * $FreeBSD$ */ #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include int32_t sdp_search(void *xss, uint32_t plen, uint16_t const *pp, uint32_t alen, uint32_t const *ap, uint32_t vlen, sdp_attr_t *vp) { struct sdp_xpdu { sdp_pdu_t pdu; uint16_t len; } __attribute__ ((packed)) xpdu; sdp_session_p ss = (sdp_session_p) xss; uint8_t *req = NULL, *rsp = NULL, *rsp_tmp = NULL; int32_t t, len; uint16_t lo, hi; if (ss == NULL) return (-1); if (ss->req == NULL || ss->rsp == NULL || plen == 0 || pp == NULL || alen == 0 || ap == NULL) { ss->error = EINVAL; return (-1); } req = ss->req; /* Calculate ServiceSearchPattern length */ plen = plen * (sizeof(pp[0]) + 1); /* Calculate AttributeIDList length */ for (len = 0, t = 0; t < alen; t ++) { lo = (uint16_t) (ap[t] >> 16); hi = (uint16_t) (ap[t]); if (lo > hi) { ss->error = EINVAL; return (-1); } if (lo != hi) len += (sizeof(ap[t]) + 1); else len += (sizeof(lo) + 1); } alen = len; /* Calculate length of the request */ len = plen + sizeof(uint8_t) + sizeof(uint16_t) + /* ServiceSearchPattern */ sizeof(uint16_t) + /* MaximumAttributeByteCount */ alen + sizeof(uint8_t) + sizeof(uint16_t); /* AttributeIDList */ if (ss->req_e - req < len) { ss->error = ENOBUFS; return (-1); } /* Put ServiceSearchPattern */ SDP_PUT8(SDP_DATA_SEQ16, req); SDP_PUT16(plen, req); for (; plen > 0; pp ++, plen -= (sizeof(pp[0]) + 1)) { SDP_PUT8(SDP_DATA_UUID16, req); SDP_PUT16(*pp, req); } /* Put MaximumAttributeByteCount */ SDP_PUT16(0xffff, req); /* Put AttributeIDList */ SDP_PUT8(SDP_DATA_SEQ16, req); SDP_PUT16(alen, req); for (; alen > 0; ap ++) { lo = (uint16_t) (*ap >> 16); hi = (uint16_t) (*ap); if (lo != hi) { /* Put attribute range */ SDP_PUT8(SDP_DATA_UINT32, req); SDP_PUT32(*ap, req); alen -= (sizeof(ap[0]) + 1); } else { /* Put attribute */ SDP_PUT8(SDP_DATA_UINT16, req); SDP_PUT16(lo, req); alen -= (sizeof(lo) + 1); } } /* Submit ServiceSearchAttributeRequest and wait for response */ ss->cslen = 0; rsp = ss->rsp; do { struct iovec iov[2]; uint8_t *req_cs = req; /* Add continuation state (if any) */ if (ss->req_e - req_cs < ss->cslen + 1) { ss->error = ENOBUFS; return (-1); } SDP_PUT8(ss->cslen, req_cs); if (ss->cslen > 0) { memcpy(req_cs, ss->cs, ss->cslen); req_cs += ss->cslen; } /* Prepare SDP PDU header */ xpdu.pdu.pid = SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST; xpdu.pdu.tid = htons(ss->tid); xpdu.pdu.len = htons(req_cs - ss->req); /* Submit request */ iov[0].iov_base = (void *) &xpdu; iov[0].iov_len = sizeof(xpdu.pdu); iov[1].iov_base = (void *) ss->req; iov[1].iov_len = req_cs - ss->req; do { len = writev(ss->s, iov, sizeof(iov)/sizeof(iov[0])); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } /* Read response */ iov[0].iov_base = (void *) &xpdu; iov[0].iov_len = sizeof(xpdu); iov[1].iov_base = (void *) rsp; iov[1].iov_len = ss->imtu; do { len = readv(ss->s, iov, sizeof(iov)/sizeof(iov[0])); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } if (len < sizeof(xpdu)) { ss->error = ENOMSG; return (-1); } xpdu.pdu.tid = ntohs(xpdu.pdu.tid); xpdu.pdu.len = ntohs(xpdu.pdu.len); xpdu.len = ntohs(xpdu.len); if (xpdu.pdu.pid == SDP_PDU_ERROR_RESPONSE || xpdu.pdu.tid != ss->tid || xpdu.pdu.len > len || xpdu.len > xpdu.pdu.len) { ss->error = EIO; return (-1); } rsp += xpdu.len; ss->tid ++; /* Save continuation state (if any) */ ss->cslen = rsp[0]; if (ss->cslen > 0) { if (ss->cslen > sizeof(ss->cs)) { ss->error = ENOBUFS; return (-1); } memcpy(ss->cs, rsp + 1, ss->cslen); /* * Ensure that we always have ss->imtu bytes * available in the ss->rsp buffer */ if (ss->rsp_e - rsp <= ss->imtu) { uint32_t size, offset; size = ss->rsp_e - ss->rsp + ss->imtu; offset = rsp - ss->rsp; rsp_tmp = realloc(ss->rsp, size); if (rsp_tmp == NULL) { ss->error = ENOMEM; return (-1); } ss->rsp = rsp_tmp; ss->rsp_e = ss->rsp + size; rsp = ss->rsp + offset; } } } while (ss->cslen > 0); /* * If we got here then we have completed SDP transaction and now * we must populate attribute values into vp array. At this point * ss->rsp points to the beginning of the response and rsp points * to the end of the response. * * From Bluetooth v1.1 spec page 364 * * The AttributeLists is a data element sequence where each element * in turn is a data element sequence representing an attribute list. * Each attribute list contains attribute IDs and attribute values * from one service record. The first element in each attribute list * contains the attribute ID of the first attribute to be returned for * that service record. The second element in each attribute list * contains the corresponding attribute value. Successive pairs of * elements in each attribute list contain additional attribute ID * and value pairs. Only attributes that have non-null values within * the service record and whose attribute IDs were specified in the * SDP_ServiceSearchAttributeRequest are contained in the AttributeLists * Neither an attribute ID nor attribute value is placed in * AttributeLists for attributes in the service record that have no * value. Within each attribute list, the attributes are listed in * ascending order of attribute ID value. */ if (vp == NULL) goto done; rsp_tmp = ss->rsp; /* Skip the first SEQ */ SDP_GET8(t, rsp_tmp); switch (t) { case SDP_DATA_SEQ8: SDP_GET8(len, rsp_tmp); break; case SDP_DATA_SEQ16: SDP_GET16(len, rsp_tmp); break; case SDP_DATA_SEQ32: SDP_GET32(len, rsp_tmp); break; default: ss->error = ENOATTR; return (-1); /* NOT REACHED */ } for (; rsp_tmp < rsp && vlen > 0; ) { /* Get set of attributes for the next record */ SDP_GET8(t, rsp_tmp); switch (t) { case SDP_DATA_SEQ8: SDP_GET8(len, rsp_tmp); break; case SDP_DATA_SEQ16: SDP_GET16(len, rsp_tmp); break; case SDP_DATA_SEQ32: SDP_GET32(len, rsp_tmp); break; default: ss->error = ENOATTR; return (-1); /* NOT REACHED */ } /* Now rsp_tmp points to list of (attr,value) pairs */ for (; len > 0 && vlen > 0; vp ++, vlen --) { /* Attribute */ SDP_GET8(t, rsp_tmp); if (t != SDP_DATA_UINT16) { ss->error = ENOATTR; return (-1); } SDP_GET16(vp->attr, rsp_tmp); /* Attribute value */ switch (rsp_tmp[0]) { case SDP_DATA_NIL: alen = 0; break; case SDP_DATA_UINT8: case SDP_DATA_INT8: case SDP_DATA_BOOL: alen = sizeof(uint8_t); break; case SDP_DATA_UINT16: case SDP_DATA_INT16: case SDP_DATA_UUID16: alen = sizeof(uint16_t); break; case SDP_DATA_UINT32: case SDP_DATA_INT32: case SDP_DATA_UUID32: alen = sizeof(uint32_t); break; case SDP_DATA_UINT64: case SDP_DATA_INT64: alen = sizeof(uint64_t); break; case SDP_DATA_UINT128: case SDP_DATA_INT128: case SDP_DATA_UUID128: alen = sizeof(uint128_t); break; case SDP_DATA_STR8: case SDP_DATA_URL8: case SDP_DATA_SEQ8: case SDP_DATA_ALT8: alen = rsp_tmp[1] + sizeof(uint8_t); break; case SDP_DATA_STR16: case SDP_DATA_URL16: case SDP_DATA_SEQ16: case SDP_DATA_ALT16: alen = ((uint16_t)rsp_tmp[1] << 8) | ((uint16_t)rsp_tmp[2]); alen += sizeof(uint16_t); break; case SDP_DATA_STR32: case SDP_DATA_URL32: case SDP_DATA_SEQ32: case SDP_DATA_ALT32: alen = ((uint32_t)rsp_tmp[1] << 24) | ((uint32_t)rsp_tmp[2] << 16) | ((uint32_t)rsp_tmp[3] << 8) | ((uint32_t)rsp_tmp[4]); alen += sizeof(uint32_t); break; default: ss->error = ENOATTR; return (-1); /* NOT REACHED */ } alen += sizeof(uint8_t); if (vp->value != NULL) { if (alen <= vp->vlen) { vp->flags = SDP_ATTR_OK; vp->vlen = alen; } else vp->flags = SDP_ATTR_TRUNCATED; memcpy(vp->value, rsp_tmp, vp->vlen); } else vp->flags = SDP_ATTR_INVALID; len -= ( sizeof(uint8_t) + sizeof(uint16_t) + alen ); rsp_tmp += alen; } } done: ss->error = 0; return (0); } diff --git a/lib/libsdp/service.c b/lib/libsdp/service.c index 2240f0da82c6..9f07d1ba86ba 100644 --- a/lib/libsdp/service.c +++ b/lib/libsdp/service.c @@ -1,240 +1,239 @@ /*- * service.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: service.c,v 1.1 2004/01/13 19:32:36 max Exp $ - * $FreeBSD$ */ #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include static int32_t sdp_receive_error_pdu(sdp_session_p ss); int32_t sdp_register_service(void *xss, uint16_t uuid, bdaddr_p const bdaddr, uint8_t const *data, uint32_t datalen, uint32_t *handle) { sdp_session_p ss = (sdp_session_p) xss; struct iovec iov[4]; sdp_pdu_t pdu; int32_t len; if (ss == NULL) return (-1); if (bdaddr == NULL || data == NULL || datalen == 0 || !(ss->flags & SDP_SESSION_LOCAL)) { ss->error = EINVAL; return (-1); } if (sizeof(pdu)+sizeof(uuid)+sizeof(*bdaddr)+datalen > SDP_LOCAL_MTU) { ss->error = EMSGSIZE; return (-1); } pdu.pid = SDP_PDU_SERVICE_REGISTER_REQUEST; pdu.tid = htons(++ss->tid); pdu.len = htons(sizeof(uuid) + sizeof(*bdaddr) + datalen); uuid = htons(uuid); iov[0].iov_base = (void *) &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = (void *) &uuid; iov[1].iov_len = sizeof(uuid); iov[2].iov_base = (void *) bdaddr; iov[2].iov_len = sizeof(*bdaddr); iov[3].iov_base = (void *) data; iov[3].iov_len = datalen; do { len = writev(ss->s, iov, sizeof(iov)/sizeof(iov[0])); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } len = sdp_receive_error_pdu(ss); if (len < 0) return (-1); if (len != sizeof(pdu) + sizeof(uint16_t) + sizeof(uint32_t)) { ss->error = EIO; return (-1); } if (handle != NULL) { *handle = (uint32_t) ss->rsp[--len]; *handle |= (uint32_t) ss->rsp[--len] << 8; *handle |= (uint32_t) ss->rsp[--len] << 16; *handle |= (uint32_t) ss->rsp[--len] << 24; } return (0); } int32_t sdp_unregister_service(void *xss, uint32_t handle) { sdp_session_p ss = (sdp_session_p) xss; struct iovec iov[2]; sdp_pdu_t pdu; int32_t len; if (ss == NULL) return (-1); if (!(ss->flags & SDP_SESSION_LOCAL)) { ss->error = EINVAL; return (-1); } if (sizeof(pdu) + sizeof(handle) > SDP_LOCAL_MTU) { ss->error = EMSGSIZE; return (-1); } pdu.pid = SDP_PDU_SERVICE_UNREGISTER_REQUEST; pdu.tid = htons(++ss->tid); pdu.len = htons(sizeof(handle)); handle = htonl(handle); iov[0].iov_base = (void *) &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = (void *) &handle; iov[1].iov_len = sizeof(handle); do { len = writev(ss->s, iov, sizeof(iov)/sizeof(iov[0])); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } return ((sdp_receive_error_pdu(ss) < 0)? -1 : 0); } int32_t sdp_change_service(void *xss, uint32_t handle, uint8_t const *data, uint32_t datalen) { sdp_session_p ss = (sdp_session_p) xss; struct iovec iov[3]; sdp_pdu_t pdu; int32_t len; if (ss == NULL) return (-1); if (data == NULL || datalen == 0 || !(ss->flags & SDP_SESSION_LOCAL)) { ss->error = EINVAL; return (-1); } if (sizeof(pdu) + sizeof(handle) + datalen > SDP_LOCAL_MTU) { ss->error = EMSGSIZE; return (-1); } pdu.pid = SDP_PDU_SERVICE_CHANGE_REQUEST; pdu.tid = htons(++ss->tid); pdu.len = htons(sizeof(handle) + datalen); handle = htons(handle); iov[0].iov_base = (void *) &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = (void *) &handle; iov[1].iov_len = sizeof(handle); iov[2].iov_base = (void *) data; iov[2].iov_len = datalen; do { len = writev(ss->s, iov, sizeof(iov)/sizeof(iov[0])); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } return ((sdp_receive_error_pdu(ss) < 0)? -1 : 0); } static int32_t sdp_receive_error_pdu(sdp_session_p ss) { sdp_pdu_p pdu; int32_t len; uint16_t error; do { len = read(ss->s, ss->rsp, ss->rsp_e - ss->rsp); } while (len < 0 && errno == EINTR); if (len < 0) { ss->error = errno; return (-1); } pdu = (sdp_pdu_p) ss->rsp; pdu->tid = ntohs(pdu->tid); pdu->len = ntohs(pdu->len); if (pdu->pid != SDP_PDU_ERROR_RESPONSE || pdu->tid != ss->tid || pdu->len < 2 || pdu->len != len - sizeof(*pdu)) { ss->error = EIO; return (-1); } error = (uint16_t) ss->rsp[sizeof(pdu)] << 8; error |= (uint16_t) ss->rsp[sizeof(pdu) + 1]; if (error != 0) { ss->error = EIO; return (-1); } return (len); } diff --git a/lib/libsdp/session.c b/lib/libsdp/session.c index 0f8e954c7386..87d3cecb09e2 100644 --- a/lib/libsdp/session.c +++ b/lib/libsdp/session.c @@ -1,204 +1,203 @@ /*- * session.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: session.c,v 1.2 2003/09/04 22:12:13 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include void * sdp_open(bdaddr_t const *l, bdaddr_t const *r) { sdp_session_p ss = NULL; struct sockaddr_l2cap sa; socklen_t size; if ((ss = calloc(1, sizeof(*ss))) == NULL) goto fail; if (l == NULL || r == NULL) { ss->error = EINVAL; goto fail; } ss->s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP); if (ss->s < 0) { ss->error = errno; goto fail; } sa.l2cap_len = sizeof(sa); sa.l2cap_family = AF_BLUETOOTH; sa.l2cap_psm = 0; sa.l2cap_cid = 0; sa.l2cap_bdaddr_type = BDADDR_BREDR; memcpy(&sa.l2cap_bdaddr, l, sizeof(sa.l2cap_bdaddr)); if (bind(ss->s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { ss->error = errno; goto fail; } sa.l2cap_psm = htole16(NG_L2CAP_PSM_SDP); memcpy(&sa.l2cap_bdaddr, r, sizeof(sa.l2cap_bdaddr)); if (connect(ss->s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { ss->error = errno; goto fail; } size = sizeof(ss->omtu); if (getsockopt(ss->s, SOL_L2CAP, SO_L2CAP_OMTU, &ss->omtu, &size) < 0) { ss->error = errno; goto fail; } if ((ss->req = malloc(ss->omtu)) == NULL) { ss->error = ENOMEM; goto fail; } ss->req_e = ss->req + ss->omtu; size = sizeof(ss->imtu); if (getsockopt(ss->s, SOL_L2CAP, SO_L2CAP_IMTU, &ss->imtu, &size) < 0) { ss->error = errno; goto fail; } if ((ss->rsp = malloc(ss->imtu)) == NULL) { ss->error = ENOMEM; goto fail; } ss->rsp_e = ss->rsp + ss->imtu; ss->error = 0; fail: return ((void *) ss); } void * sdp_open_local(char const *control) { sdp_session_p ss = NULL; struct sockaddr_un sa; if ((ss = calloc(1, sizeof(*ss))) == NULL) goto fail; ss->s = socket(PF_UNIX, SOCK_STREAM, 0); if (ss->s < 0) { ss->error = errno; goto fail; } if (control == NULL) control = SDP_LOCAL_PATH; sa.sun_len = sizeof(sa); sa.sun_family = AF_UNIX; strlcpy(sa.sun_path, control, sizeof(sa.sun_path)); if (connect(ss->s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { ss->error = errno; goto fail; } ss->flags |= SDP_SESSION_LOCAL; ss->imtu = ss->omtu = SDP_LOCAL_MTU; if ((ss->req = malloc(ss->omtu)) == NULL) { ss->error = ENOMEM; goto fail; } ss->req_e = ss->req + ss->omtu; if ((ss->rsp = malloc(ss->imtu)) == NULL) { ss->error = ENOMEM; goto fail; } ss->rsp_e = ss->rsp + ss->imtu; ss->error = 0; fail: return ((void *) ss); } int32_t sdp_close(void *xss) { sdp_session_p ss = (sdp_session_p) xss; if (ss != NULL) { if (ss->s >= 0) close(ss->s); if (ss->req != NULL) free(ss->req); if (ss->rsp != NULL) free(ss->rsp); memset(ss, 0, sizeof(*ss)); free(ss); } return (0); } int32_t sdp_error(void *xss) { sdp_session_p ss = (sdp_session_p) xss; return ((ss != NULL)? ss->error : EINVAL); } int32_t sdp_get_lcaddr(void *xss, bdaddr_t *l) { sdp_session_p ss = (sdp_session_p) xss; struct sockaddr_l2cap sa; socklen_t size; if (l == NULL || ss == NULL || ss->flags & SDP_SESSION_LOCAL) { ss->error = EINVAL; goto fail; } size = sizeof(sa); if (getsockname(ss->s, (struct sockaddr *)&sa, &size) == 0) { bdaddr_copy(l, &sa.l2cap_bdaddr); ss->error = 0; } else ss->error = errno; fail: return ((ss->error == 0) ? 0 : -1); } diff --git a/lib/libsdp/util.c b/lib/libsdp/util.c index c45aac784115..36bfb531faab 100644 --- a/lib/libsdp/util.c +++ b/lib/libsdp/util.c @@ -1,460 +1,459 @@ /*- * util.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: util.c,v 1.5 2003/09/08 02:29:35 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include /* * SDP attribute description */ struct sdp_attr_desc { uint32_t attr; char const *desc; }; typedef struct sdp_attr_desc sdp_attr_desc_t; typedef struct sdp_attr_desc * sdp_attr_desc_p; static sdp_attr_desc_t sdp_uuids_desc[] = { { SDP_UUID_PROTOCOL_SDP, "SDP", }, { SDP_UUID_PROTOCOL_UDP, "UDP", }, { SDP_UUID_PROTOCOL_RFCOMM, "RFCOMM", }, { SDP_UUID_PROTOCOL_TCP, "TCP", }, { SDP_UUID_PROTOCOL_TCS_BIN, "TCS BIN", }, { SDP_UUID_PROTOCOL_TCS_AT, "TCS AT", }, { SDP_UUID_PROTOCOL_OBEX, "OBEX", }, { SDP_UUID_PROTOCOL_IP, "IP", }, { SDP_UUID_PROTOCOL_FTP, "FTP", }, { SDP_UUID_PROTOCOL_HTTP, "HTTP", }, { SDP_UUID_PROTOCOL_WSP, "WSP", }, { SDP_UUID_PROTOCOL_BNEP, "BNEP", }, { SDP_UUID_PROTOCOL_UPNP, "UPNP", }, { SDP_UUID_PROTOCOL_HIDP, "HIDP", }, { SDP_UUID_PROTOCOL_HARDCOPY_CONTROL_CHANNEL, "Hardcopy Control Channel", }, { SDP_UUID_PROTOCOL_HARDCOPY_DATA_CHANNEL, "Hardcopy Data Channel", }, { SDP_UUID_PROTOCOL_HARDCOPY_NOTIFICATION, "Hardcopy Notification", }, { SDP_UUID_PROTOCOL_AVCTP, "AVCTP", }, { SDP_UUID_PROTOCOL_AVDTP, "AVDTP", }, { SDP_UUID_PROTOCOL_CMPT, "CMPT", }, { SDP_UUID_PROTOCOL_UDI_C_PLANE, "UDI C-Plane", }, { SDP_UUID_PROTOCOL_L2CAP, "L2CAP", }, /* Service Class IDs/Bluetooth Profile IDs */ { SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER, "Service Discovery Server", }, { SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR, "Browse Group Descriptor", }, { SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP, "Public Browse Group", }, { SDP_SERVICE_CLASS_SERIAL_PORT, "Serial Port", }, { SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP, "LAN Access Using PPP", }, { SDP_SERVICE_CLASS_DIALUP_NETWORKING, "Dial-Up Networking", }, { SDP_SERVICE_CLASS_IR_MC_SYNC, "IrMC Sync", }, { SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH, "OBEX Object Push", }, { SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER, "OBEX File Transfer", }, { SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND, "IrMC Sync Command", }, { SDP_SERVICE_CLASS_HEADSET, "Headset", }, { SDP_SERVICE_CLASS_CORDLESS_TELEPHONY, "Cordless Telephony", }, { SDP_SERVICE_CLASS_AUDIO_SOURCE, "Audio Source", }, { SDP_SERVICE_CLASS_AUDIO_SINK, "Audio Sink", }, { SDP_SERVICE_CLASS_AV_REMOTE_CONTROL_TARGET, "A/V Remote Control Target", }, { SDP_SERVICE_CLASS_ADVANCED_AUDIO_DISTRIBUTION, "Advanced Audio Distribution", }, { SDP_SERVICE_CLASS_AV_REMOTE_CONTROL, "A/V Remote Control", }, { SDP_SERVICE_CLASS_VIDEO_CONFERENCING, "Video Conferencing", }, { SDP_SERVICE_CLASS_INTERCOM, "Intercom", }, { SDP_SERVICE_CLASS_FAX, "Fax", }, { SDP_SERVICE_CLASS_HEADSET_AUDIO_GATEWAY, "Headset Audio Gateway", }, { SDP_SERVICE_CLASS_WAP, "WAP", }, { SDP_SERVICE_CLASS_WAP_CLIENT, "WAP Client", }, { SDP_SERVICE_CLASS_PANU, "PANU", }, { SDP_SERVICE_CLASS_NAP, "Network Access Point", }, { SDP_SERVICE_CLASS_GN, "GN", }, { SDP_SERVICE_CLASS_DIRECT_PRINTING, "Direct Printing", }, { SDP_SERVICE_CLASS_REFERENCE_PRINTING, "Reference Printing", }, { SDP_SERVICE_CLASS_IMAGING, "Imaging", }, { SDP_SERVICE_CLASS_IMAGING_RESPONDER, "Imaging Responder", }, { SDP_SERVICE_CLASS_IMAGING_AUTOMATIC_ARCHIVE, "Imaging Automatic Archive", }, { SDP_SERVICE_CLASS_IMAGING_REFERENCED_OBJECTS, "Imaging Referenced Objects", }, { SDP_SERVICE_CLASS_HANDSFREE, "Handsfree", }, { SDP_SERVICE_CLASS_HANDSFREE_AUDIO_GATEWAY, "Handsfree Audio Gateway", }, { SDP_SERVICE_CLASS_DIRECT_PRINTING_REFERENCE_OBJECTS, "Direct Printing Reference Objects", }, { SDP_SERVICE_CLASS_REFLECTED_UI, "Reflected UI", }, { SDP_SERVICE_CLASS_BASIC_PRINTING, "Basic Printing", }, { SDP_SERVICE_CLASS_PRINTING_STATUS, "Printing Status", }, { SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE, "Human Interface Device", }, { SDP_SERVICE_CLASS_HARDCOPY_CABLE_REPLACEMENT, "Hardcopy Cable Replacement", }, { SDP_SERVICE_CLASS_HCR_PRINT, "HCR Print", }, { SDP_SERVICE_CLASS_HCR_SCAN, "HCR Scan", }, { SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS, "Common ISDN Access", }, { SDP_SERVICE_CLASS_VIDEO_CONFERENCING_GW, "Video Conferencing Gateway", }, { SDP_SERVICE_CLASS_UDI_MT, "UDI MT", }, { SDP_SERVICE_CLASS_UDI_TA, "UDI TA", }, { SDP_SERVICE_CLASS_AUDIO_VIDEO, "Audio/Video", }, { SDP_SERVICE_CLASS_SIM_ACCESS, "SIM Access", }, { SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PCE, "Phonebook Access - PCE", }, { SDP_SERVICE_CLASS_PHONEBOOK_ACCESS_PSE, "Phonebook Access - PSE", }, { SDP_SERVICE_CLASS_PHONEBOOK_ACCESS, "Phonebook Access", }, { SDP_SERVICE_CLASS_PNP_INFORMATION, "PNP Information", }, { SDP_SERVICE_CLASS_GENERIC_NETWORKING, "Generic Networking", }, { SDP_SERVICE_CLASS_GENERIC_FILE_TRANSFER, "Generic File Transfer", }, { SDP_SERVICE_CLASS_GENERIC_AUDIO, "Generic Audio", }, { SDP_SERVICE_CLASS_GENERIC_TELEPHONY, "Generic Telephony", }, { SDP_SERVICE_CLASS_UPNP, "UPNP", }, { SDP_SERVICE_CLASS_UPNP_IP, "UPNP IP", }, { SDP_SERVICE_CLASS_ESDP_UPNP_IP_PAN, "ESDP UPNP IP PAN", }, { SDP_SERVICE_CLASS_ESDP_UPNP_IP_LAP, "ESDP UPNP IP LAP", }, { SDP_SERVICE_CLASS_ESDP_UPNP_L2CAP, "ESDP UPNP L2CAP", }, { SDP_SERVICE_CLASS_VIDEO_SOURCE, "Video Source", }, { SDP_SERVICE_CLASS_VIDEO_SINK, "Video Sink", }, { SDP_SERVICE_CLASS_VIDEO_DISTRIBUTION, "Video Distribution", }, { 0xffff, NULL, } }; static sdp_attr_desc_t sdp_attrs_desc[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, "Record handle", }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, "Service Class ID list", }, { SDP_ATTR_SERVICE_RECORD_STATE, "Service Record State", }, { SDP_ATTR_SERVICE_ID, "Service ID", }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, "Protocol Descriptor List", }, { SDP_ATTR_BROWSE_GROUP_LIST, "Browse Group List", }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, "Language Base Attribute ID List", }, { SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE, "Service Info Time-To-Live", }, { SDP_ATTR_SERVICE_AVAILABILITY, "Service Availability", }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, "Bluetooh Profile Descriptor List", }, { SDP_ATTR_DOCUMENTATION_URL, "Documentation URL", }, { SDP_ATTR_CLIENT_EXECUTABLE_URL, "Client Executable URL", }, { SDP_ATTR_ICON_URL, "Icon URL", }, { SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS, "Additional Protocol Descriptor Lists" }, { SDP_ATTR_GROUP_ID, /*SDP_ATTR_IP_SUBNET, SDP_ATTR_VERSION_NUMBER_LIST*/ "Group ID/IP Subnet/Version Number List", }, { SDP_ATTR_SERVICE_DATABASE_STATE, "Service Database State", }, { SDP_ATTR_SERVICE_VERSION, "Service Version", }, { SDP_ATTR_EXTERNAL_NETWORK, /*SDP_ATTR_NETWORK, SDP_ATTR_SUPPORTED_DATA_STORES_LIST*/ "External Network/Network/Supported Data Stores List", }, { SDP_ATTR_FAX_CLASS1_SUPPORT, /*SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL*/ "Fax Class1 Support/Remote Audio Volume Control", }, { SDP_ATTR_FAX_CLASS20_SUPPORT, /*SDP_ATTR_SUPPORTED_FORMATS_LIST*/ "Fax Class20 Support/Supported Formats List", }, { SDP_ATTR_FAX_CLASS2_SUPPORT, "Fax Class2 Support", }, { SDP_ATTR_AUDIO_FEEDBACK_SUPPORT, "Audio Feedback Support", }, { SDP_ATTR_NETWORK_ADDRESS, "Network Address", }, { SDP_ATTR_WAP_GATEWAY, "WAP Gateway", }, { SDP_ATTR_HOME_PAGE_URL, "Home Page URL", }, { SDP_ATTR_WAP_STACK_TYPE, "WAP Stack Type", }, { SDP_ATTR_SECURITY_DESCRIPTION, "Security Description", }, { SDP_ATTR_NET_ACCESS_TYPE, "Net Access Type", }, { SDP_ATTR_MAX_NET_ACCESS_RATE, "Max Net Access Rate", }, { SDP_ATTR_IPV4_SUBNET, "IPv4 Subnet", }, { SDP_ATTR_IPV6_SUBNET, "IPv6 Subnet", }, { SDP_ATTR_SUPPORTED_CAPABALITIES, "Supported Capabalities", }, { SDP_ATTR_SUPPORTED_FEATURES, "Supported Features", }, { SDP_ATTR_SUPPORTED_FUNCTIONS, "Supported Functions", }, { SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY, "Total Imaging Data Capacity", }, { SDP_ATTR_SUPPORTED_REPOSITORIES, "Supported Repositories", }, { 0xffff, NULL, } }; char const * sdp_attr2desc(uint16_t attr) { register sdp_attr_desc_p a = sdp_attrs_desc; for (; a->desc != NULL; a++) if (attr == a->attr) break; return ((a->desc != NULL)? a->desc : "Unknown"); } char const * sdp_uuid2desc(uint16_t uuid) { register sdp_attr_desc_p a = sdp_uuids_desc; for (; a->desc != NULL; a++) if (uuid == a->attr) break; return ((a->desc != NULL)? a->desc : "Unknown"); } void sdp_print(uint32_t level, uint8_t const *start, uint8_t const *end) { union { int8_t int8; int16_t int16; int32_t int32; int64_t int64; int128_t int128; uint8_t uint8; uint16_t uint16; uint32_t uint32; uint64_t uint64; } value; uint8_t type; uint32_t i; if (start == NULL || end == NULL) return; while (start < end) { for (i = 0; i < level; i++) printf("\t"); SDP_GET8(type, start); switch (type) { case SDP_DATA_NIL: printf("nil\n"); break; case SDP_DATA_UINT8: SDP_GET8(value.uint8, start); printf("uint8 %u\n", value.uint8); break; case SDP_DATA_UINT16: SDP_GET16(value.uint16, start); printf("uint16 %u\n", value.uint16); break; case SDP_DATA_UINT32: SDP_GET32(value.uint32, start); printf("uint32 %u\n", value.uint32); break; case SDP_DATA_UINT64: SDP_GET64(value.uint64, start); printf("uint64 %ju\n", value.uint64); break; case SDP_DATA_UINT128: case SDP_DATA_INT128: SDP_GET128(&value.int128, start); printf("u/int128 %#8.8x%8.8x%8.8x%8.8x\n", *(uint32_t *)&value.int128.b[0], *(uint32_t *)&value.int128.b[4], *(uint32_t *)&value.int128.b[8], *(uint32_t *)&value.int128.b[12]); break; case SDP_DATA_UUID128: SDP_GET_UUID128(&value.int128, start); printf("uuid128 %#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n", ntohl(*(uint32_t *)&value.int128.b[0]), ntohs(*(uint16_t *)&value.int128.b[4]), ntohs(*(uint16_t *)&value.int128.b[6]), ntohs(*(uint16_t *)&value.int128.b[8]), ntohs(*(uint16_t *)&value.int128.b[10]), ntohl(*(uint32_t *)&value.int128.b[12])); break; case SDP_DATA_INT8: SDP_GET8(value.int8, start); printf("int8 %d\n", value.int8); break; case SDP_DATA_INT16: SDP_GET16(value.int16, start); printf("int16 %d\n", value.int16); break; case SDP_DATA_INT32: SDP_GET32(value.int32, start); printf("int32 %d\n", value.int32); break; case SDP_DATA_INT64: SDP_GET64(value.int64, start); printf("int64 %ju\n", value.int64); break; case SDP_DATA_UUID16: SDP_GET16(value.uint16, start); printf("uuid16 %#4.4x - %s\n", value.uint16, sdp_uuid2desc(value.uint16)); break; case SDP_DATA_UUID32: SDP_GET32(value.uint32, start); printf("uuid32 %#8.8x\n", value.uint32); break; case SDP_DATA_STR8: SDP_GET8(value.uint8, start); printf("str8 %*.*s\n", value.uint8, value.uint8, start); start += value.uint8; break; case SDP_DATA_STR16: SDP_GET16(value.uint16, start); printf("str16 %*.*s\n", value.uint16, value.uint16, start); start += value.uint16; break; case SDP_DATA_STR32: SDP_GET32(value.uint32, start); printf("str32 %*.*s\n", value.uint32, value.uint32, start); start += value.uint32; break; case SDP_DATA_BOOL: SDP_GET8(value.uint8, start); printf("bool %d\n", value.uint8); break; case SDP_DATA_SEQ8: SDP_GET8(value.uint8, start); printf("seq8 %d\n", value.uint8); sdp_print(level + 1, start, start + value.uint8); start += value.uint8; break; case SDP_DATA_SEQ16: SDP_GET16(value.uint16, start); printf("seq16 %d\n", value.uint16); sdp_print(level + 1, start, start + value.uint16); start += value.uint16; break; case SDP_DATA_SEQ32: SDP_GET32(value.uint32, start); printf("seq32 %d\n", value.uint32); sdp_print(level + 1, start, start + value.uint32); start += value.uint32; break; case SDP_DATA_ALT8: SDP_GET8(value.uint8, start); printf("alt8 %d\n", value.uint8); sdp_print(level + 1, start, start + value.uint8); start += value.uint8; break; case SDP_DATA_ALT16: SDP_GET16(value.uint16, start); printf("alt16 %d\n", value.uint16); sdp_print(level + 1, start, start + value.uint16); start += value.uint16; break; case SDP_DATA_ALT32: SDP_GET32(value.uint32, start); printf("alt32 %d\n", value.uint32); sdp_print(level + 1, start, start + value.uint32); start += value.uint32; break; case SDP_DATA_URL8: SDP_GET8(value.uint8, start); printf("url8 %*.*s\n", value.uint8, value.uint8, start); start += value.uint8; break; case SDP_DATA_URL16: SDP_GET16(value.uint16, start); printf("url16 %*.*s\n", value.uint16, value.uint16, start); start += value.uint16; break; case SDP_DATA_URL32: SDP_GET32(value.uint32, start); printf("url32 %*.*s\n", value.uint32, value.uint32, start); start += value.uint32; break; default: printf("unknown data type: %#02x\n", *start ++); break; } } } diff --git a/lib/libsecureboot/h/libsecureboot.h b/lib/libsecureboot/h/libsecureboot.h index f07988a8206e..017558536825 100644 --- a/lib/libsecureboot/h/libsecureboot.h +++ b/lib/libsecureboot/h/libsecureboot.h @@ -1,98 +1,97 @@ /*- * Copyright (c) 2017-2018, Juniper Networks, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT * OWNER 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. */ /* - * $FreeBSD$ */ #ifndef _LIBSECUREBOOT_H_ #define _LIBSECUREBOOT_H_ #include #ifdef _STANDALONE #include #else #include #include #include #include #include #include #endif #include unsigned char * read_fd(int, size_t); #ifndef NEED_BRSSL_H unsigned char * read_file(const char *, size_t *); #endif extern int DebugVe; extern int VerifyFlags; #ifndef DEBUG_PRINTF #define DEBUG_PRINTF(n, x) if (DebugVe >= n) printf x #endif int ve_trust_init(void); size_t ve_trust_anchors_add_buf(unsigned char *, size_t); size_t ve_trust_anchors_revoke(unsigned char *, size_t); int ve_trust_add(const char *); void ve_debug_set(int); void ve_enforce_validity_set(int); void ve_anchor_verbose_set(int); int ve_anchor_verbose_get(void); void ve_utc_set(time_t utc); char *ve_error_get(void); int ve_error_set(const char *, ...) __printflike(1,2); int ve_self_tests(void); void fingerprint_info_add(const char *, const char *, const char *, const char *, struct stat *); char * hexdigest(char *, size_t, unsigned char *, size_t); int verify_fd(int, const char *, off_t, struct stat *); int verify_open(const char *, int); unsigned char *verify_signed(const char *, int); unsigned char *verify_sig(const char *, int); unsigned char *verify_asc(const char *, int); /* OpenPGP */ void ve_pcr_init(void); void ve_pcr_update(const char *, unsigned char *, size_t); ssize_t ve_pcr_get(unsigned char *, size_t); int ve_pcr_updating_get(void); void ve_pcr_updating_set(int); char * ve_pcr_hashed_get(int); /* flags for verify_{asc,sig,signed} */ #define VEF_VERBOSE 1 #define VE_FINGERPRINT_OK 1 #define VE_FINGERPRINT_IGNORE 2 /* errors from verify_fd */ #define VE_FINGERPRINT_NONE -2 #define VE_FINGERPRINT_WRONG -3 #define VE_FINGERPRINT_UNKNOWN -4 /* may not be an error */ #endif /* _LIBSECUREBOOT_H_ */ diff --git a/lib/libsecureboot/libsecureboot-priv.h b/lib/libsecureboot/libsecureboot-priv.h index 713ba6266cc5..039b03c70ca2 100644 --- a/lib/libsecureboot/libsecureboot-priv.h +++ b/lib/libsecureboot/libsecureboot-priv.h @@ -1,71 +1,70 @@ /*- * Copyright (c) 2017, Juniper Networks, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT * OWNER 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. */ /* - * $FreeBSD$ */ #ifndef _LIBSECUREBOOT_PRIV_H_ #define _LIBSECUREBOOT_PRIV_H_ /* public api */ #include "libsecureboot.h" struct stat; typedef struct { unsigned char *data; size_t hash_size; } hash_data; int ve_check_hash(br_hash_compat_context *, const br_hash_class *, const char *, const char *, size_t); size_t ve_trust_anchors_add(br_x509_certificate *, size_t); size_t ve_forbidden_anchors_add(br_x509_certificate *, size_t); void ve_forbidden_digest_add(hash_data *digest, size_t); char *fingerprint_info_lookup(int, const char *); br_x509_certificate * parse_certificates(unsigned char *, size_t, size_t *); int certificate_to_trust_anchor_inner(br_x509_trust_anchor *, br_x509_certificate *); int verify_rsa_digest(br_rsa_public_key *pkey, const unsigned char *hash_oid, unsigned char *mdata, size_t mlen, unsigned char *sdata, size_t slen); int is_verified(struct stat *stp); void add_verify_status(struct stat *stp, int status); int openpgp_trust_init(void); int openpgp_trust_add_buf(unsigned char *, size_t); int openpgp_trust_revoke(const char *); int openpgp_self_tests(void); int efi_secure_boot_enabled(void); br_x509_certificate* efi_get_trusted_certs(size_t *count); br_x509_certificate* efi_get_forbidden_certs(size_t *count); hash_data* efi_get_forbidden_digests(size_t *count); #endif /* _LIBSECUREBOOT_PRIV_H_ */ diff --git a/lib/libsecureboot/openpgp/decode.h b/lib/libsecureboot/openpgp/decode.h index 8da39c9cf14b..1e7e2ea1f915 100644 --- a/lib/libsecureboot/openpgp/decode.h +++ b/lib/libsecureboot/openpgp/decode.h @@ -1,57 +1,56 @@ /*- * Copyright (c) 2018, Juniper Networks, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT * OWNER 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. */ /* - * $FreeBSD$ */ #ifdef USE_BEARSSL unsigned char * mpi2bn(unsigned char **pptr, size_t *sz); #else # include # include # include BIGNUM * mpi2bn(unsigned char **pptr); #endif #define NEW(x) calloc(1,sizeof(x)) #define OPENPGP_TAG_ISTAG 0200 #define OPENPGP_TAG_ISNEW 0100 #define OPENPGP_TAG_NEW_MASK 0077 #define OPENPGP_TAG_OLD_MASK 0074 #define OPENPGP_TAG_OLD_TYPE 0003 typedef int (*decoder_t)(int, unsigned char **, int, void *); unsigned char * i2octets(int n, size_t i); int octets2i(unsigned char *ptr, size_t n); char * octets2hex(unsigned char *ptr, size_t n); int decode_tag(unsigned char *ptr, int *isnew, int *ltype); unsigned char * decode_mpi(unsigned char **pptr, size_t *sz); unsigned char * dearmor(char *pem, size_t nbytes, size_t *len); int decode_packet(int want, unsigned char **pptr, size_t nbytes, decoder_t decoder, void *decoder_arg); unsigned char * decode_subpacket(unsigned char **pptr, int *stag, int *sz); diff --git a/lib/libsecureboot/openpgp/packet.h b/lib/libsecureboot/openpgp/packet.h index 28ac3c9b40fe..58f797cd1651 100644 --- a/lib/libsecureboot/openpgp/packet.h +++ b/lib/libsecureboot/openpgp/packet.h @@ -1,82 +1,81 @@ /*- * Copyright (c) 2018, Juniper Networks, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT * OWNER 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. */ /* - * $FreeBSD$ */ #include /* * Structs to represent what we need */ typedef struct OpenPGP_user { char *id; char *name; } OpenPGP_user; struct OpenPGP_key_ { char *id; int sig_alg; OpenPGP_user *user; #ifdef USE_BEARSSL br_rsa_public_key *key; #else EVP_PKEY *key; #endif LIST_ENTRY(OpenPGP_key_) entries; }; typedef struct OpenPGP_key_ OpenPGP_key; typedef struct OpenPGP_sig { char *key_id; int sig_type; int sig_alg; int hash_alg; unsigned char *pgpbytes; size_t pgpbytes_len; unsigned char *sig; size_t sig_len; } OpenPGP_sig; void openpgp_trust_add(OpenPGP_key *key); OpenPGP_key * openpgp_trust_get(const char *keyID); OpenPGP_key * load_key_file(const char *kfile); OpenPGP_key * load_key_id(const char *keyID); void initialize(void); char * get_error_string(void); int openpgp_verify(const char *filename, unsigned char *fdata, size_t fbytes, unsigned char *sdata, size_t sbytes, int flags); int openpgp_verify_file(const char *filename, unsigned char *fdata, size_t nbytes); /* packet decoders */ #define DECODER_DECL(x) \ ssize_t decode_##x(int, unsigned char **, size_t, OpenPGP_##x *) DECODER_DECL(user); DECODER_DECL(key); DECODER_DECL(sig); diff --git a/lib/libssp/Symbol.map b/lib/libssp/Symbol.map index 51f9b784c81f..5c2e089c6ab8 100644 --- a/lib/libssp/Symbol.map +++ b/lib/libssp/Symbol.map @@ -1,26 +1,25 @@ /* - * $FreeBSD$ */ LIBSSP_1.0 { __chk_fail; __stack_chk_fail; __stack_chk_guard; /* * Currently unsupported: _FORTIFY_SOURCE symbols. It is believed * that these have never been used on FreeBSD, as our headers lack the * support that would have generated references to them. */ __memcpy_chk; __memset_chk; __snprintf_chk; __sprintf_chk; __stpcpy_chk; __strcat_chk; __strcpy_chk; __strncat_chk; __strncpy_chk; __vsnprintf_chk; __vsprintf_chk; }; diff --git a/lib/libstdthreads/Symbol.map b/lib/libstdthreads/Symbol.map index 0fe6eacda4e4..36b4c54f84e8 100644 --- a/lib/libstdthreads/Symbol.map +++ b/lib/libstdthreads/Symbol.map @@ -1,31 +1,30 @@ /* - * $FreeBSD$ */ FBSD_1.3 { call_once; cnd_broadcast; cnd_destroy; cnd_init; cnd_signal; cnd_timedwait; cnd_wait; mtx_destroy; mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; thrd_create; thrd_current; thrd_detach; thrd_equal; thrd_exit; thrd_join; thrd_sleep; thrd_yield; tss_create; tss_delete; tss_get; tss_set; }; diff --git a/lib/libthr/pthread.map b/lib/libthr/pthread.map index 15195ce0847b..348fd48df398 100644 --- a/lib/libthr/pthread.map +++ b/lib/libthr/pthread.map @@ -1,337 +1,336 @@ /* - * $FreeBSD$ */ /* * Use the same naming scheme as libc. */ FBSD_1.0 { pthread_atfork; pthread_barrier_destroy; pthread_barrier_init; pthread_barrier_wait; pthread_barrierattr_destroy; pthread_barrierattr_getpshared; pthread_barrierattr_init; pthread_barrierattr_setpshared; pthread_attr_destroy; pthread_attr_get_np; pthread_attr_getdetachstate; pthread_attr_getguardsize; pthread_attr_getinheritsched; pthread_attr_getschedparam; pthread_attr_getschedpolicy; pthread_attr_getscope; pthread_attr_getstack; pthread_attr_getstackaddr; pthread_attr_getstacksize; pthread_attr_init; pthread_attr_setcreatesuspend_np; pthread_attr_setdetachstate; pthread_attr_setguardsize; pthread_attr_setinheritsched; pthread_attr_setschedparam; pthread_attr_setschedpolicy; pthread_attr_setscope; pthread_attr_setstack; pthread_attr_setstackaddr; pthread_attr_setstacksize; pthread_cancel; pthread_cleanup_pop; pthread_cleanup_push; pthread_cond_broadcast; pthread_cond_destroy; pthread_cond_init; pthread_cond_signal; pthread_cond_timedwait; pthread_cond_wait; pthread_condattr_destroy; pthread_condattr_getclock; pthread_condattr_getpshared; pthread_condattr_init; pthread_condattr_setclock; pthread_condattr_setpshared; pthread_create; pthread_detach; pthread_equal; pthread_exit; pthread_getconcurrency; pthread_getprio; pthread_getschedparam; pthread_getspecific; pthread_join; pthread_key_create; pthread_key_delete; pthread_kill; pthread_main_np; pthread_multi_np; pthread_mutex_destroy; pthread_mutex_getprioceiling; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; pthread_mutex_timedlock; pthread_mutex_trylock; pthread_mutex_unlock; pthread_mutexattr_destroy; pthread_mutexattr_getkind_np; pthread_mutexattr_getprioceiling; pthread_mutexattr_getpshared; pthread_mutexattr_getprotocol; pthread_mutexattr_gettype; pthread_mutexattr_init; pthread_mutexattr_setkind_np; pthread_mutexattr_setprioceiling; pthread_mutexattr_setprotocol; pthread_mutexattr_setpshared; pthread_mutexattr_settype; pthread_once; pthread_resume_all_np; pthread_resume_np; pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock; pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock; pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock; pthread_rwlock_unlock; pthread_rwlock_wrlock; pthread_rwlockattr_destroy; pthread_rwlockattr_getpshared; pthread_rwlockattr_init; pthread_rwlockattr_setpshared; pthread_set_name_np; pthread_self; pthread_setcancelstate; pthread_setcanceltype; pthread_setconcurrency; pthread_setprio; pthread_setschedparam; pthread_setspecific; pthread_sigmask; pthread_single_np; pthread_spin_destroy; pthread_spin_init; pthread_spin_lock; pthread_spin_trylock; pthread_spin_unlock; pthread_suspend_all_np; pthread_suspend_np; pthread_switch_add_np; pthread_switch_delete_np; pthread_testcancel; pthread_timedjoin_np; pthread_yield; }; /* * List the private interfaces reserved for use in FreeBSD libraries. * These are not part of our application ABI. */ FBSDprivate_1.0 { __pthread_cond_timedwait; __pthread_cond_wait; __pthread_cxa_finalize; __pthread_mutex_init; __pthread_mutex_lock; __pthread_mutex_timedlock; __pthread_mutex_trylock; __pthread_distribute_static_tls; _pthread_atfork; _pthread_barrier_destroy; _pthread_barrier_init; _pthread_barrier_wait; _pthread_barrierattr_destroy; _pthread_barrierattr_getpshared; _pthread_barrierattr_init; _pthread_barrierattr_setpshared; _pthread_attr_destroy; _pthread_attr_get_np; _pthread_attr_getaffinity_np; _pthread_attr_getdetachstate; _pthread_attr_getguardsize; _pthread_attr_getinheritsched; _pthread_attr_getschedparam; _pthread_attr_getschedpolicy; _pthread_attr_getscope; _pthread_attr_getstack; _pthread_attr_getstackaddr; _pthread_attr_getstacksize; _pthread_attr_init; _pthread_attr_setaffinity_np; _pthread_attr_setcreatesuspend_np; _pthread_attr_setdetachstate; _pthread_attr_setguardsize; _pthread_attr_setinheritsched; _pthread_attr_setschedparam; _pthread_attr_setschedpolicy; _pthread_attr_setscope; _pthread_attr_setstack; _pthread_attr_setstackaddr; _pthread_attr_setstacksize; _pthread_cancel; _pthread_cancel_enter; _pthread_cancel_leave; _pthread_cleanup_pop; _pthread_cleanup_push; _pthread_cond_broadcast; _pthread_cond_destroy; _pthread_cond_init; _pthread_cond_signal; _pthread_cond_timedwait; _pthread_cond_wait; _pthread_condattr_destroy; _pthread_condattr_getclock; _pthread_condattr_getpshared; _pthread_condattr_init; _pthread_condattr_setclock; _pthread_condattr_setpshared; _pthread_create; _pthread_detach; _pthread_equal; _pthread_exit; _pthread_getaffinity_np; _pthread_getconcurrency; _pthread_getcpuclockid; _pthread_getprio; _pthread_getschedparam; _pthread_getspecific; _pthread_getthreadid_np; _pthread_join; _pthread_key_create; _pthread_key_delete; _pthread_kill; _pthread_main_np; _pthread_multi_np; _pthread_mutex_destroy; _pthread_mutex_getprioceiling; _pthread_mutex_getspinloops_np; _pthread_mutex_getyieldloops_np; _pthread_mutex_init; _pthread_mutex_init_calloc_cb; _pthread_mutex_isowned_np; _pthread_mutex_lock; _pthread_mutex_setprioceiling; _pthread_mutex_setspinloops_np; _pthread_mutex_setyieldloops_np; _pthread_mutex_timedlock; _pthread_mutex_trylock; _pthread_mutex_unlock; _pthread_mutexattr_destroy; _pthread_mutexattr_getkind_np; _pthread_mutexattr_getprioceiling; _pthread_mutexattr_getprotocol; _pthread_mutexattr_getpshared; _pthread_mutexattr_gettype; _pthread_mutexattr_init; _pthread_mutexattr_setkind_np; _pthread_mutexattr_setprioceiling; _pthread_mutexattr_setprotocol; _pthread_mutexattr_setpshared; _pthread_mutexattr_settype; _pthread_once; _pthread_resume_all_np; _pthread_resume_np; _pthread_rwlock_destroy; _pthread_rwlock_init; _pthread_rwlock_rdlock; _pthread_rwlock_timedrdlock; _pthread_rwlock_timedwrlock; _pthread_rwlock_tryrdlock; _pthread_rwlock_trywrlock; _pthread_rwlock_unlock; _pthread_rwlock_wrlock; _pthread_rwlockattr_destroy; _pthread_rwlockattr_getpshared; _pthread_rwlockattr_init; _pthread_rwlockattr_setpshared; _pthread_self; _pthread_set_name_np; _pthread_setaffinity_np; _pthread_setcancelstate; _pthread_setcanceltype; _pthread_setconcurrency; _pthread_setprio; _pthread_setschedparam; _pthread_setspecific; _pthread_sigmask; _pthread_single_np; _pthread_spin_destroy; _pthread_spin_init; _pthread_spin_lock; _pthread_spin_trylock; _pthread_spin_unlock; _pthread_suspend_all_np; _pthread_suspend_np; _pthread_switch_add_np; _pthread_switch_delete_np; _pthread_testcancel; _pthread_timedjoin_np; _pthread_yield; /* Debugger needs these. */ _libthr_debug; _thread_active_threads; _thread_bp_create; _thread_bp_death; _thread_event_mask; _thread_keytable; _thread_last_event; _thread_list; _thread_max_keys; _thread_off_attr_flags; _thread_off_dtv; _thread_off_event_buf; _thread_off_event_mask; _thread_off_key_allocated; _thread_off_key_destructor; _thread_off_linkmap; _thread_off_next; _thread_off_report_events; _thread_off_state; _thread_off_tcb; _thread_off_tid; _thread_off_tlsindex; _thread_size_key; _thread_state_running; _thread_state_zoombie; /* ABI bug workaround, indicate that pli->rtli_version is valid */ _pli_rtli_version; }; FBSD_1.1 { __pthread_cleanup_pop_imp; __pthread_cleanup_push_imp; pthread_attr_getaffinity_np; pthread_attr_setaffinity_np; pthread_getaffinity_np; pthread_getcpuclockid; pthread_setaffinity_np; pthread_mutex_getspinloops_np; pthread_mutex_getyieldloops_np; pthread_mutex_isowned_np; pthread_mutex_setspinloops_np; pthread_mutex_setyieldloops_np; }; FBSD_1.2 { pthread_getthreadid_np; }; FBSD_1.4 { pthread_mutex_consistent; pthread_mutexattr_getrobust; pthread_mutexattr_setrobust; }; FBSD_1.5 { pthread_get_name_np; }; FBSD_1.6 { pthread_getname_np; pthread_peekjoin_np; pthread_setname_np; }; diff --git a/lib/libthread_db/Symbol.map b/lib/libthread_db/Symbol.map index 4e690f9f22a8..204f885de6b6 100644 --- a/lib/libthread_db/Symbol.map +++ b/lib/libthread_db/Symbol.map @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ FBSD_1.0 { td_init; td_ta_clear_event; td_ta_delete; td_ta_event_addr; td_ta_event_getmsg; td_ta_map_id2thr; td_ta_map_lwp2thr; td_ta_new; td_ta_set_event; td_ta_thr_iter; td_ta_tsd_iter; td_thr_clear_event; td_thr_dbresume; td_thr_dbsuspend; td_thr_event_enable; td_thr_event_getmsg; td_thr_getfpregs; td_thr_getgregs; #if defined(i386) td_thr_getxmmregs; td_thr_setxmmregs; #endif td_thr_set_event; td_thr_setfpregs; td_thr_setgregs; td_thr_sstep; /* FreeBSD extension to GDB<->thread interface */ td_thr_tls_get_addr; td_thr_validate; }; FBSD_1.2 { td_thr_get_info; }; diff --git a/lib/libulog/Symbol.map b/lib/libulog/Symbol.map index 0abc40f6cdcc..d3eaae075d43 100644 --- a/lib/libulog/Symbol.map +++ b/lib/libulog/Symbol.map @@ -1,17 +1,16 @@ /* - * $FreeBSD$ */ FBSD_1.2 { ulog_login; ulog_login_pseudo; ulog_logout; ulog_logout_pseudo; addToUtmp; removeFromUtmp; removeLineFromUtmp; utempter_add_record; utempter_remove_added_record; utempter_remove_record; }; diff --git a/lib/libutil/login_cap.h b/lib/libutil/login_cap.h index ec1421b80661..7312914900a8 100644 --- a/lib/libutil/login_cap.h +++ b/lib/libutil/login_cap.h @@ -1,167 +1,166 @@ /*- * Copyright (c) 1996 by * Sean Eric Fagan * David Nugent * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, is permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice immediately at the beginning of the file, without modification, * 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. This work was done expressly for inclusion into FreeBSD. Other use * is permitted provided this notation is included. * 4. Absolutely no warranty of function or purpose is made by the authors. * 5. Modifications may be freely made to this file providing the above * conditions are met. * * Low-level routines relating to the user capabilities database * * Was login_cap.h,v 1.9 1997/05/07 20:00:01 eivind Exp - * $FreeBSD$ */ #ifndef _LOGIN_CAP_H_ #define _LOGIN_CAP_H_ #define LOGIN_DEFCLASS "default" #define LOGIN_DEFROOTCLASS "root" #define LOGIN_MECLASS "me" #define LOGIN_DEFSTYLE "passwd" #define LOGIN_DEFSERVICE "login" #define LOGIN_DEFUMASK 022 #define LOGIN_DEFPRI 0 #define _PATH_LOGIN_CONF "/etc/login.conf" #define _FILE_LOGIN_CONF ".login_conf" #define _PATH_AUTHPROG "/usr/libexec/login_" #define LOGIN_SETGROUP 0x0001 /* set group */ #define LOGIN_SETLOGIN 0x0002 /* set login (via setlogin) */ #define LOGIN_SETPATH 0x0004 /* set path */ #define LOGIN_SETPRIORITY 0x0008 /* set priority */ #define LOGIN_SETRESOURCES 0x0010 /* set resources (cputime, etc.) */ #define LOGIN_SETUMASK 0x0020 /* set umask, obviously */ #define LOGIN_SETUSER 0x0040 /* set user (via setuid) */ #define LOGIN_SETENV 0x0080 /* set user environment */ #define LOGIN_SETMAC 0x0100 /* set user default MAC label */ #define LOGIN_SETCPUMASK 0x0200 /* set user cpumask */ #define LOGIN_SETLOGINCLASS 0x0400 /* set login class in the kernel */ #define LOGIN_SETALL 0x07ff /* set everything */ #define BI_AUTH "authorize" /* accepted authentication */ #define BI_REJECT "reject" /* rejected authentication */ #define BI_CHALLENG "reject challenge" /* reject with a challenge */ #define BI_SILENT "reject silent" /* reject silently */ #define BI_REMOVE "remove" /* remove file on error */ #define BI_ROOTOKAY "authorize root" /* root authenticated */ #define BI_SECURE "authorize secure" /* okay on non-secure line */ #define BI_SETENV "setenv" /* set environment variable */ #define BI_VALUE "value" /* set local variable */ #define AUTH_OKAY 0x01 /* user authenticated */ #define AUTH_ROOTOKAY 0x02 /* root login okay */ #define AUTH_SECURE 0x04 /* secure login */ #define AUTH_SILENT 0x08 /* silent rejection */ #define AUTH_CHALLENGE 0x10 /* a chellenge was given */ #define AUTH_ALLOW (AUTH_OKAY | AUTH_ROOTOKAY | AUTH_SECURE) typedef struct login_cap { char *lc_class; char *lc_cap; char *lc_style; } login_cap_t; typedef struct login_time { u_short lt_start; /* Start time */ u_short lt_end; /* End time */ #define LTM_NONE 0x00 #define LTM_SUN 0x01 #define LTM_MON 0x02 #define LTM_TUE 0x04 #define LTM_WED 0x08 #define LTM_THU 0x10 #define LTM_FRI 0x20 #define LTM_SAT 0x40 #define LTM_ANY 0x7F #define LTM_WK 0x3E #define LTM_WD 0x41 u_char lt_dow; /* Days of week */ } login_time_t; #define LC_MAXTIMES 64 #include __BEGIN_DECLS struct passwd; void login_close(login_cap_t *); login_cap_t *login_getclassbyname(const char *, const struct passwd *); login_cap_t *login_getclass(const char *); login_cap_t *login_getpwclass(const struct passwd *); login_cap_t *login_getuserclass(const struct passwd *); const char *login_getcapstr(login_cap_t *, const char *, const char *, const char *); const char **login_getcaplist(login_cap_t *, const char *, const char *); const char *login_getstyle(login_cap_t *, const char *, const char *); rlim_t login_getcaptime(login_cap_t *, const char *, rlim_t, rlim_t); rlim_t login_getcapnum(login_cap_t *, const char *, rlim_t, rlim_t); rlim_t login_getcapsize(login_cap_t *, const char *, rlim_t, rlim_t); const char *login_getpath(login_cap_t *, const char *, const char *); int login_getcapbool(login_cap_t *, const char *, int); const char *login_setcryptfmt(login_cap_t *, const char *, const char *); int setclasscontext(const char *, unsigned int); void setclasscpumask(login_cap_t *); int setusercontext(login_cap_t *, const struct passwd *, uid_t, unsigned int); void setclassresources(login_cap_t *); void setclassenvironment(login_cap_t *, const struct passwd *, int); /* Most of these functions are deprecated */ int auth_approve(login_cap_t *, const char *, const char *); int auth_check(const char *, const char *, const char *, const char *, int *); void auth_env(void); char *auth_mkvalue(const char *); int auth_response(const char *, const char *, const char *, const char *, int *, const char *, const char *); void auth_rmfiles(void); int auth_scan(int); int auth_script(const char *, ...); int auth_script_data(const char *, int, const char *, ...); char *auth_valud(const char *); int auth_setopt(const char *, const char *); void auth_clropts(void); void auth_checknologin(login_cap_t *); int auth_cat(const char *); int auth_ttyok(login_cap_t *, const char *); int auth_hostok(login_cap_t *, const char *, char const *); int auth_timeok(login_cap_t *, time_t); struct tm; login_time_t parse_lt(const char *); int in_lt(const login_time_t *, time_t *); int in_ltm(const login_time_t *, struct tm *, time_t *); int in_ltms(const login_time_t *, struct tm *, time_t *); int in_lts(const login_time_t *, time_t *); /* helper functions */ int login_strinlist(const char **, char const *, int); int login_str2inlist(const char **, const char *, const char *, int); login_time_t * login_timelist(login_cap_t *, char const *, int *, login_time_t **); int login_ttyok(login_cap_t *, const char *, const char *, const char *); int login_hostok(login_cap_t *, const char *, const char *, const char *, const char *); __END_DECLS #endif /* _LOGIN_CAP_H_ */ diff --git a/lib/libz/Symbol.map b/lib/libz/Symbol.map index 2cc2c76787ba..7bfe7cceda77 100644 --- a/lib/libz/Symbol.map +++ b/lib/libz/Symbol.map @@ -1,115 +1,114 @@ /* - * $FreeBSD$ */ ZLIB_1.2.12 { crc32_combine_gen; crc32_combine_gen64; crc32_combine_op; }; ZLIB_1.2.9 { inflateCodesUsed; inflateValidate; uncompress2; gzfread; gzfwrite; deflateGetDictionary; adler32_z; crc32_z; }; ZLIB_1.2.7.1 { inflateGetDictionary; gzvprintf; }; ZLIB_1.2.7.0 { deflatePending; deflateResetKeep; gzgetc_; inflateResetKeep; }; ZLIB_1.2.4.0 { adler32; adler32_combine; adler32_combine64; compress; compress2; compressBound; crc32; crc32_combine; crc32_combine64; deflate; deflateBound; deflateCopy; deflateEnd; deflateInit2_; deflateInit_; deflateParams; deflatePrime; deflateReset; deflateSetDictionary; deflateSetHeader; deflateTune; get_crc_table; gzbuffer; gzclearerr; gzclose; gzclose_r; gzclose_w; gzdirect; gzdopen; gzeof; gzerror; gzflush; gzgetc; gzgets; gzoffset; gzoffset64; gzopen; gzopen64; gzprintf; gzputc; gzputs; gzread; gzrewind; gzseek; gzseek64; gzsetparams; gztell; gztell64; gzungetc; gzwrite; inflate; inflateBack; inflateBackEnd; inflateBackInit_; inflateCopy; inflateEnd; inflateGetHeader; inflateInit2_; inflateInit_; inflateMark; inflatePrime; inflateReset; inflateReset2; inflateSetDictionary; inflateSync; inflateSyncPoint; inflateUndermine; uncompress; zError; zlibCompileFlags; zlibVersion; }; FBSD_1.2 { zopen; }; FBSD_1.6 { zdopen; }; diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map index 8650d56eb9d5..6e74918ade6e 100644 --- a/lib/msun/Symbol.map +++ b/lib/msun/Symbol.map @@ -1,320 +1,319 @@ /* - * $FreeBSD$ */ /* 7.0-CURRENT */ FBSD_1.0 { __fe_dfl_env; tgamma; acos; acosf; acosh; acoshf; asin; asinf; atan2; atan2f; atanh; atanhf; cosh; coshf; exp; expf; fmod; fmodf; gamma; gamma_r; gammaf; gammaf_r; hypot; hypotf; j0; y0; j0f; y0f; j1; y1; j1f; y1f; jn; yn; jnf; ynf; lgamma; lgamma_r; lgammaf; lgammaf_r; log; log10; log10f; logf; pow; powf; remainder; remainderf; scalb; scalbf; sinh; sinhf; sqrt; sqrtf; asinh; asinhf; atan; atanf; cbrt; cbrtf; ceil; ceilf; ceill; cimag; cimagf; cimagl; conj; conjf; conjl; copysign; copysignf; copysignl; cos; cosf; creal; crealf; creall; erf; erfc; erff; erfcf; exp2; exp2f; expm1; expm1f; fabs; fabsf; fabsl; fdim; fdimf; fdiml; finite; finitef; floor; floorf; floorl; fma; fmaf; fmal; fmax; fmaxf; fmaxl; fmin; fminf; fminl; frexp; frexpf; frexpl; ilogb; ilogbf; ilogbl; __isfinite; __isfinitef; __isfinitel; isnanf; __isnanl; __isnormal; __isnormalf; __isnormall; llrint; llrintf; llround; llroundf; llroundl; log1p; log1pf; logb; logbf; lrint; lrintf; lround; lroundf; lroundl; modff; modfl; nearbyint; nearbyintf; nextafter; nexttoward; nexttowardl; nextafterl; nextafterf; nexttowardf; remquo; remquof; rint; rintf; round; roundf; roundl; scalbln; scalblnf; scalblnl; scalbn; scalbnl; scalbnf; ldexpf; ldexpl; __signbit; __signbitf; __signbitl; signgam; significand; significandf; sin; sinf; tan; tanf; tanh; tanhf; trunc; truncf; truncl; cabs; cabsf; drem; dremf; }; /* First added in 8.0-CURRENT */ FBSD_1.1 { carg; cargf; csqrt; csqrtf; logbl; nan; nanf; nanl; llrintl; lrintl; nearbyintl; rintl; exp2l; sinl; cosl; tanl; tgammaf; sqrtl; hypotl; cabsl; csqrtl; remquol; remainderl; fmodl; acosl; asinl; atan2l; atanl; cargl; cproj; cprojf; cprojl; }; /* First added in 9.0-CURRENT */ FBSD_1.2 { __isnanf; cbrtl; cexp; cexpf; log2; log2f; }; /* First added in 10.0-CURRENT */ FBSD_1.3 { feclearexcept; fegetexceptflag; fetestexcept; fegetround; fesetround; fesetenv; acoshl; asinhl; atanhl; cacos; cacosf; cacosh; cacoshf; casin; casinf; casinh; casinhf; catan; catanf; catanh; catanhf; csin; csinf; csinh; csinhf; ccos; ccosf; ccosh; ccoshf; coshl; ctan; ctanf; ctanh; ctanhf; erfcl; erfl; expl; expm1l; lgammal; log10l; log1pl; log2l; logl; powl; sinhl; tanhl; /* Implemented as weak aliases for imprecise versions */ tgammal; }; /* First added in 11.0-CURRENT */ FBSD_1.4 { lgammal_r; }; /* First added in 12.0-CURRENT */ FBSD_1.5 { cacoshl; cacosl; casinhl; casinl; catanl; catanhl; clog; clogf; clogl; cpow; cpowf; cpowl; sincos; sincosf; sincosl; }; /* First added in 14.0-CURRENT */ FBSD_1.7 { cexpl; cospi; cospif; cospil; sinpi; sinpif; sinpil; tanpi; tanpif; tanpil; }; diff --git a/lib/msun/amd64/Symbol.map b/lib/msun/amd64/Symbol.map index 3da32ffcc990..ed2f1d2119b8 100644 --- a/lib/msun/amd64/Symbol.map +++ b/lib/msun/amd64/Symbol.map @@ -1,12 +1,11 @@ /* - * $FreeBSD$ */ FBSD_1.0 { fesetexceptflag; feraiseexcept; fegetenv; feholdexcept; feupdateenv; feenableexcept; fedisableexcept; }; diff --git a/lib/msun/arm/Symbol.map b/lib/msun/arm/Symbol.map index 40fbc549560b..2bc6215688bb 100644 --- a/lib/msun/arm/Symbol.map +++ b/lib/msun/arm/Symbol.map @@ -1,16 +1,15 @@ /* - * $FreeBSD$ */ FBSD_1.0 { }; FBSD_1.3 { fesetexceptflag; feraiseexcept; fegetenv; feholdexcept; feupdateenv; feenableexcept; fedisableexcept; fegetexcept; }; diff --git a/lib/msun/bsdsrc/mathimpl.h b/lib/msun/bsdsrc/mathimpl.h index abf299658615..3d6554747dac 100644 --- a/lib/msun/bsdsrc/mathimpl.h +++ b/lib/msun/bsdsrc/mathimpl.h @@ -1,76 +1,75 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #ifndef _MATHIMPL_H_ #define _MATHIMPL_H_ #include #include #include "../src/math_private.h" /* * TRUNC() is a macro that sets the trailing 27 bits in the mantissa of an * IEEE double variable to zero. It must be expression-like for syntactic * reasons, and we implement this expression using an inline function * instead of a pure macro to avoid depending on the gcc feature of * statement-expressions. */ #define TRUNC(d) (_b_trunc(&(d))) static __inline void _b_trunc(volatile double *_dp) { uint32_t _lw; GET_LOW_WORD(_lw, *_dp); SET_LOW_WORD(*_dp, _lw & 0xf8000000); } struct Double { double a; double b; }; /* * Functions internal to the math package, yet not static. */ double __exp__D(double, double); struct Double __log__D(double); #endif /* !_MATHIMPL_H_ */ diff --git a/lib/msun/i387/Symbol.map b/lib/msun/i387/Symbol.map index 35e6e18d0259..f22361cc34d7 100644 --- a/lib/msun/i387/Symbol.map +++ b/lib/msun/i387/Symbol.map @@ -1,14 +1,13 @@ /* - * $FreeBSD$ */ FBSD_1.0 { __has_sse; __test_sse; fesetexceptflag; feraiseexcept; fegetenv; feholdexcept; feupdateenv; feenableexcept; fedisableexcept; }; diff --git a/lib/msun/powerpc/Symbol.map b/lib/msun/powerpc/Symbol.map index 47eca6f99f31..9e3c5d47180c 100644 --- a/lib/msun/powerpc/Symbol.map +++ b/lib/msun/powerpc/Symbol.map @@ -1,18 +1,17 @@ /* - * $FreeBSD$ */ FBSD_1.0 { }; FBSD_1.3 { fesetexceptflag; feraiseexcept; fegetenv; feholdexcept; feupdateenv; }; FBSD_1.7 { feenableexcept; fedisableexcept; }; diff --git a/lib/msun/riscv/Symbol.map b/lib/msun/riscv/Symbol.map index 40fbc549560b..2bc6215688bb 100644 --- a/lib/msun/riscv/Symbol.map +++ b/lib/msun/riscv/Symbol.map @@ -1,16 +1,15 @@ /* - * $FreeBSD$ */ FBSD_1.0 { }; FBSD_1.3 { fesetexceptflag; feraiseexcept; fegetenv; feholdexcept; feupdateenv; feenableexcept; fedisableexcept; fegetexcept; }; diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h index a0edea04dde2..8e72beb757f8 100644 --- a/lib/msun/src/math.h +++ b/lib/msun/src/math.h @@ -1,515 +1,514 @@ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* * from: @(#)fdlibm.h 5.1 93/09/24 - * $FreeBSD$ */ #ifndef _MATH_H_ #define _MATH_H_ #include #include #include /* * ANSI/POSIX */ extern const union __infinity_un { unsigned char __uc[8]; double __ud; } __infinity; extern const union __nan_un { unsigned char __uc[sizeof(float)]; float __uf; } __nan; #if __GNUC_PREREQ__(3, 3) #define __MATH_BUILTIN_CONSTANTS #endif #if __GNUC_PREREQ__(3, 0) #define __MATH_BUILTIN_RELOPS #endif #ifdef __MATH_BUILTIN_CONSTANTS #define HUGE_VAL __builtin_huge_val() #else #define HUGE_VAL (__infinity.__ud) #endif #if __ISO_C_VISIBLE >= 1999 #define FP_ILOGB0 (-__INT_MAX) #define FP_ILOGBNAN __INT_MAX #ifdef __MATH_BUILTIN_CONSTANTS #define HUGE_VALF __builtin_huge_valf() #define HUGE_VALL __builtin_huge_vall() #define INFINITY __builtin_inff() #define NAN __builtin_nanf("") #else #define HUGE_VALF (float)HUGE_VAL #define HUGE_VALL (long double)HUGE_VAL #define INFINITY HUGE_VALF #define NAN (__nan.__uf) #endif /* __MATH_BUILTIN_CONSTANTS */ #define MATH_ERRNO 1 #define MATH_ERREXCEPT 2 #define math_errhandling MATH_ERREXCEPT #define FP_FAST_FMAF 1 /* Symbolic constants to classify floating point numbers. */ #define FP_INFINITE 0x01 #define FP_NAN 0x02 #define FP_NORMAL 0x04 #define FP_SUBNORMAL 0x08 #define FP_ZERO 0x10 #if __STDC_VERSION__ >= 201112L || __has_extension(c_generic_selections) #define __fp_type_select(x, f, d, ld) __extension__ _Generic((x), \ float: f(x), \ double: d(x), \ long double: ld(x)) #elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) #define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof(x), long double), ld(x), \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof(x), double), d(x), \ __builtin_choose_expr( \ __builtin_types_compatible_p(__typeof(x), float), f(x), (void)0))) #else #define __fp_type_select(x, f, d, ld) \ ((sizeof(x) == sizeof(float)) ? f(x) \ : (sizeof(x) == sizeof(double)) ? d(x) \ : ld(x)) #endif #define fpclassify(x) \ __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyl) #define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel) #define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl) #define isnan(x) \ __fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl) #define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall) #ifdef __MATH_BUILTIN_RELOPS #define isgreater(x, y) __builtin_isgreater((x), (y)) #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y)) #define isless(x, y) __builtin_isless((x), (y)) #define islessequal(x, y) __builtin_islessequal((x), (y)) #define islessgreater(x, y) __builtin_islessgreater((x), (y)) #define isunordered(x, y) __builtin_isunordered((x), (y)) #else #define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y)) #define isgreaterequal(x, y) (!isunordered((x), (y)) && (x) >= (y)) #define isless(x, y) (!isunordered((x), (y)) && (x) < (y)) #define islessequal(x, y) (!isunordered((x), (y)) && (x) <= (y)) #define islessgreater(x, y) (!isunordered((x), (y)) && \ ((x) > (y) || (y) > (x))) #define isunordered(x, y) (isnan(x) || isnan(y)) #endif /* __MATH_BUILTIN_RELOPS */ #define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl) typedef __double_t double_t; typedef __float_t float_t; #endif /* __ISO_C_VISIBLE >= 1999 */ /* * XOPEN/SVID */ #if __BSD_VISIBLE || __XSI_VISIBLE #define M_E 2.7182818284590452354 /* e */ #define M_LOG2E 1.4426950408889634074 /* log 2e */ #define M_LOG10E 0.43429448190325182765 /* log 10e */ #define M_LN2 0.69314718055994530942 /* log e2 */ #define M_LN10 2.30258509299404568402 /* log e10 */ #define M_PI 3.14159265358979323846 /* pi */ #define M_PI_2 1.57079632679489661923 /* pi/2 */ #define M_PI_4 0.78539816339744830962 /* pi/4 */ #define M_1_PI 0.31830988618379067154 /* 1/pi */ #define M_2_PI 0.63661977236758134308 /* 2/pi */ #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #define MAXFLOAT ((float)3.40282346638528860e+38) extern int signgam; #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ #if __BSD_VISIBLE #if 0 /* Old value from 4.4BSD-Lite math.h; this is probably better. */ #define HUGE HUGE_VAL #else #define HUGE MAXFLOAT #endif #endif /* __BSD_VISIBLE */ /* * Most of these functions depend on the rounding mode and have the side * effect of raising floating-point exceptions, so they are not declared * as __pure2. In C99, FENV_ACCESS affects the purity of these functions. */ __BEGIN_DECLS /* * ANSI/POSIX */ int __fpclassifyd(double) __pure2; int __fpclassifyf(float) __pure2; int __fpclassifyl(long double) __pure2; int __isfinitef(float) __pure2; int __isfinite(double) __pure2; int __isfinitel(long double) __pure2; int __isinff(float) __pure2; int __isinf(double) __pure2; int __isinfl(long double) __pure2; int __isnormalf(float) __pure2; int __isnormal(double) __pure2; int __isnormall(long double) __pure2; int __signbit(double) __pure2; int __signbitf(float) __pure2; int __signbitl(long double) __pure2; static __inline int __inline_isnan(__const double __x) { return (__x != __x); } static __inline int __inline_isnanf(__const float __x) { return (__x != __x); } static __inline int __inline_isnanl(__const long double __x) { return (__x != __x); } /* * Define the following aliases, for compatibility with glibc and CUDA. */ #define __isnan __inline_isnan #define __isnanf __inline_isnanf /* * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and * isinf() as functions taking double. C99, and the subsequent POSIX revisions * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating * point type. If we are targeting SUSv2 and C99 or C11 (or C++11) then we * expose the newer definition, assuming that the language spec takes * precedence over the operating system interface spec. */ #if __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 && __ISO_C_VISIBLE < 1999 #undef isinf #undef isnan int isinf(double); int isnan(double); #endif double acos(double); double asin(double); double atan(double); double atan2(double, double); double cos(double); double sin(double); double tan(double); double cosh(double); double sinh(double); double tanh(double); double exp(double); double frexp(double, int *); /* fundamentally !__pure2 */ double ldexp(double, int); double log(double); double log10(double); double modf(double, double *); /* fundamentally !__pure2 */ double pow(double, double); double sqrt(double); double ceil(double); double fabs(double) __pure2; double floor(double); double fmod(double, double); /* * These functions are not in C90. */ #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE double acosh(double); double asinh(double); double atanh(double); double cbrt(double); double erf(double); double erfc(double); double exp2(double); double expm1(double); double fma(double, double, double); double hypot(double, double); int ilogb(double) __pure2; double lgamma(double); long long llrint(double); long long llround(double); double log1p(double); double log2(double); double logb(double); long lrint(double); long lround(double); double nan(const char *) __pure2; double nextafter(double, double); double remainder(double, double); double remquo(double, double, int *); double rint(double); #endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE */ #if __BSD_VISIBLE || __XSI_VISIBLE double j0(double); double j1(double); double jn(int, double); double y0(double); double y1(double); double yn(int, double); #if __XSI_VISIBLE <= 500 || __BSD_VISIBLE double gamma(double); #endif #if __XSI_VISIBLE <= 600 || __BSD_VISIBLE double scalb(double, double); #endif #endif /* __BSD_VISIBLE || __XSI_VISIBLE */ #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 double copysign(double, double) __pure2; double fdim(double, double); double fmax(double, double) __pure2; double fmin(double, double) __pure2; double nearbyint(double); double round(double); double scalbln(double, long); double scalbn(double, int); double tgamma(double); double trunc(double); #endif /* * BSD math library entry points */ #if __BSD_VISIBLE double drem(double, double); int finite(double) __pure2; int isnanf(float) __pure2; /* * Reentrant version of gamma & lgamma; passes signgam back by reference * as the second argument; user must allocate space for signgam. */ double gamma_r(double, int *); double lgamma_r(double, int *); /* * IEEE Test Vector */ double significand(double); #endif /* __BSD_VISIBLE */ /* float versions of ANSI/POSIX functions */ #if __ISO_C_VISIBLE >= 1999 float acosf(float); float asinf(float); float atanf(float); float atan2f(float, float); float cosf(float); float sinf(float); float tanf(float); float coshf(float); float sinhf(float); float tanhf(float); float exp2f(float); float expf(float); float expm1f(float); float frexpf(float, int *); /* fundamentally !__pure2 */ int ilogbf(float) __pure2; float ldexpf(float, int); float log10f(float); float log1pf(float); float log2f(float); float logf(float); float modff(float, float *); /* fundamentally !__pure2 */ float powf(float, float); float sqrtf(float); float ceilf(float); float fabsf(float) __pure2; float floorf(float); float fmodf(float, float); float roundf(float); float erff(float); float erfcf(float); float hypotf(float, float); float lgammaf(float); float tgammaf(float); float acoshf(float); float asinhf(float); float atanhf(float); float cbrtf(float); float logbf(float); float copysignf(float, float) __pure2; long long llrintf(float); long long llroundf(float); long lrintf(float); long lroundf(float); float nanf(const char *) __pure2; float nearbyintf(float); float nextafterf(float, float); float remainderf(float, float); float remquof(float, float, int *); float rintf(float); float scalblnf(float, long); float scalbnf(float, int); float truncf(float); float fdimf(float, float); float fmaf(float, float, float); float fmaxf(float, float) __pure2; float fminf(float, float) __pure2; #endif /* * float versions of BSD math library entry points */ #if __BSD_VISIBLE float dremf(float, float); int finitef(float) __pure2; float gammaf(float); float j0f(float); float j1f(float); float jnf(int, float); float scalbf(float, float); float y0f(float); float y1f(float); float ynf(int, float); /* * Float versions of reentrant version of gamma & lgamma; passes * signgam back by reference as the second argument; user must * allocate space for signgam. */ float gammaf_r(float, int *); float lgammaf_r(float, int *); /* * float version of IEEE Test Vector */ float significandf(float); #endif /* __BSD_VISIBLE */ /* * long double versions of ISO/POSIX math functions */ #if __ISO_C_VISIBLE >= 1999 long double acoshl(long double); long double acosl(long double); long double asinhl(long double); long double asinl(long double); long double atan2l(long double, long double); long double atanhl(long double); long double atanl(long double); long double cbrtl(long double); long double ceill(long double); long double copysignl(long double, long double) __pure2; long double coshl(long double); long double cosl(long double); long double erfcl(long double); long double erfl(long double); long double exp2l(long double); long double expl(long double); long double expm1l(long double); long double fabsl(long double) __pure2; long double fdiml(long double, long double); long double floorl(long double); long double fmal(long double, long double, long double); long double fmaxl(long double, long double) __pure2; long double fminl(long double, long double) __pure2; long double fmodl(long double, long double); long double frexpl(long double, int *); /* fundamentally !__pure2 */ long double hypotl(long double, long double); int ilogbl(long double) __pure2; long double ldexpl(long double, int); long double lgammal(long double); long long llrintl(long double); long long llroundl(long double); long double log10l(long double); long double log1pl(long double); long double log2l(long double); long double logbl(long double); long double logl(long double); long lrintl(long double); long lroundl(long double); long double modfl(long double, long double *); /* fundamentally !__pure2 */ long double nanl(const char *) __pure2; long double nearbyintl(long double); long double nextafterl(long double, long double); double nexttoward(double, long double); float nexttowardf(float, long double); long double nexttowardl(long double, long double); long double powl(long double, long double); long double remainderl(long double, long double); long double remquol(long double, long double, int *); long double rintl(long double); long double roundl(long double); long double scalblnl(long double, long); long double scalbnl(long double, int); long double sinhl(long double); long double sinl(long double); long double sqrtl(long double); long double tanhl(long double); long double tanl(long double); long double tgammal(long double); long double truncl(long double); #endif /* __ISO_C_VISIBLE >= 1999 */ #if __BSD_VISIBLE long double lgammal_r(long double, int *); void sincos(double, double *, double *); void sincosf(float, float *, float *); void sincosl(long double, long double *, long double *); double cospi(double); float cospif(float); long double cospil(long double); double sinpi(double); float sinpif(float); long double sinpil(long double); double tanpi(double); float tanpif(float); long double tanpil(long double); #endif __END_DECLS #endif /* !_MATH_H_ */ diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h index a55d97a780d7..eae2a2a317b4 100644 --- a/lib/msun/src/math_private.h +++ b/lib/msun/src/math_private.h @@ -1,811 +1,810 @@ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* * from: @(#)fdlibm.h 5.1 93/09/24 - * $FreeBSD$ */ #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ #include #include /* * The original fdlibm code used statements like: * n0 = ((*(int*)&one)>>29)^1; * index of high word * * ix0 = *(n0+(int*)&x); * high word of x * * ix1 = *((1-n0)+(int*)&x); * low word of x * * to dig two 32 bit words out of the 64 bit IEEE floating point * value. That is non-ANSI, and, moreover, the gcc instruction * scheduler gets it wrong. We instead use the following macros. * Unlike the original code, we determine the endianness at compile * time, not at run time; I don't see much benefit to selecting * endianness at run time. */ /* * A union which permits us to convert between a double and two 32 bit * ints. */ #ifdef __arm__ #if defined(__VFP_FP__) || defined(__ARM_EABI__) #define IEEE_WORD_ORDER BYTE_ORDER #else #define IEEE_WORD_ORDER BIG_ENDIAN #endif #else /* __arm__ */ #define IEEE_WORD_ORDER BYTE_ORDER #endif /* A union which permits us to convert between a long double and four 32 bit ints. */ #if IEEE_WORD_ORDER == BIG_ENDIAN typedef union { long double value; struct { u_int32_t mswhi; u_int32_t mswlo; u_int32_t lswhi; u_int32_t lswlo; } parts32; struct { u_int64_t msw; u_int64_t lsw; } parts64; } ieee_quad_shape_type; #endif #if IEEE_WORD_ORDER == LITTLE_ENDIAN typedef union { long double value; struct { u_int32_t lswlo; u_int32_t lswhi; u_int32_t mswlo; u_int32_t mswhi; } parts32; struct { u_int64_t lsw; u_int64_t msw; } parts64; } ieee_quad_shape_type; #endif #if IEEE_WORD_ORDER == BIG_ENDIAN typedef union { double value; struct { u_int32_t msw; u_int32_t lsw; } parts; struct { u_int64_t w; } xparts; } ieee_double_shape_type; #endif #if IEEE_WORD_ORDER == LITTLE_ENDIAN typedef union { double value; struct { u_int32_t lsw; u_int32_t msw; } parts; struct { u_int64_t w; } xparts; } ieee_double_shape_type; #endif /* Get two 32 bit ints from a double. */ #define EXTRACT_WORDS(ix0,ix1,d) \ do { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix0) = ew_u.parts.msw; \ (ix1) = ew_u.parts.lsw; \ } while (0) /* Get a 64-bit int from a double. */ #define EXTRACT_WORD64(ix,d) \ do { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix) = ew_u.xparts.w; \ } while (0) /* Get the more significant 32 bit int from a double. */ #define GET_HIGH_WORD(i,d) \ do { \ ieee_double_shape_type gh_u; \ gh_u.value = (d); \ (i) = gh_u.parts.msw; \ } while (0) /* Get the less significant 32 bit int from a double. */ #define GET_LOW_WORD(i,d) \ do { \ ieee_double_shape_type gl_u; \ gl_u.value = (d); \ (i) = gl_u.parts.lsw; \ } while (0) /* Set a double from two 32 bit ints. */ #define INSERT_WORDS(d,ix0,ix1) \ do { \ ieee_double_shape_type iw_u; \ iw_u.parts.msw = (ix0); \ iw_u.parts.lsw = (ix1); \ (d) = iw_u.value; \ } while (0) /* Set a double from a 64-bit int. */ #define INSERT_WORD64(d,ix) \ do { \ ieee_double_shape_type iw_u; \ iw_u.xparts.w = (ix); \ (d) = iw_u.value; \ } while (0) /* Set the more significant 32 bits of a double from an int. */ #define SET_HIGH_WORD(d,v) \ do { \ ieee_double_shape_type sh_u; \ sh_u.value = (d); \ sh_u.parts.msw = (v); \ (d) = sh_u.value; \ } while (0) /* Set the less significant 32 bits of a double from an int. */ #define SET_LOW_WORD(d,v) \ do { \ ieee_double_shape_type sl_u; \ sl_u.value = (d); \ sl_u.parts.lsw = (v); \ (d) = sl_u.value; \ } while (0) /* * A union which permits us to convert between a float and a 32 bit * int. */ typedef union { float value; /* FIXME: Assumes 32 bit int. */ unsigned int word; } ieee_float_shape_type; /* Get a 32 bit int from a float. */ #define GET_FLOAT_WORD(i,d) \ do { \ ieee_float_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) /* Set a float from a 32 bit int. */ #define SET_FLOAT_WORD(d,i) \ do { \ ieee_float_shape_type sf_u; \ sf_u.word = (i); \ (d) = sf_u.value; \ } while (0) /* * Get expsign and mantissa as 16 bit and 64 bit ints from an 80 bit long * double. */ #define EXTRACT_LDBL80_WORDS(ix0,ix1,d) \ do { \ union IEEEl2bits ew_u; \ ew_u.e = (d); \ (ix0) = ew_u.xbits.expsign; \ (ix1) = ew_u.xbits.man; \ } while (0) /* * Get expsign and mantissa as one 16 bit and two 64 bit ints from a 128 bit * long double. */ #define EXTRACT_LDBL128_WORDS(ix0,ix1,ix2,d) \ do { \ union IEEEl2bits ew_u; \ ew_u.e = (d); \ (ix0) = ew_u.xbits.expsign; \ (ix1) = ew_u.xbits.manh; \ (ix2) = ew_u.xbits.manl; \ } while (0) /* Get expsign as a 16 bit int from a long double. */ #define GET_LDBL_EXPSIGN(i,d) \ do { \ union IEEEl2bits ge_u; \ ge_u.e = (d); \ (i) = ge_u.xbits.expsign; \ } while (0) /* * Set an 80 bit long double from a 16 bit int expsign and a 64 bit int * mantissa. */ #define INSERT_LDBL80_WORDS(d,ix0,ix1) \ do { \ union IEEEl2bits iw_u; \ iw_u.xbits.expsign = (ix0); \ iw_u.xbits.man = (ix1); \ (d) = iw_u.e; \ } while (0) /* * Set a 128 bit long double from a 16 bit int expsign and two 64 bit ints * comprising the mantissa. */ #define INSERT_LDBL128_WORDS(d,ix0,ix1,ix2) \ do { \ union IEEEl2bits iw_u; \ iw_u.xbits.expsign = (ix0); \ iw_u.xbits.manh = (ix1); \ iw_u.xbits.manl = (ix2); \ (d) = iw_u.e; \ } while (0) /* Set expsign of a long double from a 16 bit int. */ #define SET_LDBL_EXPSIGN(d,v) \ do { \ union IEEEl2bits se_u; \ se_u.e = (d); \ se_u.xbits.expsign = (v); \ (d) = se_u.e; \ } while (0) #ifdef __i386__ /* Long double constants are broken on i386. */ #define LD80C(m, ex, v) { \ .xbits.man = __CONCAT(m, ULL), \ .xbits.expsign = (0x3fff + (ex)) | ((v) < 0 ? 0x8000 : 0), \ } #else /* The above works on non-i386 too, but we use this to check v. */ #define LD80C(m, ex, v) { .e = (v), } #endif #ifdef FLT_EVAL_METHOD /* * Attempt to get strict C99 semantics for assignment with non-C99 compilers. */ #if FLT_EVAL_METHOD == 0 || __GNUC__ == 0 #define STRICT_ASSIGN(type, lval, rval) ((lval) = (rval)) #else #define STRICT_ASSIGN(type, lval, rval) do { \ volatile type __lval; \ \ if (sizeof(type) >= sizeof(long double)) \ (lval) = (rval); \ else { \ __lval = (rval); \ (lval) = __lval; \ } \ } while (0) #endif #endif /* FLT_EVAL_METHOD */ /* Support switching the mode to FP_PE if necessary. */ #if defined(__i386__) && !defined(NO_FPSETPREC) #define ENTERI() ENTERIT(long double) #define ENTERIT(returntype) \ returntype __retval; \ fp_prec_t __oprec; \ \ if ((__oprec = fpgetprec()) != FP_PE) \ fpsetprec(FP_PE) #define RETURNI(x) do { \ __retval = (x); \ if (__oprec != FP_PE) \ fpsetprec(__oprec); \ RETURNF(__retval); \ } while (0) #define ENTERV() \ fp_prec_t __oprec; \ \ if ((__oprec = fpgetprec()) != FP_PE) \ fpsetprec(FP_PE) #define RETURNV() do { \ if (__oprec != FP_PE) \ fpsetprec(__oprec); \ return; \ } while (0) #else #define ENTERI() #define ENTERIT(x) #define RETURNI(x) RETURNF(x) #define ENTERV() #define RETURNV() return #endif /* Default return statement if hack*_t() is not used. */ #define RETURNF(v) return (v) /* * 2sum gives the same result as 2sumF without requiring |a| >= |b| or * a == 0, but is slower. */ #define _2sum(a, b) do { \ __typeof(a) __s, __w; \ \ __w = (a) + (b); \ __s = __w - (a); \ (b) = ((a) - (__w - __s)) + ((b) - __s); \ (a) = __w; \ } while (0) /* * 2sumF algorithm. * * "Normalize" the terms in the infinite-precision expression a + b for * the sum of 2 floating point values so that b is as small as possible * relative to 'a'. (The resulting 'a' is the value of the expression in * the same precision as 'a' and the resulting b is the rounding error.) * |a| must be >= |b| or 0, b's type must be no larger than 'a's type, and * exponent overflow or underflow must not occur. This uses a Theorem of * Dekker (1971). See Knuth (1981) 4.2.2 Theorem C. The name "TwoSum" * is apparently due to Skewchuk (1997). * * For this to always work, assignment of a + b to 'a' must not retain any * extra precision in a + b. This is required by C standards but broken * in many compilers. The brokenness cannot be worked around using * STRICT_ASSIGN() like we do elsewhere, since the efficiency of this * algorithm would be destroyed by non-null strict assignments. (The * compilers are correct to be broken -- the efficiency of all floating * point code calculations would be destroyed similarly if they forced the * conversions.) * * Fortunately, a case that works well can usually be arranged by building * any extra precision into the type of 'a' -- 'a' should have type float_t, * double_t or long double. b's type should be no larger than 'a's type. * Callers should use these types with scopes as large as possible, to * reduce their own extra-precision and efficiciency problems. In * particular, they shouldn't convert back and forth just to call here. */ #ifdef DEBUG #define _2sumF(a, b) do { \ __typeof(a) __w; \ volatile __typeof(a) __ia, __ib, __r, __vw; \ \ __ia = (a); \ __ib = (b); \ assert(__ia == 0 || fabsl(__ia) >= fabsl(__ib)); \ \ __w = (a) + (b); \ (b) = ((a) - __w) + (b); \ (a) = __w; \ \ /* The next 2 assertions are weak if (a) is already long double. */ \ assert((long double)__ia + __ib == (long double)(a) + (b)); \ __vw = __ia + __ib; \ __r = __ia - __vw; \ __r += __ib; \ assert(__vw == (a) && __r == (b)); \ } while (0) #else /* !DEBUG */ #define _2sumF(a, b) do { \ __typeof(a) __w; \ \ __w = (a) + (b); \ (b) = ((a) - __w) + (b); \ (a) = __w; \ } while (0) #endif /* DEBUG */ /* * Set x += c, where x is represented in extra precision as a + b. * x must be sufficiently normalized and sufficiently larger than c, * and the result is then sufficiently normalized. * * The details of ordering are that |a| must be >= |c| (so that (a, c) * can be normalized without extra work to swap 'a' with c). The details of * the normalization are that b must be small relative to the normalized 'a'. * Normalization of (a, c) makes the normalized c tiny relative to the * normalized a, so b remains small relative to 'a' in the result. However, * b need not ever be tiny relative to 'a'. For example, b might be about * 2**20 times smaller than 'a' to give about 20 extra bits of precision. * That is usually enough, and adding c (which by normalization is about * 2**53 times smaller than a) cannot change b significantly. However, * cancellation of 'a' with c in normalization of (a, c) may reduce 'a' * significantly relative to b. The caller must ensure that significant * cancellation doesn't occur, either by having c of the same sign as 'a', * or by having |c| a few percent smaller than |a|. Pre-normalization of * (a, b) may help. * * This is a variant of an algorithm of Kahan (see Knuth (1981) 4.2.2 * exercise 19). We gain considerable efficiency by requiring the terms to * be sufficiently normalized and sufficiently increasing. */ #define _3sumF(a, b, c) do { \ __typeof(a) __tmp; \ \ __tmp = (c); \ _2sumF(__tmp, (a)); \ (b) += (a); \ (a) = __tmp; \ } while (0) /* * Common routine to process the arguments to nan(), nanf(), and nanl(). */ void _scan_nan(uint32_t *__words, int __num_words, const char *__s); /* * Mix 0, 1 or 2 NaNs. First add 0 to each arg. This normally just turns * signaling NaNs into quiet NaNs by setting a quiet bit. We do this * because we want to never return a signaling NaN, and also because we * don't want the quiet bit to affect the result. Then mix the converted * args using the specified operation. * * When one arg is NaN, the result is typically that arg quieted. When both * args are NaNs, the result is typically the quietening of the arg whose * mantissa is largest after quietening. When neither arg is NaN, the * result may be NaN because it is indeterminate, or finite for subsequent * construction of a NaN as the indeterminate 0.0L/0.0L. * * Technical complications: the result in bits after rounding to the final * precision might depend on the runtime precision and/or on compiler * optimizations, especially when different register sets are used for * different precisions. Try to make the result not depend on at least the * runtime precision by always doing the main mixing step in long double * precision. Try to reduce dependencies on optimizations by adding the * the 0's in different precisions (unless everything is in long double * precision). */ #define nan_mix(x, y) (nan_mix_op((x), (y), +)) #define nan_mix_op(x, y, op) (((x) + 0.0L) op ((y) + 0)) #ifdef _COMPLEX_H /* * C99 specifies that complex numbers have the same representation as * an array of two elements, where the first element is the real part * and the second element is the imaginary part. */ typedef union { float complex f; float a[2]; } float_complex; typedef union { double complex f; double a[2]; } double_complex; typedef union { long double complex f; long double a[2]; } long_double_complex; #define REALPART(z) ((z).a[0]) #define IMAGPART(z) ((z).a[1]) /* * Inline functions that can be used to construct complex values. * * The C99 standard intends x+I*y to be used for this, but x+I*y is * currently unusable in general since gcc introduces many overflow, * underflow, sign and efficiency bugs by rewriting I*y as * (0.0+I)*(y+0.0*I) and laboriously computing the full complex product. * In particular, I*Inf is corrupted to NaN+I*Inf, and I*-0 is corrupted * to -0.0+I*0.0. * * The C11 standard introduced the macros CMPLX(), CMPLXF() and CMPLXL() * to construct complex values. Compilers that conform to the C99 * standard require the following functions to avoid the above issues. */ #ifndef CMPLXF static __inline float complex CMPLXF(float x, float y) { float_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #ifndef CMPLX static __inline double complex CMPLX(double x, double y) { double_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #ifndef CMPLXL static __inline long double complex CMPLXL(long double x, long double y) { long_double_complex z; REALPART(z) = x; IMAGPART(z) = y; return (z.f); } #endif #endif /* _COMPLEX_H */ /* * The rnint() family rounds to the nearest integer for a restricted range * range of args (up to about 2**MANT_DIG). We assume that the current * rounding mode is FE_TONEAREST so that this can be done efficiently. * Extra precision causes more problems in practice, and we only centralize * this here to reduce those problems, and have not solved the efficiency * problems. The exp2() family uses a more delicate version of this that * requires extracting bits from the intermediate value, so it is not * centralized here and should copy any solution of the efficiency problems. */ static inline double rnint(__double_t x) { /* * This casts to double to kill any extra precision. This depends * on the cast being applied to a double_t to avoid compiler bugs * (this is a cleaner version of STRICT_ASSIGN()). This is * inefficient if there actually is extra precision, but is hard * to improve on. We use double_t in the API to minimise conversions * for just calling here. Note that we cannot easily change the * magic number to the one that works directly with double_t, since * the rounding precision is variable at runtime on x86 so the * magic number would need to be variable. Assuming that the * rounding precision is always the default is too fragile. This * and many other complications will move when the default is * changed to FP_PE. */ return ((double)(x + 0x1.8p52) - 0x1.8p52); } static inline float rnintf(__float_t x) { /* * As for rnint(), except we could just call that to handle the * extra precision case, usually without losing efficiency. */ return ((float)(x + 0x1.8p23F) - 0x1.8p23F); } #ifdef LDBL_MANT_DIG /* * The complications for extra precision are smaller for rnintl() since it * can safely assume that the rounding precision has been increased from * its default to FP_PE on x86. We don't exploit that here to get small * optimizations from limiting the range to double. We just need it for * the magic number to work with long doubles. ld128 callers should use * rnint() instead of this if possible. ld80 callers should prefer * rnintl() since for amd64 this avoids swapping the register set, while * for i386 it makes no difference (assuming FP_PE), and for other arches * it makes little difference. */ static inline long double rnintl(long double x) { return (x + __CONCAT(0x1.8p, LDBL_MANT_DIG) / 2 - __CONCAT(0x1.8p, LDBL_MANT_DIG) / 2); } #endif /* LDBL_MANT_DIG */ /* * irint() and i64rint() give the same result as casting to their integer * return type provided their arg is a floating point integer. They can * sometimes be more efficient because no rounding is required. */ #if defined(amd64) || defined(__i386__) #define irint(x) \ (sizeof(x) == sizeof(float) && \ sizeof(__float_t) == sizeof(long double) ? irintf(x) : \ sizeof(x) == sizeof(double) && \ sizeof(__double_t) == sizeof(long double) ? irintd(x) : \ sizeof(x) == sizeof(long double) ? irintl(x) : (int)(x)) #else #define irint(x) ((int)(x)) #endif #define i64rint(x) ((int64_t)(x)) /* only needed for ld128 so not opt. */ #if defined(__i386__) static __inline int irintf(float x) { int n; __asm("fistl %0" : "=m" (n) : "t" (x)); return (n); } static __inline int irintd(double x) { int n; __asm("fistl %0" : "=m" (n) : "t" (x)); return (n); } #endif #if defined(__amd64__) || defined(__i386__) static __inline int irintl(long double x) { int n; __asm("fistl %0" : "=m" (n) : "t" (x)); return (n); } #endif /* * The following are fast floor macros for 0 <= |x| < 0x1p(N-1), where * N is the precision of the type of x. These macros are used in the * half-cycle trignometric functions (e.g., sinpi(x)). */ #define FFLOORF(x, j0, ix) do { \ (j0) = (((ix) >> 23) & 0xff) - 0x7f; \ (ix) &= ~(0x007fffff >> (j0)); \ SET_FLOAT_WORD((x), (ix)); \ } while (0) #define FFLOOR(x, j0, ix, lx) do { \ (j0) = (((ix) >> 20) & 0x7ff) - 0x3ff; \ if ((j0) < 20) { \ (ix) &= ~(0x000fffff >> (j0)); \ (lx) = 0; \ } else { \ (lx) &= ~((uint32_t)0xffffffff >> ((j0) - 20)); \ } \ INSERT_WORDS((x), (ix), (lx)); \ } while (0) #define FFLOORL80(x, j0, ix, lx) do { \ j0 = ix - 0x3fff + 1; \ if ((j0) < 32) { \ (lx) = ((lx) >> 32) << 32; \ (lx) &= ~((((lx) << 32)-1) >> (j0)); \ } else { \ uint64_t _m; \ _m = (uint64_t)-1 >> (j0); \ if ((lx) & _m) (lx) &= ~_m; \ } \ INSERT_LDBL80_WORDS((x), (ix), (lx)); \ } while (0) #define FFLOORL128(x, ai, ar) do { \ union IEEEl2bits u; \ uint64_t m; \ int e; \ u.e = (x); \ e = u.bits.exp - 16383; \ if (e < 48) { \ m = ((1llu << 49) - 1) >> (e + 1); \ u.bits.manh &= ~m; \ u.bits.manl = 0; \ } else { \ m = (uint64_t)-1 >> (e - 48); \ u.bits.manl &= ~m; \ } \ (ai) = u.e; \ (ar) = (x) - (ai); \ } while (0) #ifdef DEBUG #if defined(__amd64__) || defined(__i386__) #define breakpoint() asm("int $3") #else #include #define breakpoint() raise(SIGTRAP) #endif #endif #ifdef STRUCT_RETURN #define RETURNSP(rp) do { \ if (!(rp)->lo_set) \ RETURNF((rp)->hi); \ RETURNF((rp)->hi + (rp)->lo); \ } while (0) #define RETURNSPI(rp) do { \ if (!(rp)->lo_set) \ RETURNI((rp)->hi); \ RETURNI((rp)->hi + (rp)->lo); \ } while (0) #endif #define SUM2P(x, y) ({ \ const __typeof (x) __x = (x); \ const __typeof (y) __y = (y); \ __x + __y; \ }) /* fdlibm kernel function */ int __kernel_rem_pio2(double*,double*,int,int,int); /* double precision kernel functions */ #ifndef INLINE_REM_PIO2 int __ieee754_rem_pio2(double,double*); #endif double __kernel_sin(double,double,int); double __kernel_cos(double,double); double __kernel_tan(double,double,int); double __ldexp_exp(double,int); #ifdef _COMPLEX_H double complex __ldexp_cexp(double complex,int); #endif /* float precision kernel functions */ #ifndef INLINE_REM_PIO2F int __ieee754_rem_pio2f(float,double*); #endif #ifndef INLINE_KERNEL_SINDF float __kernel_sindf(double); #endif #ifndef INLINE_KERNEL_COSDF float __kernel_cosdf(double); #endif #ifndef INLINE_KERNEL_TANDF float __kernel_tandf(double,int); #endif float __ldexp_expf(float,int); #ifdef _COMPLEX_H float complex __ldexp_cexpf(float complex,int); #endif /* long double precision kernel functions */ long double __kernel_sinl(long double, long double, int); long double __kernel_cosl(long double, long double); long double __kernel_tanl(long double, long double, int); #endif /* !_MATH_PRIVATE_H_ */ diff --git a/lib/ncurses/ncurses/pathnames.h b/lib/ncurses/ncurses/pathnames.h index 582d7e8b4b02..4a5b8840c2b7 100644 --- a/lib/ncurses/ncurses/pathnames.h +++ b/lib/ncurses/ncurses/pathnames.h @@ -1,36 +1,35 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #define _PATH_DEF ".termcap /usr/share/misc/termcap /etc/termcap.small" #define _PATH_DEF_SEC "/usr/share/misc/termcap" diff --git a/lib/ncurses/tinfo/pathnames.h b/lib/ncurses/tinfo/pathnames.h index 582d7e8b4b02..4a5b8840c2b7 100644 --- a/lib/ncurses/tinfo/pathnames.h +++ b/lib/ncurses/tinfo/pathnames.h @@ -1,36 +1,35 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #define _PATH_DEF ".termcap /usr/share/misc/termcap /etc/termcap.small" #define _PATH_DEF_SEC "/usr/share/misc/termcap" diff --git a/libexec/bootpd/hash.h b/libexec/bootpd/hash.h index 969703d04e59..14aefe969d0d 100644 --- a/libexec/bootpd/hash.h +++ b/libexec/bootpd/hash.h @@ -1,148 +1,147 @@ #ifndef HASH_H #define HASH_H /* hash.h */ /************************************************************************ Copyright 1988, 1991 by Carnegie Mellon University All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Carnegie Mellon University not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ************************************************************************/ /* * Generalized hash table ADT - * $FreeBSD$ * * Provides multiple, dynamically-allocated, variable-sized hash tables on * various data and keys. * * This package attempts to follow some of the coding conventions suggested * by Bob Sidebotham and the AFS Clean Code Committee. */ /* * The user must supply the following: * * 1. A comparison function which is declared as: * * int compare(data1, data2) * hash_datum *data1, *data2; * * This function must compare the desired fields of data1 and * data2 and return TRUE (1) if the data should be considered * equivalent (i.e. have the same key value) or FALSE (0) * otherwise. This function is called through a pointer passed to * the various hashtable functions (thus pointers to different * functions may be passed to effect different tests on different * hash tables). * * Internally, all the functions of this package always call the * compare function with the "key" parameter as the first parameter, * and a full data element as the second parameter. Thus, the key * and element arguments to functions such as hash_Lookup() may * actually be of different types and the programmer may provide a * compare function which compares the two different object types * as desired. * * Example: * * int compare(key, element) * char *key; * struct some_complex_structure *element; * { * return !strcmp(key, element->name); * } * * key = "John C. Doe" * element = &some_complex_structure * hash_Lookup(table, hashcode, compare, key); * * 2. A hash function yielding an unsigned integer value to be used * as the hashcode (index into the hashtable). Thus, the user * may hash on whatever data is desired and may use several * different hash functions for various different hash tables. * The actual hash table index will be the passed hashcode modulo * the hash table size. * * A generalized hash function, hash_HashFunction(), is included * with this package to make things a little easier. It is not * guaranteed to use the best hash algorithm in existence. . . . */ /* * Various hash table definitions */ /* * Define "hash_datum" as a universal data type */ typedef void hash_datum; typedef struct hash_memberstruct hash_member; typedef struct hash_tblstruct hash_tbl; typedef struct hash_tblstruct_hdr hash_tblhdr; struct hash_memberstruct { hash_member *next; hash_datum *data; }; struct hash_tblstruct_hdr { unsigned size, bucketnum; hash_member *member; }; struct hash_tblstruct { unsigned size, bucketnum; hash_member *member; /* Used for linear dump */ hash_member *table[1]; /* Dynamically extended */ }; /* ANSI function prototypes or empty arg list? */ typedef int (*hash_cmpfp)(hash_datum *, hash_datum *); typedef void (*hash_freefp)(hash_datum *); extern hash_tbl *hash_Init(u_int tablesize); extern void hash_Reset(hash_tbl *tbl, hash_freefp); extern unsigned hash_HashFunction(u_char *str, u_int len); extern int hash_Exists(hash_tbl *, u_int code, hash_cmpfp, hash_datum *key); extern int hash_Insert(hash_tbl *, u_int code, hash_cmpfp, hash_datum *key, hash_datum *element); extern int hash_Delete(hash_tbl *, u_int code, hash_cmpfp, hash_datum *key, hash_freefp); extern hash_datum *hash_Lookup(hash_tbl *, u_int code, hash_cmpfp, hash_datum *key); extern hash_datum *hash_FirstEntry(hash_tbl *); extern hash_datum *hash_NextEntry(hash_tbl *); #endif /* HASH_H */ diff --git a/libexec/ftpd/extern.h b/libexec/ftpd/extern.h index aa48ea67e320..2e314ba5c117 100644 --- a/libexec/ftpd/extern.h +++ b/libexec/ftpd/extern.h @@ -1,113 +1,112 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/4/94 - * $FreeBSD$ */ #include #include void blkfree(char **); char **copyblk(char **); void cwd(char *); void delete(char *); void dologout(int); void fatalerror(char *); void ftpd_logwtmp(char *, char *, struct sockaddr *addr); int ftpd_pclose(FILE *); FILE *ftpd_popen(char *, char *); int get_line(char *, int, FILE *); void lreply(int, const char *, ...) __printflike(2, 3); void makedir(char *); void nack(char *); void pass(char *); void passive(void); void long_passive(char *, int); void perror_reply(int, char *); void pwd(void); void removedir(char *); void renamecmd(char *, char *); char *renamefrom(char *); void reply(int, const char *, ...) __printflike(2, 3); void retrieve(char *, char *); void send_file_list(char *); void statcmd(void); void statfilecmd(char *); void store(char *, char *, int); void upper(char *); void user(char *); void yyerror(char *); int yyparse(void); int ls_main(int, char **); extern int assumeutf8; extern char cbuf[]; extern union sockunion data_dest; extern int epsvall; extern int form; extern int ftpdebug; extern int guest; extern union sockunion his_addr; extern char *homedir; extern int hostinfo; extern char *hostname; extern int maxtimeout; extern int logged_in; extern int logging; extern int noepsv; extern int noguestretr; extern int noretr; extern int paranoid; extern struct passwd *pw; extern int pdata; extern char proctitle[]; extern int readonly; extern off_t restart_point; extern int timeout; extern char tmpline[]; extern int type; extern char *typenames[]; /* defined in included from ftpd.c */ extern int usedefault; struct sockaddr_in; struct sockaddr_in6; union sockunion { struct sockinet { u_char si_len; u_char si_family; u_short si_port; } su_si; struct sockaddr_in su_sin; struct sockaddr_in6 su_sin6; }; #define su_len su_si.si_len #define su_family su_si.si_family #define su_port su_si.si_port diff --git a/libexec/ftpd/pathnames.h b/libexec/ftpd/pathnames.h index 47dc25a5dfe7..75bec0d18a68 100644 --- a/libexec/ftpd/pathnames.h +++ b/libexec/ftpd/pathnames.h @@ -1,42 +1,41 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #include #define _PATH_FTPCHROOT "/etc/ftpchroot" #define _PATH_FTPWELCOME "/etc/ftpwelcome" #define _PATH_FTPLOGINMESG "/etc/ftpmotd" #define _PATH_FTPHOSTS "/etc/ftphosts" #define _PATH_FTPDSTATFILE "/var/log/ftpd" #define _PATH_LS "/bin/ls" diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h index 6872acb4f6f7..d20c2b119cfb 100644 --- a/libexec/getty/extern.h +++ b/libexec/getty/extern.h @@ -1,59 +1,58 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)extern.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ struct delayval; struct termios; extern char **environ; extern char editedhost[]; extern char hostname[]; extern struct termios tmode, omode; extern struct gettyflags gettyflags[]; extern struct gettynums gettynums[]; extern struct gettystrs gettystrs[]; int adelay(int, struct delayval *); const char *autobaud(void); int delaybits(void); void edithost(const char *); void gendefaults(void); void gettable(const char *); void makeenv(char *[]); const char *portselector(void); void set_ttydefaults(int); void setchars(void); void setdefaults(void); void set_flags(int); int speed(int); int getty_chat(char *, int, int); diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h index 2d3972e3bc10..1ef0f8acc202 100644 --- a/libexec/getty/gettytab.h +++ b/libexec/getty/gettytab.h @@ -1,176 +1,175 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94 - * $FreeBSD$ */ /* * Getty description definitions. */ struct gettystrs { const char *field; /* name to lookup in gettytab */ char *defalt; /* value we find by looking in defaults */ char *value; /* value that we find there */ }; struct gettynums { const char *field; /* name to lookup */ long defalt; /* number we find in defaults */ long value; /* number we find there */ int set; /* we actually got this one */ }; struct gettyflags { const char *field; /* name to lookup */ char invrt; /* name existing in gettytab --> false */ char defalt; /* true/false in defaults */ char value; /* true/false flag */ char set; /* we found it */ }; /* * String values. */ #define NX gettystrs[0].value #define CL gettystrs[1].value #define IM gettystrs[2].value #define LM gettystrs[3].value #define ER gettystrs[4].value #define KL gettystrs[5].value #define ET gettystrs[6].value #define PC gettystrs[7].value #define TT gettystrs[8].value #define EV gettystrs[9].value #define LO gettystrs[10].value #define HN gettystrs[11].value #define HE gettystrs[12].value #define IN gettystrs[13].value #define QU gettystrs[14].value #define XN gettystrs[15].value #define XF gettystrs[16].value #define BK gettystrs[17].value #define SU gettystrs[18].value #define DS gettystrs[19].value #define RP gettystrs[20].value #define FL gettystrs[21].value #define WE gettystrs[22].value #define LN gettystrs[23].value #define Lo gettystrs[24].value #define PP gettystrs[25].value #define IF gettystrs[26].value #define IC gettystrs[27].value #define AC gettystrs[28].value #define AL gettystrs[29].value #define DF gettystrs[30].value #define IMP gettystrs[31].value /* * Numeric definitions. */ #define IS gettynums[0].value #define OS gettynums[1].value #define SP gettynums[2].value #define ND gettynums[3].value #define CD gettynums[4].value #define TD gettynums[5].value #define FD gettynums[6].value #define BD gettynums[7].value #define TO gettynums[8].value #define F0 gettynums[9].value #define F0set gettynums[9].set #define F1 gettynums[10].value #define F1set gettynums[10].set #define F2 gettynums[11].value #define F2set gettynums[11].set #define PF gettynums[12].value #define C0 gettynums[13].value #define C0set gettynums[13].set #define C1 gettynums[14].value #define C1set gettynums[14].set #define C2 gettynums[15].value #define C2set gettynums[15].set #define I0 gettynums[16].value #define I0set gettynums[16].set #define I1 gettynums[17].value #define I1set gettynums[17].set #define I2 gettynums[18].value #define I2set gettynums[18].set #define L0 gettynums[19].value #define L0set gettynums[19].set #define L1 gettynums[20].value #define L1set gettynums[20].set #define L2 gettynums[21].value #define L2set gettynums[21].set #define O0 gettynums[22].value #define O0set gettynums[22].set #define O1 gettynums[23].value #define O1set gettynums[23].set #define O2 gettynums[24].value #define O2set gettynums[24].set #define DE gettynums[25].value #define RTset gettynums[26].set #define RT gettynums[26].value #define CT gettynums[27].value #define DC gettynums[28].value /* * Boolean values. */ #define HT gettyflags[0].value #define NL gettyflags[1].value #define EP gettyflags[2].value #define EPset gettyflags[2].set #define OP gettyflags[3].value #define OPset gettyflags[3].set #define AP gettyflags[4].value #define APset gettyflags[4].set #define EC gettyflags[5].value #define CO gettyflags[6].value #define CB gettyflags[7].value #define CK gettyflags[8].value #define CE gettyflags[9].value #define PE gettyflags[10].value #define RW gettyflags[11].value #define XC gettyflags[12].value #define LC gettyflags[13].value #define UC gettyflags[14].value #define IG gettyflags[15].value #define PS gettyflags[16].value #define HC gettyflags[17].value #define UB gettyflags[18].value #define AB gettyflags[19].value #define DX gettyflags[20].value #define NP gettyflags[21].value #define NPset gettyflags[21].set #define MB gettyflags[22].value #define HW gettyflags[23].value #define NC gettyflags[24].value #define PL gettyflags[25].value diff --git a/libexec/getty/pathnames.h b/libexec/getty/pathnames.h index 749875a6d183..4e01ec7954d4 100644 --- a/libexec/getty/pathnames.h +++ b/libexec/getty/pathnames.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93 - * $FreeBSD$ */ #include #define _PATH_GETTYTAB "/etc/gettytab" #define _PATH_LOGIN "/usr/bin/login" diff --git a/libexec/rtld-elf/Symbol.map b/libexec/rtld-elf/Symbol.map index 0a9eac82cf05..0b7ad63f60a7 100644 --- a/libexec/rtld-elf/Symbol.map +++ b/libexec/rtld-elf/Symbol.map @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ FBSD_1.0 { _rtld_error; dlclose; dlerror; dlopen; dlsym; dlfunc; dlvsym; dladdr; dllockinit; dlinfo; dl_iterate_phdr; r_debug_state; __tls_get_addr; }; FBSD_1.3 { fdlopen; }; FBSDprivate_1.0 { _rtld_thread_init; _rtld_allocate_tls; _rtld_free_tls; _rtld_atfork_pre; _rtld_atfork_post; _rtld_addr_phdr; _rtld_get_stack_prot; _rtld_is_dlopened; _r_debug_postinit; _rtld_version__FreeBSD_version; _rtld_version_laddr_offset; _rtld_version_dlpi_tls_data; }; diff --git a/libexec/rtld-elf/i386/Symbol.map b/libexec/rtld-elf/i386/Symbol.map index b80731087244..c7dcd4ce5032 100644 --- a/libexec/rtld-elf/i386/Symbol.map +++ b/libexec/rtld-elf/i386/Symbol.map @@ -1,7 +1,6 @@ /* - * $FreeBSD$ */ FBSD_1.0 { ___tls_get_addr; }; diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c index a9d859dc60f5..26386efcf487 100644 --- a/libexec/rtld-elf/libmap.c +++ b/libexec/rtld-elf/libmap.c @@ -1,498 +1,497 @@ /* - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include "debug.h" #include "rtld.h" #include "libmap.h" #include "rtld_paths.h" #include "rtld_libc.h" TAILQ_HEAD(lm_list, lm); struct lm { char *f; char *t; TAILQ_ENTRY(lm) lm_link; }; static TAILQ_HEAD(lmp_list, lmp) lmp_head = TAILQ_HEAD_INITIALIZER(lmp_head); struct lmp { char *p; enum { T_EXACT=0, T_BASENAME, T_DIRECTORY } type; struct lm_list lml; TAILQ_ENTRY(lmp) lmp_link; }; static TAILQ_HEAD(lmc_list, lmc) lmc_head = TAILQ_HEAD_INITIALIZER(lmc_head); struct lmc { char *path; dev_t dev; ino_t ino; TAILQ_ENTRY(lmc) next; }; static int lm_count; static void lmc_parse(char *, size_t); static void lmc_parse_file(const char *); static void lmc_parse_dir(const char *); static void lm_add(const char *, const char *, const char *); static void lm_free(struct lm_list *); static char *lml_find(struct lm_list *, const char *); static struct lm_list *lmp_find(const char *); static struct lm_list *lmp_init(char *); static const char *quickbasename(const char *); #define iseol(c) (((c) == '#') || ((c) == '\0') || \ ((c) == '\n') || ((c) == '\r')) /* * Do not use ctype.h macros, which rely on working TLS. Rtld does * not support TLS for itself. */ #define rtld_isspace(c) ((c) == ' ' || (c) == '\t') int lm_init(const char *libmap_override) { char *l, *p; dbg("lm_init(\"%s\")", libmap_override); TAILQ_INIT(&lmp_head); lmc_parse_file(ld_path_libmap_conf); if (libmap_override != NULL) { /* * Do some character replacement to make $LD_LIBMAP look * like a text file, then parse it. */ l = xstrdup(libmap_override); for (p = l; *p != 0; p++) { switch (*p) { case '=': *p = ' '; break; case ',': *p = '\n'; break; } } lmc_parse(l, p - l); free(l); } return (lm_count == 0); } static void lmc_parse_file(const char *path) { struct lmc *p; char *lm_map; struct stat st; ssize_t retval; int fd, saved_errno; TAILQ_FOREACH(p, &lmc_head, next) { if (strcmp(p->path, path) == 0) return; } fd = open(path, O_RDONLY | O_CLOEXEC); if (fd == -1) { dbg("lm_parse_file: open(\"%s\") failed, %s", path, rtld_strerror(errno)); return; } if (fstat(fd, &st) == -1) { dbg("lm_parse_file: fstat(\"%s\") failed, %s", path, rtld_strerror(errno)); close(fd); return; } TAILQ_FOREACH(p, &lmc_head, next) { if (p->dev == st.st_dev && p->ino == st.st_ino) { close(fd); return; } } lm_map = xmalloc(st.st_size); retval = read(fd, lm_map, st.st_size); saved_errno = errno; close(fd); if (retval != st.st_size) { if (retval == -1) { dbg("lm_parse_file: read(\"%s\") failed, %s", path, rtld_strerror(saved_errno)); } else { dbg("lm_parse_file: short read(\"%s\"), %zd vs %jd", path, retval, (uintmax_t)st.st_size); } free(lm_map); return; } p = xmalloc(sizeof(struct lmc)); p->path = xstrdup(path); p->dev = st.st_dev; p->ino = st.st_ino; TAILQ_INSERT_HEAD(&lmc_head, p, next); lmc_parse(lm_map, st.st_size); free(lm_map); } static void lmc_parse_dir(const char *idir) { DIR *d; struct dirent *dp; struct lmc *p; char conffile[MAXPATHLEN]; char *ext; TAILQ_FOREACH(p, &lmc_head, next) { if (strcmp(p->path, idir) == 0) return; } d = opendir(idir); if (d == NULL) return; p = xmalloc(sizeof(struct lmc)); p->path = xstrdup(idir); p->dev = NODEV; p->ino = 0; TAILQ_INSERT_HEAD(&lmc_head, p, next); while ((dp = readdir(d)) != NULL) { if (dp->d_ino == 0) continue; if (dp->d_type != DT_REG) continue; ext = strrchr(dp->d_name, '.'); if (ext == NULL) continue; if (strcmp(ext, ".conf") != 0) continue; if (strlcpy(conffile, idir, MAXPATHLEN) >= MAXPATHLEN) continue; /* too long */ if (strlcat(conffile, "/", MAXPATHLEN) >= MAXPATHLEN) continue; /* too long */ if (strlcat(conffile, dp->d_name, MAXPATHLEN) >= MAXPATHLEN) continue; /* too long */ lmc_parse_file(conffile); } closedir(d); } static void lmc_parse(char *lm_p, size_t lm_len) { char *cp, *f, *t, *c, *p; char prog[MAXPATHLEN]; /* allow includedir + full length path */ char line[MAXPATHLEN + 13]; size_t cnt, i; cnt = 0; p = NULL; while (cnt < lm_len) { i = 0; while (cnt < lm_len && lm_p[cnt] != '\n' && i < sizeof(line) - 1) { line[i] = lm_p[cnt]; cnt++; i++; } line[i] = '\0'; while (cnt < lm_len && lm_p[cnt] != '\n') cnt++; /* skip over nl */ cnt++; cp = &line[0]; t = f = c = NULL; /* Skip over leading space */ while (rtld_isspace(*cp)) cp++; /* Found a comment or EOL */ if (iseol(*cp)) continue; /* Found a constraint selector */ if (*cp == '[') { cp++; /* Skip leading space */ while (rtld_isspace(*cp)) cp++; /* Found comment, EOL or end of selector */ if (iseol(*cp) || *cp == ']') continue; c = cp++; /* Skip to end of word */ while (!rtld_isspace(*cp) && !iseol(*cp) && *cp != ']') cp++; /* Skip and zero out trailing space */ while (rtld_isspace(*cp)) *cp++ = '\0'; /* Check if there is a closing brace */ if (*cp != ']') continue; /* Terminate string if there was no trailing space */ *cp++ = '\0'; /* * There should be nothing except whitespace or comment from this point to the end of the line. */ while (rtld_isspace(*cp)) cp++; if (!iseol(*cp)) continue; if (strlcpy(prog, c, sizeof prog) >= sizeof prog) continue; p = prog; continue; } /* Parse the 'from' candidate. */ f = cp++; while (!rtld_isspace(*cp) && !iseol(*cp)) cp++; /* Skip and zero out the trailing whitespace */ while (rtld_isspace(*cp)) *cp++ = '\0'; /* Found a comment or EOL */ if (iseol(*cp)) continue; /* Parse 'to' mapping */ t = cp++; while (!rtld_isspace(*cp) && !iseol(*cp)) cp++; /* Skip and zero out the trailing whitespace */ while (rtld_isspace(*cp)) *cp++ = '\0'; /* Should be no extra tokens at this point */ if (!iseol(*cp)) continue; *cp = '\0'; if (strcmp(f, "includedir") == 0) lmc_parse_dir(t); else if (strcmp(f, "include") == 0) lmc_parse_file(t); else lm_add(p, f, t); } } static void lm_free(struct lm_list *lml) { struct lm *lm; dbg("%s(%p)", __func__, lml); while (!TAILQ_EMPTY(lml)) { lm = TAILQ_FIRST(lml); TAILQ_REMOVE(lml, lm, lm_link); free(lm->f); free(lm->t); free(lm); } } void lm_fini(void) { struct lmp *lmp; struct lmc *p; dbg("%s()", __func__); while (!TAILQ_EMPTY(&lmc_head)) { p = TAILQ_FIRST(&lmc_head); TAILQ_REMOVE(&lmc_head, p, next); free(p->path); free(p); } while (!TAILQ_EMPTY(&lmp_head)) { lmp = TAILQ_FIRST(&lmp_head); TAILQ_REMOVE(&lmp_head, lmp, lmp_link); free(lmp->p); lm_free(&lmp->lml); free(lmp); } } static void lm_add(const char *p, const char *f, const char *t) { struct lm_list *lml; struct lm *lm; const char *t1; if (p == NULL) p = "$DEFAULT$"; dbg("%s(\"%s\", \"%s\", \"%s\")", __func__, p, f, t); if ((lml = lmp_find(p)) == NULL) lml = lmp_init(xstrdup(p)); t1 = lml_find(lml, f); if (t1 == NULL || strcmp(t1, t) != 0) { lm = xmalloc(sizeof(struct lm)); lm->f = xstrdup(f); lm->t = xstrdup(t); TAILQ_INSERT_HEAD(lml, lm, lm_link); lm_count++; } } char * lm_find(const char *p, const char *f) { struct lm_list *lml; char *t; dbg("%s(\"%s\", \"%s\")", __func__, p, f); if (p != NULL && (lml = lmp_find(p)) != NULL) { t = lml_find(lml, f); if (t != NULL) { /* * Add a global mapping if we have * a successful constrained match. */ lm_add(NULL, f, t); return (t); } } lml = lmp_find("$DEFAULT$"); if (lml != NULL) return (lml_find(lml, f)); return (NULL); } /* * Given a libmap translation list and a library name, return the * replacement library, or NULL. */ char * lm_findn(const char *p, const char *f, const size_t n) { char pathbuf[64], *s, *t; if (n < sizeof(pathbuf) - 1) s = pathbuf; else s = xmalloc(n + 1); memcpy(s, f, n); s[n] = '\0'; t = lm_find(p, s); if (s != pathbuf) free(s); return (t); } static char * lml_find(struct lm_list *lmh, const char *f) { struct lm *lm; dbg("%s(%p, \"%s\")", __func__, lmh, f); TAILQ_FOREACH(lm, lmh, lm_link) { if (strcmp(f, lm->f) == 0) return (lm->t); } return (NULL); } /* * Given an executable name, return a pointer to the translation list or * NULL if no matches. */ static struct lm_list * lmp_find(const char *n) { struct lmp *lmp; dbg("%s(\"%s\")", __func__, n); TAILQ_FOREACH(lmp, &lmp_head, lmp_link) { if ((lmp->type == T_EXACT && strcmp(n, lmp->p) == 0) || (lmp->type == T_DIRECTORY && strncmp(n, lmp->p, strlen(lmp->p)) == 0) || (lmp->type == T_BASENAME && strcmp(quickbasename(n), lmp->p) == 0)) return (&lmp->lml); } return (NULL); } static struct lm_list * lmp_init(char *n) { struct lmp *lmp; dbg("%s(\"%s\")", __func__, n); lmp = xmalloc(sizeof(struct lmp)); lmp->p = n; if (n[strlen(n) - 1] == '/') lmp->type = T_DIRECTORY; else if (strchr(n,'/') == NULL) lmp->type = T_BASENAME; else lmp->type = T_EXACT; TAILQ_INIT(&lmp->lml); TAILQ_INSERT_HEAD(&lmp_head, lmp, lmp_link); return (&lmp->lml); } /* * libc basename is overkill. Return a pointer to the character after * the last /, or the original string if there are no slashes. */ static const char * quickbasename(const char *path) { const char *p; for (p = path; *path != '\0'; path++) { if (*path == '/') p = path + 1; } return (p); } diff --git a/libexec/rtld-elf/libmap.h b/libexec/rtld-elf/libmap.h index 2998b7b27cc9..a785f1b6c43f 100644 --- a/libexec/rtld-elf/libmap.h +++ b/libexec/rtld-elf/libmap.h @@ -1,13 +1,12 @@ /* - * $FreeBSD$ */ #ifndef LIBMAP_H #define LIBMAP_H int lm_init(const char *); void lm_fini(void); char *lm_find(const char *, const char *); char *lm_findn(const char *, const char *, const size_t); #endif diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index 10473618f787..0c790450dcec 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -1,497 +1,496 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright 1999, 2000 John D. Polstra. * 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. * * 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. * * from: FreeBSD: src/libexec/rtld-elf/sparc64/lockdflt.c,v 1.3 2002/10/09 - * $FreeBSD$ */ /* * Thread locking implementation for the dynamic linker. * * We use the "simple, non-scalable reader-preference lock" from: * * J. M. Mellor-Crummey and M. L. Scott. "Scalable Reader-Writer * Synchronization for Shared-Memory Multiprocessors." 3rd ACM Symp. on * Principles and Practice of Parallel Programming, April 1991. * * In this algorithm the lock is a single word. Its low-order bit is * set when a writer holds the lock. The remaining high-order bits * contain a count of readers desiring the lock. The algorithm requires * atomic "compare_and_store" and "add" operations, which we take * from machine/atomic.h. */ #include #include #include #include #include #include "debug.h" #include "rtld.h" #include "rtld_machdep.h" #include "rtld_libc.h" void _rtld_thread_init(struct RtldLockInfo *) __exported; void _rtld_atfork_pre(int *) __exported; void _rtld_atfork_post(int *) __exported; static char def_dlerror_msg[512]; static int def_dlerror_seen_val = 1; static char * def_dlerror_loc(void) { return (def_dlerror_msg); } static int * def_dlerror_seen(void) { return (&def_dlerror_seen_val); } #define WAFLAG 0x1 /* A writer holds the lock */ #define RC_INCR 0x2 /* Adjusts count of readers desiring lock */ typedef struct Struct_Lock { volatile u_int lock; void *base; } Lock; static sigset_t fullsigmask, oldsigmask; static int thread_flag, wnested; static uint32_t fsigblock; static void * def_lock_create(void) { void *base; char *p; uintptr_t r; Lock *l; /* * Arrange for the lock to occupy its own cache line. First, we * optimistically allocate just a cache line, hoping that malloc * will give us a well-aligned block of memory. If that doesn't * work, we allocate a larger block and take a well-aligned cache * line from it. */ base = xmalloc(CACHE_LINE_SIZE); p = base; if ((uintptr_t)p % CACHE_LINE_SIZE != 0) { free(base); base = xmalloc(2 * CACHE_LINE_SIZE); p = base; if ((r = (uintptr_t)p % CACHE_LINE_SIZE) != 0) p += CACHE_LINE_SIZE - r; } l = (Lock *)p; l->base = base; l->lock = 0; return (l); } static void def_lock_destroy(void *lock) { Lock *l = lock; free(l->base); } static void sig_fastunblock(void) { uint32_t oldval; assert((fsigblock & ~SIGFASTBLOCK_FLAGS) >= SIGFASTBLOCK_INC); oldval = atomic_fetchadd_32(&fsigblock, -SIGFASTBLOCK_INC); if (oldval == (SIGFASTBLOCK_PEND | SIGFASTBLOCK_INC)) __sys_sigfastblock(SIGFASTBLOCK_UNBLOCK, NULL); } static bool def_lock_acquire_set(Lock *l, bool wlock) { if (wlock) { if (atomic_cmpset_acq_int(&l->lock, 0, WAFLAG)) return (true); } else { atomic_add_acq_int(&l->lock, RC_INCR); if ((l->lock & WAFLAG) == 0) return (true); atomic_add_int(&l->lock, -RC_INCR); } return (false); } static void def_lock_acquire(Lock *l, bool wlock) { sigset_t tmp_oldsigmask; if (ld_fast_sigblock) { for (;;) { atomic_add_32(&fsigblock, SIGFASTBLOCK_INC); if (def_lock_acquire_set(l, wlock)) break; sig_fastunblock(); } } else { for (;;) { sigprocmask(SIG_BLOCK, &fullsigmask, &tmp_oldsigmask); if (def_lock_acquire_set(l, wlock)) break; sigprocmask(SIG_SETMASK, &tmp_oldsigmask, NULL); } if (atomic_fetchadd_int(&wnested, 1) == 0) oldsigmask = tmp_oldsigmask; } } static void def_rlock_acquire(void *lock) { def_lock_acquire(lock, false); } static void def_wlock_acquire(void *lock) { def_lock_acquire(lock, true); } static void def_lock_release(void *lock) { Lock *l = lock; atomic_add_rel_int(&l->lock, -((l->lock & WAFLAG) == 0 ? RC_INCR : WAFLAG)); if (ld_fast_sigblock) sig_fastunblock(); else if (atomic_fetchadd_int(&wnested, -1) == 1) sigprocmask(SIG_SETMASK, &oldsigmask, NULL); } static int def_thread_set_flag(int mask) { int old_val = thread_flag; thread_flag |= mask; return (old_val); } static int def_thread_clr_flag(int mask) { int old_val = thread_flag; thread_flag &= ~mask; return (old_val); } /* * Public interface exposed to the rest of the dynamic linker. */ struct RtldLockInfo lockinfo; static struct RtldLockInfo deflockinfo; static __inline int thread_mask_set(int mask) { return (lockinfo.thread_set_flag(mask)); } static __inline void thread_mask_clear(int mask) { lockinfo.thread_clr_flag(mask); } #define RTLD_LOCK_CNT 3 static struct rtld_lock { void *handle; int mask; } rtld_locks[RTLD_LOCK_CNT]; rtld_lock_t rtld_bind_lock = &rtld_locks[0]; rtld_lock_t rtld_libc_lock = &rtld_locks[1]; rtld_lock_t rtld_phdr_lock = &rtld_locks[2]; void rlock_acquire(rtld_lock_t lock, RtldLockState *lockstate) { if (lockstate == NULL) return; if (thread_mask_set(lock->mask) & lock->mask) { dbg("rlock_acquire: recursed"); lockstate->lockstate = RTLD_LOCK_UNLOCKED; return; } lockinfo.rlock_acquire(lock->handle); lockstate->lockstate = RTLD_LOCK_RLOCKED; } void wlock_acquire(rtld_lock_t lock, RtldLockState *lockstate) { if (lockstate == NULL) return; if (thread_mask_set(lock->mask) & lock->mask) { dbg("wlock_acquire: recursed"); lockstate->lockstate = RTLD_LOCK_UNLOCKED; return; } lockinfo.wlock_acquire(lock->handle); lockstate->lockstate = RTLD_LOCK_WLOCKED; } void lock_release(rtld_lock_t lock, RtldLockState *lockstate) { if (lockstate == NULL) return; switch (lockstate->lockstate) { case RTLD_LOCK_UNLOCKED: break; case RTLD_LOCK_RLOCKED: case RTLD_LOCK_WLOCKED: thread_mask_clear(lock->mask); lockinfo.lock_release(lock->handle); break; default: assert(0); } } void lock_upgrade(rtld_lock_t lock, RtldLockState *lockstate) { if (lockstate == NULL) return; lock_release(lock, lockstate); wlock_acquire(lock, lockstate); } void lock_restart_for_upgrade(RtldLockState *lockstate) { if (lockstate == NULL) return; switch (lockstate->lockstate) { case RTLD_LOCK_UNLOCKED: case RTLD_LOCK_WLOCKED: break; case RTLD_LOCK_RLOCKED: siglongjmp(lockstate->env, 1); break; default: assert(0); } } void dlerror_dflt_init(void) { lockinfo.dlerror_loc = def_dlerror_loc; lockinfo.dlerror_loc_sz = sizeof(def_dlerror_msg); lockinfo.dlerror_seen = def_dlerror_seen; } void lockdflt_init(void) { int i; deflockinfo.rtli_version = RTLI_VERSION; deflockinfo.lock_create = def_lock_create; deflockinfo.lock_destroy = def_lock_destroy; deflockinfo.rlock_acquire = def_rlock_acquire; deflockinfo.wlock_acquire = def_wlock_acquire; deflockinfo.lock_release = def_lock_release; deflockinfo.thread_set_flag = def_thread_set_flag; deflockinfo.thread_clr_flag = def_thread_clr_flag; deflockinfo.at_fork = NULL; deflockinfo.dlerror_loc = def_dlerror_loc; deflockinfo.dlerror_loc_sz = sizeof(def_dlerror_msg); deflockinfo.dlerror_seen = def_dlerror_seen; for (i = 0; i < RTLD_LOCK_CNT; i++) { rtld_locks[i].mask = (1 << i); rtld_locks[i].handle = NULL; } memcpy(&lockinfo, &deflockinfo, sizeof(lockinfo)); _rtld_thread_init(NULL); if (ld_fast_sigblock) { __sys_sigfastblock(SIGFASTBLOCK_SETPTR, &fsigblock); } else { /* * Construct a mask to block all signals. Note that * blocked traps mean that the process is terminated * if trap occurs while we are in locked section, with * the default settings for kern.forcesigexit. */ sigfillset(&fullsigmask); } } /* * Callback function to allow threads implementation to * register their own locking primitives if the default * one is not suitable. * The current context should be the only context * executing at the invocation time. */ void _rtld_thread_init(struct RtldLockInfo *pli) { const Obj_Entry *obj; SymLook req; void *locks[RTLD_LOCK_CNT]; int flags, i, res; if (pli == NULL) { lockinfo.rtli_version = RTLI_VERSION; } else { lockinfo.rtli_version = RTLI_VERSION_ONE; obj = obj_from_addr(pli->lock_create); if (obj != NULL) { symlook_init(&req, "_pli_rtli_version"); res = symlook_obj(&req, obj); if (res == 0) lockinfo.rtli_version = pli->rtli_version; } } /* disable all locking while this function is running */ flags = thread_mask_set(~0); if (pli == NULL) pli = &deflockinfo; else if (ld_fast_sigblock) { fsigblock = 0; __sys_sigfastblock(SIGFASTBLOCK_UNSETPTR, NULL); } for (i = 0; i < RTLD_LOCK_CNT; i++) if ((locks[i] = pli->lock_create()) == NULL) break; if (i < RTLD_LOCK_CNT) { while (--i >= 0) pli->lock_destroy(locks[i]); abort(); } for (i = 0; i < RTLD_LOCK_CNT; i++) { if (rtld_locks[i].handle == NULL) continue; if (flags & rtld_locks[i].mask) lockinfo.lock_release(rtld_locks[i].handle); lockinfo.lock_destroy(rtld_locks[i].handle); } for (i = 0; i < RTLD_LOCK_CNT; i++) { rtld_locks[i].handle = locks[i]; if (flags & rtld_locks[i].mask) pli->wlock_acquire(rtld_locks[i].handle); } lockinfo.lock_create = pli->lock_create; lockinfo.lock_destroy = pli->lock_destroy; lockinfo.rlock_acquire = pli->rlock_acquire; lockinfo.wlock_acquire = pli->wlock_acquire; lockinfo.lock_release = pli->lock_release; lockinfo.thread_set_flag = pli->thread_set_flag; lockinfo.thread_clr_flag = pli->thread_clr_flag; lockinfo.at_fork = pli->at_fork; if (lockinfo.rtli_version > RTLI_VERSION_ONE && pli != NULL) { strlcpy(pli->dlerror_loc(), lockinfo.dlerror_loc(), lockinfo.dlerror_loc_sz); lockinfo.dlerror_loc = pli->dlerror_loc; lockinfo.dlerror_loc_sz = pli->dlerror_loc_sz; lockinfo.dlerror_seen = pli->dlerror_seen; } /* restore thread locking state, this time with new locks */ thread_mask_clear(~0); thread_mask_set(flags); dbg("_rtld_thread_init: done"); } void _rtld_atfork_pre(int *locks) { RtldLockState ls[2]; if (locks == NULL) return; /* * Warning: this did not worked well with the rtld compat * locks above, when the thread signal mask was corrupted (set * to all signals blocked) if two locks were taken * simultaneously in the write mode. The caller of the * _rtld_atfork_pre() must provide the working implementation * of the locks anyway, and libthr locks are fine. */ wlock_acquire(rtld_phdr_lock, &ls[0]); wlock_acquire(rtld_bind_lock, &ls[1]); /* XXXKIB: I am really sorry for this. */ locks[0] = ls[1].lockstate; locks[2] = ls[0].lockstate; } void _rtld_atfork_post(int *locks) { RtldLockState ls[2]; if (locks == NULL) return; bzero(ls, sizeof(ls)); ls[0].lockstate = locks[2]; ls[1].lockstate = locks[0]; lock_release(rtld_bind_lock, &ls[1]); lock_release(rtld_phdr_lock, &ls[0]); } diff --git a/sbin/bsdlabel/pathnames.h b/sbin/bsdlabel/pathnames.h index 77ee59e0279e..f28593e71e55 100644 --- a/sbin/bsdlabel/pathnames.h +++ b/sbin/bsdlabel/pathnames.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - * $FreeBSD$ */ #include #define _PATH_BOOTDIR "/boot" #define PATH_TMPFILE "/tmp/EdDk.XXXXXXXXXX" diff --git a/sbin/ccdconfig/pathnames.h b/sbin/ccdconfig/pathnames.h index 83392b665f44..4924323e5a8e 100644 --- a/sbin/ccdconfig/pathnames.h +++ b/sbin/ccdconfig/pathnames.h @@ -1,36 +1,35 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. * * $NetBSD: pathnames.h,v 1.4 2008/04/28 20:23:07 martin Exp $ - * $FreeBSD$ */ #define _PATH_CCDCONF "/etc/ccd.conf" #define _PATH_CCDCTL "ccd.ctl" diff --git a/sbin/dump/pathnames.h b/sbin/dump/pathnames.h index 120bd72f5f11..3ee966a55ff7 100644 --- a/sbin/dump/pathnames.h +++ b/sbin/dump/pathnames.h @@ -1,40 +1,39 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - * $FreeBSD$ */ #include #define _PATH_DEFTAPE "/dev/sa0" #define _PATH_DUMPDATES "/etc/dumpdates" #define _PATH_LOCK "/tmp/dumplockXXXXXX" #define _PATH_RMT "/etc/rmt" /* path on remote host */ diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index e48f3e0aa692..1864ea19f4ca 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -1,544 +1,543 @@ /*- * SPDX-License-Identifier: BSD-3-Clause and BSD-2-Clause * * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * This software was developed for the FreeBSD Project by Marshall * Kirk McKusick and Network Associates Laboratories, the Security * Research Division of Network Associates, Inc. under DARPA/SPAWAR * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS * research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * Copyright (c) 1980, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fsck.h 8.4 (Berkeley) 5/9/95 - * $FreeBSD$ */ #ifndef _FSCK_H_ #define _FSCK_H_ #include #include #include #include #define MAXDUP 10 /* limit on dup blks (per inode) */ #define MAXBAD 10 /* limit on bad blks (per inode) */ #define MINBUFS 100 /* minimum number of buffers required */ #define INOBUFSIZE 64*1024 /* size of buffer to read inodes in pass1 */ #define ZEROBUFSIZE (dev_bsize * 128) /* size of zero buffer used by -Z */ union dinode { struct ufs1_dinode dp1; struct ufs2_dinode dp2; }; #define DIP(dp, field) \ ((sblock.fs_magic == FS_UFS1_MAGIC) ? \ (dp)->dp1.field : (dp)->dp2.field) #define DIP_SET(dp, field, val) do { \ if (sblock.fs_magic == FS_UFS1_MAGIC) \ (dp)->dp1.field = (val); \ else \ (dp)->dp2.field = (val); \ } while (0) /* * Each inode on the file system is described by the following structure. * The linkcnt is initially set to the value in the inode. Each time it * is found during the descent in passes 2, 3, and 4 the count is * decremented. Any inodes whose count is non-zero after pass 4 needs to * have its link count adjusted by the value remaining in ino_linkcnt. */ struct inostat { u_char ino_state; /* state of inode, see below */ u_char ino_type:4; /* type of inode */ u_char ino_idtype:4; /* idesc id_type, SNAP or ADDR */ u_short ino_linkcnt; /* number of links not found */ }; /* * Inode states. */ #define USTATE 0x1 /* inode not allocated */ #define FSTATE 0x2 /* inode is file */ #define FZLINK 0x3 /* inode is file with a link count of zero */ #define DSTATE 0x4 /* inode is directory */ #define DZLINK 0x5 /* inode is directory with a zero link count */ #define DFOUND 0x6 /* directory found during descent */ /* 0x7 UNUSED - see S_IS_DVALID() definition */ #define DCLEAR 0x8 /* directory is to be cleared */ #define FCLEAR 0x9 /* file is to be cleared */ /* DUNFOUND === (state == DSTATE || state == DZLINK) */ #define S_IS_DUNFOUND(state) (((state) & ~0x1) == DSTATE) /* DVALID === (state == DSTATE || state == DZLINK || state == DFOUND) */ #define S_IS_DVALID(state) (((state) & ~0x3) == DSTATE) #define INO_IS_DUNFOUND(ino) S_IS_DUNFOUND(inoinfo(ino)->ino_state) #define INO_IS_DVALID(ino) S_IS_DVALID(inoinfo(ino)->ino_state) /* * Inode state information is contained on per cylinder group lists * which are described by the following structure. */ extern struct inostatlist { long il_numalloced; /* number of inodes allocated in this cg */ struct inostat *il_stat;/* inostat info for this cylinder group */ } *inostathead; /* * Structure to reference a dinode. */ struct inode { struct bufarea *i_bp; /* buffer containing the dinode */ union dinode *i_dp; /* pointer to dinode in buffer */ ino_t i_number; /* inode number */ }; /* * Size of hash tables */ #define HASHSIZE 2048 #define HASH(x) ((x * 2654435761) & (HASHSIZE - 1)) /* * buffer cache structure. */ struct bufarea { TAILQ_ENTRY(bufarea) b_list; /* LRU buffer queue */ LIST_ENTRY(bufarea) b_hash; /* hash list */ ufs2_daddr_t b_bno; /* disk block number */ int b_size; /* size of I/O */ int b_errs; /* I/O error */ int b_flags; /* B_ flags below */ int b_type; /* BT_ type below */ int b_refcnt; /* ref count of users */ int b_index; /* for BT_LEVEL, ptr index */ /* for BT_INODES, first inum */ union { char *b_buf; /* buffer space */ ufs1_daddr_t *b_indir1; /* UFS1 indirect block */ ufs2_daddr_t *b_indir2; /* UFS2 indirect block */ struct fs *b_fs; /* super block */ struct cg *b_cg; /* cylinder group */ struct ufs1_dinode *b_dinode1; /* UFS1 inode block */ struct ufs2_dinode *b_dinode2; /* UFS2 inode block */ } b_un; }; #define IBLK(bp, i) \ ((sblock.fs_magic == FS_UFS1_MAGIC) ? \ (bp)->b_un.b_indir1[i] : (bp)->b_un.b_indir2[i]) #define IBLK_SET(bp, i, val) do { \ if (sblock.fs_magic == FS_UFS1_MAGIC) \ (bp)->b_un.b_indir1[i] = (val); \ else \ (bp)->b_un.b_indir2[i] = (val); \ } while (0) /* * Buffer flags */ #define B_DIRTY 0x00000001 /* Buffer is dirty */ /* * Type of data in buffer */ #define BT_UNKNOWN 0 /* Buffer type is unknown */ #define BT_SUPERBLK 1 /* Buffer holds a superblock */ #define BT_CYLGRP 2 /* Buffer holds a cylinder group map */ #define BT_LEVEL1 3 /* Buffer holds single level indirect */ #define BT_LEVEL2 4 /* Buffer holds double level indirect */ #define BT_LEVEL3 5 /* Buffer holds triple level indirect */ #define BT_EXTATTR 6 /* Buffer holds external attribute data */ #define BT_INODES 7 /* Buffer holds inodes */ #define BT_DIRDATA 8 /* Buffer holds directory data */ #define BT_DATA 9 /* Buffer holds user data */ #define BT_NUMBUFTYPES 10 #define BT_NAMES { \ "unknown", \ "Superblock", \ "Cylinder Group", \ "Single Level Indirect", \ "Double Level Indirect", \ "Triple Level Indirect", \ "External Attribute", \ "Inode Block", \ "Directory Contents", \ "User Data" } extern char *buftype[]; #define BT_BUFTYPE(type) \ type < BT_NUMBUFTYPES ? buftype[type] : buftype[BT_UNKNOWN] extern long readcnt[BT_NUMBUFTYPES]; extern long totalreadcnt[BT_NUMBUFTYPES]; extern struct timespec readtime[BT_NUMBUFTYPES]; extern struct timespec totalreadtime[BT_NUMBUFTYPES]; extern struct timespec startprog; extern struct bufarea *icachebp; /* inode cache buffer */ extern struct bufarea sblk; /* file system superblock */ extern struct bufarea *pdirbp; /* current directory contents */ #define dirty(bp) do { \ if (fswritefd < 0) \ pfatal("SETTING DIRTY FLAG IN READ_ONLY MODE\n"); \ else \ (bp)->b_flags |= B_DIRTY; \ } while (0) #define initbarea(bp, type) do { \ (bp)->b_bno = (ufs2_daddr_t)-4; \ (bp)->b_size = 0; \ (bp)->b_errs = 0; \ (bp)->b_flags = 0; \ (bp)->b_type = type; \ (bp)->b_refcnt = 0; \ (bp)->b_index = 0; \ } while (0) #define sbdirty() dirty(&sblk) #define sblock (*sblk.b_un.b_fs) enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE}; extern ino_t cursnapshot; struct inodesc { enum fixstate id_fix; /* policy on fixing errors */ int (*id_func)(struct inodesc *); /* function to be applied to blocks of inode */ struct bufarea *id_bp; /* ckinode: buffer with indirect pointers */ union dinode *id_dp; /* ckinode: dinode being traversed */ ino_t id_number; /* inode number described */ ino_t id_parent; /* for DATA nodes, their parent */ ufs_lbn_t id_lbn; /* logical block number of current block */ ufs2_daddr_t id_blkno; /* current block number being examined */ int id_level; /* level of indirection of this block */ int id_numfrags; /* number of frags contained in block */ ufs_lbn_t id_lballoc; /* pass1: last LBN that is allocated */ off_t id_filesize; /* for DATA nodes, the size of the directory */ ufs2_daddr_t id_entryno;/* for DATA nodes, current entry number */ int id_loc; /* for DATA nodes, current location in dir */ struct direct *id_dirp; /* for DATA nodes, ptr to current entry */ char *id_name; /* for DATA nodes, name to find or enter */ char id_type; /* type of descriptor, DATA, ADDR, or SNAP */ }; /* file types */ #define DATA 1 /* a directory */ #define SNAP 2 /* a snapshot */ #define ADDR 3 /* anything but a directory or a snapshot */ /* * Linked list of duplicate blocks. * * The list is composed of two parts. The first part of the * list (from duplist through the node pointed to by muldup) * contains a single copy of each duplicate block that has been * found. The second part of the list (from muldup to the end) * contains duplicate blocks that have been found more than once. * To check if a block has been found as a duplicate it is only * necessary to search from duplist through muldup. To find the * total number of times that a block has been found as a duplicate * the entire list must be searched for occurrences of the block * in question. The following diagram shows a sample list where * w (found twice), x (found once), y (found three times), and z * (found once) are duplicate block numbers: * * w -> y -> x -> z -> y -> w -> y * ^ ^ * | | * duplist muldup */ struct dups { struct dups *next; ufs2_daddr_t dup; }; extern struct dups *duplist; /* head of dup list */ extern struct dups *muldup; /* end of unique duplicate dup block numbers */ /* * Inode cache data structures. */ struct inoinfo { SLIST_ENTRY(inoinfo) i_hash; /* hash list */ ino_t i_number; /* inode number of this entry */ ino_t i_parent; /* inode number of parent */ ino_t i_dotdot; /* inode number of `..' */ size_t i_isize; /* size of inode */ u_int i_depth; /* depth of directory from root */ u_int i_flags; /* flags, see below */ u_int i_numblks; /* size of block array in bytes */ ufs2_daddr_t i_blks[1]; /* actually longer */ }; extern SLIST_HEAD(inohash, inoinfo) *inphash; extern struct inoinfo **inpsort; /* * flags for struct inoinfo */ #define INFO_NEW 0x0000001 /* replaced broken directory */ extern long dirhash, inplast; extern unsigned long numdirs, listmax; extern long countdirs; /* number of directories we actually found */ #define MIBSIZE 3 /* size of fsck sysctl MIBs */ extern int adjblkcnt[MIBSIZE]; /* MIB cmd to adjust inode block count */ extern int adjrefcnt[MIBSIZE]; /* MIB cmd to adjust inode reference count */ extern int adjndir[MIBSIZE]; /* MIB cmd to adjust number of directories */ extern int adjnbfree[MIBSIZE]; /* MIB cmd to adjust number of free blocks */ extern int adjnifree[MIBSIZE]; /* MIB cmd to adjust number of free inodes */ extern int adjnffree[MIBSIZE]; /* MIB cmd to adjust number of free frags */ extern int adjnumclusters[MIBSIZE]; /* MIB cmd adjust number of free clusters */ extern int adjdepth[MIBSIZE]; /* MIB cmd to adjust directory depth count */ extern int freefiles[MIBSIZE]; /* MIB cmd to free a set of files */ extern int freedirs[MIBSIZE]; /* MIB cmd to free a set of directories */ extern int freeblks[MIBSIZE]; /* MIB cmd to free a set of data blocks */ extern int setsize[MIBSIZE]; /* MIB cmd to set inode size */ extern struct fsck_cmd cmd; /* sysctl file system update commands */ extern int bkgrdcheck; /* determine if background check is possible */ extern int bkgrdsumadj; /* whether the kernel has the ability to adjust the superblock summary fields */ extern off_t bflag; /* location of alternate super block */ extern int bkgrdflag; /* use a snapshot to run on an active system */ extern char *blockmap; /* ptr to primary blk allocation map */ extern char *cdevname; /* name of device being checked */ extern int cgheader_corrupt; /* one or more CG headers are corrupt */ extern char ckclean; /* only do work if not cleanly unmounted */ extern int ckhashadd; /* check hashes to be added */ extern char *copybuf; /* buffer to copy snapshot blocks */ extern int cvtlevel; /* convert to newer file system format */ extern long dev_bsize; /* computed value of DEV_BSIZE */ extern u_int real_dev_bsize; /* actual disk sector size, not overridden */ extern int debug; /* output debugging info */ extern int Eflag; /* delete empty data blocks */ extern int fsmodified; /* 1 => write done to file system */ extern int fsreadfd; /* file descriptor for reading file system */ extern int fswritefd; /* file descriptor for writing file system */ extern char havesb; /* superblock has been read */ extern int inoopt; /* trim out unused inodes */ extern ino_t lfdir; /* lost & found directory inode number */ extern int lfmode; /* lost & found directory creation mode */ extern const char *lfname; /* lost & found directory name */ extern ufs2_daddr_t maxfsblock; /* number of blocks in the file system */ extern ino_t maxino; /* number of inodes in file system */ extern ufs2_daddr_t n_blks; /* number of blocks in use */ extern ino_t n_files; /* number of files in use */ extern char nflag; /* assume a no response */ extern char preen; /* just fix normal inconsistencies */ extern char rerun; /* rerun fsck. Only used in non-preen mode */ extern char resolved; /* cleared if unresolved changes => not clean */ extern int returntosingle; /* 1 => return to single user mode on exit */ extern long secsize; /* actual disk sector size */ extern char skipclean; /* skip clean file systems if preening */ extern int snapcnt; /* number of active snapshots */ extern struct inode snaplist[FSMAXSNAP + 1]; /* list of active snapshots */ extern char snapname[BUFSIZ]; /* when doing snapshots, the name of the file */ extern int sujrecovery; /* 1 => doing check using the journal */ extern int surrender; /* Give up if reads fail */ extern char usedsoftdep; /* just fix soft dependency inconsistencies */ extern int wantrestart; /* Restart fsck on early termination */ extern char yflag; /* assume a yes response */ extern int zflag; /* zero unused directory space */ extern int Zflag; /* zero empty data blocks */ extern volatile sig_atomic_t got_siginfo; /* received a SIGINFO */ extern volatile sig_atomic_t got_sigalarm; /* received a SIGALRM */ #define clearinode(dp) \ if (sblock.fs_magic == FS_UFS1_MAGIC) { \ (dp)->dp1 = zino.dp1; \ } else { \ (dp)->dp2 = zino.dp2; \ } extern union dinode zino; #define setbmap(blkno) setbit(blockmap, blkno) #define testbmap(blkno) isset(blockmap, blkno) #define clrbmap(blkno) clrbit(blockmap, blkno) #define STOP 0x01 #define SKIP 0x02 #define KEEPON 0x04 #define ALTERED 0x08 #define FOUND 0x10 #define EEXIT 8 /* Standard error exit. */ #define ERERUN 16 /* fsck needs to be re-run. */ #define ERESTART -1 int flushentry(void); /* * Wrapper for malloc() that flushes the cylinder group cache to try * to get space. */ static inline void* Malloc(size_t size) { void *retval; while ((retval = malloc(size)) == NULL) if (flushentry() == 0) break; return (retval); } /* * Wrapper for calloc() that flushes the cylinder group cache to try * to get space. */ static inline void* Calloc(size_t cnt, size_t size) { void *retval; while ((retval = calloc(cnt, size)) == NULL) if (flushentry() == 0) break; return (retval); } struct fstab; void adjust(struct inodesc *, int lcnt); void alarmhandler(int sig); ufs2_daddr_t allocblk(long cg, long frags, ufs2_daddr_t (*checkblkavail) (ufs2_daddr_t blkno, long frags)); ino_t allocdir(ino_t parent, ino_t request, int mode); ino_t allocino(ino_t request, int type); void binval(struct bufarea *); void blkerror(ino_t ino, const char *type, ufs2_daddr_t blk); char *blockcheck(char *name); int blread(int fd, char *buf, ufs2_daddr_t blk, long size); void bufinit(void); void blwrite(int fd, char *buf, ufs2_daddr_t blk, ssize_t size); void blerase(int fd, ufs2_daddr_t blk, long size); void blzero(int fd, ufs2_daddr_t blk, long size); void brelse(struct bufarea *); struct inoinfo *cacheino(union dinode *dp, ino_t inumber); void catch(int); void catchquit(int); void cgdirty(struct bufarea *); struct bufarea *cglookup(int cg); int changeino(ino_t dir, const char *name, ino_t newnum, int depth); void check_blkcnt(struct inode *ip); int check_cgmagic(int cg, struct bufarea *cgbp); void rebuild_cg(int cg, struct bufarea *cgbp); void check_dirdepth(struct inoinfo *inp); int chkfilesize(mode_t mode, u_int64_t filesize); int chkrange(ufs2_daddr_t blk, int cnt); void ckfini(int markclean); int ckinode(union dinode *dp, struct inodesc *); void clri(struct inodesc *, const char *type, int flag); int clearentry(struct inodesc *); void copyonwrite(struct fs *, struct bufarea *, ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long)); void direrror(ino_t ino, const char *errmesg); int dirscan(struct inodesc *); int dofix(struct inodesc *, const char *msg); int eascan(struct inodesc *, struct ufs2_dinode *dp); void fileerror(ino_t cwd, ino_t ino, const char *errmesg); void finalIOstats(void); int findino(struct inodesc *); int findname(struct inodesc *); void flush(int fd, struct bufarea *bp); int freeblock(struct inodesc *); void freedirino(ino_t ino, ino_t parent); void freeino(ino_t ino); void freeinodebuf(void); void fsckinit(void); void fsutilinit(void); int ftypeok(union dinode *dp); void getblk(struct bufarea *bp, ufs2_daddr_t blk, long size); struct bufarea *getdatablk(ufs2_daddr_t blkno, long size, int type); struct inoinfo *getinoinfo(ino_t inumber); union dinode *getnextinode(ino_t inumber, int rebuiltcg); void getpathname(char *namebuf, ino_t curdir, ino_t ino); void ginode(ino_t, struct inode *); void gjournal_check(const char *filesys); void infohandler(int sig); void irelse(struct inode *); ufs2_daddr_t ino_blkatoff(union dinode *, ino_t, ufs_lbn_t, int *, struct bufarea **); void inocleanup(void); void inodirty(struct inode *); struct inostat *inoinfo(ino_t inum); void IOstats(char *what); int linkup(ino_t orphan, ino_t parentdir, char *name); int makeentry(ino_t parent, ino_t ino, const char *name); int openfilesys(char *dev); void panic(const char *fmt, ...) __printflike(1, 2); void pass1(void); void pass1b(void); int pass1check(struct inodesc *); void pass2(void); void pass3(void); void pass4(void); void pass5(void); void pfatal(const char *fmt, ...) __printflike(1, 2); void propagate(void); void prtbuf(struct bufarea *, const char *, ...) __printflike(2, 3); void prtinode(struct inode *); void pwarn(const char *fmt, ...) __printflike(1, 2); int readsb(void); int removecachedino(ino_t); int reply(const char *question); void rwerror(const char *mesg, ufs2_daddr_t blk); void sblock_init(void); void setinodebuf(int, ino_t); int setup(char *dev); int snapblkfree(struct fs *, ufs2_daddr_t, long, ino_t, ufs2_daddr_t (*)(ufs2_daddr_t, long)); void snapremove(ino_t); void snapflush(ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t, long)); ufs2_daddr_t std_checkblkavail(ufs2_daddr_t blkno, long frags); ufs2_daddr_t suj_checkblkavail(ufs2_daddr_t, long); int suj_check(const char *filesys); void update_maps(struct cg *, struct cg*, int); #endif /* !_FSCK_H_ */ diff --git a/sbin/fsck_msdosfs/dosfs.h b/sbin/fsck_msdosfs/dosfs.h index 6016a5077dfd..a8da745b1ce3 100644 --- a/sbin/fsck_msdosfs/dosfs.h +++ b/sbin/fsck_msdosfs/dosfs.h @@ -1,133 +1,132 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank * Copyright (c) 1995 Martin Husemann * Some structure declaration borrowed from Paul Popelka * (paulp@uts.amdahl.com), see /sys/msdosfs/ for reference. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. * $NetBSD: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $ - * $FreeBSD$ */ #ifndef DOSFS_H #define DOSFS_H /* support 4Kn disk reads */ #define DOSBOOTBLOCKSIZE_REAL 512 #define DOSBOOTBLOCKSIZE 4096 typedef u_int32_t cl_t; /* type holding a cluster number */ /* * architecture independent description of all the info stored in a * FAT boot block. */ struct bootblock { u_int bpbBytesPerSec; /* bytes per sector */ u_int bpbSecPerClust; /* sectors per cluster */ u_int bpbResSectors; /* number of reserved sectors */ u_int bpbFATs; /* number of bpbFATs */ u_int bpbRootDirEnts; /* number of root directory entries */ u_int32_t bpbSectors; /* total number of sectors */ u_int bpbMedia; /* media descriptor */ u_int bpbFATsmall; /* number of sectors per FAT */ u_int SecPerTrack; /* sectors per track */ u_int bpbHeads; /* number of heads */ u_int32_t bpbHiddenSecs; /* # of hidden sectors */ u_int32_t bpbHugeSectors; /* # of sectors if bpbbpbSectors == 0 */ cl_t bpbRootClust; /* Start of Root Directory */ u_int bpbFSInfo; /* FSInfo sector */ u_int bpbBackup; /* Backup of Bootblocks */ cl_t FSFree; /* Number of free clusters acc. FSInfo */ cl_t FSNext; /* Next free cluster acc. FSInfo */ /* and some more calculated values */ u_int flags; /* some flags: */ #define FAT32 1 /* this is a FAT32 file system */ /* * Maybe, we should separate out * various parts of FAT32? XXX */ int ValidFat; /* valid fat if FAT32 non-mirrored */ cl_t ClustMask; /* mask for entries in FAT */ cl_t NumClusters; /* # of entries in a FAT */ u_int32_t NumSectors; /* how many sectors are there */ u_int32_t FATsecs; /* how many sectors are in FAT */ u_int32_t NumFatEntries; /* how many entries really are there */ u_int FirstCluster; /* at what sector is Cluster CLUST_FIRST */ u_int ClusterSize; /* Cluster size in bytes */ /* Now some statistics: */ u_int NumFiles; /* # of plain files */ u_int NumFree; /* # of free clusters */ u_int NumBad; /* # of bad clusters */ }; #define CLUST_FREE 0 /* 0 means cluster is free */ #define CLUST_FIRST 2 /* 2 is the minimum valid cluster number */ #define CLUST_RSRVD 0xfffffff6 /* start of reserved clusters */ #define CLUST_BAD 0xfffffff7 /* a cluster with a defect */ #define CLUST_EOFS 0xfffffff8 /* start of EOF indicators */ #define CLUST_EOF 0xffffffff /* standard value for last cluster */ #define CLUST_DEAD 0xfdeadc0d /* error encountered */ /* * Masks for cluster values */ #define CLUST12_MASK 0xfff #define CLUST16_MASK 0xffff #define CLUST32_MASK 0xfffffff #define DOSLONGNAMELEN 256 /* long name maximal length */ #define LRFIRST 0x40 /* first long name record */ #define LRNOMASK 0x1f /* mask to extract long record * sequence number */ /* * Architecture independent description of a directory entry */ struct dosDirEntry { struct dosDirEntry *parent, /* previous tree level */ *next, /* next brother */ *child; /* if this is a directory */ char name[8+1+3+1]; /* alias name first part */ char lname[DOSLONGNAMELEN]; /* real name */ uint flags; /* attributes */ cl_t head; /* cluster no */ u_int32_t size; /* filesize in bytes */ uint fsckflags; /* flags during fsck */ }; /* Flags in fsckflags: */ #define DIREMPTY 1 #define DIREMPWARN 2 /* * TODO-list of unread directories */ struct dirTodoNode { struct dosDirEntry *dir; struct dirTodoNode *next; }; #endif diff --git a/sbin/fsck_msdosfs/ext.h b/sbin/fsck_msdosfs/ext.h index 1f6453dedb74..d0f4dd6279f7 100644 --- a/sbin/fsck_msdosfs/ext.h +++ b/sbin/fsck_msdosfs/ext.h @@ -1,154 +1,153 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank * Copyright (c) 1995 Martin Husemann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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. * $NetBSD: ext.h,v 1.6 2000/04/25 23:02:51 jdolecek Exp $ - * $FreeBSD$ */ #ifndef EXT_H #define EXT_H #include #include #include "dosfs.h" #define LOSTDIR "LOST.DIR" /* * Options: */ extern int alwaysno; /* assume "no" for all questions */ extern int alwaysyes; /* assume "yes" for all questions */ extern int preen; /* we are preening */ extern int rdonly; /* device is opened read only (supersedes above) */ extern int skipclean; /* skip clean file systems if preening */ extern int allow_mmap; /* allow the use of mmap() */ /* * function declarations */ int ask(int, const char *, ...) __printflike(2, 3); /* * Check the dirty flag. If the file system is clean, then return 1. * Otherwise, return 0 (this includes the case of FAT12 file systems -- * they have no dirty flag, so they must be assumed to be unclean). */ int checkdirty(int, struct bootblock *); /* * Check file system given as arg */ int checkfilesys(const char *); /* * Return values of various functions */ #define FSOK 0 /* Check was OK */ #define FSBOOTMOD 1 /* Boot block was modified */ #define FSDIRMOD 2 /* Some directory was modified */ #define FSFATMOD 4 /* The FAT was modified */ #define FSERROR 8 /* Some unrecovered error remains */ #define FSFATAL 16 /* Some unrecoverable error occurred */ #define FSDIRTY 32 /* File system is dirty */ /* * read a boot block in a machine independent fashion and translate * it into our struct bootblock. */ int readboot(int, struct bootblock *); /* * Correct the FSInfo block. */ int writefsinfo(int, struct bootblock *); /* Opaque type */ struct fat_descriptor; int cleardirty(struct fat_descriptor *); void fat_clear_cl_head(struct fat_descriptor *, cl_t); bool fat_is_cl_head(struct fat_descriptor *, cl_t); cl_t fat_get_cl_next(struct fat_descriptor *, cl_t); int fat_set_cl_next(struct fat_descriptor *, cl_t, cl_t); cl_t fat_allocate_cluster(struct fat_descriptor *fat); struct bootblock* fat_get_boot(struct fat_descriptor *); int fat_get_fd(struct fat_descriptor *); bool fat_is_valid_cl(struct fat_descriptor *, cl_t); /* * Read the FAT 0 and return a pointer to the newly allocated * descriptor of it. */ int readfat(int, struct bootblock *, struct fat_descriptor **); /* * Write back FAT entries */ int writefat(struct fat_descriptor *); /* * Read a directory */ int resetDosDirSection(struct fat_descriptor *); void finishDosDirSection(void); int handleDirTree(struct fat_descriptor *); /* * Cross-check routines run after everything is completely in memory */ int checkchain(struct fat_descriptor *, cl_t, size_t *); /* * Check for lost cluster chains */ int checklost(struct fat_descriptor *); /* * Try to reconnect a lost cluster chain */ int reconnect(struct fat_descriptor *, cl_t, size_t); void finishlf(void); /* * Small helper functions */ /* * Return the type of a reserved cluster as text */ const char *rsrvdcltype(cl_t); /* * Clear a cluster chain in a FAT */ void clearchain(struct fat_descriptor *, cl_t); #endif diff --git a/sbin/growfs/debug.h b/sbin/growfs/debug.h index 068e89c3441f..527f4ed63b73 100644 --- a/sbin/growfs/debug.h +++ b/sbin/growfs/debug.h @@ -1,145 +1,144 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 2000 Christoph Herrmann, Thomas-Henning von Kamptz * Copyright (c) 1980, 1989, 1993 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Christoph Herrmann and Thomas-Henning von Kamptz, Munich and Frankfurt. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgment: * This product includes software developed by the University of * California, Berkeley and its contributors, as well as Christoph * Herrmann and Thomas-Henning von Kamptz. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $TSHeader: src/sbin/growfs/debug.h,v 1.2 2000/11/16 18:43:50 tom Exp $ - * $FreeBSD$ * */ #ifdef FS_DEBUG /* ********************************************************** INCLUDES ***** */ #include #include #include void dbg_open(const char *); void dbg_close(void); void dbg_dump_hex(struct fs *, const char *, unsigned char *); void dbg_dump_fs(struct fs *, const char *); void dbg_dump_cg(const char *, struct cg *); void dbg_dump_csum(const char *, struct csum *); void dbg_dump_csum_total(const char *, struct csum_total *); void dbg_dump_ufs1_ino(struct fs *, const char *, struct ufs1_dinode *); void dbg_dump_ufs2_ino(struct fs *, const char *, struct ufs2_dinode *); void dbg_dump_iblk(struct fs *, const char *, char *, size_t); void dbg_dump_inmap(struct fs *, const char *, struct cg *); void dbg_dump_frmap(struct fs *, const char *, struct cg *); void dbg_dump_clmap(struct fs *, const char *, struct cg *); void dbg_dump_clsum(struct fs *, const char *, struct cg *); void dbg_dump_sptbl(struct fs *, const char *, struct cg *); #define DBG_OPEN(P) dbg_open((P)) #define DBG_CLOSE dbg_close() #define DBG_DUMP_HEX(F,C,M) dbg_dump_hex((F),(C),(M)) #define DBG_DUMP_FS(F,C) dbg_dump_fs((F),(C)) #define DBG_DUMP_CG(F,C,M) dbg_dump_cg((C),(M)) #define DBG_DUMP_CSUM(F,C,M) dbg_dump_csum((C),(M)) #define DBG_DUMP_INO(F,C,M) (F)->fs_magic == FS_UFS1_MAGIC \ ? dbg_dump_ufs1_ino((F),(C),(struct ufs1_dinode *)(M)) \ : dbg_dump_ufs2_ino((F),(C),(struct ufs2_dinode *)(M)) #define DBG_DUMP_IBLK(F,C,M,L) dbg_dump_iblk((F),(C),(M),(L)) #define DBG_DUMP_INMAP(F,C,M) dbg_dump_inmap((F),(C),(M)) #define DBG_DUMP_FRMAP(F,C,M) dbg_dump_frmap((F),(C),(M)) #define DBG_DUMP_CLMAP(F,C,M) dbg_dump_clmap((F),(C),(M)) #define DBG_DUMP_CLSUM(F,C,M) dbg_dump_clsum((F),(C),(M)) #ifdef NOT_CURRENTLY #define DBG_DUMP_SPTBL(F,C,M) dbg_dump_sptbl((F),(C),(M)) #endif #define DL_TRC 0x01 #define DL_INFO 0x02 extern int _dbg_lvl_; #define DBG_FUNC(N) char __FKT__[] = {N}; #define DBG_ENTER if(_dbg_lvl_ & DL_TRC) { \ fprintf(stderr, "~>%s: %s\n", __FILE__, __FKT__ ); \ } #define DBG_LEAVE if(_dbg_lvl_ & DL_TRC) { \ fprintf(stderr, "~<%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ } #define DBG_TRC if(_dbg_lvl_ & DL_TRC) { \ fprintf(stderr, "~=%s[%d]: %s\n", __FILE__, __LINE__, __FKT__ ); \ } #define DBG_PRINT0(A) if(_dbg_lvl_ & DL_INFO) { \ fprintf(stderr, "~ %s", (A)); \ } #define DBG_PRINT1(A,B) if(_dbg_lvl_ & DL_INFO) { \ fprintf(stderr, "~ "); \ fprintf(stderr, (A), (B)); \ } #define DBG_PRINT2(A,B,C) if(_dbg_lvl_ & DL_INFO) { \ fprintf(stderr, "~ "); \ fprintf(stderr, (A), (B), (C)); \ } #define DBG_PRINT3(A,B,C,D) if(_dbg_lvl_ & DL_INFO) { \ fprintf(stderr, "~ "); \ fprintf(stderr, (A), (B), (C), (D)); \ } #define DBG_PRINT4(A,B,C,D,E) if(_dbg_lvl_ & DL_INFO) { \ fprintf(stderr, "~ "); \ fprintf(stderr, (A), (B), (C), (D), (E)); \ } #else /* not FS_DEBUG */ #define DBG_OPEN(P) #define DBG_CLOSE #define DBG_DUMP_HEX(F,C,M) #define DBG_DUMP_FS(F,C) #define DBG_DUMP_CG(F,C,M) #define DBG_DUMP_CSUM(F,C,M) #define DBG_DUMP_INO(F,C,M) #define DBG_DUMP_IBLK(F,C,M,L) #define DBG_DUMP_INMAP(F,C,M) #define DBG_DUMP_FRMAP(F,C,M) #define DBG_DUMP_CLMAP(F,C,M) #define DBG_DUMP_CLSUM(F,C,M) #define DBG_DUMP_SPTBL(F,C,M) #define DBG_FUNC(N) #define DBG_ENTER #define DBG_TRC #define DBG_LEAVE #define DBG_PRINT0(A) #define DBG_PRINT1(A,B) #define DBG_PRINT2(A,B,C) #define DBG_PRINT3(A,B,C,D) #define DBG_PRINT4(A,B,C,D,E) #endif /* FS_DEBUG */ diff --git a/sbin/init/pathnames.h b/sbin/init/pathnames.h index 7dc75ba52491..e385aed648b4 100644 --- a/sbin/init/pathnames.h +++ b/sbin/init/pathnames.h @@ -1,46 +1,45 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Donn Seeley at Berkeley Software Design, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - * $FreeBSD$ */ #include #define _PATH_INITLOG "/var/log/init.log" #define _PATH_SLOGGER "/sbin/session_logger" #define _PATH_RUNCOM "/etc/rc" #define _PATH_RUNDOWN "/etc/rc.shutdown" #define _PATH_RUNFINAL "/etc/rc.final" #define _PATH_REROOT "/dev/reroot" #define _PATH_REROOT_INIT _PATH_REROOT "/init" diff --git a/sbin/ipf/iplang/iplang_y.y b/sbin/ipf/iplang/iplang_y.y index e6c88ddcd9bc..efddeacbf9c6 100644 --- a/sbin/ipf/iplang/iplang_y.y +++ b/sbin/ipf/iplang/iplang_y.y @@ -1,1757 +1,1756 @@ /* $FreeBSD$ */ %{ /* * Copyright (C) 2012 by Darren Reed. * * See the IPFILTER.LICENCE file for details on licencing. * * Id: iplang_y.y,v 2.9.2.4 2006/03/17 12:11:29 darrenr Exp $ - * $FreeBSD$ */ #include #include #include #if !defined(__SVR4) && !defined(__svr4__) # include #else # include #endif #include #include #include #include #include #include #include #include #include #include #include #include # include # include # include #include #include #include #include #include #include "ipsend.h" #include "ip_compat.h" #include "ipf.h" #include "iplang.h" extern int opts; extern struct ipopt_names ionames[]; extern int state, state, lineNum, token; extern int yylineno; extern char yytext[]; extern FILE *yyin; int yylex __P((void)); #define YYDEBUG 1 int yydebug = 1; iface_t *iflist = NULL, **iftail = &iflist; iface_t *cifp = NULL; arp_t *arplist = NULL, **arptail = &arplist, *carp = NULL; struct in_addr defrouter; send_t sending; char *sclass = NULL; u_short c_chksum(u_short *, u_int, u_long); u_long p_chksum(u_short *, u_int); u_long ipbuffer[67584/sizeof(u_long)]; /* 66K */ aniphdr_t *aniphead = NULL, *canip = NULL, **aniptail = &aniphead; ip_t *ip = NULL; udphdr_t *udp = NULL; tcphdr_t *tcp = NULL; icmphdr_t *icmp = NULL; struct statetoopt { int sto_st; int sto_op; }; struct in_addr getipv4addr(char *arg); u_short getportnum(char *, char *); struct ether_addr *geteaddr(char *, struct ether_addr *); void *new_header(int); void free_aniplist(void); void inc_anipheaders(int); void new_data(void); void set_datalen(char **); void set_datafile(char **); void set_data(char **); void new_packet(void); void set_ipv4proto(char **); void set_ipv4src(char **); void set_ipv4dst(char **); void set_ipv4off(char **); void set_ipv4v(char **); void set_ipv4hl(char **); void set_ipv4ttl(char **); void set_ipv4tos(char **); void set_ipv4id(char **); void set_ipv4sum(char **); void set_ipv4len(char **); void new_tcpheader(void); void set_tcpsport(char **); void set_tcpdport(char **); void set_tcpseq(char **); void set_tcpack(char **); void set_tcpoff(char **); void set_tcpurp(char **); void set_tcpwin(char **); void set_tcpsum(char **); void set_tcpflags(char **); void set_tcpopt(int, char **); void end_tcpopt(void); void new_udpheader(void); void set_udplen(char **); void set_udpsum(char **); void prep_packet(void); void packet_done(void); void new_interface(void); void check_interface(void); void set_ifname(char **); void set_ifmtu(int); void set_ifv4addr(char **); void set_ifeaddr(char **); void new_arp(void); void set_arpeaddr(char **); void set_arpv4addr(char **); void reset_send(void); void set_sendif(char **); void set_sendvia(char **); void set_defaultrouter(char **); void new_icmpheader(void); void set_icmpcode(int); void set_icmptype(int); void set_icmpcodetok(char **); void set_icmptypetok(char **); void set_icmpid(int); void set_icmpseq(int); void set_icmpotime(int); void set_icmprtime(int); void set_icmpttime(int); void set_icmpmtu(int); void set_redir(int, char **); void new_ipv4opt(void); void set_icmppprob(int); void add_ipopt(int, void *); void end_ipopt(void); void set_secclass(char **); void free_anipheader(void); void end_ipv4(void); void end_icmp(void); void end_udp(void); void end_tcp(void); void end_data(void); void yyerror(char *); void iplang(FILE *); int arp_getipv4(char *, char *); int yyparse(void); %} %union { char *str; int num; } %token IL_NUMBER %type number digits optnumber %token IL_TOKEN %type token optoken %token IL_HEXDIGIT IL_COLON IL_DOT IL_EOF IL_COMMENT %token IL_INTERFACE IL_IFNAME IL_MTU IL_EADDR %token IL_IPV4 IL_V4PROTO IL_V4SRC IL_V4DST IL_V4OFF IL_V4V IL_V4HL IL_V4TTL %token IL_V4TOS IL_V4SUM IL_V4LEN IL_V4OPT IL_V4ID %token IL_TCP IL_SPORT IL_DPORT IL_TCPFL IL_TCPSEQ IL_TCPACK IL_TCPOFF %token IL_TCPWIN IL_TCPSUM IL_TCPURP IL_TCPOPT IL_TCPO_NOP IL_TCPO_EOL %token IL_TCPO_MSS IL_TCPO_WSCALE IL_TCPO_TS %token IL_UDP IL_UDPLEN IL_UDPSUM %token IL_ICMP IL_ICMPTYPE IL_ICMPCODE %token IL_SEND IL_VIA %token IL_ARP %token IL_DEFROUTER %token IL_SUM IL_OFF IL_LEN IL_V4ADDR IL_OPT %token IL_DATA IL_DLEN IL_DVALUE IL_DFILE %token IL_IPO_NOP IL_IPO_RR IL_IPO_ZSU IL_IPO_MTUP IL_IPO_MTUR IL_IPO_EOL %token IL_IPO_TS IL_IPO_TR IL_IPO_SEC IL_IPO_LSRR IL_IPO_ESEC %token IL_IPO_SATID IL_IPO_SSRR IL_IPO_ADDEXT IL_IPO_VISA IL_IPO_IMITD %token IL_IPO_EIP IL_IPO_FINN IL_IPO_SECCLASS IL_IPO_CIPSO IL_IPO_ENCODE %token IL_IPS_RESERV4 IL_IPS_TOPSECRET IL_IPS_SECRET IL_IPS_RESERV3 %token IL_IPS_CONFID IL_IPS_UNCLASS IL_IPS_RESERV2 IL_IPS_RESERV1 %token IL_ICMP_ECHOREPLY IL_ICMP_UNREACH IL_ICMP_UNREACH_NET %token IL_ICMP_UNREACH_HOST IL_ICMP_UNREACH_PROTOCOL IL_ICMP_UNREACH_PORT %token IL_ICMP_UNREACH_NEEDFRAG IL_ICMP_UNREACH_SRCFAIL %token IL_ICMP_UNREACH_NET_UNKNOWN IL_ICMP_UNREACH_HOST_UNKNOWN %token IL_ICMP_UNREACH_ISOLATED IL_ICMP_UNREACH_NET_PROHIB %token IL_ICMP_UNREACH_HOST_PROHIB IL_ICMP_UNREACH_TOSNET %token IL_ICMP_UNREACH_TOSHOST IL_ICMP_UNREACH_FILTER_PROHIB %token IL_ICMP_UNREACH_HOST_PRECEDENCE IL_ICMP_UNREACH_PRECEDENCE_CUTOFF %token IL_ICMP_SOURCEQUENCH IL_ICMP_REDIRECT IL_ICMP_REDIRECT_NET %token IL_ICMP_REDIRECT_HOST IL_ICMP_REDIRECT_TOSNET %token IL_ICMP_REDIRECT_TOSHOST IL_ICMP_ECHO IL_ICMP_ROUTERADVERT %token IL_ICMP_ROUTERSOLICIT IL_ICMP_TIMXCEED IL_ICMP_TIMXCEED_INTRANS %token IL_ICMP_TIMXCEED_REASS IL_ICMP_PARAMPROB IL_ICMP_PARAMPROB_OPTABSENT %token IL_ICMP_TSTAMP IL_ICMP_TSTAMPREPLY IL_ICMP_IREQ IL_ICMP_IREQREPLY %token IL_ICMP_MASKREQ IL_ICMP_MASKREPLY IL_ICMP_SEQ IL_ICMP_ID %token IL_ICMP_OTIME IL_ICMP_RTIME IL_ICMP_TTIME %% file: line | line file | IL_COMMENT | IL_COMMENT file ; line: iface | arp | send | defrouter | ipline ; iface: ifhdr '{' ifaceopts '}' ';' { check_interface(); } ; ifhdr: IL_INTERFACE { new_interface(); } ; ifaceopts: ifaceopt | ifaceopt ifaceopts ; ifaceopt: IL_IFNAME token { set_ifname(&$2); } | IL_MTU number { set_ifmtu($2); } | IL_V4ADDR token { set_ifv4addr(&$2); } | IL_EADDR token { set_ifeaddr(&$2); } ; send: sendhdr '{' sendbody '}' ';' { packet_done(); } | sendhdr ';' { packet_done(); } ; sendhdr: IL_SEND { reset_send(); } ; sendbody: sendopt | sendbody sendopt ; sendopt: IL_IFNAME token { set_sendif(&$2); } | IL_VIA token { set_sendvia(&$2); } ; arp: arphdr '{' arpbody '}' ';' ; arphdr: IL_ARP { new_arp(); } ; arpbody: arpopt | arpbody arpopt ; arpopt: IL_V4ADDR token { set_arpv4addr(&$2); } | IL_EADDR token { set_arpeaddr(&$2); } ; defrouter: IL_DEFROUTER token { set_defaultrouter(&$2); } ; bodyline: ipline | tcp tcpline | udp udpline | icmp icmpline | data dataline ; ipline: ipv4 '{' ipv4body '}' ';' { end_ipv4(); } ; ipv4: IL_IPV4 { new_packet(); } ipv4body: ipv4type | ipv4type ipv4body | bodyline ; ipv4type: IL_V4PROTO token { set_ipv4proto(&$2); } | IL_V4SRC token { set_ipv4src(&$2); } | IL_V4DST token { set_ipv4dst(&$2); } | IL_V4OFF token { set_ipv4off(&$2); } | IL_V4V token { set_ipv4v(&$2); } | IL_V4HL token { set_ipv4hl(&$2); } | IL_V4ID token { set_ipv4id(&$2); } | IL_V4TTL token { set_ipv4ttl(&$2); } | IL_V4TOS token { set_ipv4tos(&$2); } | IL_V4SUM token { set_ipv4sum(&$2); } | IL_V4LEN token { set_ipv4len(&$2); } | ipv4opt '{' ipv4optlist '}' ';' { end_ipopt(); } ; tcp: IL_TCP { new_tcpheader(); } ; tcpline: '{' tcpheader '}' ';' { end_tcp(); } ; tcpheader: tcpbody | tcpbody tcpheader | bodyline ; tcpbody: IL_SPORT token { set_tcpsport(&$2); } | IL_DPORT token { set_tcpdport(&$2); } | IL_TCPSEQ token { set_tcpseq(&$2); } | IL_TCPACK token { set_tcpack(&$2); } | IL_TCPOFF token { set_tcpoff(&$2); } | IL_TCPURP token { set_tcpurp(&$2); } | IL_TCPWIN token { set_tcpwin(&$2); } | IL_TCPSUM token { set_tcpsum(&$2); } | IL_TCPFL token { set_tcpflags(&$2); } | IL_TCPOPT '{' tcpopts '}' ';' { end_tcpopt(); } ; tcpopts: | tcpopt tcpopts ; tcpopt: IL_TCPO_NOP ';' { set_tcpopt(IL_TCPO_NOP, NULL); } | IL_TCPO_EOL ';' { set_tcpopt(IL_TCPO_EOL, NULL); } | IL_TCPO_MSS optoken { set_tcpopt(IL_TCPO_MSS,&$2);} | IL_TCPO_WSCALE optoken { set_tcpopt(IL_TCPO_WSCALE,&$2);} | IL_TCPO_TS optoken { set_tcpopt(IL_TCPO_TS, &$2);} ; udp: IL_UDP { new_udpheader(); } ; udpline: '{' udpheader '}' ';' { end_udp(); } ; udpheader: udpbody | udpbody udpheader | bodyline ; udpbody: IL_SPORT token { set_tcpsport(&$2); } | IL_DPORT token { set_tcpdport(&$2); } | IL_UDPLEN token { set_udplen(&$2); } | IL_UDPSUM token { set_udpsum(&$2); } ; icmp: IL_ICMP { new_icmpheader(); } ; icmpline: '{' icmpbody '}' ';' { end_icmp(); } ; icmpbody: icmpheader | icmpheader bodyline ; icmpheader: IL_ICMPTYPE icmptype | IL_ICMPTYPE icmptype icmpcode ; icmpcode: IL_ICMPCODE token { set_icmpcodetok(&$2); } ; icmptype: IL_ICMP_ECHOREPLY ';' { set_icmptype(ICMP_ECHOREPLY); } | IL_ICMP_ECHOREPLY '{' icmpechoopts '}' ';' | unreach | IL_ICMP_SOURCEQUENCH ';' { set_icmptype(ICMP_SOURCEQUENCH); } | redirect | IL_ICMP_ROUTERADVERT ';' { set_icmptype(ICMP_ROUTERADVERT); } | IL_ICMP_ROUTERSOLICIT ';' { set_icmptype(ICMP_ROUTERSOLICIT); } | IL_ICMP_ECHO ';' { set_icmptype(ICMP_ECHO); } | IL_ICMP_ECHO '{' icmpechoopts '}' ';' | IL_ICMP_TIMXCEED ';' { set_icmptype(ICMP_TIMXCEED); } | IL_ICMP_TIMXCEED '{' exceed '}' ';' | IL_ICMP_TSTAMP ';' { set_icmptype(ICMP_TSTAMP); } | IL_ICMP_TSTAMPREPLY ';' { set_icmptype(ICMP_TSTAMPREPLY); } | IL_ICMP_TSTAMPREPLY '{' icmptsopts '}' ';' | IL_ICMP_IREQ ';' { set_icmptype(ICMP_IREQ); } | IL_ICMP_IREQREPLY ';' { set_icmptype(ICMP_IREQREPLY); } | IL_ICMP_IREQREPLY '{' data dataline '}' ';' | IL_ICMP_MASKREQ ';' { set_icmptype(ICMP_MASKREQ); } | IL_ICMP_MASKREPLY ';' { set_icmptype(ICMP_MASKREPLY); } | IL_ICMP_MASKREPLY '{' token '}' ';' | IL_ICMP_PARAMPROB ';' { set_icmptype(ICMP_PARAMPROB); } | IL_ICMP_PARAMPROB '{' paramprob '}' ';' | IL_TOKEN ';' { set_icmptypetok(&$1); } ; icmpechoopts: | icmpechoopts icmpecho ; icmpecho: IL_ICMP_SEQ number { set_icmpseq($2); } | IL_ICMP_ID number { set_icmpid($2); } ; icmptsopts: | icmptsopts icmpts ';' ; icmpts: IL_ICMP_OTIME number { set_icmpotime($2); } | IL_ICMP_RTIME number { set_icmprtime($2); } | IL_ICMP_TTIME number { set_icmpttime($2); } ; unreach: IL_ICMP_UNREACH | IL_ICMP_UNREACH '{' unreachopts '}' ';' ; unreachopts: IL_ICMP_UNREACH_NET line | IL_ICMP_UNREACH_HOST line | IL_ICMP_UNREACH_PROTOCOL line | IL_ICMP_UNREACH_PORT line | IL_ICMP_UNREACH_NEEDFRAG number ';' { set_icmpmtu($2); } | IL_ICMP_UNREACH_SRCFAIL line | IL_ICMP_UNREACH_NET_UNKNOWN line | IL_ICMP_UNREACH_HOST_UNKNOWN line | IL_ICMP_UNREACH_ISOLATED line | IL_ICMP_UNREACH_NET_PROHIB line | IL_ICMP_UNREACH_HOST_PROHIB line | IL_ICMP_UNREACH_TOSNET line | IL_ICMP_UNREACH_TOSHOST line | IL_ICMP_UNREACH_FILTER_PROHIB line | IL_ICMP_UNREACH_HOST_PRECEDENCE line | IL_ICMP_UNREACH_PRECEDENCE_CUTOFF line ; redirect: IL_ICMP_REDIRECT | IL_ICMP_REDIRECT '{' redirectopts '}' ';' ; redirectopts: | IL_ICMP_REDIRECT_NET token { set_redir(0, &$2); } | IL_ICMP_REDIRECT_HOST token { set_redir(1, &$2); } | IL_ICMP_REDIRECT_TOSNET token { set_redir(2, &$2); } | IL_ICMP_REDIRECT_TOSHOST token { set_redir(3, &$2); } ; exceed: IL_ICMP_TIMXCEED_INTRANS line | IL_ICMP_TIMXCEED_REASS line ; paramprob: IL_ICMP_PARAMPROB_OPTABSENT | IL_ICMP_PARAMPROB_OPTABSENT paraprobarg paraprobarg: '{' number '}' ';' { set_icmppprob($2); } ; ipv4opt: IL_V4OPT { new_ipv4opt(); } ; ipv4optlist: | ipv4opts ipv4optlist ; ipv4opts: IL_IPO_NOP ';' { add_ipopt(IL_IPO_NOP, NULL); } | IL_IPO_RR optnumber { add_ipopt(IL_IPO_RR, &$2); } | IL_IPO_ZSU ';' { add_ipopt(IL_IPO_ZSU, NULL); } | IL_IPO_MTUP ';' { add_ipopt(IL_IPO_MTUP, NULL); } | IL_IPO_MTUR ';' { add_ipopt(IL_IPO_MTUR, NULL); } | IL_IPO_ENCODE ';' { add_ipopt(IL_IPO_ENCODE, NULL); } | IL_IPO_TS ';' { add_ipopt(IL_IPO_TS, NULL); } | IL_IPO_TR ';' { add_ipopt(IL_IPO_TR, NULL); } | IL_IPO_SEC ';' { add_ipopt(IL_IPO_SEC, NULL); } | IL_IPO_SECCLASS secclass { add_ipopt(IL_IPO_SECCLASS, sclass); } | IL_IPO_LSRR token { add_ipopt(IL_IPO_LSRR,&$2); } | IL_IPO_ESEC ';' { add_ipopt(IL_IPO_ESEC, NULL); } | IL_IPO_CIPSO ';' { add_ipopt(IL_IPO_CIPSO, NULL); } | IL_IPO_SATID optnumber { add_ipopt(IL_IPO_SATID,&$2);} | IL_IPO_SSRR token { add_ipopt(IL_IPO_SSRR,&$2); } | IL_IPO_ADDEXT ';' { add_ipopt(IL_IPO_ADDEXT, NULL); } | IL_IPO_VISA ';' { add_ipopt(IL_IPO_VISA, NULL); } | IL_IPO_IMITD ';' { add_ipopt(IL_IPO_IMITD, NULL); } | IL_IPO_EIP ';' { add_ipopt(IL_IPO_EIP, NULL); } | IL_IPO_FINN ';' { add_ipopt(IL_IPO_FINN, NULL); } ; secclass: IL_IPS_RESERV4 ';' { set_secclass(&$1); } | IL_IPS_TOPSECRET ';' { set_secclass(&$1); } | IL_IPS_SECRET ';' { set_secclass(&$1); } | IL_IPS_RESERV3 ';' { set_secclass(&$1); } | IL_IPS_CONFID ';' { set_secclass(&$1); } | IL_IPS_UNCLASS ';' { set_secclass(&$1); } | IL_IPS_RESERV2 ';' { set_secclass(&$1); } | IL_IPS_RESERV1 ';' { set_secclass(&$1); } ; data: IL_DATA { new_data(); } ; dataline: '{' databody '}' ';' { end_data(); } ; databody: dataopts | dataopts databody ; dataopts: IL_DLEN token { set_datalen(&$2); } | IL_DVALUE token { set_data(&$2); } | IL_DFILE token { set_datafile(&$2); } ; token: IL_TOKEN ';' ; optoken: ';' { $$ = ""; } | token ; number: digits ';' ; optnumber: ';' { $$ = 0; } | number ; digits: IL_NUMBER | digits IL_NUMBER ; %% struct statetoopt toipopts[] = { { IL_IPO_NOP, IPOPT_NOP }, { IL_IPO_RR, IPOPT_RR }, { IL_IPO_ZSU, IPOPT_ZSU }, { IL_IPO_MTUP, IPOPT_MTUP }, { IL_IPO_MTUR, IPOPT_MTUR }, { IL_IPO_ENCODE, IPOPT_ENCODE }, { IL_IPO_TS, IPOPT_TS }, { IL_IPO_TR, IPOPT_TR }, { IL_IPO_SEC, IPOPT_SECURITY }, { IL_IPO_SECCLASS, IPOPT_SECURITY }, { IL_IPO_LSRR, IPOPT_LSRR }, { IL_IPO_ESEC, IPOPT_E_SEC }, { IL_IPO_CIPSO, IPOPT_CIPSO }, { IL_IPO_SATID, IPOPT_SATID }, { IL_IPO_SSRR, IPOPT_SSRR }, { IL_IPO_ADDEXT, IPOPT_ADDEXT }, { IL_IPO_VISA, IPOPT_VISA }, { IL_IPO_IMITD, IPOPT_IMITD }, { IL_IPO_EIP, IPOPT_EIP }, { IL_IPO_FINN, IPOPT_FINN }, { 0, 0 } }; struct statetoopt tosecopts[] = { { IL_IPS_RESERV4, IPSO_CLASS_RES4 }, { IL_IPS_TOPSECRET, IPSO_CLASS_TOPS }, { IL_IPS_SECRET, IPSO_CLASS_SECR }, { IL_IPS_RESERV3, IPSO_CLASS_RES3 }, { IL_IPS_CONFID, IPSO_CLASS_CONF }, { IL_IPS_UNCLASS, IPSO_CLASS_UNCL }, { IL_IPS_RESERV2, IPSO_CLASS_RES2 }, { IL_IPS_RESERV1, IPSO_CLASS_RES1 }, { 0, 0 } }; struct in_addr getipv4addr(arg) char *arg; { struct hostent *hp; struct in_addr in; in.s_addr = 0xffffffff; if ((hp = gethostbyname(arg))) bcopy(hp->h_addr, &in.s_addr, sizeof(struct in_addr)); else in.s_addr = inet_addr(arg); return(in); } u_short getportnum(pr, name) char *pr, *name; { struct servent *sp; if (!(sp = getservbyname(name, pr))) return(htons(atoi(name))); return(sp->s_port); } struct ether_addr *geteaddr(char *arg, struct ether_addr *buf) { struct ether_addr *e; e = ether_aton(arg); if (!e) fprintf(stderr, "Invalid ethernet address: %s\n", arg); else # ifdef __FreeBSD__ bcopy(e->octet, buf->octet, sizeof(e->octet)); # else bcopy(e->ether_addr_octet, buf->ether_addr_octet, sizeof(e->ether_addr_octet)); # endif return(e); } void *new_header(int type) { aniphdr_t *aip, *oip = canip; int sz = 0; aip = (aniphdr_t *)calloc(1, sizeof(*aip)); *aniptail = aip; aniptail = &aip->ah_next; aip->ah_p = type; aip->ah_prev = oip; canip = aip; if (type == IPPROTO_UDP) sz = sizeof(udphdr_t); else if (type == IPPROTO_TCP) sz = sizeof(tcphdr_t); else if (type == IPPROTO_ICMP) sz = sizeof(icmphdr_t); else if (type == IPPROTO_IP) sz = sizeof(ip_t); if (oip) canip->ah_data = oip->ah_data + oip->ah_len; else canip->ah_data = (char *)ipbuffer; /* * Increase the size fields in all wrapping headers. */ for (aip = aniphead; aip; aip = aip->ah_next) { aip->ah_len += sz; if (aip->ah_p == IPPROTO_IP) aip->ah_ip->ip_len += sz; else if (aip->ah_p == IPPROTO_UDP) aip->ah_udp->uh_ulen += sz; } return(void *)canip->ah_data; } void free_aniplist(void) { aniphdr_t *aip, **aipp = &aniphead; while ((aip = *aipp)) { *aipp = aip->ah_next; free(aip); } aniptail = &aniphead; } void inc_anipheaders(int inc) { aniphdr_t *aip; for (aip = aniphead; aip; aip = aip->ah_next) { aip->ah_len += inc; if (aip->ah_p == IPPROTO_IP) aip->ah_ip->ip_len += inc; else if (aip->ah_p == IPPROTO_UDP) aip->ah_udp->uh_ulen += inc; } } void new_data(void) { (void) new_header(-1); canip->ah_len = 0; } void set_datalen(char **arg) { int len; len = strtol(*arg, NULL, 0); inc_anipheaders(len); free(*arg); *arg = NULL; } void set_data(char **arg) { u_char *s = (u_char *)*arg, *t = (u_char *)canip->ah_data, c; int len = 0, todo = 0, quote = 0, val = 0; while ((c = *s++)) { if (todo) { if (ISDIGIT(c)) { todo--; if (c > '7') { fprintf(stderr, "octal with %c!\n", c); break; } val <<= 3; val |= (c - '0'); } if (!ISDIGIT(c) || !todo) { *t++ = (u_char)(val & 0xff); todo = 0; } if (todo) continue; } if (quote) { if (ISDIGIT(c)) { todo = 2; if (c > '7') { fprintf(stderr, "octal with %c!\n", c); break; } val = (c - '0'); } else { switch (c) { case '\"' : *t++ = '\"'; break; case '\\' : *t++ = '\\'; break; case 'n' : *t++ = '\n'; break; case 'r' : *t++ = '\r'; break; case 't' : *t++ = '\t'; break; } } quote = 0; continue; } if (c == '\\') quote = 1; else *t++ = c; } if (todo) *t++ = (u_char)(val & 0xff); if (quote) *t++ = '\\'; len = t - (u_char *)canip->ah_data; inc_anipheaders(len - canip->ah_len); canip->ah_len = len; } void set_datafile(char **arg) { struct stat sb; char *file = *arg; int fd, len; if ((fd = open(file, O_RDONLY)) == -1) { perror("open"); exit(-1); } if (fstat(fd, &sb) == -1) { perror("fstat"); exit(-1); } if ((sb.st_size + aniphead->ah_len ) > 65535) { fprintf(stderr, "data file %s too big to include.\n", file); close(fd); return; } if ((len = read(fd, canip->ah_data, sb.st_size)) == -1) { perror("read"); close(fd); return; } inc_anipheaders(len); canip->ah_len += len; close(fd); } void new_packet(void) { static u_short id = 0; if (!aniphead) bzero((char *)ipbuffer, sizeof(ipbuffer)); ip = (ip_t *)new_header(IPPROTO_IP); ip->ip_v = IPVERSION; ip->ip_hl = sizeof(ip_t) >> 2; ip->ip_len = sizeof(ip_t); ip->ip_ttl = 63; ip->ip_id = htons(id++); } void set_ipv4proto(arg) char **arg; { struct protoent *pr; if ((pr = getprotobyname(*arg))) ip->ip_p = pr->p_proto; else if (!(ip->ip_p = atoi(*arg))) fprintf(stderr, "unknown protocol %s\n", *arg); free(*arg); *arg = NULL; } void set_ipv4src(char **arg) { ip->ip_src = getipv4addr(*arg); free(*arg); *arg = NULL; } void set_ipv4dst(char **arg) { ip->ip_dst = getipv4addr(*arg); free(*arg); *arg = NULL; } void set_ipv4off(char **arg) { ip->ip_off = htons(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_ipv4v(char **arg) { ip->ip_v = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void set_ipv4hl(char **arg) { int newhl, inc; newhl = strtol(*arg, NULL, 0); inc = (newhl - ip->ip_hl) << 2; ip->ip_len += inc; ip->ip_hl = newhl; canip->ah_len += inc; free(*arg); *arg = NULL; } void set_ipv4ttl(char **arg) { ip->ip_ttl = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void set_ipv4tos(char **arg) { ip->ip_tos = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void set_ipv4id(char **arg) { ip->ip_id = htons(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_ipv4sum(char **arg) { ip->ip_sum = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void set_ipv4len(char **arg) { int len; len = strtol(*arg, NULL, 0); inc_anipheaders(len - ip->ip_len); ip->ip_len = len; free(*arg); *arg = NULL; } void new_tcpheader(void) { if ((ip->ip_p) && (ip->ip_p != IPPROTO_TCP)) { fprintf(stderr, "protocol %d specified with TCP!\n", ip->ip_p); return; } ip->ip_p = IPPROTO_TCP; tcp = (tcphdr_t *)new_header(IPPROTO_TCP); tcp->th_win = htons(4096); tcp->th_off = sizeof(*tcp) >> 2; } void set_tcpsport(char **arg) { u_short *port; char *pr; if (ip->ip_p == IPPROTO_UDP) { port = &udp->uh_sport; pr = "udp"; } else { port = &tcp->th_sport; pr = "udp"; } *port = getportnum(pr, *arg); free(*arg); *arg = NULL; } void set_tcpdport(char **arg) { u_short *port; char *pr; if (ip->ip_p == IPPROTO_UDP) { port = &udp->uh_dport; pr = "udp"; } else { port = &tcp->th_dport; pr = "udp"; } *port = getportnum(pr, *arg); free(*arg); *arg = NULL; } void set_tcpseq(char **arg) { tcp->th_seq = htonl(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_tcpack(char **arg) { tcp->th_ack = htonl(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_tcpoff(char **arg) { int off; off = strtol(*arg, NULL, 0); inc_anipheaders((off - tcp->th_off) << 2); tcp->th_off = off; free(*arg); *arg = NULL; } void set_tcpurp(char **arg) { tcp->th_urp = htons(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_tcpwin(char **arg) { tcp->th_win = htons(strtol(*arg, NULL, 0)); free(*arg); *arg = NULL; } void set_tcpsum(char **arg) { tcp->th_sum = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void set_tcpflags(char **arg) { static char flags[] = "ASURPF"; static int flagv[] = { TH_ACK, TH_SYN, TH_URG, TH_RST, TH_PUSH, TH_FIN } ; char *s, *t; for (s = *arg; *s; s++) if (!(t = strchr(flags, *s))) { if (s - *arg) { fprintf(stderr, "unknown TCP flag %c\n", *s); break; } tcp->th_flags = strtol(*arg, NULL, 0); break; } else tcp->th_flags |= flagv[t - flags]; free(*arg); *arg = NULL; } void set_tcpopt(int state, char **arg) { u_char *s; int val, len, val2, pad, optval; if (arg && *arg) val = atoi(*arg); else val = 0; s = (u_char *)tcp + sizeof(*tcp) + canip->ah_optlen; switch (state) { case IL_TCPO_EOL : optval = 0; len = 1; break; case IL_TCPO_NOP : optval = 1; len = 1; break; case IL_TCPO_MSS : optval = 2; len = 4; break; case IL_TCPO_WSCALE : optval = 3; len = 3; break; case IL_TCPO_TS : optval = 8; len = 10; break; default : optval = 0; len = 0; break; } if (len > 1) { /* * prepend padding - if required. */ if (len & 3) for (pad = 4 - (len & 3); pad; pad--) { *s++ = 1; canip->ah_optlen++; } /* * build tcp option */ *s++ = (u_char)optval; *s++ = (u_char)len; if (len > 2) { if (len == 3) { /* 1 byte - char */ *s++ = (u_char)val; } else if (len == 4) { /* 2 bytes - short */ *s++ = (u_char)((val >> 8) & 0xff); *s++ = (u_char)(val & 0xff); } else if (len >= 6) { /* 4 bytes - long */ val2 = htonl(val); bcopy((char *)&val2, s, 4); } s += (len - 2); } } else *s++ = (u_char)optval; canip->ah_lastopt = optval; canip->ah_optlen += len; if (arg && *arg) { free(*arg); *arg = NULL; } } void end_tcpopt(void) { int pad; char *s = (char *)tcp; s += sizeof(*tcp) + canip->ah_optlen; /* * pad out so that we have a multiple of 4 bytes in size fo the * options. make sure last byte is EOL. */ if (canip->ah_optlen & 3) { if (canip->ah_lastopt != 1) { for (pad = 3 - (canip->ah_optlen & 3); pad; pad--) { *s++ = 1; canip->ah_optlen++; } canip->ah_optlen++; } else { s -= 1; for (pad = 3 - (canip->ah_optlen & 3); pad; pad--) { *s++ = 1; canip->ah_optlen++; } } *s++ = 0; } tcp->th_off = (sizeof(*tcp) + canip->ah_optlen) >> 2; inc_anipheaders(canip->ah_optlen); } void new_udpheader(void) { if ((ip->ip_p) && (ip->ip_p != IPPROTO_UDP)) { fprintf(stderr, "protocol %d specified with UDP!\n", ip->ip_p); return; } ip->ip_p = IPPROTO_UDP; udp = (udphdr_t *)new_header(IPPROTO_UDP); udp->uh_ulen = sizeof(*udp); } void set_udplen(arg) char **arg; { int len; len = strtol(*arg, NULL, 0); inc_anipheaders(len - udp->uh_ulen); udp->uh_ulen = len; free(*arg); *arg = NULL; } void set_udpsum(char **arg) { udp->uh_sum = strtol(*arg, NULL, 0); free(*arg); *arg = NULL; } void prep_packet(void) { iface_t *ifp; struct in_addr gwip; ifp = sending.snd_if; if (!ifp) { fprintf(stderr, "no interface defined for sending!\n"); return; } if (ifp->if_fd == -1) ifp->if_fd = initdevice(ifp->if_name, 5); gwip = sending.snd_gw; if (!gwip.s_addr) { if (aniphead == NULL) { fprintf(stderr, "no destination address defined for sending\n"); return; } gwip = aniphead->ah_ip->ip_dst; } (void) send_ip(ifp->if_fd, ifp->if_MTU, (ip_t *)ipbuffer, gwip, 2); } void packet_done(void) { char outline[80]; int i, j, k; u_char *s = (u_char *)ipbuffer, *t = (u_char *)outline; if (opts & OPT_VERBOSE) { ip->ip_len = htons(ip->ip_len); for (i = ntohs(ip->ip_len), j = 0; i; i--, j++, s++) { if (j && !(j & 0xf)) { *t++ = '\n'; *t = '\0'; fputs(outline, stdout); fflush(stdout); t = (u_char *)outline; *t = '\0'; } sprintf((char *)t, "%02x", *s & 0xff); t += 2; if (!((j + 1) & 0xf)) { s -= 15; sprintf((char *)t, " "); t += 8; for (k = 16; k; k--, s++) *t++ = (isprint(*s) ? *s : '.'); s--; } if ((j + 1) & 0xf) *t++ = ' ';; } if (j & 0xf) { for (k = 16 - (j & 0xf); k; k--) { *t++ = ' '; *t++ = ' '; *t++ = ' '; } sprintf((char *)t, " "); t += 7; s -= j & 0xf; for (k = j & 0xf; k; k--, s++) *t++ = (isprint(*s) ? *s : '.'); *t++ = '\n'; *t = '\0'; } fputs(outline, stdout); fflush(stdout); ip->ip_len = ntohs(ip->ip_len); } prep_packet(); free_aniplist(); } void new_interface(void) { cifp = (iface_t *)calloc(1, sizeof(iface_t)); *iftail = cifp; iftail = &cifp->if_next; cifp->if_fd = -1; } void check_interface(void) { if (!cifp->if_name || !*cifp->if_name) fprintf(stderr, "No interface name given!\n"); if (!cifp->if_MTU || !*cifp->if_name) fprintf(stderr, "Interface %s has an MTU of 0!\n", cifp->if_name); } void set_ifname(char **arg) { cifp->if_name = *arg; *arg = NULL; } void set_ifmtu(int arg) { cifp->if_MTU = arg; } void set_ifv4addr(char **arg) { cifp->if_addr = getipv4addr(*arg); free(*arg); *arg = NULL; } void set_ifeaddr(char **arg) { (void) geteaddr(*arg, &cifp->if_eaddr); free(*arg); *arg = NULL; } void new_arp(void) { carp = (arp_t *)calloc(1, sizeof(arp_t)); *arptail = carp; arptail = &carp->arp_next; } void set_arpeaddr(char **arg) { (void) geteaddr(*arg, &carp->arp_eaddr); free(*arg); *arg = NULL; } void set_arpv4addr(char **arg) { carp->arp_addr = getipv4addr(*arg); free(*arg); *arg = NULL; } int arp_getipv4(char *ip, char *addr) { arp_t *a; for (a = arplist; a; a = a->arp_next) if (!bcmp(ip, (char *)&a->arp_addr, 4)) { bcopy((char *)&a->arp_eaddr, addr, 6); return(0); } return(-1); } void reset_send(void) { sending.snd_if = iflist; sending.snd_gw = defrouter; } void set_sendif(char **arg) { iface_t *ifp; for (ifp = iflist; ifp; ifp = ifp->if_next) if (ifp->if_name && !strcmp(ifp->if_name, *arg)) break; sending.snd_if = ifp; if (!ifp) fprintf(stderr, "couldn't find interface %s\n", *arg); free(*arg); *arg = NULL; } void set_sendvia(char **arg) { sending.snd_gw = getipv4addr(*arg); free(*arg); *arg = NULL; } void set_defaultrouter(char **arg) { defrouter = getipv4addr(*arg); free(*arg); *arg = NULL; } void new_icmpheader(void) { if ((ip->ip_p) && (ip->ip_p != IPPROTO_ICMP)) { fprintf(stderr, "protocol %d specified with ICMP!\n", ip->ip_p); return; } ip->ip_p = IPPROTO_ICMP; icmp = (icmphdr_t *)new_header(IPPROTO_ICMP); } void set_icmpcode(int code) { icmp->icmp_code = code; } void set_icmptype(int type) { icmp->icmp_type = type; } void set_icmpcodetok(char **code) { char *s; int i; for (i = 0; (s = icmpcodes[i]); i++) if (!strcmp(s, *code)) { icmp->icmp_code = i; break; } if (!s) fprintf(stderr, "unknown ICMP code %s\n", *code); free(*code); *code = NULL; } void set_icmptypetok(char **type) { char *s; int i, done = 0; for (i = 0; !(s = icmptypes[i]) || strcmp(s, "END"); i++) if (s && !strcmp(s, *type)) { icmp->icmp_type = i; done = 1; break; } if (!done) fprintf(stderr, "unknown ICMP type %s\n", *type); free(*type); *type = NULL; } void set_icmpid(int arg) { icmp->icmp_id = htons(arg); } void set_icmpseq(int arg) { icmp->icmp_seq = htons(arg); } void set_icmpotime(int arg) { icmp->icmp_otime = htonl(arg); } void set_icmprtime(int arg) { icmp->icmp_rtime = htonl(arg); } void set_icmpttime(int arg) { icmp->icmp_ttime = htonl(arg); } void set_icmpmtu(int arg) { icmp->icmp_nextmtu = htons(arg); } void set_redir(int redir, char **arg) { icmp->icmp_code = redir; icmp->icmp_gwaddr = getipv4addr(*arg); free(*arg); *arg = NULL; } void set_icmppprob(int num) { icmp->icmp_pptr = num; } void new_ipv4opt(void) { new_header(-2); } void add_ipopt(int state, void *ptr) { struct ipopt_names *io; struct statetoopt *sto; char numbuf[16], *arg, **param = ptr; int inc, hlen; if (state == IL_IPO_RR || state == IL_IPO_SATID) { if (param) snprintf(numbuf, sizeof(numbuf), "%d", *(int *)param); else strcpy(numbuf, "0"); arg = numbuf; } else arg = param ? *param : NULL; if (canip->ah_next) { fprintf(stderr, "cannot specify options after data body\n"); return; } for (sto = toipopts; sto->sto_st; sto++) if (sto->sto_st == state) break; if (!sto->sto_st) { fprintf(stderr, "No mapping for state %d to IP option\n", state); return; } hlen = sizeof(ip_t) + canip->ah_optlen; for (io = ionames; io->on_name; io++) if (io->on_value == sto->sto_op) break; canip->ah_lastopt = io->on_value; if (io->on_name) { inc = addipopt((char *)ip + hlen, io, hlen - sizeof(ip_t),arg); if (inc > 0) { while (inc & 3) { ((char *)ip)[sizeof(*ip) + inc] = IPOPT_NOP; canip->ah_lastopt = IPOPT_NOP; inc++; } hlen += inc; } } canip->ah_optlen = hlen - sizeof(ip_t); if (state != IL_IPO_RR && state != IL_IPO_SATID) if (param && *param) { free(*param); *param = NULL; } sclass = NULL; } void end_ipopt(void) { int pad; char *s, *buf = (char *)ip; /* * pad out so that we have a multiple of 4 bytes in size fo the * options. make sure last byte is EOL. */ if (canip->ah_lastopt == IPOPT_NOP) { buf[sizeof(*ip) + canip->ah_optlen - 1] = IPOPT_EOL; } else if (canip->ah_lastopt != IPOPT_EOL) { s = buf + sizeof(*ip) + canip->ah_optlen; for (pad = 3 - (canip->ah_optlen & 3); pad; pad--) { *s++ = IPOPT_NOP; *s = IPOPT_EOL; canip->ah_optlen++; } canip->ah_optlen++; } else { s = buf + sizeof(*ip) + canip->ah_optlen - 1; for (pad = 3 - (canip->ah_optlen & 3); pad; pad--) { *s++ = IPOPT_NOP; *s = IPOPT_EOL; canip->ah_optlen++; } } ip->ip_hl = (sizeof(*ip) + canip->ah_optlen) >> 2; inc_anipheaders(canip->ah_optlen); free_anipheader(); } void set_secclass(char **arg) { sclass = *arg; *arg = NULL; } void free_anipheader(void) { aniphdr_t *aip; aip = canip; if ((canip = aip->ah_prev)) { canip->ah_next = NULL; aniptail = &canip->ah_next; } if (canip) free(aip); } void end_ipv4(void) { aniphdr_t *aip; ip->ip_sum = 0; ip->ip_len = htons(ip->ip_len); ip->ip_sum = chksum((u_short *)ip, ip->ip_hl << 2); ip->ip_len = ntohs(ip->ip_len); free_anipheader(); for (aip = aniphead, ip = NULL; aip; aip = aip->ah_next) if (aip->ah_p == IPPROTO_IP) ip = aip->ah_ip; } void end_icmp(void) { aniphdr_t *aip; icmp->icmp_cksum = 0; icmp->icmp_cksum = chksum((u_short *)icmp, canip->ah_len); free_anipheader(); for (aip = aniphead, icmp = NULL; aip; aip = aip->ah_next) if (aip->ah_p == IPPROTO_ICMP) icmp = aip->ah_icmp; } void end_udp(void) { u_long sum; aniphdr_t *aip; ip_t iptmp; bzero((char *)&iptmp, sizeof(iptmp)); iptmp.ip_p = ip->ip_p; iptmp.ip_src = ip->ip_src; iptmp.ip_dst = ip->ip_dst; iptmp.ip_len = htons(ip->ip_len - (ip->ip_hl << 2)); sum = p_chksum((u_short *)&iptmp, (u_int)sizeof(iptmp)); udp->uh_ulen = htons(udp->uh_ulen); udp->uh_sum = c_chksum((u_short *)udp, (u_int)ntohs(iptmp.ip_len), sum); free_anipheader(); for (aip = aniphead, udp = NULL; aip; aip = aip->ah_next) if (aip->ah_p == IPPROTO_UDP) udp = aip->ah_udp; } void end_tcp(void) { u_long sum; aniphdr_t *aip; ip_t iptmp; bzero((char *)&iptmp, sizeof(iptmp)); iptmp.ip_p = ip->ip_p; iptmp.ip_src = ip->ip_src; iptmp.ip_dst = ip->ip_dst; iptmp.ip_len = htons(ip->ip_len - (ip->ip_hl << 2)); sum = p_chksum((u_short *)&iptmp, (u_int)sizeof(iptmp)); tcp->th_sum = 0; tcp->th_sum = c_chksum((u_short *)tcp, (u_int)ntohs(iptmp.ip_len), sum); free_anipheader(); for (aip = aniphead, tcp = NULL; aip; aip = aip->ah_next) if (aip->ah_p == IPPROTO_TCP) tcp = aip->ah_tcp; } void end_data(void) { free_anipheader(); } void iplang(FILE *fp) { yyin = fp; yydebug = (opts & OPT_DEBUG) ? 1 : 0; while (!feof(fp)) yyparse(); } u_short c_chksum(u_short *buf, u_int len, u_long init) { u_long sum = init; int nwords = len >> 1; for(; nwords > 0; nwords--) sum += *buf++; sum = (sum>>16) + (sum & 0xffff); sum += (sum >>16); return(~sum); } u_long p_chksum(u_short *buf, u_int len) { u_long sum = 0; int nwords = len >> 1; for(; nwords > 0; nwords--) sum += *buf++; return(sum); } diff --git a/sbin/mount/mntopts.h b/sbin/mount/mntopts.h index 3488d34fe96c..21d4965ea39b 100644 --- a/sbin/mount/mntopts.h +++ b/sbin/mount/mntopts.h @@ -1,112 +1,111 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mntopts.h 8.7 (Berkeley) 3/29/95 - * $FreeBSD$ */ struct mntopt { const char *m_option; /* option name */ int m_inverse; /* if a negative option, e.g. "atime" */ long long m_flag; /* bit to set, e.g. MNT_RDONLY */ int m_altloc; /* 1 => set bit in altflags */ }; /* User-visible MNT_ flags. */ #define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 } #define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 } #define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 } #define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 } #define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 } #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 } #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 } #define MOPT_UNION { "union", 0, MNT_UNION, 0 } #define MOPT_USERQUOTA { "userquota", 0, 0, 0 } #define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 } #define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 } #define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 } #define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 } #define MOPT_SNAPSHOT { "snapshot", 0, MNT_SNAPSHOT, 0 } #define MOPT_MULTILABEL { "multilabel", 0, MNT_MULTILABEL, 0 } #define MOPT_ACLS { "acls", 0, MNT_ACLS, 0 } #define MOPT_NFS4ACLS { "nfsv4acls", 0, MNT_NFS4ACLS, 0 } #define MOPT_AUTOMOUNTED { "automounted",0, MNT_AUTOMOUNTED, 0 } #define MOPT_UNTRUSTED { "untrusted", 0, MNT_UNTRUSTED, 0 } /* Control flags. */ #define MOPT_FORCE { "force", 0, MNT_FORCE, 0 } #define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 } #define MOPT_RO { "ro", 0, MNT_RDONLY, 0 } #define MOPT_RW { "rw", 1, MNT_RDONLY, 0 } #define MOPT_NOCOVER { "cover", 1, MNT_NOCOVER, 0 } #define MOPT_EMPTYDIR { "emptydir", 0, MNT_EMPTYDIR, 0 } /* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */ #define MOPT_AUTO { "auto", 0, 0, 0 } /* A handy macro as terminator of MNT_ array. */ #define MOPT_END { NULL, 0, 0, 0 } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ MOPT_AUTO /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_USERQUOTA, \ MOPT_GROUPQUOTA, \ MOPT_FSTAB_COMPAT, \ MOPT_NOATIME, \ MOPT_NOEXEC, \ MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \ MOPT_NOSUID, \ MOPT_NOSYMFOLLOW, \ MOPT_RDONLY, \ MOPT_UNION, \ MOPT_NOCLUSTERR, \ MOPT_NOCLUSTERW, \ MOPT_MULTILABEL, \ MOPT_ACLS, \ MOPT_NFS4ACLS, \ MOPT_AUTOMOUNTED, \ MOPT_UNTRUSTED, \ MOPT_NOCOVER, \ MOPT_EMPTYDIR void getmntopts(const char *, const struct mntopt *, int *, int *); void rmslashes(char *, char *); int checkpath(const char *, char resolved_path[]); int checkpath_allow_file(const char *, char resolved_path[]); struct statfs *getmntpoint(const char *); int chkdoreload(struct statfs *, void (*)(const char *, ...) __printflike(1,2)); extern int getmnt_silent; void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, size_t len); void build_iovec_argf(struct iovec **iov, int *iovlen, const char *name, const char *fmt, ...); void free_iovec(struct iovec **iovec, int *iovlen); diff --git a/sbin/mount/pathnames.h b/sbin/mount/pathnames.h index 7dfb3f1a30e0..f584d7ce9f12 100644 --- a/sbin/mount/pathnames.h +++ b/sbin/mount/pathnames.h @@ -1,35 +1,34 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.2 (Berkeley) 3/27/94 - * $FreeBSD$ */ #define _PATH_MOUNTDPID "/var/run/mountd.pid" diff --git a/sbin/rcorder/sprite.h b/sbin/rcorder/sprite.h index e311ee6e0f66..29b25b0ba263 100644 --- a/sbin/rcorder/sprite.h +++ b/sbin/rcorder/sprite.h @@ -1,116 +1,115 @@ /* $NetBSD: sprite.h,v 1.1 1999/11/23 05:28:22 mrg Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1988, 1989, 1990, 1993 * The Regents of the University of California. All rights reserved. * Copyright (c) 1989 by Berkeley Softworks * All rights reserved. * * This code is derived from software contributed to Berkeley by * Adam de Boor. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: @(#)sprite.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * sprite.h -- * * Common constants and type declarations for Sprite. */ #ifndef _SPRITE #define _SPRITE /* * A boolean type is defined as an integer, not an enum. This allows a * boolean argument to be an expression that isn't strictly 0 or 1 valued. */ typedef int Boolean; #ifndef TRUE #define TRUE 1 #endif /* TRUE */ #ifndef FALSE #define FALSE 0 #endif /* FALSE */ /* * Functions that must return a status can return a ReturnStatus to * indicate success or type of failure. */ typedef int ReturnStatus; /* * The following statuses overlap with the first 2 generic statuses * defined in status.h: * * SUCCESS There was no error. * FAILURE There was a general error. */ #define SUCCESS 0x00000000 #define FAILURE 0x00000001 /* * A nil pointer must be something that will cause an exception if * referenced. There are two nils: the kernels nil and the nil used * by user processes. */ #define NIL ~0 #define USER_NIL 0 #ifndef NULL #define NULL 0 #endif /* NULL */ /* * An address is just a pointer in C. It is defined as a character pointer * so that address arithmetic will work properly, a byte at a time. */ typedef char *Address; /* * ClientData is an uninterpreted word. It is defined as an int so that * kdbx will not interpret client data as a string. Unlike an "Address", * client data will generally not be used in arithmetic. * But we don't have kdbx anymore so we define it as void (christos) */ typedef void *ClientData; #endif /* _SPRITE */ diff --git a/sbin/restore/extern.h b/sbin/restore/extern.h index c33034c48c5e..fac58891a355 100644 --- a/sbin/restore/extern.h +++ b/sbin/restore/extern.h @@ -1,116 +1,115 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 1/7/94 - * $FreeBSD$ */ struct entry *addentry(char *, ino_t, int); long addfile(char *, ino_t, int); int addwhiteout(char *); void badentry(struct entry *, char *); void canon(char *, char *, size_t); void checkrestore(void); void closemt(void); void createfiles(void); void createleaves(char *); void createlinks(void); long deletefile(char *, ino_t, int); void deleteino(ino_t); void delwhiteout(struct entry *); ino_t dirlookup(const char *); void done(int) __dead2; void dumpsymtable(char *, long); void extractdirs(int); int extractfile(char *); void findunreflinks(void); char *flagvalues(struct entry *); void freeentry(struct entry *); void freename(char *); int genliteraldir(char *, ino_t); char *gentempname(struct entry *); void getfile(void (*)(char *, size_t), void (*)(char *, size_t), void (*)(char *, size_t)); void getvol(long); void initsymtable(char *); int inodetype(ino_t); int linkit(char *, char *, int); struct entry *lookupino(ino_t); struct entry *lookupname(char *); long listfile(char *, ino_t, int); ino_t lowerbnd(ino_t); void mktempname(struct entry *); void moveentry(struct entry *, char *); void msg(const char *, ...) __printflike(1, 2); char *myname(struct entry *); void newnode(struct entry *); void newtapebuf(long); long nodeupdates(char *, ino_t, int); void onintr(int); void panic(const char *, ...) __printflike(1, 2); void pathcheck(char *); struct direct *pathsearch(const char *); void printdumpinfo(void); void removeleaf(struct entry *); void removenode(struct entry *); void removeoldleaves(void); void removeoldnodes(void); void renameit(char *, char *); int reply(char *); void *rst_opendir(const char *); struct direct *rst_readdir(RST_DIR *); void rst_closedir(void *); void runcmdshell(void); char *savename(char *); enum set_extattr_mode { SXA_FILE, SXA_LINK, SXA_FD, }; void set_extattr(int, char *, void *, int, enum set_extattr_mode); void setdirmodes(int); void setinput(char *, int); void setup(void); void skipdirs(void); void skipfile(void); void skipmaps(void); void swabst(u_char *, u_char *); void treescan(char *, ino_t, long (*)(char *, ino_t, int)); ino_t upperbnd(ino_t); long verifyfile(char *, ino_t, int); void xtrnull(char *, size_t); /* From ../dump/dumprmt.c */ void rmtclose(void); int rmthost(char *); int rmtioctl(int, int); int rmtopen(char *, int); int rmtread(char *, int); int rmtseek(int, int); diff --git a/sbin/restore/restore.h b/sbin/restore/restore.h index 2e6ff623dc3a..e4db29340b8e 100644 --- a/sbin/restore/restore.h +++ b/sbin/restore/restore.h @@ -1,155 +1,154 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)restore.h 8.3 (Berkeley) 9/13/94 - * $FreeBSD$ */ /* * Flags */ extern int bflag; /* set input block size */ extern int dflag; /* print out debugging info */ extern int Dflag; /* degraded mode - try hard to get stuff back */ extern int hflag; /* restore hierarchies */ extern int mflag; /* restore by name instead of inode number */ extern int Nflag; /* do not write the disk */ extern int uflag; /* unlink symlink targets */ extern int vflag; /* print out actions taken */ extern int yflag; /* always try to recover from tape errors */ /* * Global variables */ extern char *dumpmap; /* map of inodes on this dump tape */ extern char *usedinomap; /* map of inodes that are in use on this fs */ extern ino_t maxino; /* highest numbered inode in this file system */ extern long dumpnum; /* location of the dump on this tape */ extern long volno; /* current volume being read */ extern long ntrec; /* number of TP_BSIZE records per tape block */ extern time_t dumptime; /* time that this dump begins */ extern time_t dumpdate; /* time that this dump was made */ extern char command; /* opration being performed */ extern FILE *terminal; /* file descriptor for the terminal input */ extern int Bcvt; /* need byte swapping on inodes and dirs */ extern int oldinofmt; /* reading tape with FreeBSD 1 format inodes */ /* * Each file in the file system is described by one of these entries */ struct entry { char *e_name; /* the current name of this entry */ u_char e_namlen; /* length of this name */ char e_type; /* type of this entry, see below */ short e_flags; /* status flags, see below */ ino_t e_ino; /* inode number in previous file sys */ long e_index; /* unique index (for dumpped table) */ struct entry *e_parent; /* pointer to parent directory (..) */ struct entry *e_sibling; /* next element in this directory (.) */ struct entry *e_links; /* hard links to this inode */ struct entry *e_entries; /* for directories, their entries */ struct entry *e_next; /* hash chain list */ }; /* types */ #define LEAF 1 /* non-directory entry */ #define NODE 2 /* directory entry */ #define LINK 4 /* synthesized type, stripped by addentry */ /* flags */ #define EXTRACT 0x0001 /* entry is to be replaced from the tape */ #define NEW 0x0002 /* a new entry to be extracted */ #define KEEP 0x0004 /* entry is not to change */ #define REMOVED 0x0010 /* entry has been removed */ #define TMPNAME 0x0020 /* entry has been given a temporary name */ #define EXISTED 0x0040 /* directory already existed during extract */ /* * Constants associated with entry structs */ #define HARDLINK 1 #define SYMLINK 2 #define TMPHDR "RSTTMP" /* * The entry describes the next file available on the tape */ extern struct context { short action; /* action being taken on this file */ mode_t mode; /* mode of file */ ino_t ino; /* inumber of file */ uid_t uid; /* file owner */ gid_t gid; /* file group */ int file_flags; /* status flags (chflags) */ int rdev; /* device number of file */ time_t atime_sec; /* access time seconds */ time_t mtime_sec; /* modified time seconds */ time_t birthtime_sec; /* creation time seconds */ int atime_nsec; /* access time nanoseconds */ int mtime_nsec; /* modified time nanoseconds */ int birthtime_nsec; /* creation time nanoseconds */ int extsize; /* size of extended attribute data */ off_t size; /* size of file */ char *name; /* name of file */ } curfile; /* actions */ #define USING 1 /* extracting from the tape */ #define SKIP 2 /* skipping */ #define UNKNOWN 3 /* disposition or starting point is unknown */ /* * Definitions for library routines operating on directories. */ typedef struct rstdirdesc RST_DIR; /* * Flags to setdirmodes. */ #define FORCE 0x0001 /* * Useful macros */ #define TSTINO(ino, map) \ (map[(u_int)((ino) - 1) / CHAR_BIT] & \ (1 << ((u_int)((ino) - 1) % CHAR_BIT))) #define SETINO(ino, map) \ map[(u_int)((ino) - 1) / CHAR_BIT] |= \ 1 << ((u_int)((ino) - 1) % CHAR_BIT) #define dprintf if (dflag) fprintf #define vprintf if (vflag) fprintf #define GOOD 1 #define FAIL 0 #define NFS_DR_NEWINODEFMT 0x2 /* Tape uses 4.4 BSD inode format */ diff --git a/share/syscons/scrnmaps/iso-8859-7_to_cp437 b/share/syscons/scrnmaps/iso-8859-7_to_cp437 index 7c1b49dba2da..88d18d98cc2d 100644 --- a/share/syscons/scrnmaps/iso-8859-7_to_cp437 +++ b/share/syscons/scrnmaps/iso-8859-7_to_cp437 @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ static scrmap_t scrmap = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x27, 0x27, 0x9c, 0x00, 0x00, 0x7c, 0x26, 0x00, 0x43, 0x00, 0xae, 0xaa, 0x2d, 0x00, 0x2d, 0xf8, 0xf1, 0xfd, 0x33, 0x00, 0x00, 0x8f, 0xfa, 0x90, 0x48, 0x49, 0xaf, 0x4f, 0xab, 0x59, 0x56, 0x8c, 0x41, 0x42, 0xe2, 0x44, 0x45, 0x5a, 0x48, 0xe9, 0x49, 0x4b, 0x4c, 0x4d, 0x4e, 0xf0, 0x4f, 0xef, 0x50, 0x00, 0xe4, 0x54, 0x59, 0xe8, 0x58, 0x80, 0xea, 0x49, 0x9a, 0xa0, 0x82, 0xa4, 0xa1, 0x98, 0xe0, 0xe1, 0x67, 0xeb, 0xee, 0x7a, 0x6e, 0xe9, 0x69, 0x6b, 0x6c, 0xe6, 0x76, 0x6a, 0x6f, 0xe3, 0x70, 0x73, 0xe5, 0xe7, 0x75, 0xed, 0x78, 0x87, 0x77, 0x8b, 0x98, 0xa2, 0xa3, 0x77, 0x00 }; diff --git a/share/syscons/scrnmaps/us-ascii_to_cp437 b/share/syscons/scrnmaps/us-ascii_to_cp437 index 5e7d631237b3..3993fd842208 100644 --- a/share/syscons/scrnmaps/us-ascii_to_cp437 +++ b/share/syscons/scrnmaps/us-ascii_to_cp437 @@ -1,38 +1,37 @@ /* - * $FreeBSD$ */ static scrmap_t scrmap = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/stand/efi/loader/arch/amd64/start.S b/stand/efi/loader/arch/amd64/start.S index 774ef4fa7901..34bf166c6501 100644 --- a/stand/efi/loader/arch/amd64/start.S +++ b/stand/efi/loader/arch/amd64/start.S @@ -1,76 +1,75 @@ /*- * Copyright (C) 1999 Hewlett-Packard Co. * Contributed by David Mosberger . * Copyright (C) 2005 Intel Co. * Contributed by Fenghua Yu . * 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 Hewlett-Packard Co. 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 FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER 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. */ /* * crt0-efi-x86_64.S - x86_64 EFI startup code. - * $FreeBSD$ */ .text .align 4 .globl _start _start: subq $8, %rsp pushq %rcx pushq %rdx 0: lea ImageBase(%rip), %rdi lea _DYNAMIC(%rip), %rsi popq %rcx popq %rdx pushq %rcx pushq %rdx call self_reloc popq %rdi popq %rsi call efi_main addq $8, %rsp .exit: ret /* * hand-craft a dummy .reloc section so EFI knows it's a relocatable * executable: */ .data .section .reloc, "a" .long 0 .long 10 .word 0 diff --git a/stand/ficl/aarch64/sysdep.h b/stand/ficl/aarch64/sysdep.h index 3726b9ef838f..1bb45efcae26 100644 --- a/stand/ficl/aarch64/sysdep.h +++ b/stand/ficl/aarch64/sysdep.h @@ -1,411 +1,410 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) (void)(x) #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int #endif #if !defined UNS32 #define UNS32 unsigned int #endif #if !defined UNS16 #define UNS16 unsigned short #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT long #endif #if !defined FICL_UNS #define FICL_UNS unsigned long #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 64 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 0 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 3 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) 0 /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); #endif /*__SYSDEP_H__*/ diff --git a/stand/ficl/arm/sysdep.h b/stand/ficl/arm/sysdep.h index 00718eedd35c..e376aa9d334b 100644 --- a/stand/ficl/arm/sysdep.h +++ b/stand/ficl/arm/sysdep.h @@ -1,432 +1,431 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) (void)(x) #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int #endif #if !defined UNS32 #define UNS32 unsigned int #endif #if !defined UNS16 #define UNS16 unsigned short #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT INT32 #endif #if !defined FICL_UNS #define FICL_UNS UNS32 #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 32 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FILE 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 1 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FILE ** Includes the FILE and FILE-EXT wordset and associated code. Turn this off if you do not ** have a filesystem! ** Contributed by Larry Hastings */ #if !defined (FICL_WANT_FILE) #define FICL_WANT_FILE 0 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 2 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); /* ** FICL_HAVE_FTRUNCATE indicates whether the current OS supports ** the ftruncate() function (available on most UNIXes). This ** function is necessary to provide the complete File-Access wordset. */ #if !defined (FICL_HAVE_FTRUNCATE) #define FICL_HAVE_FTRUNCATE 0 #endif #endif /*__SYSDEP_H__*/ diff --git a/stand/ficl/mips/sysdep.h b/stand/ficl/mips/sysdep.h index 3ae748e259c7..9c2f1d2140b9 100644 --- a/stand/ficl/mips/sysdep.h +++ b/stand/ficl/mips/sysdep.h @@ -1,432 +1,431 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) &x #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int #endif #if !defined UNS32 #define UNS32 unsigned int #endif #if !defined UNS16 #define UNS16 unsigned short #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT INT32 #endif #if !defined FICL_UNS #define FICL_UNS UNS32 #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 32 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FILE 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 1 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FILE ** Includes the FILE and FILE-EXT wordset and associated code. Turn this off if you do not ** have a filesystem! ** Contributed by Larry Hastings */ #if !defined (FICL_WANT_FILE) #define FICL_WANT_FILE 0 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 2 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) 0 /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); /* ** FICL_HAVE_FTRUNCATE indicates whether the current OS supports ** the ftruncate() function (available on most UNIXes). This ** function is necessary to provide the complete File-Access wordset. */ #if !defined (FICL_HAVE_FTRUNCATE) #define FICL_HAVE_FTRUNCATE 0 #endif #endif /*__SYSDEP_H__*/ diff --git a/stand/ficl/mips64/sysdep.h b/stand/ficl/mips64/sysdep.h index 5c9e163acb70..6c1d8486137c 100644 --- a/stand/ficl/mips64/sysdep.h +++ b/stand/ficl/mips64/sysdep.h @@ -1,432 +1,431 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) &x #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int #endif #if !defined UNS32 #define UNS32 unsigned int #endif #if !defined UNS16 #define UNS16 unsigned short #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT long #endif #if !defined FICL_UNS #define FICL_UNS unsigned long #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 64 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FILE 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 1 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FILE ** Includes the FILE and FILE-EXT wordset and associated code. Turn this off if you do not ** have a filesystem! ** Contributed by Larry Hastings */ #if !defined (FICL_WANT_FILE) #define FICL_WANT_FILE 0 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 3 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) 0 /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); /* ** FICL_HAVE_FTRUNCATE indicates whether the current OS supports ** the ftruncate() function (available on most UNIXes). This ** function is necessary to provide the complete File-Access wordset. */ #if !defined (FICL_HAVE_FTRUNCATE) #define FICL_HAVE_FTRUNCATE 0 #endif #endif /*__SYSDEP_H__*/ diff --git a/stand/ficl/powerpc/sysdep.h b/stand/ficl/powerpc/sysdep.h index b31625e18649..405d4c38176d 100644 --- a/stand/ficl/powerpc/sysdep.h +++ b/stand/ficl/powerpc/sysdep.h @@ -1,435 +1,434 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) &x #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int32_t #endif #if !defined UNS32 #define UNS32 uint32_t #endif #if !defined UNS16 #define UNS16 uint16_t #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT INT32 #endif #if !defined FICL_UNS #define FICL_UNS UNS32 #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 32 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FILE 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 1 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FILE ** Includes the FILE and FILE-EXT wordset and associated code. Turn this off if you do not ** have a filesystem! ** Contributed by Larry Hastings */ #if !defined (FICL_WANT_FILE) #define FICL_WANT_FILE 0 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 2 #endif #if !defined FICL_ALIGN_ADD #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) 0 /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); /* ** FICL_HAVE_FTRUNCATE indicates whether the current OS supports ** the ftruncate() function (available on most UNIXes). This ** function is necessary to provide the complete File-Access wordset. */ #if !defined (FICL_HAVE_FTRUNCATE) #define FICL_HAVE_FTRUNCATE 0 #endif #endif /*__SYSDEP_H__*/ diff --git a/stand/ficl/riscv/sysdep.h b/stand/ficl/riscv/sysdep.h index 3726b9ef838f..1bb45efcae26 100644 --- a/stand/ficl/riscv/sysdep.h +++ b/stand/ficl/riscv/sysdep.h @@ -1,411 +1,410 @@ /******************************************************************* s y s d e p . h ** Forth Inspired Command Language ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 16 Oct 1997 ** Ficl system dependent types and prototypes... ** ** Note: Ficl also depends on the use of "assert" when ** FICL_ROBUST is enabled. This may require some consideration ** in firmware systems since assert often ** assumes stderr/stdout. ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) ** All rights reserved. ** ** Get the latest Ficl release at http://ficl.sourceforge.net ** ** L I C E N S E and D I S C L A I M E R ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** 1. Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** 2. Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** I am interested in hearing from anyone who uses ficl. If you have ** a problem, a success story, a defect, an enhancement request, or ** if you would like to contribute to the ficl release, please send ** contact me by email at the address above. ** ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $ -** $FreeBSD$ */ #if !defined (__SYSDEP_H__) #define __SYSDEP_H__ #include #include /* size_t, NULL */ #include #include #if !defined IGNORE /* Macro to silence unused param warnings */ #define IGNORE(x) (void)(x) #endif /* ** TRUE and FALSE for C boolean operations, and ** portable 32 bit types for CELLs ** */ #if !defined TRUE #define TRUE 1 #endif #if !defined FALSE #define FALSE 0 #endif /* ** System dependent data type declarations... */ #if !defined INT32 #define INT32 int #endif #if !defined UNS32 #define UNS32 unsigned int #endif #if !defined UNS16 #define UNS16 unsigned short #endif #if !defined UNS8 #define UNS8 unsigned char #endif #if !defined NULL #define NULL ((void *)0) #endif /* ** FICL_UNS and FICL_INT must have the same size as a void* on ** the target system. A CELL is a union of void*, FICL_UNS, and ** FICL_INT. ** (11/2000: same for FICL_FLOAT) */ #if !defined FICL_INT #define FICL_INT long #endif #if !defined FICL_UNS #define FICL_UNS unsigned long #endif #if !defined FICL_FLOAT #define FICL_FLOAT float #endif /* ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL */ #if !defined BITS_PER_CELL #define BITS_PER_CELL 64 #endif #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64)) Error! #endif typedef struct { FICL_UNS hi; FICL_UNS lo; } DPUNS; typedef struct { FICL_UNS quot; FICL_UNS rem; } UNSQR; typedef struct { FICL_INT hi; FICL_INT lo; } DPINT; typedef struct { FICL_INT quot; FICL_INT rem; } INTQR; /* ** B U I L D C O N T R O L S */ #if !defined (FICL_MINIMAL) #define FICL_MINIMAL 0 #endif #if (FICL_MINIMAL) #define FICL_WANT_SOFTWORDS 0 #define FICL_WANT_FLOAT 0 #define FICL_WANT_USER 0 #define FICL_WANT_LOCALS 0 #define FICL_WANT_DEBUGGER 0 #define FICL_WANT_OOP 0 #define FICL_PLATFORM_EXTEND 0 #define FICL_MULTITHREAD 0 #define FICL_ROBUST 0 #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_PLATFORM_EXTEND ** Includes words defined in ficlCompilePlatform */ #if !defined (FICL_PLATFORM_EXTEND) #define FICL_PLATFORM_EXTEND 1 #endif /* ** FICL_WANT_FLOAT ** Includes a floating point stack for the VM, and words to do float operations. ** Contributed by Guy Carver */ #if !defined (FICL_WANT_FLOAT) #define FICL_WANT_FLOAT 0 #endif /* ** FICL_WANT_DEBUGGER ** Inludes a simple source level debugger */ #if !defined (FICL_WANT_DEBUGGER) #define FICL_WANT_DEBUGGER 1 #endif /* ** User variables: per-instance variables bound to the VM. ** Kinda like thread-local storage. Could be implemented in a ** VM private dictionary, but I've chosen the lower overhead ** approach of an array of CELLs instead. */ #if !defined FICL_WANT_USER #define FICL_WANT_USER 1 #endif #if !defined FICL_USER_CELLS #define FICL_USER_CELLS 16 #endif /* ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and ** a private dictionary for local variable compilation. */ #if !defined FICL_WANT_LOCALS #define FICL_WANT_LOCALS 1 #endif /* Max number of local variables per definition */ #if !defined FICL_MAX_LOCALS #define FICL_MAX_LOCALS 16 #endif /* ** FICL_WANT_OOP ** Inludes object oriented programming support (in softwords) ** OOP support requires locals and user variables! */ #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER) #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 0 #endif #endif #if !defined (FICL_WANT_OOP) #define FICL_WANT_OOP 1 #endif /* ** FICL_WANT_SOFTWORDS ** Controls inclusion of all softwords in softcore.c */ #if !defined (FICL_WANT_SOFTWORDS) #define FICL_WANT_SOFTWORDS 1 #endif /* ** FICL_MULTITHREAD enables dictionary mutual exclusion ** wia the ficlLockDictionary system dependent function. ** Note: this implementation is experimental and poorly ** tested. Further, it's unnecessary unless you really ** intend to have multiple SESSIONS (poor choice of name ** on my part) - that is, threads that modify the dictionary ** at the same time. */ #if !defined FICL_MULTITHREAD #define FICL_MULTITHREAD 0 #endif /* ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be ** defined in C in sysdep.c. Use this if you cannot easily ** generate an inline asm definition */ #if !defined (PORTABLE_LONGMULDIV) #define PORTABLE_LONGMULDIV 0 #endif /* ** INLINE_INNER_LOOP causes the inner interpreter to be inline code ** instead of a function call. This is mainly because MS VC++ 5 ** chokes with an internal compiler error on the function version. ** in release mode. Sheesh. */ #if !defined INLINE_INNER_LOOP #if defined _DEBUG #define INLINE_INNER_LOOP 0 #else #define INLINE_INNER_LOOP 1 #endif #endif /* ** FICL_ROBUST enables bounds checking of stacks and the dictionary. ** This will detect stack over and underflows and dictionary overflows. ** Any exceptional condition will result in an assertion failure. ** (As generated by the ANSI assert macro) ** FICL_ROBUST == 1 --> stack checking in the outer interpreter ** FICL_ROBUST == 2 also enables checking in many primitives */ #if !defined FICL_ROBUST #define FICL_ROBUST 2 #endif /* ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of ** a new virtual machine's stacks, unless overridden at ** create time. */ #if !defined FICL_DEFAULT_STACK #define FICL_DEFAULT_STACK 128 #endif /* ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate ** for the system dictionary by default. The value ** can be overridden at startup time as well. ** FICL_DEFAULT_ENV specifies the number of cells to allot ** for the environment-query dictionary. */ #if !defined FICL_DEFAULT_DICT #define FICL_DEFAULT_DICT 12288 #endif #if !defined FICL_DEFAULT_ENV #define FICL_DEFAULT_ENV 260 #endif /* ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in ** the dictionary search order. See Forth DPANS sec 16.3.3 ** (file://dpans16.htm#16.3.3) */ #if !defined FICL_DEFAULT_VOCS #define FICL_DEFAULT_VOCS 16 #endif /* ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure ** that stores pointers to parser extension functions. I would never expect to have ** more than 8 of these, so that's the default limit. Too many of these functions ** will probably exact a nasty performance penalty. */ #if !defined FICL_MAX_PARSE_STEPS #define FICL_MAX_PARSE_STEPS 8 #endif /* ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if ** included as part of softcore.c) */ #if !defined FICL_EXTENDED_PREFIX #define FICL_EXTENDED_PREFIX 0 #endif /* ** FICL_ALIGN is the power of two to which the dictionary ** pointer address must be aligned. This value is usually ** either 1 or 2, depending on the memory architecture ** of the target system; 2 is safe on any 16 or 32 bit ** machine. 3 would be appropriate for a 64 bit machine. */ #if !defined FICL_ALIGN #define FICL_ALIGN 3 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1) #endif /* ** System dependent routines -- ** edit the implementations in sysdep.c to be compatible ** with your runtime environment... ** ficlTextOut sends a NULL terminated string to the ** default output device - used for system error messages ** ficlMalloc and ficlFree have the same semantics as malloc and free ** in standard C ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned ** product ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient ** and remainder */ struct vm; void ficlTextOut(struct vm *pVM, char *msg, int fNewline); void *ficlMalloc (size_t size); void ficlFree (void *p); void *ficlRealloc(void *p, size_t size); /* ** Stub function for dictionary access control - does nothing ** by default, user can redefine to guarantee exclusive dict ** access to a single thread for updates. All dict update code ** must be bracketed as follows: ** ficlLockDictionary(TRUE); ** ** ficlLockDictionary(FALSE); ** ** Returns zero if successful, nonzero if unable to acquire lock ** before timeout (optional - could also block forever) ** ** NOTE: this function must be implemented with lock counting ** semantics: nested calls must behave properly. */ #if FICL_MULTITHREAD int ficlLockDictionary(short fLock); #else #define ficlLockDictionary(x) 0 /* ignore */ #endif /* ** 64 bit integer math support routines: multiply two UNS32s ** to get a 64 bit product, & divide the product by an UNS32 ** to get an UNS32 quotient and remainder. Much easier in asm ** on a 32 bit CPU than in C, which usually doesn't support ** the double length result (but it should). */ DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y); UNSQR ficlLongDiv(DPUNS q, FICL_UNS y); #endif /*__SYSDEP_H__*/ diff --git a/stand/i386/boot2/lib.h b/stand/i386/boot2/lib.h index d8d3317e5aa0..d25dd0f7d28f 100644 --- a/stand/i386/boot2/lib.h +++ b/stand/i386/boot2/lib.h @@ -1,24 +1,23 @@ /* * Copyright (c) 1998 Robert Nordier * All rights reserved. * * Redistribution and use in source and binary forms are freely * permitted provided that the above copyright notice and this * paragraph and the following disclaimer are duplicated in all * such forms. * * This software is provided "AS IS" and without any express or * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. */ /* - * $FreeBSD$ */ int sio_init(int) __attribute__((regparm (3))); int sio_flush(void); void sio_putc(int) __attribute__((regparm (3))); int sio_getc(void); int sio_ischar(void); diff --git a/stand/i386/btx/lib/btxv86.h b/stand/i386/btx/lib/btxv86.h index 0dca768cc2ac..567fdf4690f3 100644 --- a/stand/i386/btx/lib/btxv86.h +++ b/stand/i386/btx/lib/btxv86.h @@ -1,75 +1,74 @@ /* * Copyright (c) 1998 Robert Nordier * All rights reserved. * * Redistribution and use in source and binary forms are freely * permitted provided that the above copyright notice and this * paragraph and the following disclaimer are duplicated in all * such forms. * * This software is provided "AS IS" and without any express or * implied warranties, including, without limitation, the implied * warranties of merchantability and fitness for a particular * purpose. */ /* - * $FreeBSD$ */ #ifndef _BTXV86_H_ #define _BTXV86_H_ #include #include /* * Memory buffer space for real mode IO. * Just one page is not much, but the space is rather limited. * See ../btx/btx.S for details. */ #define V86_IO_BUFFER 0x8000 #define V86_IO_BUFFER_SIZE 0x1000 #define V86_ADDR 0x10000 /* Segment:offset address */ #define V86_CALLF 0x20000 /* Emulate far call */ #define V86_FLAGS 0x40000 /* Return flags */ struct __v86 { uint32_t ctl; /* Control flags */ uint32_t addr; /* Interrupt number or address */ uint32_t es; /* V86 ES register */ uint32_t ds; /* V86 DS register */ uint32_t fs; /* V86 FS register */ uint32_t gs; /* V86 GS register */ uint32_t eax; /* V86 EAX register */ uint32_t ecx; /* V86 ECX register */ uint32_t edx; /* V86 EDX register */ uint32_t ebx; /* V86 EBX register */ uint32_t efl; /* V86 eflags register */ uint32_t ebp; /* V86 EBP register */ uint32_t esi; /* V86 ESI register */ uint32_t edi; /* V86 EDI register */ }; extern struct __v86 __v86; /* V86 interface structure */ void __v86int(void); #define v86 __v86 #define v86int __v86int extern uint32_t __base; extern uint32_t __args; #define PTOV(pa) ((caddr_t)(pa) - __base) #define VTOP(va) ((vm_offset_t)(va) + __base) #define VTOPSEG(va) (uint16_t)(VTOP((caddr_t)va) >> 4) #define VTOPOFF(va) (uint16_t)(VTOP((caddr_t)va) & 0xf) #define V86_CY(x) ((x) & PSL_C) #define V86_ZR(x) ((x) & PSL_Z) void __exit(int) __attribute__((__noreturn__)); void __exec(caddr_t, ...); #endif /* !_BTXV86_H_ */ diff --git a/stand/i386/libi386/multiboot.h b/stand/i386/libi386/multiboot.h index 819fa2e5019f..d68f17b52810 100644 --- a/stand/i386/libi386/multiboot.h +++ b/stand/i386/libi386/multiboot.h @@ -1,225 +1,224 @@ /* multiboot.h - Multiboot header file. */ /* Copyright (C) 1999,2003,2007,2008,2009 Free Software Foundation, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * -* $FreeBSD$ */ #ifndef MULTIBOOT_HEADER #define MULTIBOOT_HEADER 1 /* How many bytes from the start of the file we search for the header. */ #define MULTIBOOT_SEARCH 8192 /* The magic field should contain this. */ #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* This should be in %eax. */ #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* The bits in the required part of flags field we don't support. */ #define MULTIBOOT_UNSUPPORTED 0x0000fffc /* Alignment of multiboot modules. */ #define MULTIBOOT_MOD_ALIGN 0x00001000 /* Alignment of the multiboot info structure. */ #define MULTIBOOT_INFO_ALIGN 0x00000004 /* Flags set in the 'flags' member of the multiboot header. */ /* Align all boot modules on i386 page (4KB) boundaries. */ #define MULTIBOOT_PAGE_ALIGN 0x00000001 /* Must pass memory information to OS. */ #define MULTIBOOT_MEMORY_INFO 0x00000002 /* Must pass video information to OS. */ #define MULTIBOOT_VIDEO_MODE 0x00000004 /* This flag indicates the use of the address fields in the header. */ #define MULTIBOOT_AOUT_KLUDGE 0x00010000 /* Flags to be set in the 'flags' member of the multiboot info structure. */ /* is there basic lower/upper memory information? */ #define MULTIBOOT_INFO_MEMORY 0x00000001 /* is there a boot device set? */ #define MULTIBOOT_INFO_BOOTDEV 0x00000002 /* is the command-line defined? */ #define MULTIBOOT_INFO_CMDLINE 0x00000004 /* are there modules to do something with? */ #define MULTIBOOT_INFO_MODS 0x00000008 /* These next two are mutually exclusive */ /* is there a symbol table loaded? */ #define MULTIBOOT_INFO_AOUT_SYMS 0x00000010 /* is there an ELF section header table? */ #define MULTIBOOT_INFO_ELF_SHDR 0X00000020 /* is there a full memory map? */ #define MULTIBOOT_INFO_MEM_MAP 0x00000040 /* Is there drive info? */ #define MULTIBOOT_INFO_DRIVE_INFO 0x00000080 /* Is there a config table? */ #define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100 /* Is there a boot loader name? */ #define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200 /* Is there a APM table? */ #define MULTIBOOT_INFO_APM_TABLE 0x00000400 /* Is there video information? */ #define MULTIBOOT_INFO_VIDEO_INFO 0x00000800 #ifndef ASM_FILE typedef unsigned short multiboot_uint16_t; typedef unsigned int multiboot_uint32_t; typedef unsigned long long multiboot_uint64_t; struct multiboot_header { /* Must be MULTIBOOT_MAGIC - see above. */ multiboot_uint32_t magic; /* Feature flags. */ multiboot_uint32_t flags; /* The above fields plus this one must equal 0 mod 2^32. */ multiboot_uint32_t checksum; /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ multiboot_uint32_t header_addr; multiboot_uint32_t load_addr; multiboot_uint32_t load_end_addr; multiboot_uint32_t bss_end_addr; multiboot_uint32_t entry_addr; /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ multiboot_uint32_t mode_type; multiboot_uint32_t width; multiboot_uint32_t height; multiboot_uint32_t depth; }; /* The symbol table for a.out. */ struct multiboot_aout_symbol_table { multiboot_uint32_t tabsize; multiboot_uint32_t strsize; multiboot_uint32_t addr; multiboot_uint32_t reserved; }; typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t; /* The section header table for ELF. */ struct multiboot_elf_section_header_table { multiboot_uint32_t num; multiboot_uint32_t size; multiboot_uint32_t addr; multiboot_uint32_t shndx; }; typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t; struct multiboot_info { /* Multiboot info version number */ multiboot_uint32_t flags; /* Available memory from BIOS */ multiboot_uint32_t mem_lower; multiboot_uint32_t mem_upper; /* "root" partition */ multiboot_uint32_t boot_device; /* Kernel command line */ multiboot_uint32_t cmdline; /* Boot-Module list */ multiboot_uint32_t mods_count; multiboot_uint32_t mods_addr; union { multiboot_aout_symbol_table_t aout_sym; multiboot_elf_section_header_table_t elf_sec; } u; /* Memory Mapping buffer */ multiboot_uint32_t mmap_length; multiboot_uint32_t mmap_addr; /* Drive Info buffer */ multiboot_uint32_t drives_length; multiboot_uint32_t drives_addr; /* ROM configuration table */ multiboot_uint32_t config_table; /* Boot Loader Name */ multiboot_uint32_t boot_loader_name; /* APM table */ multiboot_uint32_t apm_table; /* Video */ multiboot_uint32_t vbe_control_info; multiboot_uint32_t vbe_mode_info; multiboot_uint16_t vbe_mode; multiboot_uint16_t vbe_interface_seg; multiboot_uint16_t vbe_interface_off; multiboot_uint16_t vbe_interface_len; }; typedef struct multiboot_info multiboot_info_t; struct multiboot_mmap_entry { multiboot_uint32_t size; multiboot_uint64_t addr; multiboot_uint64_t len; #define MULTIBOOT_MEMORY_AVAILABLE 1 #define MULTIBOOT_MEMORY_RESERVED 2 multiboot_uint32_t type; } __attribute__((packed)); typedef struct multiboot_mmap_entry multiboot_memory_map_t; struct multiboot_mod_list { /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ multiboot_uint32_t mod_start; multiboot_uint32_t mod_end; /* Module command line */ multiboot_uint32_t cmdline; /* padding to take it to 16 bytes (must be zero) */ multiboot_uint32_t pad; }; typedef struct multiboot_mod_list multiboot_module_t; #endif /* ! ASM_FILE */ #endif /* ! MULTIBOOT_HEADER */ diff --git a/stand/kboot/arch/powerpc64/kerneltramp.S b/stand/kboot/arch/powerpc64/kerneltramp.S index 15fdfc26bd90..211a6e474d2a 100644 --- a/stand/kboot/arch/powerpc64/kerneltramp.S +++ b/stand/kboot/arch/powerpc64/kerneltramp.S @@ -1,102 +1,101 @@ /* * This is the analog to the kexec "purgatory" code * * The goal here is to call the actual kernel entry point with the arguments it * expects when kexec calls into it with no arguments. The value of the kernel * entry point and arguments r3-r7 are copied into the trampoline text (which * can be executed from any address) at bytes 8-32. kexec begins execution * of APs at 0x60 bytes past the entry point, executing in a copy relocated * to the absolute address 0x60. Here we implement a loop waiting on the release * of a lock by the kernel at 0x40. * - * $FreeBSD$ */ #include .globl CNAME(kerneltramp),CNAME(szkerneltramp) CNAME(kerneltramp): mflr %r9 bl 2f .space 24 /* branch address, r3-r7 */ /* * MUST BE IN SYNC WITH: * struct trampoline_data { * uint32_t kernel_entry; * uint32_t dtb; * uint32_t phys_mem_offset; * uint32_t of_entry; * uint32_t mdp; * uint32_t mdp_size; * }; */ . = kerneltramp + 0x40 /* AP spinlock */ .long 0 . = kerneltramp + 0x60 /* AP entry point */ li %r3,0x40 1: lwz %r1,0(%r3) cmpwi %r1,0 beq 1b /* Jump into CPU reset */ li %r0,0x100 icbi 0,%r0 isync sync ba 0x100 2: /* Continuation of kerneltramp */ mflr %r8 mtlr %r9 mfmsr %r10 andi. %r10, %r10, 1 /* test MSR_LE */ bne little_endian /* We're starting in BE */ big_endian: lwz %r3,4(%r8) lwz %r4,8(%r8) lwz %r5,12(%r8) lwz %r6,16(%r8) lwz %r7,20(%r8) lwz %r10, 0(%r8) mtctr %r10 bctr /* We're starting in LE */ little_endian: /* Entries are BE, swap them during load. */ li %r10, 4 lwbrx %r3, %r8, %r10 li %r10, 8 lwbrx %r4, %r8, %r10 li %r10, 12 lwbrx %r5, %r8, %r10 li %r10, 16 lwbrx %r6, %r8, %r10 li %r10, 20 lwbrx %r7, %r8, %r10 /* Clear MSR_LE flag to enter the BE world */ mfmsr %r10 clrrdi %r10, %r10, 1 mtsrr1 %r10 /* Entry is at 0(%r8) */ li %r10, 0 lwbrx %r10, %r8, %r10 mtsrr0 %r10 rfid endkerneltramp: .data CNAME(szkerneltramp): .long endkerneltramp - CNAME(kerneltramp) diff --git a/tests/sys/cddl/zfs/bin/chg_usr_exec.c b/tests/sys/cddl/zfs/bin/chg_usr_exec.c index c1de099aa1bf..bcc7027f550b 100644 --- a/tests/sys/cddl/zfs/bin/chg_usr_exec.c +++ b/tests/sys/cddl/zfs/bin/chg_usr_exec.c @@ -1,78 +1,77 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)chg_usr_exec.c 1.3 07/05/25 SMI" #include #include #include #include #include #include int main(int argc, char *argv[]) { char *plogin = NULL; char cmds[BUFSIZ] = { 0 }; char sep[] = " "; struct passwd *ppw = NULL; int i, len; if (argc < 3 || strlen(argv[1]) == 0) { (void) printf("\tUsage: %s ...\n", argv[0]); return (1); } plogin = argv[1]; len = 0; for (i = 2; i < argc; i++) { (void) snprintf(cmds+len, sizeof (cmds)-len, "%s%s", argv[i], sep); len += strlen(argv[i]) + strlen(sep); } if ((ppw = getpwnam(plogin)) == NULL) { perror("getpwnam"); return (errno); } if (setgid(ppw->pw_gid) != 0) { perror("setgid"); return (errno); } if (setuid(ppw->pw_uid) != 0) { perror("setuid"); return (errno); } if (execl("/bin/sh", "sh", "-c", cmds, (char *)0) != 0) { perror("execl"); return (errno); } return (0); } diff --git a/tests/sys/cddl/zfs/bin/devname2devid.c b/tests/sys/cddl/zfs/bin/devname2devid.c index 09de8168eba4..ee5f2e997e8c 100644 --- a/tests/sys/cddl/zfs/bin/devname2devid.c +++ b/tests/sys/cddl/zfs/bin/devname2devid.c @@ -1,123 +1,122 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)devname2devid.c 1.3 07/05/25 SMI" #include #include #include #include #include #include #include /* * Usage: devname2devid * * Examples: * # ./devname2devid /dev/c1t4d0s0 * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/a * # ./devname2devid /dev/c1t4d0 * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/wd * # ./devname2devid /dev/c1t4d0s1 * devid id1,sd@SSEAGATE_ST318404LSUN18G_3BT2G0Z300002146G4CR/b * # * * This program accepts a disk or disk slice path and prints a * device id. * * Exit values: * 0 - means success * 1 - means failure * */ int main(int argc, char *argv[]) { int fd; ddi_devid_t devid; char *minor_name, *devidstr, *device; #ifdef DEBUG devid_nmlist_t *list = NULL; char *search_path; int i; #endif if (argc == 1) { (void) printf("%s [search path]\n", argv[0]); exit(1); } device = argv[1]; if ((fd = open(device, O_RDONLY|O_NDELAY)) < 0) { perror(device); exit(1); } if (devid_get(fd, &devid) != 0) { perror("devid_get"); exit(1); } if (devid_get_minor_name(fd, &minor_name) != 0) { perror("devid_get_minor_name"); exit(1); } if ((devidstr = devid_str_encode(devid, minor_name)) == 0) { perror("devid_str_encode"); exit(1); } (void) printf("devid %s\n", devidstr); devid_str_free(devidstr); #ifdef DEBUG if (argc == 3) { search_path = argv[2]; } else { search_path = "/dev/"; } if (devid_deviceid_to_nmlist(search_path, devid, DEVID_MINOR_NAME_ALL, &list)) { perror("devid_deviceid_to_nmlist"); exit(1); } /* loop through list and process device names and numbers */ for (i = 0; list[i].devname != NULL; i++) { (void) printf("devname: %s %p\n", list[i].devname, list[i].dev); } devid_free_nmlist(list); #endif /* DEBUG */ devid_str_free(minor_name); devid_free(devid); return (0); } diff --git a/tests/sys/cddl/zfs/bin/dir_rd_update.c b/tests/sys/cddl/zfs/bin/dir_rd_update.c index 6e7fd93e10a5..a2202cfa7582 100644 --- a/tests/sys/cddl/zfs/bin/dir_rd_update.c +++ b/tests/sys/cddl/zfs/bin/dir_rd_update.c @@ -1,122 +1,121 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)dir_rd_update.c 1.2 07/01/09 SMI" /* * Assertion: * * A read operation and directory update operation performed * concurrently on the same directory can lead to deadlock * on a UFS logging file system, but not on a ZFS file system. */ #include #include #include #include #include #include #include #include #define TMP_DIR /tmp static char dirpath[256]; int main(int argc, char **argv) { char *cp1 = ""; int i = 0; int ret = 0; int testdd = 0; pid_t pid; static const int op_num = 5; if (argc == 1) { (void) printf("Usage: %s \n", argv[0]); exit(-1); } for (i = 0; i < 256; i++) { dirpath[i] = 0; } cp1 = argv[1]; (void) strcpy(&dirpath[0], (const char *)cp1); (void) strcat(&dirpath[strlen(dirpath)], "TMP_DIR"); ret = mkdir(dirpath, 0777); if (ret != 0) { if (errno != EEXIST) { (void) printf( "%s: mkdir(<%s>, 0777) failed: errno (decimal)=%d\n", argv[0], dirpath, errno); exit(-1); } } testdd = open(dirpath, O_RDONLY|O_SYNC); if (testdd < 0) { (void) printf( "%s: open(<%s>, O_RDONLY|O_SYNC) failed: errno (decimal)=%d\n", argv[0], dirpath, errno); exit(-1); } else { (void) close(testdd); } pid = fork(); if (pid > 0) { int fd = open(dirpath, O_RDONLY|O_SYNC); char buf[16]; int rdret; int j = 0; while (j < op_num) { (void) sleep(1); rdret = read(fd, buf, 16); if (rdret == -1) { (void) printf("readdir failed"); } j++; } } else if (pid == 0) { int fd = open(dirpath, O_RDONLY); int chownret; int k = 0; while (k < op_num) { (void) sleep(1); chownret = fchown(fd, 0, 0); if (chownret == -1) { (void) printf("chown failed"); } k++; } } return (0); } diff --git a/tests/sys/cddl/zfs/bin/file_check.c b/tests/sys/cddl/zfs/bin/file_check.c index dc2f348a724c..10d69b424f4d 100644 --- a/tests/sys/cddl/zfs/bin/file_check.c +++ b/tests/sys/cddl/zfs/bin/file_check.c @@ -1,89 +1,88 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)file_check.c 1.3 07/05/25 SMI" #include "file_common.h" static unsigned char bigbuffer[BIGBUFFERSIZE]; /* * Given a filename, check that the file consists entirely * of a particular pattern. If the pattern is not specified a * default will be used. For default values see file_common.h */ int main(int argc, char **argv) { int bigfd; long i, n; uint8_t fillchar = DATA; int bigbuffersize = BIGBUFFERSIZE; int64_t read_count = 0; /* * Validate arguments */ if (argc < 2) { (void) printf("Usage: %s filename [pattern]\n", argv[0]); exit(1); } if (argv[2]) { fillchar = atoi(argv[2]); } /* * Read the file contents and check every character * against the supplied pattern. Abort if the * pattern check fails. */ if ((bigfd = open(argv[1], O_RDONLY)) == -1) { (void) printf("open %s failed %d\n", argv[1], errno); exit(1); } do { if ((n = read(bigfd, &bigbuffer, bigbuffersize)) == -1) { (void) printf("read failed (%ld), %d\n", n, errno); exit(errno); } for (i = 0; i < n; i++) { if (bigbuffer[i] != fillchar) { (void) printf("error %s: 0x%x != 0x%x)\n", argv[1], bigbuffer[i], fillchar); exit(1); } } read_count += n; } while (n == bigbuffersize); return (0); } diff --git a/tests/sys/cddl/zfs/bin/file_common.h b/tests/sys/cddl/zfs/bin/file_common.h index 3ae1b07cd221..adc0bd47f94b 100644 --- a/tests/sys/cddl/zfs/bin/file_common.h +++ b/tests/sys/cddl/zfs/bin/file_common.h @@ -1,65 +1,64 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #ifndef FILE_COMMON_H #define FILE_COMMON_H #pragma ident "@(#)file_common.h 1.3 07/05/25 SMI" /* * header file for file_* utilities. These utilities * are used by the test cases to perform various file * operations (append writes, for example). */ #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include #include #include #include #define BLOCKSZ 8192 #define DATA 0xa5 #define DATA_RANGE 120 #define BIGBUFFERSIZE 0x800000 #define BIGFILESIZE 20 extern char *optarg; extern int optind, opterr, optopt; #ifdef __cplusplus } #endif #endif /* FILE_COMMON_H */ diff --git a/tests/sys/cddl/zfs/bin/file_trunc.c b/tests/sys/cddl/zfs/bin/file_trunc.c index 5fe3ad61a32a..685b05eb5df2 100644 --- a/tests/sys/cddl/zfs/bin/file_trunc.c +++ b/tests/sys/cddl/zfs/bin/file_trunc.c @@ -1,240 +1,239 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)file_trunc.c 1.2 07/05/25 SMI" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define FSIZE 256*1024*1024 #define BSIZE 512 /* Initialize Globals */ static long fsize = FSIZE; static size_t bsize = BSIZE; static int count = 0; static int rflag = 0; static int seed = 0; static int vflag = 0; static int errflag = 0; static off_t offset = 0; static char *filename = NULL; static void usage(char *execname); static void parse_options(int argc, char *argv[]); static void do_write(int fd); static void do_trunc(int fd); static void usage(char *execname) { (void) fprintf(stderr, "usage: %s [-b blocksize] [-c count] [-f filesize]" " [-o offset] [-s seed] [-r] [-v] filename\n", execname); (void) exit(1); } int main(int argc, char *argv[]) { int i = 0; int fd = -1; parse_options(argc, argv); fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fd < 0) { perror("open"); exit(3); } while (i < count) { (void) do_write(fd); (void) do_trunc(fd); i++; } (void) close(fd); return (0); } static void parse_options(int argc, char *argv[]) { int c; extern char *optarg; extern int optind, optopt; count = fsize / bsize; seed = time(NULL); while ((c = getopt(argc, argv, "b:c:f:o:rs:v")) != -1) { switch (c) { case 'b': bsize = atoi(optarg); break; case 'c': count = atoi(optarg); break; case 'f': fsize = atoi(optarg); break; case 'o': offset = atoi(optarg); break; case 'r': rflag++; break; case 's': seed = atoi(optarg); break; case 'v': vflag++; break; case ':': (void) fprintf(stderr, "Option -%c requires an operand\n", optopt); errflag++; break; case '?': (void) fprintf(stderr, "Unrecognized option: -%c\n", optopt); errflag++; break; } if (errflag) { (void) usage(argv[0]); } } if (argc <= optind) { (void) fprintf(stderr, "No filename specified\n"); usage(argv[0]); } filename = argv[optind]; if (vflag) { (void) fprintf(stderr, "Seed = %d\n", seed); } srandom(seed); } static void do_write(int fd) { off_t roffset = 0; char *buf = NULL; char *rbuf = NULL; buf = (char *)calloc(1, bsize); rbuf = (char *)calloc(1, bsize); if (buf == NULL || rbuf == NULL) { perror("malloc"); exit(4); } roffset = random() % fsize; if (lseek(fd, (offset + roffset), SEEK_SET) < 0) { perror("lseek"); exit(5); } strcpy(buf, "ZFS Test Suite Truncation Test"); if (write(fd, buf, bsize) < bsize) { perror("write"); exit(6); } if (rflag) { if (lseek(fd, (offset + roffset), SEEK_SET) < 0) { perror("lseek"); exit(7); } if (read(fd, rbuf, bsize) < bsize) { perror("read"); exit(8); } if (memcmp(buf, rbuf, bsize) != 0) { perror("memcmp"); exit(9); } } if (vflag) { (void) fprintf(stderr, "Wrote to offset %ld\n", (offset + roffset)); if (rflag) { (void) fprintf(stderr, "Read back from offset %ld\n", (offset + roffset)); } } (void) free(buf); (void) free(rbuf); } static void do_trunc(int fd) { off_t roffset = 0; roffset = random() % fsize; if (ftruncate(fd, (offset + roffset)) < 0) { perror("truncate"); exit(7); } if (vflag) { (void) fprintf(stderr, "Truncated at offset %ld\n", (offset + roffset)); } } diff --git a/tests/sys/cddl/zfs/bin/file_write.c b/tests/sys/cddl/zfs/bin/file_write.c index 07ba6503dff8..68e45253064e 100644 --- a/tests/sys/cddl/zfs/bin/file_write.c +++ b/tests/sys/cddl/zfs/bin/file_write.c @@ -1,241 +1,240 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)file_write.c 1.4 07/10/09 SMI" #include "file_common.h" #include #include static unsigned char bigbuffer[BIGBUFFERSIZE]; /* * Writes (or appends) a given value to a file repeatedly. * See header file for defaults. */ static void usage(void) __dead2; static char *execname; int main(int argc, char **argv) { int bigfd; int c; int oflag = 0; int err = 0; int k; long i; int64_t good_writes = 0; uint8_t nxtfillchar; /* * Default Parameters */ int write_count = BIGFILESIZE; uint8_t fillchar = DATA; int block_size = BLOCKSZ; char *filename = NULL; char *operation = NULL; off_t noffset, offset = 0; int verbose = 0; int rsync = 0; int wsync = 0; execname = argv[0]; /* * Process Arguments */ while ((c = getopt(argc, argv, "b:c:d:s:f:o:vwr")) != -1) { switch (c) { case 'b': block_size = atoi(optarg); break; case 'c': write_count = atoi(optarg); break; case 'd': fillchar = atoi(optarg); break; case 's': offset = atoll(optarg); break; case 'f': filename = optarg; break; case 'o': operation = optarg; break; case 'v': verbose = 1; break; case 'w': wsync = 1; break; case 'r': rsync = 1; break; case '?': (void) printf("unknown arg %c\n", optopt); usage(); break; } } /* * Validate Parameters */ if (!filename) { (void) printf("Filename not specified (-f )\n"); err++; } if (!operation) { (void) printf("Operation not specified (-o ).\n"); err++; } if (block_size > BIGBUFFERSIZE) { (void) printf("block_size is too large max==%d.\n", BIGBUFFERSIZE); err++; } if (err) usage(); /* * Prepare the buffer and determine the requested operation */ nxtfillchar = fillchar; k = 0; for (i = 0; i < block_size; i++) { bigbuffer[i] = nxtfillchar; if (fillchar == 0) { if ((k % DATA_RANGE) == 0) { k = 0; } nxtfillchar = k++; } } /* * using the strncmp of operation will make the operation match the * first shortest match - as the operations are unique from the first * character this means that we match single character operations */ if ((strncmp(operation, "create", strlen(operation) + 1)) == 0 || (strncmp(operation, "overwrite", strlen(operation) + 1)) == 0) { oflag = (O_RDWR|O_CREAT); } else if ((strncmp(operation, "append", strlen(operation) + 1)) == 0) { oflag = (O_RDWR|O_APPEND); } else { (void) printf("valid operations are not '%s'\n", operation); usage(); } #ifdef UNSUPPORTED if (rsync) { oflag = oflag | O_RSYNC; } #endif if (wsync) { oflag = oflag | O_SYNC; } /* * Given an operation (create/overwrite/append), open the file * accordingly and perform a write of the appropriate type. */ if ((bigfd = open(filename, oflag, 0666)) == -1) { (void) printf("open %s: failed [%s]%d. Aborting!\n", filename, strerror(errno), errno); exit(errno); } noffset = lseek(bigfd, offset, SEEK_SET); if (noffset != offset) { (void) printf("lseek %s (%"PRId64"/%"PRId64") " "failed [%s]%d. Aborting!\n", filename, offset, noffset, strerror(errno), errno); exit(errno); } if (verbose) { (void) printf("%s: block_size = %d, write_count = %d, " "offset = %"PRId64", data = %s%d\n", filename, block_size, write_count, offset, (fillchar == 0) ? "0->" : "", (fillchar == 0) ? DATA_RANGE : fillchar); } for (i = 0; i < write_count; i++) { ssize_t n; if ((n = write(bigfd, &bigbuffer, block_size)) == -1) { (void) printf("write failed (%ld), " "good_writes = %"PRId64", " "error: %s[%d]\n", (long)n, good_writes, strerror(errno), errno); exit(errno); } good_writes++; } if (verbose) { (void) printf("Success: good_writes = %"PRId64" (%"PRId64")\n", good_writes, (good_writes * block_size)); } return (0); } static void usage(void) { char *base = (char *)"file_write"; char *exec = (char *)execname; if (exec != NULL) exec = strdup(exec); if (exec != NULL) base = basename(exec); (void) printf("Usage: %s [-v] -o {create,overwrite,append} -f file_name" " [-b block_size]\n" "\t[-s offset] [-c write_count] [-d data]\n" "\twhere [data] equal to zero causes chars " "0->%d to be repeated throughout\n", base, DATA_RANGE); if (exec) { free(exec); } exit(1); } diff --git a/tests/sys/cddl/zfs/bin/largest_file.c b/tests/sys/cddl/zfs/bin/largest_file.c index 67b7b95dbbea..5b57ef048da0 100644 --- a/tests/sys/cddl/zfs/bin/largest_file.c +++ b/tests/sys/cddl/zfs/bin/largest_file.c @@ -1,132 +1,131 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)largest_file.c 1.3 07/05/25 SMI" #include "file_common.h" #include #include #include /* * -------------------------------------------------------------- * * Assertion: * The last byte of the largest file size can be * accessed without any errors. Also, the writing * beyond the last byte of the largest file size * will produce an errno of EFBIG. * * -------------------------------------------------------------- * If the write() system call below returns a "1", * then the last byte can be accessed. * -------------------------------------------------------------- */ static void sigxfsz(int); static void usage(char *); int main(int argc, char **argv) { int fd = 0; off_t offset = (OFF_MAX - 1); off_t lseek_ret = 0; int write_ret = 0; int err = 0; char mybuf[5]; char *testfile; if (argc != 2) { usage(argv[0]); } (void) sigset(SIGXFSZ, sigxfsz); testfile = strdup(argv[1]); fd = open(testfile, O_CREAT | O_RDWR); if (fd < 0) { perror("Failed to create testfile"); err = errno; goto out; } lseek_ret = lseek(fd, offset, SEEK_SET); if (lseek_ret < 0) { perror("Failed to seek to end of testfile"); err = errno; goto out; } write_ret = write(fd, mybuf, 1); if (write_ret < 0) { perror("Failed to write to end of file"); err = errno; goto out; } offset = 0; lseek_ret = lseek(fd, offset, SEEK_CUR); if (lseek_ret < 0) { perror("Failed to seek to end of file"); err = errno; goto out; } write_ret = write(fd, mybuf, 1); if (write_ret < 0) { if (errno == EFBIG) { (void) printf("write errno=EFBIG: success\n"); err = 0; } else { perror("Did not receive EFBIG"); err = errno; } } else { (void) printf("write completed successfully, test failed\n"); err = 1; } out: (void) unlink(testfile); free(testfile); return (err); } static void usage(char *name) { (void) printf("%s \n", name); exit(1); } /* ARGSUSED */ static void sigxfsz(int signo) { (void) printf("\nlargest_file: sigxfsz() caught SIGXFSZ\n"); } diff --git a/tests/sys/cddl/zfs/bin/mktree.c b/tests/sys/cddl/zfs/bin/mktree.c index 03aa2d676098..149c981ec7a1 100644 --- a/tests/sys/cddl/zfs/bin/mktree.c +++ b/tests/sys/cddl/zfs/bin/mktree.c @@ -1,196 +1,195 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)mktree.c 1.3 07/05/25 SMI" #include #include #include #include #include #include #include #include #include #define TYPE_D 'D' #define TYPE_F 'F' extern int errno; static char fdname[MAXPATHLEN] = {0}; static char *pbasedir = NULL; static int nlevel = 2; static int ndir = 2; static int nfile = 2; static void usage(char *this); static void crtfile(char *pname); static char *getfdname(char *pdir, char type, int level, int dir, int file); static int mktree(char *pbasedir, int level); int main(int argc, char *argv[]) { int c, ret; while ((c = getopt(argc, argv, "b:l:d:f:")) != -1) { switch (c) { case 'b': pbasedir = optarg; break; case 'l': nlevel = atoi(optarg); break; case 'd': ndir = atoi(optarg); break; case 'f': nfile = atoi(optarg); break; case '?': usage(argv[0]); } } if (nlevel < 0 || ndir < 0 || nfile < 0 || pbasedir == NULL) { usage(argv[0]); } ret = mktree(pbasedir, 1); return (ret); } static void usage(char *this) { (void) fprintf(stderr, "\tUsage: %s -b -l [nlevel] -d [ndir] -f [nfile]\n", this); exit(1); } static int mktree(char *pdir, int level) { int d, f; char dname[MAXPATHLEN] = {0}; char fname[MAXPATHLEN] = {0}; if (level > nlevel) { return (1); } for (d = 0; d < ndir; d++) { (void) memset(dname, '\0', sizeof (dname)); (void) strcpy(dname, getfdname(pdir, TYPE_D, level, d, 0)); if (mkdir(dname, 0777) != 0) { (void) fprintf(stderr, "mkdir(%s) failed." "\n[%d]: %s.\n", dname, errno, strerror(errno)); exit(errno); } /* * No sub-directory need be created, only create files in it. */ if (mktree(dname, level+1) != 0) { for (f = 0; f < nfile; f++) { (void) memset(fname, '\0', sizeof (fname)); (void) strcpy(fname, getfdname(dname, TYPE_F, level+1, d, f)); crtfile(fname); } } } for (f = 0; f < nfile; f++) { (void) memset(fname, '\0', sizeof (fname)); (void) strcpy(fname, getfdname(pdir, TYPE_F, level, d, f)); crtfile(fname); } return (0); } static char * getfdname(char *pdir, char type, int level, int dir, int file) { (void) snprintf(fdname, sizeof (fdname), "%s/%c-l%dd%df%d", pdir, type, level, dir, file); return (fdname); } static void crtfile(char *pname) { int fd = -1; int afd = -1; int i, size; char *context = "0123456789ABCDF"; char *pbuf; if (pname == NULL) { exit(1); } size = sizeof (char) * 1024; pbuf = (char *)valloc(size); for (i = 0; i < size / strlen(context); i++) { int offset = i * strlen(context); (void) snprintf(pbuf+offset, size-offset, "%s", context); } if ((fd = open(pname, O_CREAT|O_RDWR, 0777)) < 0) { (void) fprintf(stderr, "open(%s, O_CREAT|O_RDWR, 0777) failed." "\n[%d]: %s.\n", pname, errno, strerror(errno)); exit(errno); } if (write(fd, pbuf, 1024) < 1024) { (void) fprintf(stderr, "write(fd, pbuf, 1024) failed." "\n[%d]: %s.\n", errno, strerror(errno)); exit(errno); } #if UNSUPPORTED if ((afd = openat(fd, "xattr", O_CREAT | O_RDWR | O_XATTR, 0777)) < 0) { (void) fprintf(stderr, "openat failed.\n[%d]: %s.\n", errno, strerror(errno)); exit(errno); } if (write(afd, pbuf, 1024) < 1024) { (void) fprintf(stderr, "write(afd, pbuf, 1024) failed." "\n[%d]: %s.\n", errno, strerror(errno)); exit(errno); } (void) close(afd); #endif (void) close(fd); free(pbuf); } diff --git a/tests/sys/cddl/zfs/bin/mmapwrite.c b/tests/sys/cddl/zfs/bin/mmapwrite.c index 756b33b5cb98..57ff66d7ec0e 100644 --- a/tests/sys/cddl/zfs/bin/mmapwrite.c +++ b/tests/sys/cddl/zfs/bin/mmapwrite.c @@ -1,99 +1,98 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)mmapwrite.c 1.4 07/05/25 SMI" #include #include #include #include #include #include /* * -------------------------------------------------------------------- * Bug Id: 5032643 * * Simply writing to a file and mmaping that file at the same time can * result in deadlock. Nothing perverse like writing from the file's * own mapping is required. * -------------------------------------------------------------------- */ static void * mapper(void *fdp) { void *addr; int fd = *(int *)fdp; if ((addr = mmap(0, 8192, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { perror("mmap"); exit(1); } for (;;) { if (mmap(addr, 8192, PROT_READ, MAP_SHARED|MAP_FIXED, fd, 0) == MAP_FAILED) { perror("mmap"); exit(1); } } /* NOTREACHED */ return ((void *)1); } int main(int argc, char **argv) { int fd; char buf[BUFSIZ]; pthread_t pt; if (argc != 2) { (void) printf("usage: %s \n", argv[0]); exit(1); } if ((fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC, 0666)) == -1) { perror("open"); exit(1); } if (pthread_create(&pt, NULL, mapper, &fd) != 0) { perror("pthread_create"); exit(1); } for (;;) { if (write(fd, buf, sizeof (buf)) == -1) { perror("write"); exit(1); } } /* NOTREACHED */ return (0); } diff --git a/tests/sys/cddl/zfs/bin/randfree_file.c b/tests/sys/cddl/zfs/bin/randfree_file.c index 3c43abcf6c27..ff5f99e28cce 100644 --- a/tests/sys/cddl/zfs/bin/randfree_file.c +++ b/tests/sys/cddl/zfs/bin/randfree_file.c @@ -1,104 +1,103 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)randfree_file.c 1.3 07/05/25 SMI" #include "file_common.h" /* * Create a file with assigned size and then free the specified * section of the file */ static void usage(char *progname); static void usage(char *progname) { (void) fprintf(stderr, "usage: %s [-l filesize] [-s start-offset]" "[-n section-len] filename\n", progname); exit(1); } int main(int argc, char *argv[]) { char *filename, *buf; size_t filesize; off_t start_off, off_len; int fd, ch; struct flock fl; while ((ch = getopt(argc, argv, "l:s:n:")) != EOF) { switch (ch) { case 'l': filesize = atoll(optarg); break; case 's': start_off = atoll(optarg); break; case 'n': off_len = atoll(optarg); break; default: usage(argv[0]); break; } } if (optind == argc - 1) filename = argv[optind]; else usage(argv[0]); buf = (char *)malloc(filesize); if ((fd = open(filename, O_RDWR|O_CREAT|O_TRUNC)) < 0) { perror("open"); return (1); } if (write(fd, buf, filesize) < filesize) { perror("write"); return (1); } #if UNSUPPORTED fl.l_whence = SEEK_SET; fl.l_start = start_off; fl.l_len = off_len; if (fcntl(fd, F_FREESP, &fl) != 0) { perror("fcntl"); return (1); } #else fprintf(stderr, "fcntl: F_FREESP not supported\n"); return (1); #endif free(buf); return (0); } diff --git a/tests/sys/cddl/zfs/bin/readmmap.c b/tests/sys/cddl/zfs/bin/readmmap.c index c21697798285..4e360c762e45 100644 --- a/tests/sys/cddl/zfs/bin/readmmap.c +++ b/tests/sys/cddl/zfs/bin/readmmap.c @@ -1,141 +1,140 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)readmmap.c 1.4 07/05/25 SMI" /* * -------------------------------------------------------------- * BugId 5047993 : Getting bad read data. * * Usage: readmmap * * where: * filename is an absolute path to the file name. * * Return values: * 1 : error * 0 : no errors * -------------------------------------------------------------- */ #include #include #include #include #include #include #include int main(int argc, char **argv) { char *filename = "badfile"; size_t size = 4395; size_t idx = 0; char *buf = NULL; char *map = NULL; int fd = -1, bytes, retval = 0; unsigned seed; if (argc < 2 || optind == argc) { (void) fprintf(stderr, "usage: %s \n", argv[0]); exit(1); } if ((buf = calloc(1, size)) == NULL) { perror("calloc"); exit(1); } filename = argv[optind]; (void) remove(filename); fd = open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fd == -1) { perror("open to create"); retval = 1; goto end; } bytes = write(fd, buf, size); if (bytes != size) { (void) printf("short write: %d != %zu\n", bytes, size); retval = 1; goto end; } map = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (map == MAP_FAILED) { perror("mmap"); retval = 1; goto end; } seed = time(NULL); srandom(seed); idx = random() % size; map[idx] = 1; if (msync(map, size, MS_SYNC) != 0) { perror("msync"); retval = 1; goto end; } if (munmap(map, size) != 0) { perror("munmap"); retval = 1; goto end; } bytes = pread(fd, buf, size, 0); if (bytes != size) { (void) printf("short read: %d != %zu\n", bytes, size); retval = 1; goto end; } if (buf[idx] != 1) { (void) printf( "bad data from read! got buf[%zu]=%d, expected 1\n", idx, buf[idx]); retval = 1; goto end; } (void) printf("good data from read: buf[%zu]=1\n", idx); end: if (fd != -1) { (void) close(fd); } if (buf != NULL) { free(buf); } return (retval); } diff --git a/tests/sys/cddl/zfs/bin/rename_dir.c b/tests/sys/cddl/zfs/bin/rename_dir.c index 3a475f2544d3..b84cb46f5ba4 100644 --- a/tests/sys/cddl/zfs/bin/rename_dir.c +++ b/tests/sys/cddl/zfs/bin/rename_dir.c @@ -1,92 +1,91 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)rename_dir.c 1.1 07/05/25 SMI" /* * Assertion: * Create two directory trees in zfs filesystem, and rename * directory across the directory structure. ZFS can handle * the race situation. */ /* * Need to create the following directory structures before * running this program: * * mkdir -p 1/2/3/4/5 a/b/c/d/e */ #include #include #include #include int main() { int i = 1; char buf[256]; char *msg = "rename() fails to handle race situation\n"; switch (fork()) { case -1: perror("fork"); exit(1); break; case 0: while (i > 0) { int c_count = 0; if (rename("a/b/c", "1/2/3/c") == 0) c_count++; if (rename("1/2/3/c", "a/b/c") == 0) c_count++; if (c_count) { (void) strlcat(buf, "c_count: %d,", 256); (void) strlcat(buf, msg, 256); (void) fprintf(stderr, buf, c_count); } } break; default: while (i > 0) { int p_count = 0; if (rename("1", "a/b/c/d/e/1") == 0) p_count++; if (rename("a/b/c/d/e/1", "1") == 0) p_count++; if (p_count) { (void) strlcat(buf, "p_count: %d,", 256); (void) strlcat(buf, msg, 256); (void) fprintf(stderr, buf, p_count); } } break; } return (0); } diff --git a/tests/sys/cddl/zfs/bin/rm_lnkcnt_zero_file.c b/tests/sys/cddl/zfs/bin/rm_lnkcnt_zero_file.c index c6ebb22b3d38..0ece80a6813c 100644 --- a/tests/sys/cddl/zfs/bin/rm_lnkcnt_zero_file.c +++ b/tests/sys/cddl/zfs/bin/rm_lnkcnt_zero_file.c @@ -1,148 +1,147 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)rm_lnkcnt_zero_file.c 1.3 07/05/25 SMI" /* * -------------------------------------------------------------------- * The purpose of this test is to see if the bug reported (#4723351) for * UFS exists when using a ZFS file system. * -------------------------------------------------------------------- * */ #define _REENTRANT 1 #include #include #include #include #include #include #include #include static const int TRUE = 1; static char *filebase; static int pickidx() { return (random() % 1000); } /* ARGSUSED */ static void * mover(void *a) { char buf[256]; int idx, ret; while (TRUE) { idx = pickidx(); (void) sprintf(buf, "%s.%03d", filebase, idx); ret = rename(filebase, buf); if (ret < 0 && errno != ENOENT) (void) perror("renaming file"); } return (NULL); } /* ARGSUSED */ static void * cleaner(void *a) { char buf[256]; int idx, ret; while (TRUE) { idx = pickidx(); (void) sprintf(buf, "%s.%03d", filebase, idx); ret = remove(buf); if (ret < 0 && errno != ENOENT) (void) perror("removing file"); } return (NULL); } static void * writer(void *a) { int *fd = (int *)a; while (TRUE) { (void) close (*fd); *fd = open(filebase, O_APPEND | O_RDWR | O_CREAT, 0644); if (*fd < 0) perror("refreshing file"); (void) write(*fd, "test\n", 5); } return (NULL); } int main(int argc, char **argv) { int fd; pthread_t tid; if (argc == 1) { (void) printf("Usage: %s \n", argv[0]); exit(-1); } filebase = argv[1]; fd = open(filebase, O_APPEND | O_RDWR | O_CREAT, 0644); if (fd < 0) { perror("creating test file"); exit(-1); } if (pthread_setconcurrency(4)) { /* 3 threads + main */ fprintf(stderr, "failed to set concurrency\n"); exit(-1); } (void) pthread_create(&tid, NULL, mover, NULL); (void) pthread_create(&tid, NULL, cleaner, NULL); (void) pthread_create(&tid, NULL, writer, (void *) &fd); while (TRUE) { int ret; struct stat st; ret = stat(filebase, &st); if (ret == 0 && (st.st_nlink > 2 || st.st_nlink < 1)) { (void) printf("st.st_nlink = %d, exiting\n", \ (int)st.st_nlink); exit(0); } (void) sleep(1); } return (0); } diff --git a/tests/sys/cddl/zfs/tests/ctime/ctime_001_pos.c b/tests/sys/cddl/zfs/tests/ctime/ctime_001_pos.c index d858cebd26a8..02feb0343f86 100644 --- a/tests/sys/cddl/zfs/tests/ctime/ctime_001_pos.c +++ b/tests/sys/cddl/zfs/tests/ctime/ctime_001_pos.c @@ -1,381 +1,380 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)ctime_001_pos.c 1.1 07/05/25 SMI" #include #include #include #include #include #include #include #include #include #define ST_ATIME 0 #define ST_CTIME 1 #define ST_MTIME 2 #define ALL_MODE (mode_t)(S_IRWXU|S_IRWXG|S_IRWXO) typedef struct timetest { int type; char *name; int (*func)(const char *pfile); } timetest_t; #ifdef __stc_assertion__ /* * ID: ctime_001_pos * * DESCRIPTION: * Verify time will be changed correctly according to relevant operating. * * STRATEGY: * 1. Define time test array. * 2. loop each item in this array. * 3. Verify the time will be changed after relevant operating. * * TESTABILITY: explicit * * TEST_AUTOMATION_LEVEL: automated * * CODING_STATUS: COMPLETED (2007-01-30) * */ #endif /* __stc_assertion__ */ /* * Get file specific time information. */ int get_file_time(char *pfile, int what, time_t *ptr); int do_read(const char *pfile); int do_write(const char *pfile); int do_link(const char *pfile); int do_creat(const char *pfile); int do_utime(const char *pfile); int do_chmod(const char *pfile); int do_chown(const char *pfile); static char tfile[BUFSIZ] = { 0 }; static char msg[BUFSIZ] = { 0 }; static timetest_t timetest_table[] = { { ST_ATIME, "st_atime", do_read }, { ST_ATIME, "st_atime", do_utime }, { ST_MTIME, "st_mtime", do_creat }, { ST_MTIME, "st_mtime", do_write }, { ST_MTIME, "st_mtime", do_utime }, { ST_CTIME, "st_ctime", do_creat }, { ST_CTIME, "st_ctime", do_write }, { ST_CTIME, "st_ctime", do_chmod }, { ST_CTIME, "st_ctime", do_chown }, { ST_CTIME, "st_ctime", do_link }, { ST_CTIME, "st_ctime", do_utime }, }; #define NCOMMAND (sizeof (timetest_table) / sizeof (timetest_table[0])) int main(int argc, char *argv[]) { int i, ret, fd; const char *env_names[2] = {"TESTDIR", "TESTFILE"}; char *env_vals[2]; /* * Get envirnment variable value */ for (i = 0; i < sizeof (env_names) / sizeof (char *); i++) { if ((env_vals[i] = getenv(env_names[i])) == NULL) { fprintf(stderr, "getenv(%s) returned NULL\n", env_names[i]); exit(1); } } (void) snprintf(tfile, sizeof (tfile), "%s/%s", env_vals[0], env_vals[1]); /* * If the test file is existing, remove it firstly */ if (access(tfile, F_OK) == 0) { unlink(tfile); } fd = open(tfile, O_WRONLY | O_CREAT | O_TRUNC, ALL_MODE); if (fd < 0) { perror("open"); exit(1); } (void) close(fd); for (i = 0; i < NCOMMAND; i++) { time_t t1, t2; /* * Get original time before operating. */ ret = get_file_time(tfile, timetest_table[i].type, &t1); if (ret != 0) { fprintf(stderr, "ERROR: get_file_time(%s, %d, &t1) returned %d\n", tfile, timetest_table[i].type, ret); exit(1); } /* * Sleep 2 seconds to be sure that the timeofday has changed, * then invoke command on given file */ sleep(2); timetest_table[i].func(tfile); /* * Get time after operating. */ ret = get_file_time(tfile, timetest_table[i].type, &t2); if (ret != 0) { fprintf(stderr, "get_file_time(%s, %d, &t2)\n", tfile, timetest_table[i].type); exit(1); } if (t1 == t2) { fprintf(stderr, "%s: t1(%ld) == t2(%ld)\n", timetest_table[i].name, (long)t1, (long)t2); exit(1); } } (void) unlink(tfile); return (0); } int get_file_time(char *pfile, int what, time_t *ptr) { struct stat stat_buf; if (pfile == NULL || ptr == NULL) { return (-1); } if (stat(pfile, &stat_buf) == -1) { return (-1); } switch (what) { case ST_ATIME: *ptr = stat_buf.st_atime; return (0); case ST_CTIME: *ptr = stat_buf.st_ctime; return (0); case ST_MTIME: *ptr = stat_buf.st_mtime; return (0); default: return (-1); } } int do_read(const char *pfile) { int fd, ret = 0; char buf[BUFSIZ] = { 0 }; if (pfile == NULL) { return (-1); } if ((fd = open(pfile, O_RDONLY, ALL_MODE)) == -1) { return (-1); } if (read(fd, buf, sizeof (buf)) == -1) { ret = errno; } (void) close(fd); if (ret != 0) { fprintf(stderr, "read(%d, buf, %zu)\n", fd, sizeof (buf)); exit(1); } return (ret); } int do_write(const char *pfile) { int fd, ret = 0; char buf[BUFSIZ] = "call function do_write()"; if (pfile == NULL) { return (-1); } if ((fd = open(pfile, O_WRONLY, ALL_MODE)) == -1) { return (-1); } if (write(fd, buf, strlen(buf)) == -1) { ret = errno; } (void) close(fd); if (ret != 0) { fprintf(stderr, "write(%d, buf, %zu)\n", fd, strlen(buf)); exit(1); } return (ret); } int do_link(const char *pfile) { int ret = 0; char link_file[BUFSIZ] = { 0 }; char *ptr = link_file; if (pfile == NULL) { return (-1); } /* * Figure out source file directory name, and create * the link file in the same directory. */ snprintf(link_file, sizeof (link_file), "%s", pfile); ptr = strrchr(link_file, '/'); snprintf(ptr + 1, sizeof (link_file) - (ptr + 1 - link_file), "link_file"); if (link(pfile, link_file) == -1) { ret = errno; } if (ret != 0) { fprintf(stderr, "link(%s, %s)\n", pfile, link_file); exit(1); } unlink(link_file); return (ret); } int do_creat(const char *pfile) { int fd, ret = 0; if (pfile == NULL) { return (-1); } if ((fd = creat(pfile, ALL_MODE)) == -1) { ret = errno; } if (fd != -1) { (void) close(fd); } if (ret != 0) { fprintf(stderr, "creat(%s, ALL_MODE)\n", pfile); exit(1); } return (ret); } int do_utime(const char *pfile) { int ret = 0; if (pfile == NULL) { return (-1); } /* * Times of the file are set to the current time */ if (utime(pfile, NULL) == -1) { ret = errno; } if (ret != 0) { fprintf(stderr, "utime(%s, NULL)\n", pfile); exit(1); } return (ret); } int do_chmod(const char *pfile) { int ret = 0; if (pfile == NULL) { return (-1); } if (chmod(pfile, ALL_MODE) == -1) { ret = errno; } if (ret != 0) { fprintf(stderr, "chmod(%s, ALL_MODE)\n", pfile); exit(1); } return (ret); } int do_chown(const char *pfile) { int ret = 0; if (pfile == NULL) { return (-1); } if (chown(pfile, getuid(), getgid()) == -1) { ret = errno; } if (ret != 0) { fprintf(stderr, "chown(%s, %d, %d)\n", pfile, (int)getuid(), (int)getgid()); exit(1); } return (ret); } diff --git a/tests/sys/cddl/zfs/tests/exec/mmap_exec.c b/tests/sys/cddl/zfs/tests/exec/mmap_exec.c index 409bf2ffca1e..23e61b5cf775 100644 --- a/tests/sys/cddl/zfs/tests/exec/mmap_exec.c +++ b/tests/sys/cddl/zfs/tests/exec/mmap_exec.c @@ -1,70 +1,69 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)mmap_exec.c 1.3 07/05/25 SMI" #include #include #include #include #include #include extern int errno; int main(int argc, char *argv[]) { int fd; struct stat statbuf; if (argc != 2) { (void) printf("Error: missing binary name.\n"); (void) printf("Usage:\n\t%s \n", argv[0]); return (1); } errno = 0; if ((fd = open(argv[1], O_RDONLY)) < 0) { perror("open"); return (errno); } if (fstat(fd, &statbuf) < 0) { perror("fstat"); return (errno); } if (mmap(0, statbuf.st_size, PROT_EXEC, MAP_SHARED, fd, 0) == MAP_FAILED) { perror("mmap"); return (errno); } return (0); } diff --git a/tests/sys/cddl/zfs/tests/threadsappend/threadsappend.c b/tests/sys/cddl/zfs/tests/threadsappend/threadsappend.c index bd264cd66c59..2c311675431a 100644 --- a/tests/sys/cddl/zfs/tests/threadsappend/threadsappend.c +++ b/tests/sys/cddl/zfs/tests/threadsappend/threadsappend.c @@ -1,135 +1,134 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #pragma ident "@(#)threadsappend.c 1.3 07/05/25 SMI" #include #include #include #include #include #include #include #include #include /* * The size of the output file, "go.out", should be 80*8192*2 = 1310720 * * $ cd /tmp; go; ls -l go.out * done. * -rwxr-xr-x 1 jdm staff 1310720 Apr 13 19:45 go.out * $ cd /zfs; go; ls -l go.out * done. * -rwxr-xr-x 1 jdm staff 663552 Apr 13 19:45 go.out * * The file on zfs is short as it does not appear that zfs is making the * implicit seek to EOF and the actual write atomic. From the SUSv3 * interface spec, behavior is undefined if concurrent writes are performed * from multi-processes to a single file. So I don't know if this is a * standards violation, but I cannot find any such disclaimers in our * man pages. This issue came up at a customer site in another context, and * the suggestion was to open the file with O_APPEND, but that wouldn't * help with zfs(see 4977529). Also see bug# 5031301. */ static int outfd = 0; static void * go(void *data) { int i = 0, n = *(int *)data; ssize_t ret = 0; char buf[8192] = {0}; (void) memset(buf, n, sizeof (buf)); for (i = 0; i < 80; i++) { ret = write(outfd, buf, sizeof (buf)); } return (NULL); } static void usage() { (void) fprintf(stderr, "usage: zfs_threadsappend \n"); exit(1); } int main(int argc, char **argv) { pthread_t threads[2]; int ret = 0; long ncpus = 0; int i; if (argc != 2) { usage(); } ncpus = sysconf(_SC_NPROCESSORS_ONLN); if (ncpus < 0) { (void) fprintf(stderr, "Invalid return from sysconf(_SC_NPROCESSORS_ONLN)" " : errno (decimal)=%d\n", errno); exit(1); } if (ncpus < 2) { (void) fprintf(stderr, "Must execute this binary on a multi-processor system\n"); exit(1); } outfd = open(argv[optind++], O_RDWR|O_CREAT|O_APPEND|O_TRUNC, 0777); if (outfd == -1) { (void) fprintf(stderr, "zfs_threadsappend: " "open(%s, O_RDWR|O_CREAT|O_APPEND|O_TRUNC, 0777)" " failed\n", argv[optind]); perror("open"); exit(1); } for (i = 0; i < 2; i++) { ret = pthread_create(&threads[i], NULL, go, (void *)&i); if (ret != 0) { (void) fprintf(stderr, "zfs_threadsappend: thr_create(#%d) " "failed error=%d\n", i+1, ret); exit(1); } } for (i = 0; i < 2; i++) { if (pthread_join(threads[i], NULL) != 0) break; } return (0); } diff --git a/tests/sys/cddl/zfs/tests/txg_integrity/fsync_integrity.c b/tests/sys/cddl/zfs/tests/txg_integrity/fsync_integrity.c index b2d4bf0dc11a..17c6b63d45d8 100644 --- a/tests/sys/cddl/zfs/tests/txg_integrity/fsync_integrity.c +++ b/tests/sys/cddl/zfs/tests/txg_integrity/fsync_integrity.c @@ -1,517 +1,516 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2013 Spectra Logic. All rights reserved. * Use is subject to license terms. */ /* * Verify the integrity of non-aligned writes to the same blocks within the same * transaction group, where an fsync is issued by a non-final writer. * * This test verifies that the unoverride in the following sequence of events is * handled correctly: * * 1) A new transaction group opens * 2) A write is issued to a certain block * 3) The writer fsyncs() that file * 4) TBD module immediately writes that block, then places an override in the * syncer's TBD data structure, indicating that it doesn't need to write that * block when syncing. * 5) Another write is issued to the same block, with different data. * 6) TBD module unoverrides that block in the syncer's TBD data structure * 7) The syncer writes that block * * Outline: * Create a big zero-filled file. * Create a bunch of different IO patterns. Each IO pattern consists of: * * A partition of the file range into 64 different non-overlapping chunks. * * A permutation of those chunks * For each repetition: * For each IO pattern: * Create one binary semaphore per chunk, per (n-1) threads * Create n threads. * The first thread will write each chunk in order. It will post a * semaphore after each write to indicate that it has completed * writing that chunk. * The second thread will pend on those semaphores in order. Each time it * receives a semaphore, it will write a different pattern to that * chunk. Then it will post a different semaphore to signal the next * thread. * The final thread will not post any semaphores * Every even-numbered thread, starting with the first (0th), will fsync() * the file after its write. The final thread, being odd-numbered, * won't. * Join all threads * Read the entire file and verify that * 1) Every write went to the correct location * 2) The final thread's write is left in the file */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define NUM_REPETITIONS 16 #define CLUSTERSIZE (1 << 17) #define NUM_CHUNKS 64 #define FSIZE (64 * (CLUSTERSIZE)) //FSIZE may range from NUM_CHUNKS clusters to 8GB #define USE_THREADS 1 #define NUM_THREADS 8 typedef struct { //partitions describes the boundaries between chunks. Each element is a //fraction of the filesize in 1.31 fixed point format. So the boundary //between chunk n and chunk n-1 is (FSIZE * partitions[n-1] / (1<<31) . //partitions[-1] is understood to be 0 and partitions[NUM_CHUNKS] must be 1.0 //partitions is sorted, of course. //Partition boundaries must be dword aligned. Thus, in order to work with //multiple values of FSIZE, partitions values must be aligned to multiples of //8 / (NUM_CHUNKS * CLUSTERSIZE) = 1 / 524288 = 0x0.00002 uint32_t partitions[NUM_CHUNKS]; int permutation[NUM_CHUNKS]; //the order in which to write the chunks } pattern_t; typedef struct { int thread_num; pattern_t* pat; } thread_data_t; /* Returns (via begin and end) the range of a chunk. Begin is inclusive, * end is exclusive */ void get_chunk_range(const pattern_t* pat, int chunk, uint32_t* begin, uint32_t* end){ if (chunk == 0){ *begin = 0; } else{ *begin = (uint32_t)((uint64_t)FSIZE * (uint64_t)pat->partitions[chunk - 1] >> 31); } *end = (uint32_t)((uint64_t)FSIZE * (uint64_t)pat->partitions[chunk] >> 31); } /* The most basic, trivial IO pattern. Fully sequential, and the follower * writes every other block */ const pattern_t trivial_pattern = { {0x2000000, 0x4000000, 0x6000000, 0x8000000, 0xa000000, 0xc000000, 0xe000000, 0x10000000, 0x12000000, 0x14000000, 0x16000000, 0x18000000, 0x1a000000, 0x1c000000, 0x1e000000, 0x20000000, 0x22000000, 0x24000000, 0x26000000, 0x28000000, 0x2a000000, 0x2c000000, 0x2e000000, 0x30000000, 0x32000000, 0x34000000, 0x36000000, 0x38000000, 0x3a000000, 0x3c000000, 0x3e000000, 0x40000000, 0x42000000, 0x44000000, 0x46000000, 0x48000000, 0x4a000000, 0x4c000000, 0x4e000000, 0x50000000, 0x52000000, 0x54000000, 0x56000000, 0x58000000, 0x5a000000, 0x5c000000, 0x5e000000, 0x60000000, 0x62000000, 0x64000000, 0x66000000, 0x68000000, 0x6a000000, 0x6c000000, 0x6e000000, 0x70000000, 0x72000000, 0x74000000, 0x76000000, 0x78000000, 0x7a000000, 0x7c000000, 0x7e000000, 0x80000000}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}, }; //The below patterns were randomly generated const pattern_t pat0 = { { 0x1eac000, 0x88a4000, 0xaffe000, 0xcdb7000, 0xd2d5000, 0xe16f000, 0xe499000, 0x11f71000, 0x1242d000, 0x12c07000, 0x143bc000, 0x1460a000, 0x15dd7000, 0x1700e000, 0x1be7e000, 0x1e14d000, 0x1e6ac000, 0x21097000, 0x24b74000, 0x27166000, 0x27669000, 0x30539000, 0x3218b000, 0x37591000, 0x37b60000, 0x39818000, 0x39d08000, 0x3c90e000, 0x3e54f000, 0x3fb99000, 0x42c8e000, 0x43a62000, 0x43f50000, 0x4c0c9000, 0x4c422000, 0x4c737000, 0x4d41e000, 0x4d738000, 0x4da71000, 0x4f4e8000, 0x508e3000, 0x51396000, 0x51ab5000, 0x52a02000, 0x54238000, 0x54d6a000, 0x55029000, 0x5584b000, 0x5c42c000, 0x5c4a7000, 0x5dac5000, 0x5fe4d000, 0x63f86000, 0x66ad0000, 0x67b3d000, 0x69ce5000, 0x6c179000, 0x6e79e000, 0x6f83f000, 0x71165000, 0x72bd9000, 0x7ac79000, 0x7dc94000, 0x80000000, }, { 57, 16, 28, 25, 10, 59, 52, 46, 30, 6, 40, 36, 39, 9, 21, 51, 33, 45, 44, 19, 2, 50, 55, 5, 58, 13, 23, 0, 12, 53, 42, 32, 31, 48, 35, 61, 49, 54, 18, 24, 8, 41, 62, 4, 47, 17, 1, 3, 34, 14, 63, 22, 15, 26, 38, 56, 27, 60, 29, 11, 7, 43, 20, 37, }, }; const pattern_t pat1 = { { 0x2b5000, 0x16db000, 0x5eb5000, 0x93a0000, 0xa7cb000, 0xa9e9000, 0xd144000, 0xe7c2000, 0xeb7d000, 0x10919000, 0x10cbd000, 0x11f85000, 0x17360000, 0x1760a000, 0x18eab000, 0x1ae6b000, 0x1c5f6000, 0x1df38000, 0x21bec000, 0x239d1000, 0x26b81000, 0x2747b000, 0x27a03000, 0x2b3cc000, 0x2cbf9000, 0x2ec0f000, 0x30a68000, 0x30bea000, 0x30c64000, 0x311af000, 0x35823000, 0x35d23000, 0x3b20e000, 0x405d8000, 0x414c8000, 0x43a91000, 0x44049000, 0x4ab4e000, 0x4ae21000, 0x4d293000, 0x511e5000, 0x516fc000, 0x52d77000, 0x57229000, 0x5da57000, 0x5dbe6000, 0x6070e000, 0x60fc0000, 0x64b24000, 0x67636000, 0x67658000, 0x6b040000, 0x6b28f000, 0x6e551000, 0x707c0000, 0x71b5c000, 0x72062000, 0x762a1000, 0x788a0000, 0x7a1e1000, 0x7b06a000, 0x7e04c000, 0x7f4cf000, 0x80000000, }, { 45, 8, 55, 9, 21, 54, 41, 7, 6, 22, 31, 47, 23, 11, 48, 53, 0, 61, 63, 50, 17, 27, 12, 19, 10, 40, 14, 51, 39, 59, 2, 43, 18, 42, 52, 28, 16, 44, 3, 5, 15, 35, 58, 33, 57, 49, 34, 30, 46, 4, 37, 60, 32, 36, 25, 56, 24, 13, 20, 38, 29, 26, 62, 1, }, }; const pattern_t pat2 = { { 0x912d000, 0xe610000, 0xf755000, 0x116df000, 0x128e5000, 0x1bd51000, 0x24e9a000, 0x27643000, 0x28cf4000, 0x292c9000, 0x2c907000, 0x2d389000, 0x2d941000, 0x2eb3f000, 0x30e94000, 0x31738000, 0x3343b000, 0x342ce000, 0x34d12000, 0x3536d000, 0x35e1a000, 0x35e4d000, 0x35fd5000, 0x3642b000, 0x3924d000, 0x392a5000, 0x3e531000, 0x3f0ee000, 0x3fdf8000, 0x41593000, 0x41c80000, 0x43959000, 0x43bc0000, 0x461c8000, 0x48922000, 0x49519000, 0x4f6fa000, 0x50274000, 0x508ae000, 0x536ed000, 0x54154000, 0x59894000, 0x5a666000, 0x5b0a6000, 0x5b9ff000, 0x5c109000, 0x5d8d0000, 0x5ddc5000, 0x5fcc5000, 0x63366000, 0x63adc000, 0x645b6000, 0x670eb000, 0x6b1b1000, 0x6c996000, 0x6ed2a000, 0x6ee4f000, 0x71fcd000, 0x734a3000, 0x76bdf000, 0x77b3f000, 0x7c65a000, 0x7d200000, 0x80000000, }, { 31, 35, 36, 52, 27, 56, 40, 13, 51, 49, 43, 37, 62, 42, 24, 29, 48, 25, 7, 61, 22, 57, 11, 32, 2, 54, 41, 6, 55, 15, 20, 26, 63, 44, 12, 4, 19, 58, 60, 59, 47, 23, 30, 50, 53, 34, 9, 38, 45, 8, 28, 3, 16, 33, 5, 21, 1, 10, 46, 18, 0, 14, 39, 17, }, }; const pattern_t pat3 = { { 0x553000, 0x19de000, 0x6a20000, 0x8a53000, 0x8ef9000, 0xc325000, 0x1132e000, 0x139fa000, 0x1426b000, 0x150ff000, 0x1bbc1000, 0x1e84c000, 0x1f43e000, 0x1f731000, 0x21ec8000, 0x231f4000, 0x23440000, 0x23466000, 0x260b6000, 0x286a7000, 0x29518000, 0x29e35000, 0x2fdb7000, 0x3089d000, 0x362e0000, 0x3c1f9000, 0x3df2d000, 0x3fce6000, 0x402f3000, 0x4117f000, 0x41e06000, 0x4374f000, 0x451e5000, 0x45a59000, 0x4956b000, 0x4960f000, 0x4a934000, 0x4bc6f000, 0x4d462000, 0x4eef8000, 0x4f609000, 0x50dc1000, 0x51022000, 0x54396000, 0x5641b000, 0x578f1000, 0x589cf000, 0x59093000, 0x5da6b000, 0x5fbf0000, 0x605a2000, 0x65428000, 0x65530000, 0x6705a000, 0x6db65000, 0x71cef000, 0x725a2000, 0x73bf5000, 0x75acb000, 0x76065000, 0x7614c000, 0x77aab000, 0x78f70000, 0x80000000, }, { 15, 30, 31, 16, 49, 13, 55, 59, 4, 24, 26, 44, 17, 0, 18, 54, 10, 3, 46, 34, 29, 22, 45, 5, 38, 32, 39, 50, 48, 53, 12, 25, 35, 56, 51, 52, 1, 33, 43, 63, 47, 37, 23, 20, 60, 14, 11, 21, 8, 57, 27, 41, 6, 58, 62, 2, 19, 61, 28, 36, 40, 7, 9, 42, }, }; const pattern_t pat4 = { { 0x425000, 0x8e8000, 0x4b90000, 0x883c000, 0x968e000, 0xbacc000, 0x10e59000, 0x125a1000, 0x12f00000, 0x14e7c000, 0x156de000, 0x192a1000, 0x1a2b9000, 0x1b4a0000, 0x1be9c000, 0x1d3bd000, 0x24242000, 0x2516b000, 0x2b88d000, 0x2b96a000, 0x2bcd3000, 0x2c5a9000, 0x2da74000, 0x2dba1000, 0x3097f000, 0x332ef000, 0x34525000, 0x36193000, 0x3725c000, 0x37e66000, 0x3d315000, 0x3e813000, 0x404ae000, 0x40c68000, 0x42f93000, 0x44b14000, 0x44b15000, 0x473b2000, 0x49048000, 0x4c794000, 0x50b60000, 0x52b3d000, 0x58c61000, 0x5b7d4000, 0x5ce71000, 0x5d21d000, 0x5d63e000, 0x5e00f000, 0x60e8b000, 0x66381000, 0x66c70000, 0x68430000, 0x707c2000, 0x71979000, 0x72681000, 0x74017000, 0x7721d000, 0x7a1be000, 0x7a2cd000, 0x7b225000, 0x7c311000, 0x7e03a000, 0x7e402000, 0x80000000, }, { 52, 62, 28, 47, 51, 37, 31, 36, 4, 58, 26, 29, 16, 59, 57, 33, 22, 27, 49, 44, 19, 56, 34, 23, 5, 14, 45, 48, 21, 25, 18, 12, 43, 53, 60, 17, 46, 15, 63, 30, 42, 38, 41, 8, 39, 20, 1, 10, 54, 40, 32, 24, 9, 2, 35, 3, 7, 0, 61, 11, 13, 55, 6, 50, }, }; const pattern_t pat5 = { { 0xae7000, 0x436e000, 0x81e1000, 0xb276000, 0xf8bf000, 0xfb26000, 0xfe7e000, 0x137ad000, 0x14b8e000, 0x157aa000, 0x1981a000, 0x1a32f000, 0x1bc9e000, 0x1def5000, 0x1e8ef000, 0x2068f000, 0x22692000, 0x22a6c000, 0x255bf000, 0x26977000, 0x27619000, 0x2977c000, 0x2ce0c000, 0x2e1ec000, 0x2e26c000, 0x31ce8000, 0x34e6c000, 0x365cd000, 0x37e87000, 0x385e3000, 0x3a7e2000, 0x3a9c7000, 0x41597000, 0x42e8a000, 0x453cc000, 0x454bf000, 0x4b24c000, 0x4ba54000, 0x4e307000, 0x4f059000, 0x55d5a000, 0x56277000, 0x56b90000, 0x5882d000, 0x5a2c5000, 0x5b369000, 0x5d442000, 0x5d671000, 0x5fdd0000, 0x60ce0000, 0x63713000, 0x64130000, 0x65973000, 0x67ad9000, 0x68764000, 0x68bb2000, 0x690d1000, 0x6a2c8000, 0x73e9f000, 0x74e75000, 0x77861000, 0x77ee5000, 0x7cddb000, 0x80000000, }, { 42, 25, 15, 58, 32, 61, 30, 56, 48, 62, 38, 50, 7, 45, 16, 29, 12, 4, 41, 3, 27, 18, 57, 10, 51, 17, 21, 14, 35, 19, 44, 47, 49, 26, 59, 63, 28, 55, 20, 13, 5, 6, 37, 54, 40, 22, 23, 46, 11, 36, 34, 31, 2, 60, 9, 52, 24, 1, 53, 0, 39, 43, 8, 33, }, }; const pattern_t pat6 = { { 0xad2000, 0x222f000, 0x64b4000, 0x6c66000, 0x6f35000, 0x9e50000, 0xe744000, 0xf129000, 0x101bb000, 0x11bf8000, 0x14b89000, 0x1691c000, 0x17a0d000, 0x1817a000, 0x1997a000, 0x1d736000, 0x1db33000, 0x1fdd8000, 0x21e56000, 0x2266c000, 0x22875000, 0x22b84000, 0x230ed000, 0x239c5000, 0x24e1a000, 0x275f5000, 0x29036000, 0x29f69000, 0x2e538000, 0x2efca000, 0x2f0bc000, 0x2f1bf000, 0x305cb000, 0x31ce7000, 0x345c4000, 0x35d4f000, 0x36e56000, 0x3ae9e000, 0x3cc27000, 0x40117000, 0x4299f000, 0x434c3000, 0x443d4000, 0x4552d000, 0x4a8a8000, 0x4cdea000, 0x51bd5000, 0x580c4000, 0x58381000, 0x59dc0000, 0x5ba7f000, 0x5d88b000, 0x5e0c4000, 0x5ee57000, 0x61f3f000, 0x63a4a000, 0x68a8a000, 0x68ec5000, 0x6937b000, 0x720be000, 0x72cf5000, 0x74fc8000, 0x76464000, 0x80000000, }, { 31, 46, 36, 22, 63, 12, 51, 60, 13, 44, 41, 6, 11, 17, 42, 24, 16, 61, 20, 26, 35, 21, 29, 55, 50, 45, 62, 19, 54, 9, 30, 34, 53, 52, 10, 39, 0, 49, 48, 38, 40, 28, 23, 56, 2, 5, 4, 59, 14, 57, 3, 25, 43, 32, 27, 47, 8, 7, 37, 33, 1, 18, 58, 15, }, }; const pattern_t pat7 = { { 0xd83000, 0x1597000, 0x245b000, 0x6a75000, 0x8fda000, 0x960e000, 0xd310000, 0xe6cd000, 0x1409a000, 0x15221000, 0x16059000, 0x1b3a4000, 0x1ceea000, 0x1ed1a000, 0x1ef0f000, 0x21723000, 0x21efc000, 0x24594000, 0x26d7f000, 0x28c4f000, 0x2fa89000, 0x304f0000, 0x30dbb000, 0x30de3000, 0x3365d000, 0x36dbc000, 0x3acb2000, 0x3e291000, 0x3f7da000, 0x41352000, 0x41a0f000, 0x435c8000, 0x4475a000, 0x47536000, 0x47726000, 0x4a81f000, 0x4be4e000, 0x4bf05000, 0x4c15b000, 0x515b4000, 0x52ef5000, 0x548cc000, 0x5692a000, 0x59ef2000, 0x5b97c000, 0x5c4f0000, 0x5d1b9000, 0x618ed000, 0x61bcc000, 0x61e07000, 0x639a3000, 0x65302000, 0x68041000, 0x6be56000, 0x721a3000, 0x72c99000, 0x740b9000, 0x7586d000, 0x75eca000, 0x76406000, 0x7b68a000, 0x7dd26000, 0x7ed55000, 0x80000000, }, { 44, 57, 22, 35, 63, 11, 15, 49, 61, 40, 29, 20, 19, 42, 32, 12, 41, 6, 46, 60, 52, 5, 36, 10, 2, 8, 3, 33, 54, 39, 58, 48, 62, 7, 51, 34, 0, 1, 18, 9, 55, 31, 23, 38, 25, 21, 17, 24, 13, 50, 16, 14, 43, 53, 45, 28, 59, 37, 26, 30, 47, 27, 56, 4, }, }; const pattern_t pat8 = { { 0x1b8000, 0x27eb000, 0x5a4d000, 0x6ecc000, 0xb52e000, 0xb70e000, 0xc6db000, 0xd83d000, 0xed51000, 0x13c59000, 0x13fef000, 0x142e1000, 0x192d0000, 0x1aa63000, 0x1e230000, 0x1f464000, 0x20de4000, 0x2234b000, 0x25459000, 0x27018000, 0x28263000, 0x29cc7000, 0x32227000, 0x32c63000, 0x34af0000, 0x37e27000, 0x3afc9000, 0x3c166000, 0x3df20000, 0x405bd000, 0x41273000, 0x45c39000, 0x471be000, 0x4758e000, 0x4b3fc000, 0x4c6b2000, 0x4c80f000, 0x4ccd6000, 0x4d9e0000, 0x4e07f000, 0x4eeda000, 0x541ae000, 0x58aa7000, 0x5a2c6000, 0x5a628000, 0x5ab94000, 0x5bddc000, 0x5d1d4000, 0x5e643000, 0x5f72f000, 0x64771000, 0x67bd4000, 0x6a28c000, 0x6c977000, 0x6cc4e000, 0x710c4000, 0x74b86000, 0x75cf7000, 0x77d4b000, 0x7870e000, 0x7c47c000, 0x7eb52000, 0x7fbea000, 0x80000000, }, { 7, 29, 62, 8, 54, 38, 35, 45, 60, 55, 1, 40, 4, 19, 50, 63, 48, 51, 13, 27, 33, 39, 52, 46, 10, 9, 56, 2, 42, 43, 47, 44, 17, 5, 25, 6, 57, 23, 15, 58, 59, 22, 14, 26, 32, 61, 30, 0, 11, 12, 36, 24, 53, 49, 3, 20, 31, 28, 34, 18, 41, 21, 16, 37, }, }; const pattern_t pat9 = { { 0x5b59000, 0xa6d7000, 0xbad3000, 0xdf91000, 0x115ad000, 0x13fde000, 0x17618000, 0x1b8e9000, 0x1e1b7000, 0x1e97d000, 0x21737000, 0x21a5e000, 0x24140000, 0x2558f000, 0x2647a000, 0x28257000, 0x285f6000, 0x2cb7a000, 0x2ebb1000, 0x30ae8000, 0x31543000, 0x315cb000, 0x31616000, 0x335ba000, 0x33ed6000, 0x35cf3000, 0x4162b000, 0x4409b000, 0x4629a000, 0x4b745000, 0x4c0ba000, 0x4cbc5000, 0x4dd97000, 0x4f34b000, 0x4f637000, 0x539d6000, 0x53f3d000, 0x56383000, 0x5642b000, 0x5a71f000, 0x5affa000, 0x5b486000, 0x5b8ef000, 0x60d88000, 0x61629000, 0x625cd000, 0x63326000, 0x6735e000, 0x67379000, 0x6a26a000, 0x6a281000, 0x6b997000, 0x6c50d000, 0x6cc6c000, 0x6f496000, 0x717ad000, 0x732ec000, 0x744dc000, 0x771e8000, 0x77cf0000, 0x79cad000, 0x7bb21000, 0x7e7b4000, 0x80000000, }, { 35, 9, 46, 6, 29, 2, 3, 54, 55, 57, 41, 16, 44, 5, 0, 59, 10, 61, 22, 42, 47, 12, 14, 50, 39, 34, 21, 32, 25, 15, 26, 8, 38, 60, 28, 53, 62, 49, 58, 43, 36, 37, 52, 7, 19, 63, 17, 11, 45, 33, 23, 27, 24, 18, 48, 56, 31, 13, 51, 30, 4, 20, 40, 1, }, }; const pattern_t pat10 = { { 0xa72000, 0x180a000, 0x6406000, 0x66df000, 0x83bb000, 0xa96f000, 0xd193000, 0x13b9b000, 0x13dae000, 0x16109000, 0x1853d000, 0x18887000, 0x19f0a000, 0x22151000, 0x229ba000, 0x26b58000, 0x2aaf4000, 0x2bf50000, 0x31a2e000, 0x31d4e000, 0x32196000, 0x3513a000, 0x36a2d000, 0x3746b000, 0x389ad000, 0x39d27000, 0x3dad3000, 0x3de55000, 0x3ea9b000, 0x3ec06000, 0x3f921000, 0x432d3000, 0x43bec000, 0x43dda000, 0x47b2b000, 0x4886e000, 0x4928e000, 0x49ad2000, 0x4d0df000, 0x4f40d000, 0x50959000, 0x54fa4000, 0x56091000, 0x5688d000, 0x5b7d8000, 0x5f6fd000, 0x601e4000, 0x64eaa000, 0x6752e000, 0x67fff000, 0x6a184000, 0x6ad7a000, 0x6adbc000, 0x6c434000, 0x6f451000, 0x6ffb4000, 0x707ee000, 0x71161000, 0x7146b000, 0x75dbf000, 0x77259000, 0x7acd4000, 0x7af71000, 0x80000000, }, { 61, 38, 5, 23, 62, 11, 53, 9, 17, 45, 30, 29, 41, 60, 39, 21, 40, 19, 44, 33, 42, 50, 56, 28, 32, 46, 43, 20, 16, 3, 54, 8, 4, 26, 15, 34, 47, 12, 6, 27, 48, 0, 1, 2, 57, 59, 7, 58, 49, 35, 24, 37, 52, 63, 10, 55, 36, 13, 14, 25, 18, 22, 31, 51, }, }; const pattern_t pat11 = { { 0x996000, 0xaff000, 0x199a000, 0x46f3000, 0x74c0000, 0x758d000, 0xcd09000, 0xe48c000, 0xe8de000, 0xf111000, 0xf87b000, 0x10b1c000, 0x15d63000, 0x17b21000, 0x182d3000, 0x19167000, 0x198ce000, 0x1bd47000, 0x1dff1000, 0x1edc0000, 0x1f890000, 0x20860000, 0x23207000, 0x29bd5000, 0x2ac0f000, 0x2e395000, 0x2e707000, 0x329de000, 0x3497f000, 0x3807f000, 0x38a94000, 0x40a19000, 0x4168e000, 0x42ca0000, 0x42de9000, 0x45194000, 0x464f2000, 0x4700f000, 0x47dbb000, 0x4dae7000, 0x50660000, 0x535a8000, 0x5546b000, 0x57b55000, 0x5860a000, 0x5a9ee000, 0x5b8d9000, 0x5c49f000, 0x5cb4d000, 0x5d28c000, 0x60dcd000, 0x62557000, 0x64b0c000, 0x654cb000, 0x65746000, 0x65e29000, 0x6648f000, 0x66c56000, 0x6999e000, 0x6a11c000, 0x6ca04000, 0x79e60000, 0x7edce000, 0x80000000, }, { 16, 28, 2, 38, 10, 57, 21, 26, 61, 43, 46, 31, 56, 7, 47, 48, 58, 25, 63, 4, 59, 15, 32, 50, 1, 40, 53, 18, 17, 24, 29, 30, 55, 36, 49, 42, 41, 37, 23, 39, 6, 51, 33, 9, 45, 5, 35, 19, 44, 11, 34, 0, 27, 12, 60, 62, 20, 13, 22, 8, 14, 54, 3, 52, }, }; const pattern_t pat12 = { { 0x513000, 0x1b72000, 0x1e27000, 0x3a63000, 0x1115c000, 0x158b4000, 0x1664f000, 0x1b667000, 0x1f838000, 0x21410000, 0x260c7000, 0x2cd8f000, 0x2ce37000, 0x2df16000, 0x2e59e000, 0x2e8eb000, 0x2ebd2000, 0x2f1d2000, 0x2fc42000, 0x30d00000, 0x31ef1000, 0x3301a000, 0x38097000, 0x38a1e000, 0x3d818000, 0x3e898000, 0x3f90f000, 0x47710000, 0x478bb000, 0x485ab000, 0x48e54000, 0x4cfe1000, 0x53a89000, 0x53d10000, 0x56308000, 0x56f3b000, 0x577f6000, 0x58734000, 0x5889b000, 0x58ad7000, 0x5923a000, 0x59aef000, 0x5dad3000, 0x5e32f000, 0x63b3a000, 0x665c9000, 0x68cde000, 0x69252000, 0x6a777000, 0x6a79a000, 0x6c1f0000, 0x6cb9a000, 0x6d319000, 0x6dc82000, 0x6dd4d000, 0x6e188000, 0x7184d000, 0x7206e000, 0x73980000, 0x740ad000, 0x75473000, 0x7614d000, 0x79b17000, 0x80000000, }, { 4, 60, 10, 35, 6, 31, 5, 18, 53, 17, 20, 8, 56, 29, 7, 48, 40, 0, 12, 39, 2, 43, 15, 61, 42, 30, 50, 14, 49, 38, 34, 58, 24, 55, 33, 63, 28, 51, 59, 46, 11, 22, 45, 41, 13, 44, 23, 47, 3, 32, 16, 54, 26, 19, 25, 52, 27, 57, 36, 9, 37, 21, 62, 1, }, }; const pattern_t pat13 = { { 0x351e000, 0x5917000, 0xa992000, 0xc471000, 0xc69c000, 0xc6ed000, 0xc919000, 0xd713000, 0xec14000, 0xfa31000, 0x17567000, 0x1d81a000, 0x1f3c8000, 0x215b5000, 0x26e41000, 0x2a2d4000, 0x2b750000, 0x2bea0000, 0x2c5ae000, 0x2ca2c000, 0x30a94000, 0x31074000, 0x314d3000, 0x31b1e000, 0x31de2000, 0x32062000, 0x33da5000, 0x37838000, 0x385ec000, 0x38740000, 0x387f9000, 0x38be6000, 0x3d2f7000, 0x3eaf5000, 0x40266000, 0x402f3000, 0x40fda000, 0x4a4bd000, 0x4b831000, 0x4bfc9000, 0x4ccaa000, 0x4ea43000, 0x50190000, 0x547c8000, 0x58cc6000, 0x58ea5000, 0x59de1000, 0x5c7f1000, 0x5f713000, 0x63f9a000, 0x6686d000, 0x675c1000, 0x6cccc000, 0x6e409000, 0x6fb6d000, 0x71a70000, 0x72f60000, 0x77bd9000, 0x79013000, 0x7a8d3000, 0x7b341000, 0x7d8f7000, 0x7fe43000, 0x80000000, }, { 10, 52, 48, 8, 34, 4, 35, 19, 3, 17, 54, 45, 31, 38, 24, 44, 21, 36, 22, 11, 43, 40, 39, 26, 5, 30, 2, 7, 57, 12, 20, 32, 62, 15, 55, 14, 25, 58, 6, 33, 49, 9, 59, 27, 13, 63, 42, 61, 1, 51, 0, 50, 37, 47, 16, 18, 41, 56, 60, 46, 23, 28, 53, 29, }, }; const pattern_t pat14 = { { 0xf8e000, 0x169a000, 0x3816000, 0x67a9000, 0x89f3000, 0xac97000, 0xc8da000, 0xf077000, 0x119f1000, 0x13902000, 0x19785000, 0x1ca7f000, 0x1f958000, 0x2027d000, 0x2251f000, 0x24661000, 0x25604000, 0x2b924000, 0x2be5f000, 0x2ec27000, 0x330a5000, 0x3349e000, 0x33a84000, 0x344fa000, 0x34514000, 0x37966000, 0x37f0b000, 0x37fcd000, 0x386d0000, 0x39600000, 0x39de4000, 0x3e601000, 0x3e7f1000, 0x42c61000, 0x48806000, 0x4d3d0000, 0x4f5ff000, 0x512c1000, 0x53fd4000, 0x59440000, 0x5b386000, 0x5e8a0000, 0x5fca3000, 0x6016c000, 0x61ca8000, 0x64915000, 0x66b99000, 0x67226000, 0x69b2f000, 0x6a473000, 0x6a590000, 0x6c844000, 0x6cb8c000, 0x713b5000, 0x7558a000, 0x75eab000, 0x76d15000, 0x77efe000, 0x78762000, 0x7bddc000, 0x7ce92000, 0x7dc44000, 0x7f54b000, 0x80000000, }, { 54, 31, 48, 10, 51, 49, 55, 19, 38, 18, 44, 5, 17, 20, 16, 11, 9, 3, 42, 59, 63, 45, 25, 60, 57, 21, 40, 29, 0, 39, 26, 7, 53, 12, 13, 2, 58, 41, 22, 8, 14, 28, 46, 24, 27, 6, 52, 32, 56, 4, 30, 36, 15, 47, 23, 37, 43, 35, 50, 33, 61, 34, 1, 62, }, }; const pattern_t pat15 = { { 0xe16000, 0xec6000, 0xf6b000, 0x634b000, 0x6896000, 0x91db000, 0xc2c8000, 0xe083000, 0xfd7f000, 0x10479000, 0x17740000, 0x18292000, 0x1aaca000, 0x1cb55000, 0x1d2be000, 0x222af000, 0x2cb03000, 0x2fabc000, 0x32034000, 0x35c0f000, 0x3c5ec000, 0x40908000, 0x4128e000, 0x44411000, 0x44bcd000, 0x4f0ac000, 0x5167b000, 0x5541c000, 0x581bc000, 0x584e5000, 0x588fb000, 0x593d3000, 0x5b25d000, 0x5dc99000, 0x60b35000, 0x60ffc000, 0x638e8000, 0x63cf8000, 0x64ee1000, 0x6523c000, 0x654a1000, 0x687bf000, 0x68bef000, 0x69826000, 0x69d90000, 0x6a622000, 0x6d1b9000, 0x6d1e1000, 0x6d886000, 0x6fe4a000, 0x6feac000, 0x720b2000, 0x734dc000, 0x73530000, 0x73f1e000, 0x7479c000, 0x76e33000, 0x786dc000, 0x79b40000, 0x79e49000, 0x7b66c000, 0x7b904000, 0x7c906000, 0x80000000, }, { 6, 17, 62, 20, 61, 32, 22, 14, 28, 18, 3, 42, 63, 43, 46, 34, 29, 30, 35, 1, 37, 40, 10, 26, 5, 31, 15, 54, 8, 33, 9, 4, 39, 53, 23, 25, 41, 59, 12, 13, 60, 2, 7, 56, 58, 27, 11, 38, 36, 45, 47, 0, 57, 50, 48, 16, 51, 49, 55, 52, 44, 24, 19, 21, }, }; const pattern_t pat16 = { { 0x596a000, 0x8644000, 0xa943000, 0xd59e000, 0x1062f000, 0x1082a000, 0x10c1b000, 0x10f9e000, 0x11e64000, 0x12e73000, 0x15ce7000, 0x16037000, 0x16d2e000, 0x17035000, 0x185ad000, 0x18d9b000, 0x19ac7000, 0x1b2fa000, 0x1cd6c000, 0x1d5f0000, 0x1f72c000, 0x20891000, 0x24bfa000, 0x25c1d000, 0x28e24000, 0x2a5f8000, 0x2e0ae000, 0x2fddf000, 0x3119d000, 0x332ee000, 0x3480a000, 0x34ea5000, 0x3534e000, 0x3538b000, 0x362e2000, 0x38f58000, 0x39ab0000, 0x3a519000, 0x3a62b000, 0x3b006000, 0x3d523000, 0x3e0f7000, 0x42366000, 0x42feb000, 0x44013000, 0x46b98000, 0x49794000, 0x4dce7000, 0x4f1f3000, 0x57ecd000, 0x5aaa2000, 0x5f419000, 0x61517000, 0x6797d000, 0x69a20000, 0x6a070000, 0x70575000, 0x75322000, 0x75a9e000, 0x79043000, 0x79875000, 0x7addc000, 0x7de88000, 0x80000000, }, { 26, 25, 6, 50, 32, 53, 34, 27, 3, 16, 49, 28, 46, 38, 56, 4, 18, 24, 51, 36, 63, 5, 48, 13, 43, 55, 0, 62, 35, 7, 41, 21, 44, 60, 31, 39, 14, 8, 61, 58, 52, 23, 59, 33, 10, 37, 20, 30, 40, 22, 11, 54, 57, 1, 29, 47, 2, 17, 19, 45, 15, 9, 12, 42, }, }; const pattern_t pat17 = { { 0x28ab000, 0x3ac8000, 0x3fe1000, 0x63a7000, 0x90fc000, 0xb3f2000, 0xd2f2000, 0xe032000, 0x12d4c000, 0x13135000, 0x14652000, 0x15331000, 0x1570c000, 0x1688e000, 0x16bc3000, 0x1cbe3000, 0x1fe0f000, 0x2517f000, 0x26c6b000, 0x2a284000, 0x2a4e2000, 0x2add5000, 0x2bd06000, 0x2ca3a000, 0x2eb11000, 0x324d1000, 0x35662000, 0x38695000, 0x38ce7000, 0x391ac000, 0x398f9000, 0x39949000, 0x401f3000, 0x457f0000, 0x45c6d000, 0x4b561000, 0x522fc000, 0x54ef0000, 0x559f8000, 0x562a7000, 0x56a04000, 0x57b68000, 0x59702000, 0x5ffc9000, 0x63a76000, 0x63c37000, 0x65d3e000, 0x67130000, 0x6a03a000, 0x6bcd6000, 0x6be96000, 0x6bf52000, 0x6fcd9000, 0x7038c000, 0x70a47000, 0x72881000, 0x72ed0000, 0x75035000, 0x75c11000, 0x77fa5000, 0x797c9000, 0x79813000, 0x7bbbb000, 0x80000000, }, { 18, 15, 56, 5, 25, 47, 39, 55, 12, 14, 51, 33, 0, 7, 9, 44, 50, 31, 62, 59, 3, 35, 23, 17, 30, 60, 11, 24, 40, 20, 52, 2, 22, 8, 57, 42, 32, 54, 36, 48, 49, 13, 58, 10, 28, 63, 16, 41, 27, 21, 37, 4, 1, 29, 19, 6, 53, 45, 46, 38, 34, 43, 61, 26, }, }; const pattern_t pat18 = { { 0x38d6000, 0x5379000, 0x5cae000, 0x5d20000, 0xa248000, 0xb4d0000, 0xd7c0000, 0xf731000, 0x116ae000, 0x151d2000, 0x1747d000, 0x1bfb6000, 0x1d758000, 0x2053d000, 0x24dda000, 0x25274000, 0x269c0000, 0x273e8000, 0x2a5d0000, 0x2ad34000, 0x3016b000, 0x30d1a000, 0x32960000, 0x34b3b000, 0x36e4f000, 0x37934000, 0x38c42000, 0x3c2d2000, 0x3d23d000, 0x3d89a000, 0x3dc85000, 0x3e9a7000, 0x3f25b000, 0x45bd1000, 0x48d94000, 0x4b126000, 0x4e17c000, 0x4f377000, 0x50908000, 0x51957000, 0x53410000, 0x5412c000, 0x55256000, 0x56b17000, 0x5707b000, 0x5bbe5000, 0x5d067000, 0x5e1c1000, 0x6380b000, 0x66009000, 0x68240000, 0x69fc4000, 0x6c327000, 0x6c5d2000, 0x6f69d000, 0x739c7000, 0x744bc000, 0x74cd8000, 0x787b8000, 0x78c61000, 0x7969d000, 0x79aae000, 0x7b032000, 0x80000000, }, { 16, 48, 50, 60, 13, 39, 20, 4, 63, 18, 14, 30, 55, 8, 62, 37, 43, 41, 11, 0, 36, 33, 34, 49, 17, 58, 38, 22, 19, 5, 21, 12, 47, 25, 57, 61, 7, 3, 10, 23, 52, 24, 6, 53, 2, 26, 1, 31, 28, 46, 42, 9, 45, 29, 27, 54, 32, 56, 51, 44, 35, 59, 40, 15, }, }; const pattern_t pat19 = { { 0x297d000, 0x34e0000, 0x7801000, 0x9664000, 0x96fa000, 0xbb9f000, 0xc192000, 0xc4a5000, 0xca74000, 0xcce8000, 0x173d8000, 0x1a8d8000, 0x1b299000, 0x1b52d000, 0x1e813000, 0x2185e000, 0x21abe000, 0x2b9a4000, 0x2c4b6000, 0x2fa27000, 0x343ba000, 0x356fd000, 0x37c6e000, 0x38365000, 0x3a9e4000, 0x3b599000, 0x4296b000, 0x43196000, 0x4381e000, 0x44783000, 0x47a75000, 0x4bd78000, 0x4d05d000, 0x4edb2000, 0x4eefd000, 0x4fecc000, 0x51f68000, 0x5252b000, 0x5439e000, 0x55fb3000, 0x5814f000, 0x5939d000, 0x60a78000, 0x62a86000, 0x633b0000, 0x64a68000, 0x64b62000, 0x66207000, 0x66540000, 0x67f90000, 0x68bf3000, 0x6a069000, 0x6d2ac000, 0x70c9f000, 0x71bab000, 0x724bc000, 0x783d8000, 0x7900e000, 0x79399000, 0x79763000, 0x7c8a8000, 0x7e680000, 0x7f6de000, 0x80000000, }, { 14, 59, 60, 24, 18, 22, 62, 12, 45, 2, 32, 11, 25, 37, 13, 7, 50, 39, 56, 17, 47, 40, 29, 43, 15, 34, 4, 57, 31, 38, 21, 28, 36, 27, 42, 1, 23, 33, 5, 61, 44, 55, 8, 30, 10, 41, 19, 48, 16, 52, 49, 46, 54, 58, 6, 0, 51, 3, 26, 20, 53, 9, 35, 63, }, }; const pattern_t pat20 = { { 0x8f7000, 0xa01000, 0x38e3000, 0x5299000, 0x6875000, 0x7f3e000, 0x827f000, 0x9413000, 0xca71000, 0xfb11000, 0x10beb000, 0x176be000, 0x1924f000, 0x1cfd6000, 0x1d20d000, 0x1ebb7000, 0x22c93000, 0x23601000, 0x2cf7a000, 0x2d3af000, 0x2e391000, 0x2f294000, 0x318ad000, 0x34ddd000, 0x365e4000, 0x3b8d2000, 0x3c0f8000, 0x3d2fd000, 0x3e431000, 0x3f0fe000, 0x4074e000, 0x40d1c000, 0x41936000, 0x4347b000, 0x452d7000, 0x486d3000, 0x4b47e000, 0x4b709000, 0x4c349000, 0x4ff13000, 0x50faa000, 0x51a07000, 0x52f30000, 0x55f29000, 0x57ad4000, 0x5909f000, 0x5a0f6000, 0x5de57000, 0x60d2f000, 0x625ff000, 0x6288e000, 0x65077000, 0x6a707000, 0x6a73f000, 0x6d720000, 0x6e390000, 0x6edc9000, 0x6ee78000, 0x77ac2000, 0x77ad3000, 0x7868f000, 0x79a1b000, 0x7aec6000, 0x80000000, }, { 21, 56, 38, 11, 62, 9, 30, 47, 34, 23, 37, 16, 5, 49, 10, 43, 4, 45, 36, 7, 42, 1, 53, 57, 20, 59, 55, 50, 46, 39, 60, 27, 12, 31, 48, 25, 15, 22, 44, 52, 14, 33, 0, 29, 17, 18, 2, 32, 24, 19, 6, 41, 54, 8, 35, 26, 61, 3, 51, 13, 63, 28, 40, 58, }, }; const pattern_t pat21 = { { 0x2a8e000, 0xa4bd000, 0xa935000, 0xcc05000, 0xdfe4000, 0xe014000, 0xff46000, 0x18c8c000, 0x199ec000, 0x19ce0000, 0x1f684000, 0x1ff5c000, 0x22d58000, 0x27651000, 0x280e5000, 0x2e2a4000, 0x2e432000, 0x2f96e000, 0x2f9c3000, 0x3343d000, 0x338bb000, 0x34032000, 0x34101000, 0x368c2000, 0x37b95000, 0x39492000, 0x39932000, 0x3b611000, 0x3c89e000, 0x40aa9000, 0x42358000, 0x4890e000, 0x495c9000, 0x4a79d000, 0x4c58e000, 0x4df9a000, 0x4f304000, 0x4fa4c000, 0x54d1d000, 0x58461000, 0x58f43000, 0x5a3d1000, 0x5a765000, 0x5c5c0000, 0x60488000, 0x60fad000, 0x613e5000, 0x61d61000, 0x62d17000, 0x641ff000, 0x67f8b000, 0x69c5d000, 0x6b931000, 0x6efd4000, 0x70333000, 0x70857000, 0x721f6000, 0x72f53000, 0x74450000, 0x746f7000, 0x76067000, 0x7774a000, 0x77ea6000, 0x80000000, }, { 28, 51, 33, 2, 30, 55, 29, 17, 40, 48, 32, 9, 39, 1, 49, 50, 37, 43, 62, 11, 10, 26, 22, 6, 8, 7, 45, 47, 46, 42, 60, 5, 12, 56, 4, 23, 35, 25, 13, 16, 61, 54, 31, 63, 34, 19, 41, 59, 38, 24, 0, 58, 53, 44, 3, 18, 52, 20, 36, 27, 14, 21, 57, 15, }, }; const pattern_t pat22 = { { 0x314d000, 0x4452000, 0x6673000, 0xab09000, 0xc80d000, 0x10eda000, 0x129c2000, 0x12f1f000, 0x13e9b000, 0x1450c000, 0x15aeb000, 0x1667c000, 0x190b2000, 0x19ac5000, 0x1c0ac000, 0x1c229000, 0x1ece8000, 0x1fc48000, 0x22abd000, 0x24268000, 0x2adce000, 0x2b809000, 0x30a11000, 0x31d08000, 0x36700000, 0x39e6a000, 0x3b84b000, 0x41e84000, 0x46301000, 0x4a326000, 0x50fda000, 0x5299a000, 0x56acf000, 0x57f66000, 0x586ab000, 0x58df5000, 0x591cc000, 0x59b91000, 0x59cbd000, 0x5b4d0000, 0x5cca7000, 0x5cfce000, 0x5d120000, 0x5d51a000, 0x5eaa0000, 0x5ebac000, 0x5f0e1000, 0x5f285000, 0x5f4d3000, 0x5ff61000, 0x60b51000, 0x61435000, 0x651fd000, 0x6b954000, 0x705aa000, 0x71a41000, 0x73ec7000, 0x75f92000, 0x76854000, 0x77cb9000, 0x782ca000, 0x7a2af000, 0x7eaa6000, 0x80000000, }, { 16, 8, 5, 59, 4, 18, 26, 43, 33, 57, 6, 47, 56, 46, 10, 54, 52, 0, 50, 30, 39, 24, 38, 63, 28, 25, 49, 31, 55, 62, 3, 17, 23, 13, 37, 53, 34, 14, 44, 12, 19, 36, 27, 61, 51, 42, 41, 60, 45, 1, 7, 35, 21, 58, 20, 15, 2, 9, 22, 29, 48, 32, 40, 11, }, }; const pattern_t pat23 = { { 0x47000, 0x680000, 0x176a000, 0x1db8000, 0x600e000, 0x808c000, 0x9e58000, 0xa82f000, 0xaebb000, 0xc938000, 0xd0eb000, 0xdc5e000, 0xe503000, 0x11e56000, 0x12dbd000, 0x14681000, 0x15200000, 0x18256000, 0x1be75000, 0x1d2a0000, 0x1ed67000, 0x27e8a000, 0x2bc39000, 0x2bf4b000, 0x2c94f000, 0x2d575000, 0x2d82e000, 0x2e440000, 0x2ecda000, 0x2fbc2000, 0x33ab0000, 0x360b8000, 0x39630000, 0x3a654000, 0x3d2b6000, 0x3eeff000, 0x41590000, 0x417ea000, 0x42ff9000, 0x4bca4000, 0x503b0000, 0x508e4000, 0x52a2e000, 0x535b6000, 0x54335000, 0x57412000, 0x57dc6000, 0x590d9000, 0x5fc0a000, 0x60552000, 0x60665000, 0x6168d000, 0x65b16000, 0x67328000, 0x6742d000, 0x68c88000, 0x6b802000, 0x6f6d2000, 0x7040e000, 0x77e31000, 0x79c71000, 0x7da4a000, 0x7e26b000, 0x80000000, }, { 63, 50, 51, 33, 28, 35, 24, 14, 4, 23, 47, 11, 37, 41, 12, 55, 62, 32, 34, 30, 25, 43, 16, 0, 3, 49, 61, 15, 57, 46, 59, 44, 31, 27, 21, 53, 5, 2, 8, 56, 52, 22, 60, 40, 20, 1, 48, 18, 17, 19, 54, 29, 9, 38, 42, 6, 39, 45, 13, 10, 26, 58, 36, 7, }, }; const pattern_t pat24 = { { 0x3890000, 0x3fd9000, 0x62d6000, 0x7df0000, 0x895c000, 0xab61000, 0xc23b000, 0x10ab3000, 0x1247c000, 0x13f00000, 0x16604000, 0x1a444000, 0x1c2c8000, 0x1c467000, 0x1d396000, 0x1e683000, 0x21080000, 0x2442a000, 0x27fea000, 0x282eb000, 0x28e2c000, 0x2a625000, 0x2b3b2000, 0x2bbd5000, 0x2c886000, 0x2cbe8000, 0x31518000, 0x35425000, 0x355f4000, 0x35d7a000, 0x3851d000, 0x396a6000, 0x3d10f000, 0x3d890000, 0x49238000, 0x4ab7e000, 0x4fadf000, 0x50603000, 0x5233a000, 0x53279000, 0x5586c000, 0x56968000, 0x58101000, 0x588b6000, 0x5bc19000, 0x5cc10000, 0x623f6000, 0x629f4000, 0x63176000, 0x63dcc000, 0x681d0000, 0x69c0e000, 0x6a9fa000, 0x6ae5e000, 0x6d2ba000, 0x6e422000, 0x73f94000, 0x77932000, 0x78b24000, 0x794c1000, 0x795d2000, 0x7ae08000, 0x7b3ce000, 0x80000000, }, { 56, 47, 54, 62, 29, 43, 25, 59, 41, 7, 52, 63, 15, 21, 16, 14, 39, 17, 45, 11, 27, 24, 55, 31, 53, 4, 6, 2, 20, 23, 5, 37, 32, 58, 13, 51, 1, 8, 3, 57, 46, 30, 35, 49, 18, 40, 9, 22, 42, 38, 34, 0, 19, 33, 26, 60, 10, 48, 36, 61, 44, 12, 50, 28, }, }; const pattern_t pat25 = { { 0xcb000, 0x22bf000, 0x2461000, 0x246b000, 0x5c6f000, 0x5fb4000, 0x69a9000, 0x718c000, 0x92e6000, 0xbb2e000, 0xd916000, 0xf3dc000, 0xf568000, 0x10246000, 0x12d53000, 0x14dfd000, 0x1598a000, 0x1956a000, 0x1b01b000, 0x1b3b8000, 0x1ce06000, 0x20bc5000, 0x21351000, 0x233b0000, 0x23f2b000, 0x24e41000, 0x29cca000, 0x2b5bd000, 0x2ba68000, 0x2bf7f000, 0x31a58000, 0x34570000, 0x39941000, 0x3b765000, 0x3cd13000, 0x3d251000, 0x3fa05000, 0x40745000, 0x45c68000, 0x4a282000, 0x4ad19000, 0x4b4aa000, 0x4ca18000, 0x4e0b8000, 0x4eb97000, 0x4f68b000, 0x4fca2000, 0x52466000, 0x52edf000, 0x5602a000, 0x57f60000, 0x5cc18000, 0x5cee3000, 0x5da37000, 0x5dba4000, 0x64b77000, 0x66e9f000, 0x68b9d000, 0x6aac9000, 0x6d873000, 0x6f7e6000, 0x71036000, 0x75a54000, 0x80000000, }, { 1, 58, 13, 5, 62, 10, 49, 48, 19, 24, 54, 57, 20, 39, 35, 41, 28, 42, 6, 44, 34, 45, 55, 3, 2, 60, 38, 36, 30, 25, 7, 23, 53, 50, 61, 29, 40, 47, 22, 12, 27, 0, 52, 31, 8, 15, 37, 11, 46, 32, 4, 56, 17, 33, 26, 43, 51, 16, 9, 59, 63, 21, 14, 18, }, }; const pattern_t pat26 = { { 0x1f4e000, 0x46f7000, 0x90a7000, 0xafe3000, 0xb2a8000, 0xb8b0000, 0xc480000, 0xc4e1000, 0xf03c000, 0xf075000, 0x14dbd000, 0x17728000, 0x1a146000, 0x1ab02000, 0x1af49000, 0x1be7a000, 0x1dc7a000, 0x1de5e000, 0x1f4f9000, 0x2092b000, 0x20a63000, 0x22937000, 0x22fe3000, 0x23e1c000, 0x28c46000, 0x294d6000, 0x2ad19000, 0x2b18b000, 0x2b233000, 0x2b685000, 0x2c792000, 0x2e6c2000, 0x2fa86000, 0x3320f000, 0x36f17000, 0x38406000, 0x38b1b000, 0x3a132000, 0x3b269000, 0x3cc43000, 0x3e2a2000, 0x3e3bb000, 0x3e83b000, 0x3ea14000, 0x4035d000, 0x4137f000, 0x4615b000, 0x50531000, 0x517c8000, 0x519e6000, 0x55ebc000, 0x594f8000, 0x5a732000, 0x5d2cb000, 0x5e409000, 0x5f394000, 0x5f3a8000, 0x60dc6000, 0x61373000, 0x6ebd6000, 0x6fd61000, 0x77161000, 0x7ce81000, 0x80000000, }, { 61, 48, 12, 55, 3, 58, 51, 56, 15, 29, 54, 11, 31, 49, 40, 37, 7, 4, 23, 35, 25, 18, 27, 43, 6, 41, 17, 45, 52, 53, 47, 16, 42, 0, 30, 13, 38, 62, 1, 8, 21, 28, 57, 9, 60, 19, 44, 50, 14, 36, 22, 2, 32, 59, 34, 10, 63, 39, 5, 24, 33, 20, 46, 26, }, }; const pattern_t pat27 = { { 0xa6a000, 0x4c7a000, 0x5183000, 0x8dda000, 0x9cbd000, 0xb860000, 0x10c24000, 0x12dda000, 0x147ab000, 0x14aa4000, 0x16c8f000, 0x17d5b000, 0x18b5c000, 0x1a163000, 0x1b0a1000, 0x24221000, 0x25ef8000, 0x267f1000, 0x268b7000, 0x26b07000, 0x273ad000, 0x27bc2000, 0x2856c000, 0x29896000, 0x2efeb000, 0x331a7000, 0x348e8000, 0x3707f000, 0x3f444000, 0x3fe2a000, 0x433b3000, 0x435d3000, 0x46d82000, 0x4a9d3000, 0x4c6cf000, 0x4ca36000, 0x4ec42000, 0x4f79c000, 0x53cd3000, 0x58c78000, 0x5d910000, 0x616cc000, 0x62800000, 0x65ded000, 0x68831000, 0x6b321000, 0x6cd46000, 0x6d0fa000, 0x6d2f9000, 0x6e353000, 0x6fd5e000, 0x706c5000, 0x7249f000, 0x75d6c000, 0x77528000, 0x783ad000, 0x79738000, 0x79bfe000, 0x79ee9000, 0x7b74a000, 0x7bb41000, 0x7bbeb000, 0x7bbfb000, 0x80000000, }, { 61, 53, 12, 15, 26, 30, 32, 2, 16, 5, 39, 43, 20, 21, 49, 37, 11, 51, 18, 44, 31, 19, 24, 40, 1, 35, 50, 6, 57, 14, 46, 17, 22, 48, 29, 7, 34, 45, 10, 63, 23, 41, 54, 38, 4, 25, 42, 13, 56, 62, 36, 28, 33, 59, 55, 3, 9, 0, 58, 60, 47, 8, 52, 27, }, }; const pattern_t pat28 = { { 0x439a000, 0x6860000, 0xd252000, 0x1105c000, 0x113c8000, 0x1429a000, 0x14922000, 0x15f32000, 0x1992f000, 0x1a1db000, 0x1a87c000, 0x1b260000, 0x1b292000, 0x1c253000, 0x1ea33000, 0x20bbc000, 0x215ae000, 0x25249000, 0x27c89000, 0x27e36000, 0x28bf2000, 0x29c27000, 0x2a575000, 0x2c6fa000, 0x31639000, 0x3184a000, 0x319c3000, 0x348a7000, 0x38aa8000, 0x39dd5000, 0x3a067000, 0x3c0dd000, 0x3cfd4000, 0x3ebb6000, 0x43259000, 0x46494000, 0x46fcb000, 0x4a050000, 0x4b5c4000, 0x4cff3000, 0x4edaa000, 0x4f025000, 0x542e1000, 0x55364000, 0x56338000, 0x56ef8000, 0x5711b000, 0x573d1000, 0x5943b000, 0x5b912000, 0x61ce2000, 0x65211000, 0x65dca000, 0x6dee2000, 0x6df30000, 0x7334d000, 0x73e76000, 0x7473a000, 0x75846000, 0x75fd0000, 0x77174000, 0x773e9000, 0x7a8db000, 0x80000000, }, { 43, 11, 8, 56, 5, 22, 42, 55, 14, 32, 2, 47, 24, 51, 35, 25, 15, 58, 41, 27, 33, 37, 4, 36, 7, 53, 26, 48, 38, 19, 29, 28, 40, 10, 1, 46, 59, 63, 61, 62, 60, 30, 21, 39, 44, 57, 20, 18, 17, 54, 49, 52, 3, 12, 45, 13, 50, 9, 16, 23, 0, 6, 31, 34, }, }; const pattern_t pat29 = { { 0x363000, 0x9bc000, 0x1907000, 0x41d5000, 0x5a6e000, 0x9f36000, 0xa3ee000, 0x14b98000, 0x1845c000, 0x188ea000, 0x1b297000, 0x1c024000, 0x1e1eb000, 0x1f3a4000, 0x2047f000, 0x2420a000, 0x28871000, 0x296dd000, 0x2c92c000, 0x2dd42000, 0x3444f000, 0x35b90000, 0x3683c000, 0x3d8ea000, 0x3fe6b000, 0x4200e000, 0x421cf000, 0x42a46000, 0x44463000, 0x44e61000, 0x45c82000, 0x485f8000, 0x48fe8000, 0x4a532000, 0x4a6fd000, 0x4c8f9000, 0x4dbd7000, 0x5052a000, 0x512bb000, 0x5281d000, 0x5315d000, 0x5a202000, 0x5a9fc000, 0x5c11a000, 0x6010b000, 0x62aa3000, 0x63d05000, 0x6774c000, 0x6776d000, 0x68105000, 0x699d5000, 0x69bc2000, 0x6b1b9000, 0x704d5000, 0x73d5c000, 0x73d94000, 0x78483000, 0x78c8c000, 0x78cc5000, 0x7ac8d000, 0x7ae00000, 0x7b597000, 0x7e6ab000, 0x80000000, }, { 52, 40, 59, 29, 42, 34, 63, 44, 33, 37, 51, 23, 5, 36, 38, 43, 9, 4, 28, 55, 1, 6, 21, 26, 13, 24, 30, 15, 35, 17, 46, 20, 16, 10, 49, 48, 39, 62, 19, 14, 61, 27, 53, 2, 57, 58, 45, 7, 56, 50, 54, 25, 31, 11, 22, 47, 3, 0, 32, 12, 8, 41, 60, 18, }, }; const pattern_t pat30 = { { 0x45c5000, 0x6bf3000, 0xc293000, 0xe470000, 0xe5b7000, 0x1256c000, 0x1444d000, 0x15699000, 0x16e86000, 0x1a4d5000, 0x1b803000, 0x1dcf9000, 0x1dd6f000, 0x1f57f000, 0x22879000, 0x263e9000, 0x29423000, 0x2a1a9000, 0x2a699000, 0x2c8fb000, 0x2d2e0000, 0x2ec5e000, 0x317a4000, 0x35a64000, 0x36967000, 0x37299000, 0x37c07000, 0x3b9bb000, 0x3c054000, 0x3ccbc000, 0x3d94a000, 0x3e2e9000, 0x3e7a4000, 0x40b98000, 0x44658000, 0x44738000, 0x44fe3000, 0x451d9000, 0x4536c000, 0x46df2000, 0x48855000, 0x503ce000, 0x53104000, 0x531fc000, 0x54c1b000, 0x56086000, 0x5642b000, 0x573a4000, 0x5887f000, 0x5a871000, 0x5c970000, 0x5e566000, 0x62b8f000, 0x642ce000, 0x65ee5000, 0x66db3000, 0x6727c000, 0x6a9a2000, 0x74a8f000, 0x7c29a000, 0x7cc57000, 0x7f221000, 0x7f28f000, 0x80000000, }, { 29, 35, 8, 49, 30, 55, 27, 38, 58, 61, 0, 28, 15, 39, 5, 37, 32, 42, 46, 54, 12, 14, 1, 31, 59, 11, 47, 9, 13, 50, 2, 62, 60, 18, 20, 51, 23, 24, 53, 6, 25, 48, 41, 3, 33, 57, 44, 19, 22, 52, 4, 45, 10, 21, 56, 36, 17, 43, 7, 63, 16, 34, 26, 40, }, }; const pattern_t pat31 = { { 0x143f000, 0x2068000, 0x328c000, 0x70a6000, 0x92a7000, 0x93dd000, 0xa3a8000, 0xbe51000, 0xbfc8000, 0xe353000, 0x1272f000, 0x143a4000, 0x16825000, 0x20bf8000, 0x20d9f000, 0x21e32000, 0x22426000, 0x2246b000, 0x22cea000, 0x25dc2000, 0x29324000, 0x29cd1000, 0x2aa44000, 0x2cd84000, 0x2dafb000, 0x2e74b000, 0x2f5b1000, 0x3a7a9000, 0x3bb38000, 0x3c11a000, 0x3c30a000, 0x3e2f1000, 0x4187b000, 0x42190000, 0x44e34000, 0x4d850000, 0x53ceb000, 0x540db000, 0x54937000, 0x5530a000, 0x5a111000, 0x5c280000, 0x5ef17000, 0x5fccf000, 0x64434000, 0x6498e000, 0x662c4000, 0x6a7e2000, 0x6b5a1000, 0x6c11f000, 0x6dd97000, 0x6ef1b000, 0x6f44e000, 0x7084f000, 0x73b53000, 0x7872c000, 0x78ed7000, 0x7935b000, 0x79bf9000, 0x7a6af000, 0x7b6fd000, 0x7bd42000, 0x7f233000, 0x80000000, }, { 6, 25, 28, 44, 27, 43, 58, 33, 23, 21, 16, 48, 30, 26, 5, 20, 49, 38, 2, 45, 11, 61, 17, 0, 53, 13, 7, 52, 40, 31, 36, 4, 10, 8, 24, 22, 42, 63, 35, 60, 47, 29, 46, 19, 1, 3, 34, 55, 59, 14, 39, 12, 32, 50, 62, 54, 56, 51, 57, 15, 41, 18, 37, 9, }, }; const pattern_t* patterns[] = {&trivial_pattern, &pat0, &pat1, &pat2, &pat3, &pat4, &pat5, &pat6, &pat7, &pat8, &pat9, &pat10, &pat11, &pat12, &pat13, &pat14, &pat15, &pat16, &pat17, &pat18, &pat19, &pat20, &pat21, &pat22, &pat23, &pat24, &pat25, &pat26, &pat27, &pat28, &pat29, &pat30, &pat31}; //static variables used by the worker threads static int outfd = 0; static sem_t chunk_sems[NUM_THREADS - 1][NUM_CHUNKS]; static void usage() { (void) fprintf(stderr, "usage: fsync_integrity \n"); exit(2); } /* Fills a buffer with a special marker. The marker contains information about * the file offset where this buffer is supposed to go, and whether it will * be written by a leader or a follower */ static void marker_fill(uint64_t* buf, int file_ofs, size_t len, int thread_num){ int ofs; uint32_t thread_mark = thread_num; uint32_t final_mark = 0xe005b0ca; //"CABOOSE" in little endian for (ofs = file_ofs; ofs < file_ofs + len; ofs += sizeof(uint64_t)){ uint64_t mark = ((thread_num == (NUM_THREADS - 1) ? (uint64_t)final_mark : (uint64_t)thread_mark) << (uint64_t)32) | htonl(ofs & 0xFFFFFFFF); int buf_idx = (ofs - file_ofs) / sizeof(uint64_t); buf[buf_idx] = mark; } } static int verify_file(int fd, const pattern_t* p_pat){ int chunk_idx; int good_data = 1; int err = 0; for(chunk_idx=0; chunk_idx < NUM_CHUNKS; chunk_idx++){ int i; uint32_t chunk_start, chunk_end; get_chunk_range(p_pat, chunk_idx, &chunk_start, &chunk_end); size_t size = chunk_end - chunk_start; uint64_t* desired_buf = malloc(size); uint64_t* actual_buf = malloc(size); marker_fill(desired_buf, chunk_start, size, NUM_THREADS - 1); //read the actual data from the file if( read(fd, actual_buf, size) <= 0 ){ perror("read"); exit(1); } //verify the data for(i=0; i < size / sizeof(uint64_t); i++){ int chunk_offset = sizeof(uint64_t) * i; int file_offset = chunk_start + chunk_offset; if (good_data && (actual_buf[i] != desired_buf[i])){ fprintf(stderr, "fsync_integrity: miscompare at " "chunk %i, chunk offset %x, file offset %x\n", chunk_idx, chunk_offset, file_offset); fprintf(stderr, "Expected %016lx, got %016lx\n", desired_buf[i], actual_buf[i]); err = 1; good_data = 0; } else if (!good_data && (actual_buf[i] == desired_buf[i])) { fprintf(stderr, "fsync_integrity: miscompare ends at " "chunk %i, chunk offset %x, file offset %x\n", chunk_idx, chunk_offset, file_offset); good_data = 1; } } free(desired_buf); free(actual_buf); } return (err); } /* Writes a special marker to every byte within the chunk */ static void write_chunk(pattern_t* p_pat, int chunk_idx, int thread_num) { uint32_t chunk_start, chunk_end; get_chunk_range(p_pat, chunk_idx, &chunk_start, &chunk_end); size_t size = chunk_end - chunk_start; uint64_t* buf = malloc(size); marker_fill(buf, chunk_start, size, thread_num); pwrite(outfd, (void*)buf, size, chunk_start); free(buf); } static void my_sync(int fd){ if (fsync(fd)){ perror("fsync"); exit(1); } } static void* worker(void* args) { int perm_idx, thread_num; thread_data_t* data; data = (thread_data_t*)args; thread_num = data->thread_num; for(perm_idx = 0; perm_idx < NUM_CHUNKS; perm_idx++) { int chunk_idx = data->pat->permutation[perm_idx]; /* Acquire the semaphore, if necessary */ if (thread_num > 0) { if (-1 == sem_wait(&chunk_sems[thread_num - 1][chunk_idx])){ perror("sem_wait"); exit(1); } } /* Write the data */ write_chunk(data->pat, chunk_idx, thread_num); /* Sync, if we are an even thread */ if ((thread_num % 2) == 0) my_sync(outfd); /* Post the final semaphore, if necessary */ if (thread_num < NUM_THREADS - 1) { if (sem_post(&chunk_sems[thread_num][chunk_idx]) == -1){ perror("sem_post"); exit(1); } } } return 0; } int main(int argc, char** argv) { int rep; int pat; pthread_t threads[NUM_THREADS]; thread_data_t thread_data[NUM_THREADS]; if (argc != 2){ usage(); } for(rep=0; rep < NUM_REPETITIONS; rep++){ printf("Starting repetition %d\n", rep); for(pat=0; pat < sizeof(patterns) / sizeof(patterns[0]); pat++){ int i; const pattern_t *pat_p = patterns[pat]; /* pattern_t *pat_p = (void *)(uintptr_t)(const void *)patterns[pat];*/ int sem_idx; int ofs=0; /* printf("Starting on patterns[%d]\n" , pat);*/ outfd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0644); if (outfd == -1){ perror("open"); exit(1); } //set the file size if ( ftruncate(outfd, FSIZE)){ perror("ftruncate"); exit(1); } //Zero-fill the file to avoid fragmentation, as recommended by mmap(2). for(ofs=0; ofs < FSIZE; ofs+=CLUSTERSIZE){ char buffer[CLUSTERSIZE]; bzero(buffer, CLUSTERSIZE); if ( -1 == write(outfd, buffer, CLUSTERSIZE)){ perror("write"); exit(1); } } //Return the file pointer to the beginning prior to mmap if (-1 == lseek(outfd, 0, SEEK_SET)){ perror("lseek"); } //Create the semaphores for(i=0; i < NUM_THREADS - 1; i++) { for(sem_idx=0; sem_idx < NUM_CHUNKS; sem_idx++){ if (sem_init(&chunk_sems[i][sem_idx], 0, 0)){ perror("sem_init"); exit(1); } } } //Create the worker threads for(i=0; i < NUM_THREADS; i++) { thread_data[i].pat = pat_p; thread_data[i].thread_num = i; if (pthread_create(&threads[i], NULL, worker, (void*)&thread_data[i])){ perror("pthread_create"); exit(1); } } //Join the threads for(i=0; i < NUM_THREADS; i++) { if (pthread_join(threads[i], NULL)){ perror("pthread_join"); exit(1); } } //destroy the semaphores for(i=0; i < NUM_THREADS - 1; i++) { for(sem_idx=0; sem_idx < NUM_CHUNKS; sem_idx++){ if (sem_destroy(&chunk_sems[i][sem_idx])){ perror("sem_destory"); exit(1); } } } //printf("destroyed semaphores\n"); //Verify the contents of the file. if (verify_file(outfd, patterns[pat])) { exit(1); } //printf("finished verify_file\n"); //close the file: if (close(outfd)){ perror("close"); exit(1); } } } return 0; } diff --git a/tests/sys/cddl/zfs/tests/txg_integrity/txg_integrity.c b/tests/sys/cddl/zfs/tests/txg_integrity/txg_integrity.c index ec1275dfccc0..388d838f4d34 100644 --- a/tests/sys/cddl/zfs/tests/txg_integrity/txg_integrity.c +++ b/tests/sys/cddl/zfs/tests/txg_integrity/txg_integrity.c @@ -1,609 +1,608 @@ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * $FreeBSD$ */ /* * Copyright 2011-2012 Spectra Logic. All rights reserved. * Use is subject to license terms. */ /* * Verify the integrity of non-aligned writes to the same blocks that cross * transaction groups. * * This test verifies that non-aligned writes are correctly committed to the * file system, even adjacent transaction groups include writes to the same * blocks. The test runs through multiple repetitions in an attempt to trigger * race conditions. * * Outline: * Create a 32MB file. * Create a bunch of different IO patterns. Each IO pattern consists of: * * A partition of the 32MB range into 64 different non-overlapping chunks. * * A permutation of those chunks * * A selection of 32 chunks that will be written by the follower. * For each repetitions: * For each IO pattern: * For each phase (leader syncs and follower syncs): * Create one binary semaphore per chunk. * Create two threads, a leader and a follower thread. * The leader thread will write each chunk in order. It will post a * semaphore after each write to indicate that it has completed * writing that chunk. If this is the "leader syncs" phase, it will * call fsync() halfway through to force the closure of a transaction * group. * The follower will pend on those semaphores in order. Each time it * receives a semaphore, it will write a different pattern to that * chunk. If this is the "follower syncs" phase, it will call fsync() * halfway through to force the closure of a transaction group. * Join both threads * Read the entire file and verify that * 1) Every write went to the correct location * 2) Each of the follower's writes overwrote the leader's. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define NUM_REPETITIONS 15 #define CLUSTERSIZE (1 << 16) #define NUM_CHUNKS 64 #define FSIZE (512 * (CLUSTERSIZE)) //FSIZE may range from NUM_CHUNKS clusters to 8GB #define USE_THREADS 1 #define USE_MMAP 0 typedef struct { //partitions describes the boundaries between chunks. Each element is a //fraction of the filesize in 1.31 fixed point format. So the boundary //between chunk n and chunk n-1 is (FSIZE * partitions[n-1] / (1<<31) . //partitions[-1] is understood to be 0 and partitions[NUM_CHUNKS] must be 1.0 //partitions is sorted, of course. //Partition boundaries must be dword aligned. Thus, in order to work with //multiple values of FSIZE, partitions values must be aligned to multiples of //8 / (NUM_CHUNKS * CLUSTERSIZE) = 1 / 524288 = 0x0.00002 uint32_t partitions[NUM_CHUNKS]; int permutation[NUM_CHUNKS]; //the order in which to write the chunks //a bitmap of the chunks that should be written by the follower //chunk 0 corresponds to bit 1, chunk 1 to bit 2, etc uint64_t follower_chunks; } pattern_t; /* Returns (via begin and end) the range of a chunk. Begin is inclusive, * end is exclusive */ void get_chunk_range(const pattern_t* pat, int chunk, uint32_t* begin, uint32_t* end){ if (chunk == 0){ *begin = 0; } else{ *begin = (uint32_t)((uint64_t)FSIZE * (uint64_t)pat->partitions[chunk - 1] >> 31); } *end = (uint32_t)((uint64_t)FSIZE * (uint64_t)pat->partitions[chunk] >> 31); } typedef enum{ leader_syncs = 0, follower_syncs, NUM_PHASES } phase_t; /* The most basic, trivial IO pattern. Fully sequential, and the follower * writes every other block */ const pattern_t trivial_pattern = { {0x2000000, 0x4000000, 0x6000000, 0x8000000, 0xa000000, 0xc000000, 0xe000000, 0x10000000, 0x12000000, 0x14000000, 0x16000000, 0x18000000, 0x1a000000, 0x1c000000, 0x1e000000, 0x20000000, 0x22000000, 0x24000000, 0x26000000, 0x28000000, 0x2a000000, 0x2c000000, 0x2e000000, 0x30000000, 0x32000000, 0x34000000, 0x36000000, 0x38000000, 0x3a000000, 0x3c000000, 0x3e000000, 0x40000000, 0x42000000, 0x44000000, 0x46000000, 0x48000000, 0x4a000000, 0x4c000000, 0x4e000000, 0x50000000, 0x52000000, 0x54000000, 0x56000000, 0x58000000, 0x5a000000, 0x5c000000, 0x5e000000, 0x60000000, 0x62000000, 0x64000000, 0x66000000, 0x68000000, 0x6a000000, 0x6c000000, 0x6e000000, 0x70000000, 0x72000000, 0x74000000, 0x76000000, 0x78000000, 0x7a000000, 0x7c000000, 0x7e000000, 0x80000000}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63}, 0x5555555555555555 }; //The below patterns were randomly generated const pattern_t pat0 = { { 0x1eac000, 0x88a4000, 0xaffe000, 0xcdb7000, 0xd2d5000, 0xe16f000, 0xe499000, 0x11f71000, 0x1242d000, 0x12c07000, 0x143bc000, 0x1460a000, 0x15dd7000, 0x1700e000, 0x1be7e000, 0x1e14d000, 0x1e6ac000, 0x21097000, 0x24b74000, 0x27166000, 0x27669000, 0x30539000, 0x3218b000, 0x37591000, 0x37b60000, 0x39818000, 0x39d08000, 0x3c90e000, 0x3e54f000, 0x3fb99000, 0x42c8e000, 0x43a62000, 0x43f50000, 0x4c0c9000, 0x4c422000, 0x4c737000, 0x4d41e000, 0x4d738000, 0x4da71000, 0x4f4e8000, 0x508e3000, 0x51396000, 0x51ab5000, 0x52a02000, 0x54238000, 0x54d6a000, 0x55029000, 0x5584b000, 0x5c42c000, 0x5c4a7000, 0x5dac5000, 0x5fe4d000, 0x63f86000, 0x66ad0000, 0x67b3d000, 0x69ce5000, 0x6c179000, 0x6e79e000, 0x6f83f000, 0x71165000, 0x72bd9000, 0x7ac79000, 0x7dc94000, 0x80000000, }, { 57, 16, 28, 25, 10, 59, 52, 46, 30, 6, 40, 36, 39, 9, 21, 51, 33, 45, 44, 19, 2, 50, 55, 5, 58, 13, 23, 0, 12, 53, 42, 32, 31, 48, 35, 61, 49, 54, 18, 24, 8, 41, 62, 4, 47, 17, 1, 3, 34, 14, 63, 22, 15, 26, 38, 56, 27, 60, 29, 11, 7, 43, 20, 37, }, 0xa2f002a1a7795bbb }; const pattern_t pat1 = { { 0x2b5000, 0x16db000, 0x5eb5000, 0x93a0000, 0xa7cb000, 0xa9e9000, 0xd144000, 0xe7c2000, 0xeb7d000, 0x10919000, 0x10cbd000, 0x11f85000, 0x17360000, 0x1760a000, 0x18eab000, 0x1ae6b000, 0x1c5f6000, 0x1df38000, 0x21bec000, 0x239d1000, 0x26b81000, 0x2747b000, 0x27a03000, 0x2b3cc000, 0x2cbf9000, 0x2ec0f000, 0x30a68000, 0x30bea000, 0x30c64000, 0x311af000, 0x35823000, 0x35d23000, 0x3b20e000, 0x405d8000, 0x414c8000, 0x43a91000, 0x44049000, 0x4ab4e000, 0x4ae21000, 0x4d293000, 0x511e5000, 0x516fc000, 0x52d77000, 0x57229000, 0x5da57000, 0x5dbe6000, 0x6070e000, 0x60fc0000, 0x64b24000, 0x67636000, 0x67658000, 0x6b040000, 0x6b28f000, 0x6e551000, 0x707c0000, 0x71b5c000, 0x72062000, 0x762a1000, 0x788a0000, 0x7a1e1000, 0x7b06a000, 0x7e04c000, 0x7f4cf000, 0x80000000, }, { 45, 8, 55, 9, 21, 54, 41, 7, 6, 22, 31, 47, 23, 11, 48, 53, 0, 61, 63, 50, 17, 27, 12, 19, 10, 40, 14, 51, 39, 59, 2, 43, 18, 42, 52, 28, 16, 44, 3, 5, 15, 35, 58, 33, 57, 49, 34, 30, 46, 4, 37, 60, 32, 36, 25, 56, 24, 13, 20, 38, 29, 26, 62, 1, }, 0xc88ca673fa160cbe }; const pattern_t pat2 = { { 0x912d000, 0xe610000, 0xf755000, 0x116df000, 0x128e5000, 0x1bd51000, 0x24e9a000, 0x27643000, 0x28cf4000, 0x292c9000, 0x2c907000, 0x2d389000, 0x2d941000, 0x2eb3f000, 0x30e94000, 0x31738000, 0x3343b000, 0x342ce000, 0x34d12000, 0x3536d000, 0x35e1a000, 0x35e4d000, 0x35fd5000, 0x3642b000, 0x3924d000, 0x392a5000, 0x3e531000, 0x3f0ee000, 0x3fdf8000, 0x41593000, 0x41c80000, 0x43959000, 0x43bc0000, 0x461c8000, 0x48922000, 0x49519000, 0x4f6fa000, 0x50274000, 0x508ae000, 0x536ed000, 0x54154000, 0x59894000, 0x5a666000, 0x5b0a6000, 0x5b9ff000, 0x5c109000, 0x5d8d0000, 0x5ddc5000, 0x5fcc5000, 0x63366000, 0x63adc000, 0x645b6000, 0x670eb000, 0x6b1b1000, 0x6c996000, 0x6ed2a000, 0x6ee4f000, 0x71fcd000, 0x734a3000, 0x76bdf000, 0x77b3f000, 0x7c65a000, 0x7d200000, 0x80000000, }, { 31, 35, 36, 52, 27, 56, 40, 13, 51, 49, 43, 37, 62, 42, 24, 29, 48, 25, 7, 61, 22, 57, 11, 32, 2, 54, 41, 6, 55, 15, 20, 26, 63, 44, 12, 4, 19, 58, 60, 59, 47, 23, 30, 50, 53, 34, 9, 38, 45, 8, 28, 3, 16, 33, 5, 21, 1, 10, 46, 18, 0, 14, 39, 17, }, 0x51ac7692bd1a78d2 }; const pattern_t pat3 = { { 0x553000, 0x19de000, 0x6a20000, 0x8a53000, 0x8ef9000, 0xc325000, 0x1132e000, 0x139fa000, 0x1426b000, 0x150ff000, 0x1bbc1000, 0x1e84c000, 0x1f43e000, 0x1f731000, 0x21ec8000, 0x231f4000, 0x23440000, 0x23466000, 0x260b6000, 0x286a7000, 0x29518000, 0x29e35000, 0x2fdb7000, 0x3089d000, 0x362e0000, 0x3c1f9000, 0x3df2d000, 0x3fce6000, 0x402f3000, 0x4117f000, 0x41e06000, 0x4374f000, 0x451e5000, 0x45a59000, 0x4956b000, 0x4960f000, 0x4a934000, 0x4bc6f000, 0x4d462000, 0x4eef8000, 0x4f609000, 0x50dc1000, 0x51022000, 0x54396000, 0x5641b000, 0x578f1000, 0x589cf000, 0x59093000, 0x5da6b000, 0x5fbf0000, 0x605a2000, 0x65428000, 0x65530000, 0x6705a000, 0x6db65000, 0x71cef000, 0x725a2000, 0x73bf5000, 0x75acb000, 0x76065000, 0x7614c000, 0x77aab000, 0x78f70000, 0x80000000, }, { 15, 30, 31, 16, 49, 13, 55, 59, 4, 24, 26, 44, 17, 0, 18, 54, 10, 3, 46, 34, 29, 22, 45, 5, 38, 32, 39, 50, 48, 53, 12, 25, 35, 56, 51, 52, 1, 33, 43, 63, 47, 37, 23, 20, 60, 14, 11, 21, 8, 57, 27, 41, 6, 58, 62, 2, 19, 61, 28, 36, 40, 7, 9, 42, }, 0x7d291499a7ecc986 }; const pattern_t pat4 = { { 0x425000, 0x8e8000, 0x4b90000, 0x883c000, 0x968e000, 0xbacc000, 0x10e59000, 0x125a1000, 0x12f00000, 0x14e7c000, 0x156de000, 0x192a1000, 0x1a2b9000, 0x1b4a0000, 0x1be9c000, 0x1d3bd000, 0x24242000, 0x2516b000, 0x2b88d000, 0x2b96a000, 0x2bcd3000, 0x2c5a9000, 0x2da74000, 0x2dba1000, 0x3097f000, 0x332ef000, 0x34525000, 0x36193000, 0x3725c000, 0x37e66000, 0x3d315000, 0x3e813000, 0x404ae000, 0x40c68000, 0x42f93000, 0x44b14000, 0x44b15000, 0x473b2000, 0x49048000, 0x4c794000, 0x50b60000, 0x52b3d000, 0x58c61000, 0x5b7d4000, 0x5ce71000, 0x5d21d000, 0x5d63e000, 0x5e00f000, 0x60e8b000, 0x66381000, 0x66c70000, 0x68430000, 0x707c2000, 0x71979000, 0x72681000, 0x74017000, 0x7721d000, 0x7a1be000, 0x7a2cd000, 0x7b225000, 0x7c311000, 0x7e03a000, 0x7e402000, 0x80000000, }, { 52, 62, 28, 47, 51, 37, 31, 36, 4, 58, 26, 29, 16, 59, 57, 33, 22, 27, 49, 44, 19, 56, 34, 23, 5, 14, 45, 48, 21, 25, 18, 12, 43, 53, 60, 17, 46, 15, 63, 30, 42, 38, 41, 8, 39, 20, 1, 10, 54, 40, 32, 24, 9, 2, 35, 3, 7, 0, 61, 11, 13, 55, 6, 50, }, 0xd0e57ce640cdc726 }; const pattern_t pat5 = { { 0xae7000, 0x436e000, 0x81e1000, 0xb276000, 0xf8bf000, 0xfb26000, 0xfe7e000, 0x137ad000, 0x14b8e000, 0x157aa000, 0x1981a000, 0x1a32f000, 0x1bc9e000, 0x1def5000, 0x1e8ef000, 0x2068f000, 0x22692000, 0x22a6c000, 0x255bf000, 0x26977000, 0x27619000, 0x2977c000, 0x2ce0c000, 0x2e1ec000, 0x2e26c000, 0x31ce8000, 0x34e6c000, 0x365cd000, 0x37e87000, 0x385e3000, 0x3a7e2000, 0x3a9c7000, 0x41597000, 0x42e8a000, 0x453cc000, 0x454bf000, 0x4b24c000, 0x4ba54000, 0x4e307000, 0x4f059000, 0x55d5a000, 0x56277000, 0x56b90000, 0x5882d000, 0x5a2c5000, 0x5b369000, 0x5d442000, 0x5d671000, 0x5fdd0000, 0x60ce0000, 0x63713000, 0x64130000, 0x65973000, 0x67ad9000, 0x68764000, 0x68bb2000, 0x690d1000, 0x6a2c8000, 0x73e9f000, 0x74e75000, 0x77861000, 0x77ee5000, 0x7cddb000, 0x80000000, }, { 42, 25, 15, 58, 32, 61, 30, 56, 48, 62, 38, 50, 7, 45, 16, 29, 12, 4, 41, 3, 27, 18, 57, 10, 51, 17, 21, 14, 35, 19, 44, 47, 49, 26, 59, 63, 28, 55, 20, 13, 5, 6, 37, 54, 40, 22, 23, 46, 11, 36, 34, 31, 2, 60, 9, 52, 24, 1, 53, 0, 39, 43, 8, 33, }, 0xc8b474decf8e9c40 }; const pattern_t pat6 = { { 0xad2000, 0x222f000, 0x64b4000, 0x6c66000, 0x6f35000, 0x9e50000, 0xe744000, 0xf129000, 0x101bb000, 0x11bf8000, 0x14b89000, 0x1691c000, 0x17a0d000, 0x1817a000, 0x1997a000, 0x1d736000, 0x1db33000, 0x1fdd8000, 0x21e56000, 0x2266c000, 0x22875000, 0x22b84000, 0x230ed000, 0x239c5000, 0x24e1a000, 0x275f5000, 0x29036000, 0x29f69000, 0x2e538000, 0x2efca000, 0x2f0bc000, 0x2f1bf000, 0x305cb000, 0x31ce7000, 0x345c4000, 0x35d4f000, 0x36e56000, 0x3ae9e000, 0x3cc27000, 0x40117000, 0x4299f000, 0x434c3000, 0x443d4000, 0x4552d000, 0x4a8a8000, 0x4cdea000, 0x51bd5000, 0x580c4000, 0x58381000, 0x59dc0000, 0x5ba7f000, 0x5d88b000, 0x5e0c4000, 0x5ee57000, 0x61f3f000, 0x63a4a000, 0x68a8a000, 0x68ec5000, 0x6937b000, 0x720be000, 0x72cf5000, 0x74fc8000, 0x76464000, 0x80000000, }, { 31, 46, 36, 22, 63, 12, 51, 60, 13, 44, 41, 6, 11, 17, 42, 24, 16, 61, 20, 26, 35, 21, 29, 55, 50, 45, 62, 19, 54, 9, 30, 34, 53, 52, 10, 39, 0, 49, 48, 38, 40, 28, 23, 56, 2, 5, 4, 59, 14, 57, 3, 25, 43, 32, 27, 47, 8, 7, 37, 33, 1, 18, 58, 15, }, 0xe5172947f6d4e10a }; const pattern_t pat7 = { { 0xd83000, 0x1597000, 0x245b000, 0x6a75000, 0x8fda000, 0x960e000, 0xd310000, 0xe6cd000, 0x1409a000, 0x15221000, 0x16059000, 0x1b3a4000, 0x1ceea000, 0x1ed1a000, 0x1ef0f000, 0x21723000, 0x21efc000, 0x24594000, 0x26d7f000, 0x28c4f000, 0x2fa89000, 0x304f0000, 0x30dbb000, 0x30de3000, 0x3365d000, 0x36dbc000, 0x3acb2000, 0x3e291000, 0x3f7da000, 0x41352000, 0x41a0f000, 0x435c8000, 0x4475a000, 0x47536000, 0x47726000, 0x4a81f000, 0x4be4e000, 0x4bf05000, 0x4c15b000, 0x515b4000, 0x52ef5000, 0x548cc000, 0x5692a000, 0x59ef2000, 0x5b97c000, 0x5c4f0000, 0x5d1b9000, 0x618ed000, 0x61bcc000, 0x61e07000, 0x639a3000, 0x65302000, 0x68041000, 0x6be56000, 0x721a3000, 0x72c99000, 0x740b9000, 0x7586d000, 0x75eca000, 0x76406000, 0x7b68a000, 0x7dd26000, 0x7ed55000, 0x80000000, }, { 44, 57, 22, 35, 63, 11, 15, 49, 61, 40, 29, 20, 19, 42, 32, 12, 41, 6, 46, 60, 52, 5, 36, 10, 2, 8, 3, 33, 54, 39, 58, 48, 62, 7, 51, 34, 0, 1, 18, 9, 55, 31, 23, 38, 25, 21, 17, 24, 13, 50, 16, 14, 43, 53, 45, 28, 59, 37, 26, 30, 47, 27, 56, 4, }, 0xc509d471a7ae3363 }; const pattern_t pat8 = { { 0x1b8000, 0x27eb000, 0x5a4d000, 0x6ecc000, 0xb52e000, 0xb70e000, 0xc6db000, 0xd83d000, 0xed51000, 0x13c59000, 0x13fef000, 0x142e1000, 0x192d0000, 0x1aa63000, 0x1e230000, 0x1f464000, 0x20de4000, 0x2234b000, 0x25459000, 0x27018000, 0x28263000, 0x29cc7000, 0x32227000, 0x32c63000, 0x34af0000, 0x37e27000, 0x3afc9000, 0x3c166000, 0x3df20000, 0x405bd000, 0x41273000, 0x45c39000, 0x471be000, 0x4758e000, 0x4b3fc000, 0x4c6b2000, 0x4c80f000, 0x4ccd6000, 0x4d9e0000, 0x4e07f000, 0x4eeda000, 0x541ae000, 0x58aa7000, 0x5a2c6000, 0x5a628000, 0x5ab94000, 0x5bddc000, 0x5d1d4000, 0x5e643000, 0x5f72f000, 0x64771000, 0x67bd4000, 0x6a28c000, 0x6c977000, 0x6cc4e000, 0x710c4000, 0x74b86000, 0x75cf7000, 0x77d4b000, 0x7870e000, 0x7c47c000, 0x7eb52000, 0x7fbea000, 0x80000000, }, { 7, 29, 62, 8, 54, 38, 35, 45, 60, 55, 1, 40, 4, 19, 50, 63, 48, 51, 13, 27, 33, 39, 52, 46, 10, 9, 56, 2, 42, 43, 47, 44, 17, 5, 25, 6, 57, 23, 15, 58, 59, 22, 14, 26, 32, 61, 30, 0, 11, 12, 36, 24, 53, 49, 3, 20, 31, 28, 34, 18, 41, 21, 16, 37, }, 0x8b938ea7b599224d }; const pattern_t pat9 = { { 0x5b59000, 0xa6d7000, 0xbad3000, 0xdf91000, 0x115ad000, 0x13fde000, 0x17618000, 0x1b8e9000, 0x1e1b7000, 0x1e97d000, 0x21737000, 0x21a5e000, 0x24140000, 0x2558f000, 0x2647a000, 0x28257000, 0x285f6000, 0x2cb7a000, 0x2ebb1000, 0x30ae8000, 0x31543000, 0x315cb000, 0x31616000, 0x335ba000, 0x33ed6000, 0x35cf3000, 0x4162b000, 0x4409b000, 0x4629a000, 0x4b745000, 0x4c0ba000, 0x4cbc5000, 0x4dd97000, 0x4f34b000, 0x4f637000, 0x539d6000, 0x53f3d000, 0x56383000, 0x5642b000, 0x5a71f000, 0x5affa000, 0x5b486000, 0x5b8ef000, 0x60d88000, 0x61629000, 0x625cd000, 0x63326000, 0x6735e000, 0x67379000, 0x6a26a000, 0x6a281000, 0x6b997000, 0x6c50d000, 0x6cc6c000, 0x6f496000, 0x717ad000, 0x732ec000, 0x744dc000, 0x771e8000, 0x77cf0000, 0x79cad000, 0x7bb21000, 0x7e7b4000, 0x80000000, }, { 35, 9, 46, 6, 29, 2, 3, 54, 55, 57, 41, 16, 44, 5, 0, 59, 10, 61, 22, 42, 47, 12, 14, 50, 39, 34, 21, 32, 25, 15, 26, 8, 38, 60, 28, 53, 62, 49, 58, 43, 36, 37, 52, 7, 19, 63, 17, 11, 45, 33, 23, 27, 24, 18, 48, 56, 31, 13, 51, 30, 4, 20, 40, 1, }, 0xfc4c41bb3d34a11d }; const pattern_t pat10 = { { 0xa72000, 0x180a000, 0x6406000, 0x66df000, 0x83bb000, 0xa96f000, 0xd193000, 0x13b9b000, 0x13dae000, 0x16109000, 0x1853d000, 0x18887000, 0x19f0a000, 0x22151000, 0x229ba000, 0x26b58000, 0x2aaf4000, 0x2bf50000, 0x31a2e000, 0x31d4e000, 0x32196000, 0x3513a000, 0x36a2d000, 0x3746b000, 0x389ad000, 0x39d27000, 0x3dad3000, 0x3de55000, 0x3ea9b000, 0x3ec06000, 0x3f921000, 0x432d3000, 0x43bec000, 0x43dda000, 0x47b2b000, 0x4886e000, 0x4928e000, 0x49ad2000, 0x4d0df000, 0x4f40d000, 0x50959000, 0x54fa4000, 0x56091000, 0x5688d000, 0x5b7d8000, 0x5f6fd000, 0x601e4000, 0x64eaa000, 0x6752e000, 0x67fff000, 0x6a184000, 0x6ad7a000, 0x6adbc000, 0x6c434000, 0x6f451000, 0x6ffb4000, 0x707ee000, 0x71161000, 0x7146b000, 0x75dbf000, 0x77259000, 0x7acd4000, 0x7af71000, 0x80000000, }, { 61, 38, 5, 23, 62, 11, 53, 9, 17, 45, 30, 29, 41, 60, 39, 21, 40, 19, 44, 33, 42, 50, 56, 28, 32, 46, 43, 20, 16, 3, 54, 8, 4, 26, 15, 34, 47, 12, 6, 27, 48, 0, 1, 2, 57, 59, 7, 58, 49, 35, 24, 37, 52, 63, 10, 55, 36, 13, 14, 25, 18, 22, 31, 51, }, 0xbaba0d4f32308c7d }; const pattern_t pat11 = { { 0x996000, 0xaff000, 0x199a000, 0x46f3000, 0x74c0000, 0x758d000, 0xcd09000, 0xe48c000, 0xe8de000, 0xf111000, 0xf87b000, 0x10b1c000, 0x15d63000, 0x17b21000, 0x182d3000, 0x19167000, 0x198ce000, 0x1bd47000, 0x1dff1000, 0x1edc0000, 0x1f890000, 0x20860000, 0x23207000, 0x29bd5000, 0x2ac0f000, 0x2e395000, 0x2e707000, 0x329de000, 0x3497f000, 0x3807f000, 0x38a94000, 0x40a19000, 0x4168e000, 0x42ca0000, 0x42de9000, 0x45194000, 0x464f2000, 0x4700f000, 0x47dbb000, 0x4dae7000, 0x50660000, 0x535a8000, 0x5546b000, 0x57b55000, 0x5860a000, 0x5a9ee000, 0x5b8d9000, 0x5c49f000, 0x5cb4d000, 0x5d28c000, 0x60dcd000, 0x62557000, 0x64b0c000, 0x654cb000, 0x65746000, 0x65e29000, 0x6648f000, 0x66c56000, 0x6999e000, 0x6a11c000, 0x6ca04000, 0x79e60000, 0x7edce000, 0x80000000, }, { 16, 28, 2, 38, 10, 57, 21, 26, 61, 43, 46, 31, 56, 7, 47, 48, 58, 25, 63, 4, 59, 15, 32, 50, 1, 40, 53, 18, 17, 24, 29, 30, 55, 36, 49, 42, 41, 37, 23, 39, 6, 51, 33, 9, 45, 5, 35, 19, 44, 11, 34, 0, 27, 12, 60, 62, 20, 13, 22, 8, 14, 54, 3, 52, }, 0x6458c1af941ce1f7 }; const pattern_t pat12 = { { 0x513000, 0x1b72000, 0x1e27000, 0x3a63000, 0x1115c000, 0x158b4000, 0x1664f000, 0x1b667000, 0x1f838000, 0x21410000, 0x260c7000, 0x2cd8f000, 0x2ce37000, 0x2df16000, 0x2e59e000, 0x2e8eb000, 0x2ebd2000, 0x2f1d2000, 0x2fc42000, 0x30d00000, 0x31ef1000, 0x3301a000, 0x38097000, 0x38a1e000, 0x3d818000, 0x3e898000, 0x3f90f000, 0x47710000, 0x478bb000, 0x485ab000, 0x48e54000, 0x4cfe1000, 0x53a89000, 0x53d10000, 0x56308000, 0x56f3b000, 0x577f6000, 0x58734000, 0x5889b000, 0x58ad7000, 0x5923a000, 0x59aef000, 0x5dad3000, 0x5e32f000, 0x63b3a000, 0x665c9000, 0x68cde000, 0x69252000, 0x6a777000, 0x6a79a000, 0x6c1f0000, 0x6cb9a000, 0x6d319000, 0x6dc82000, 0x6dd4d000, 0x6e188000, 0x7184d000, 0x7206e000, 0x73980000, 0x740ad000, 0x75473000, 0x7614d000, 0x79b17000, 0x80000000, }, { 4, 60, 10, 35, 6, 31, 5, 18, 53, 17, 20, 8, 56, 29, 7, 48, 40, 0, 12, 39, 2, 43, 15, 61, 42, 30, 50, 14, 49, 38, 34, 58, 24, 55, 33, 63, 28, 51, 59, 46, 11, 22, 45, 41, 13, 44, 23, 47, 3, 32, 16, 54, 26, 19, 25, 52, 27, 57, 36, 9, 37, 21, 62, 1, }, 0x1a7a56b619472b96 }; const pattern_t pat13 = { { 0x351e000, 0x5917000, 0xa992000, 0xc471000, 0xc69c000, 0xc6ed000, 0xc919000, 0xd713000, 0xec14000, 0xfa31000, 0x17567000, 0x1d81a000, 0x1f3c8000, 0x215b5000, 0x26e41000, 0x2a2d4000, 0x2b750000, 0x2bea0000, 0x2c5ae000, 0x2ca2c000, 0x30a94000, 0x31074000, 0x314d3000, 0x31b1e000, 0x31de2000, 0x32062000, 0x33da5000, 0x37838000, 0x385ec000, 0x38740000, 0x387f9000, 0x38be6000, 0x3d2f7000, 0x3eaf5000, 0x40266000, 0x402f3000, 0x40fda000, 0x4a4bd000, 0x4b831000, 0x4bfc9000, 0x4ccaa000, 0x4ea43000, 0x50190000, 0x547c8000, 0x58cc6000, 0x58ea5000, 0x59de1000, 0x5c7f1000, 0x5f713000, 0x63f9a000, 0x6686d000, 0x675c1000, 0x6cccc000, 0x6e409000, 0x6fb6d000, 0x71a70000, 0x72f60000, 0x77bd9000, 0x79013000, 0x7a8d3000, 0x7b341000, 0x7d8f7000, 0x7fe43000, 0x80000000, }, { 10, 52, 48, 8, 34, 4, 35, 19, 3, 17, 54, 45, 31, 38, 24, 44, 21, 36, 22, 11, 43, 40, 39, 26, 5, 30, 2, 7, 57, 12, 20, 32, 62, 15, 55, 14, 25, 58, 6, 33, 49, 9, 59, 27, 13, 63, 42, 61, 1, 51, 0, 50, 37, 47, 16, 18, 41, 56, 60, 46, 23, 28, 53, 29, }, 0x8eb1b741cb9906f4 }; const pattern_t pat14 = { { 0xf8e000, 0x169a000, 0x3816000, 0x67a9000, 0x89f3000, 0xac97000, 0xc8da000, 0xf077000, 0x119f1000, 0x13902000, 0x19785000, 0x1ca7f000, 0x1f958000, 0x2027d000, 0x2251f000, 0x24661000, 0x25604000, 0x2b924000, 0x2be5f000, 0x2ec27000, 0x330a5000, 0x3349e000, 0x33a84000, 0x344fa000, 0x34514000, 0x37966000, 0x37f0b000, 0x37fcd000, 0x386d0000, 0x39600000, 0x39de4000, 0x3e601000, 0x3e7f1000, 0x42c61000, 0x48806000, 0x4d3d0000, 0x4f5ff000, 0x512c1000, 0x53fd4000, 0x59440000, 0x5b386000, 0x5e8a0000, 0x5fca3000, 0x6016c000, 0x61ca8000, 0x64915000, 0x66b99000, 0x67226000, 0x69b2f000, 0x6a473000, 0x6a590000, 0x6c844000, 0x6cb8c000, 0x713b5000, 0x7558a000, 0x75eab000, 0x76d15000, 0x77efe000, 0x78762000, 0x7bddc000, 0x7ce92000, 0x7dc44000, 0x7f54b000, 0x80000000, }, { 54, 31, 48, 10, 51, 49, 55, 19, 38, 18, 44, 5, 17, 20, 16, 11, 9, 3, 42, 59, 63, 45, 25, 60, 57, 21, 40, 29, 0, 39, 26, 7, 53, 12, 13, 2, 58, 41, 22, 8, 14, 28, 46, 24, 27, 6, 52, 32, 56, 4, 30, 36, 15, 47, 23, 37, 43, 35, 50, 33, 61, 34, 1, 62, }, 0xa13fa3d92bcc578 }; const pattern_t pat15 = { { 0xe16000, 0xec6000, 0xf6b000, 0x634b000, 0x6896000, 0x91db000, 0xc2c8000, 0xe083000, 0xfd7f000, 0x10479000, 0x17740000, 0x18292000, 0x1aaca000, 0x1cb55000, 0x1d2be000, 0x222af000, 0x2cb03000, 0x2fabc000, 0x32034000, 0x35c0f000, 0x3c5ec000, 0x40908000, 0x4128e000, 0x44411000, 0x44bcd000, 0x4f0ac000, 0x5167b000, 0x5541c000, 0x581bc000, 0x584e5000, 0x588fb000, 0x593d3000, 0x5b25d000, 0x5dc99000, 0x60b35000, 0x60ffc000, 0x638e8000, 0x63cf8000, 0x64ee1000, 0x6523c000, 0x654a1000, 0x687bf000, 0x68bef000, 0x69826000, 0x69d90000, 0x6a622000, 0x6d1b9000, 0x6d1e1000, 0x6d886000, 0x6fe4a000, 0x6feac000, 0x720b2000, 0x734dc000, 0x73530000, 0x73f1e000, 0x7479c000, 0x76e33000, 0x786dc000, 0x79b40000, 0x79e49000, 0x7b66c000, 0x7b904000, 0x7c906000, 0x80000000, }, { 6, 17, 62, 20, 61, 32, 22, 14, 28, 18, 3, 42, 63, 43, 46, 34, 29, 30, 35, 1, 37, 40, 10, 26, 5, 31, 15, 54, 8, 33, 9, 4, 39, 53, 23, 25, 41, 59, 12, 13, 60, 2, 7, 56, 58, 27, 11, 38, 36, 45, 47, 0, 57, 50, 48, 16, 51, 49, 55, 52, 44, 24, 19, 21, }, 0xef2ebd111c482f52 }; const pattern_t pat16 = { { 0x596a000, 0x8644000, 0xa943000, 0xd59e000, 0x1062f000, 0x1082a000, 0x10c1b000, 0x10f9e000, 0x11e64000, 0x12e73000, 0x15ce7000, 0x16037000, 0x16d2e000, 0x17035000, 0x185ad000, 0x18d9b000, 0x19ac7000, 0x1b2fa000, 0x1cd6c000, 0x1d5f0000, 0x1f72c000, 0x20891000, 0x24bfa000, 0x25c1d000, 0x28e24000, 0x2a5f8000, 0x2e0ae000, 0x2fddf000, 0x3119d000, 0x332ee000, 0x3480a000, 0x34ea5000, 0x3534e000, 0x3538b000, 0x362e2000, 0x38f58000, 0x39ab0000, 0x3a519000, 0x3a62b000, 0x3b006000, 0x3d523000, 0x3e0f7000, 0x42366000, 0x42feb000, 0x44013000, 0x46b98000, 0x49794000, 0x4dce7000, 0x4f1f3000, 0x57ecd000, 0x5aaa2000, 0x5f419000, 0x61517000, 0x6797d000, 0x69a20000, 0x6a070000, 0x70575000, 0x75322000, 0x75a9e000, 0x79043000, 0x79875000, 0x7addc000, 0x7de88000, 0x80000000, }, { 26, 25, 6, 50, 32, 53, 34, 27, 3, 16, 49, 28, 46, 38, 56, 4, 18, 24, 51, 36, 63, 5, 48, 13, 43, 55, 0, 62, 35, 7, 41, 21, 44, 60, 31, 39, 14, 8, 61, 58, 52, 23, 59, 33, 10, 37, 20, 30, 40, 22, 11, 54, 57, 1, 29, 47, 2, 17, 19, 45, 15, 9, 12, 42, }, 0xb19913245ddeb436 }; const pattern_t pat17 = { { 0x28ab000, 0x3ac8000, 0x3fe1000, 0x63a7000, 0x90fc000, 0xb3f2000, 0xd2f2000, 0xe032000, 0x12d4c000, 0x13135000, 0x14652000, 0x15331000, 0x1570c000, 0x1688e000, 0x16bc3000, 0x1cbe3000, 0x1fe0f000, 0x2517f000, 0x26c6b000, 0x2a284000, 0x2a4e2000, 0x2add5000, 0x2bd06000, 0x2ca3a000, 0x2eb11000, 0x324d1000, 0x35662000, 0x38695000, 0x38ce7000, 0x391ac000, 0x398f9000, 0x39949000, 0x401f3000, 0x457f0000, 0x45c6d000, 0x4b561000, 0x522fc000, 0x54ef0000, 0x559f8000, 0x562a7000, 0x56a04000, 0x57b68000, 0x59702000, 0x5ffc9000, 0x63a76000, 0x63c37000, 0x65d3e000, 0x67130000, 0x6a03a000, 0x6bcd6000, 0x6be96000, 0x6bf52000, 0x6fcd9000, 0x7038c000, 0x70a47000, 0x72881000, 0x72ed0000, 0x75035000, 0x75c11000, 0x77fa5000, 0x797c9000, 0x79813000, 0x7bbbb000, 0x80000000, }, { 18, 15, 56, 5, 25, 47, 39, 55, 12, 14, 51, 33, 0, 7, 9, 44, 50, 31, 62, 59, 3, 35, 23, 17, 30, 60, 11, 24, 40, 20, 52, 2, 22, 8, 57, 42, 32, 54, 36, 48, 49, 13, 58, 10, 28, 63, 16, 41, 27, 21, 37, 4, 1, 29, 19, 6, 53, 45, 46, 38, 34, 43, 61, 26, }, 0x710633dc35c17b71 }; const pattern_t pat18 = { { 0x38d6000, 0x5379000, 0x5cae000, 0x5d20000, 0xa248000, 0xb4d0000, 0xd7c0000, 0xf731000, 0x116ae000, 0x151d2000, 0x1747d000, 0x1bfb6000, 0x1d758000, 0x2053d000, 0x24dda000, 0x25274000, 0x269c0000, 0x273e8000, 0x2a5d0000, 0x2ad34000, 0x3016b000, 0x30d1a000, 0x32960000, 0x34b3b000, 0x36e4f000, 0x37934000, 0x38c42000, 0x3c2d2000, 0x3d23d000, 0x3d89a000, 0x3dc85000, 0x3e9a7000, 0x3f25b000, 0x45bd1000, 0x48d94000, 0x4b126000, 0x4e17c000, 0x4f377000, 0x50908000, 0x51957000, 0x53410000, 0x5412c000, 0x55256000, 0x56b17000, 0x5707b000, 0x5bbe5000, 0x5d067000, 0x5e1c1000, 0x6380b000, 0x66009000, 0x68240000, 0x69fc4000, 0x6c327000, 0x6c5d2000, 0x6f69d000, 0x739c7000, 0x744bc000, 0x74cd8000, 0x787b8000, 0x78c61000, 0x7969d000, 0x79aae000, 0x7b032000, 0x80000000, }, { 16, 48, 50, 60, 13, 39, 20, 4, 63, 18, 14, 30, 55, 8, 62, 37, 43, 41, 11, 0, 36, 33, 34, 49, 17, 58, 38, 22, 19, 5, 21, 12, 47, 25, 57, 61, 7, 3, 10, 23, 52, 24, 6, 53, 2, 26, 1, 31, 28, 46, 42, 9, 45, 29, 27, 54, 32, 56, 51, 44, 35, 59, 40, 15, }, 0xb53f1e4266db260c }; const pattern_t pat19 = { { 0x297d000, 0x34e0000, 0x7801000, 0x9664000, 0x96fa000, 0xbb9f000, 0xc192000, 0xc4a5000, 0xca74000, 0xcce8000, 0x173d8000, 0x1a8d8000, 0x1b299000, 0x1b52d000, 0x1e813000, 0x2185e000, 0x21abe000, 0x2b9a4000, 0x2c4b6000, 0x2fa27000, 0x343ba000, 0x356fd000, 0x37c6e000, 0x38365000, 0x3a9e4000, 0x3b599000, 0x4296b000, 0x43196000, 0x4381e000, 0x44783000, 0x47a75000, 0x4bd78000, 0x4d05d000, 0x4edb2000, 0x4eefd000, 0x4fecc000, 0x51f68000, 0x5252b000, 0x5439e000, 0x55fb3000, 0x5814f000, 0x5939d000, 0x60a78000, 0x62a86000, 0x633b0000, 0x64a68000, 0x64b62000, 0x66207000, 0x66540000, 0x67f90000, 0x68bf3000, 0x6a069000, 0x6d2ac000, 0x70c9f000, 0x71bab000, 0x724bc000, 0x783d8000, 0x7900e000, 0x79399000, 0x79763000, 0x7c8a8000, 0x7e680000, 0x7f6de000, 0x80000000, }, { 14, 59, 60, 24, 18, 22, 62, 12, 45, 2, 32, 11, 25, 37, 13, 7, 50, 39, 56, 17, 47, 40, 29, 43, 15, 34, 4, 57, 31, 38, 21, 28, 36, 27, 42, 1, 23, 33, 5, 61, 44, 55, 8, 30, 10, 41, 19, 48, 16, 52, 49, 46, 54, 58, 6, 0, 51, 3, 26, 20, 53, 9, 35, 63, }, 0x64f54c0a0deae9ab }; const pattern_t pat20 = { { 0x8f7000, 0xa01000, 0x38e3000, 0x5299000, 0x6875000, 0x7f3e000, 0x827f000, 0x9413000, 0xca71000, 0xfb11000, 0x10beb000, 0x176be000, 0x1924f000, 0x1cfd6000, 0x1d20d000, 0x1ebb7000, 0x22c93000, 0x23601000, 0x2cf7a000, 0x2d3af000, 0x2e391000, 0x2f294000, 0x318ad000, 0x34ddd000, 0x365e4000, 0x3b8d2000, 0x3c0f8000, 0x3d2fd000, 0x3e431000, 0x3f0fe000, 0x4074e000, 0x40d1c000, 0x41936000, 0x4347b000, 0x452d7000, 0x486d3000, 0x4b47e000, 0x4b709000, 0x4c349000, 0x4ff13000, 0x50faa000, 0x51a07000, 0x52f30000, 0x55f29000, 0x57ad4000, 0x5909f000, 0x5a0f6000, 0x5de57000, 0x60d2f000, 0x625ff000, 0x6288e000, 0x65077000, 0x6a707000, 0x6a73f000, 0x6d720000, 0x6e390000, 0x6edc9000, 0x6ee78000, 0x77ac2000, 0x77ad3000, 0x7868f000, 0x79a1b000, 0x7aec6000, 0x80000000, }, { 21, 56, 38, 11, 62, 9, 30, 47, 34, 23, 37, 16, 5, 49, 10, 43, 4, 45, 36, 7, 42, 1, 53, 57, 20, 59, 55, 50, 46, 39, 60, 27, 12, 31, 48, 25, 15, 22, 44, 52, 14, 33, 0, 29, 17, 18, 2, 32, 24, 19, 6, 41, 54, 8, 35, 26, 61, 3, 51, 13, 63, 28, 40, 58, }, 0x786427ef60db40f4 }; const pattern_t pat21 = { { 0x2a8e000, 0xa4bd000, 0xa935000, 0xcc05000, 0xdfe4000, 0xe014000, 0xff46000, 0x18c8c000, 0x199ec000, 0x19ce0000, 0x1f684000, 0x1ff5c000, 0x22d58000, 0x27651000, 0x280e5000, 0x2e2a4000, 0x2e432000, 0x2f96e000, 0x2f9c3000, 0x3343d000, 0x338bb000, 0x34032000, 0x34101000, 0x368c2000, 0x37b95000, 0x39492000, 0x39932000, 0x3b611000, 0x3c89e000, 0x40aa9000, 0x42358000, 0x4890e000, 0x495c9000, 0x4a79d000, 0x4c58e000, 0x4df9a000, 0x4f304000, 0x4fa4c000, 0x54d1d000, 0x58461000, 0x58f43000, 0x5a3d1000, 0x5a765000, 0x5c5c0000, 0x60488000, 0x60fad000, 0x613e5000, 0x61d61000, 0x62d17000, 0x641ff000, 0x67f8b000, 0x69c5d000, 0x6b931000, 0x6efd4000, 0x70333000, 0x70857000, 0x721f6000, 0x72f53000, 0x74450000, 0x746f7000, 0x76067000, 0x7774a000, 0x77ea6000, 0x80000000, }, { 28, 51, 33, 2, 30, 55, 29, 17, 40, 48, 32, 9, 39, 1, 49, 50, 37, 43, 62, 11, 10, 26, 22, 6, 8, 7, 45, 47, 46, 42, 60, 5, 12, 56, 4, 23, 35, 25, 13, 16, 61, 54, 31, 63, 34, 19, 41, 59, 38, 24, 0, 58, 53, 44, 3, 18, 52, 20, 36, 27, 14, 21, 57, 15, }, 0x615a5f41d4c3d653 }; const pattern_t pat22 = { { 0x314d000, 0x4452000, 0x6673000, 0xab09000, 0xc80d000, 0x10eda000, 0x129c2000, 0x12f1f000, 0x13e9b000, 0x1450c000, 0x15aeb000, 0x1667c000, 0x190b2000, 0x19ac5000, 0x1c0ac000, 0x1c229000, 0x1ece8000, 0x1fc48000, 0x22abd000, 0x24268000, 0x2adce000, 0x2b809000, 0x30a11000, 0x31d08000, 0x36700000, 0x39e6a000, 0x3b84b000, 0x41e84000, 0x46301000, 0x4a326000, 0x50fda000, 0x5299a000, 0x56acf000, 0x57f66000, 0x586ab000, 0x58df5000, 0x591cc000, 0x59b91000, 0x59cbd000, 0x5b4d0000, 0x5cca7000, 0x5cfce000, 0x5d120000, 0x5d51a000, 0x5eaa0000, 0x5ebac000, 0x5f0e1000, 0x5f285000, 0x5f4d3000, 0x5ff61000, 0x60b51000, 0x61435000, 0x651fd000, 0x6b954000, 0x705aa000, 0x71a41000, 0x73ec7000, 0x75f92000, 0x76854000, 0x77cb9000, 0x782ca000, 0x7a2af000, 0x7eaa6000, 0x80000000, }, { 16, 8, 5, 59, 4, 18, 26, 43, 33, 57, 6, 47, 56, 46, 10, 54, 52, 0, 50, 30, 39, 24, 38, 63, 28, 25, 49, 31, 55, 62, 3, 17, 23, 13, 37, 53, 34, 14, 44, 12, 19, 36, 27, 61, 51, 42, 41, 60, 45, 1, 7, 35, 21, 58, 20, 15, 2, 9, 22, 29, 48, 32, 40, 11, }, 0x828366dbf1f83654 }; const pattern_t pat23 = { { 0x47000, 0x680000, 0x176a000, 0x1db8000, 0x600e000, 0x808c000, 0x9e58000, 0xa82f000, 0xaebb000, 0xc938000, 0xd0eb000, 0xdc5e000, 0xe503000, 0x11e56000, 0x12dbd000, 0x14681000, 0x15200000, 0x18256000, 0x1be75000, 0x1d2a0000, 0x1ed67000, 0x27e8a000, 0x2bc39000, 0x2bf4b000, 0x2c94f000, 0x2d575000, 0x2d82e000, 0x2e440000, 0x2ecda000, 0x2fbc2000, 0x33ab0000, 0x360b8000, 0x39630000, 0x3a654000, 0x3d2b6000, 0x3eeff000, 0x41590000, 0x417ea000, 0x42ff9000, 0x4bca4000, 0x503b0000, 0x508e4000, 0x52a2e000, 0x535b6000, 0x54335000, 0x57412000, 0x57dc6000, 0x590d9000, 0x5fc0a000, 0x60552000, 0x60665000, 0x6168d000, 0x65b16000, 0x67328000, 0x6742d000, 0x68c88000, 0x6b802000, 0x6f6d2000, 0x7040e000, 0x77e31000, 0x79c71000, 0x7da4a000, 0x7e26b000, 0x80000000, }, { 63, 50, 51, 33, 28, 35, 24, 14, 4, 23, 47, 11, 37, 41, 12, 55, 62, 32, 34, 30, 25, 43, 16, 0, 3, 49, 61, 15, 57, 46, 59, 44, 31, 27, 21, 53, 5, 2, 8, 56, 52, 22, 60, 40, 20, 1, 48, 18, 17, 19, 54, 29, 9, 38, 42, 6, 39, 45, 13, 10, 26, 58, 36, 7, }, 0xd8456d32bb91872e }; const pattern_t pat24 = { { 0x3890000, 0x3fd9000, 0x62d6000, 0x7df0000, 0x895c000, 0xab61000, 0xc23b000, 0x10ab3000, 0x1247c000, 0x13f00000, 0x16604000, 0x1a444000, 0x1c2c8000, 0x1c467000, 0x1d396000, 0x1e683000, 0x21080000, 0x2442a000, 0x27fea000, 0x282eb000, 0x28e2c000, 0x2a625000, 0x2b3b2000, 0x2bbd5000, 0x2c886000, 0x2cbe8000, 0x31518000, 0x35425000, 0x355f4000, 0x35d7a000, 0x3851d000, 0x396a6000, 0x3d10f000, 0x3d890000, 0x49238000, 0x4ab7e000, 0x4fadf000, 0x50603000, 0x5233a000, 0x53279000, 0x5586c000, 0x56968000, 0x58101000, 0x588b6000, 0x5bc19000, 0x5cc10000, 0x623f6000, 0x629f4000, 0x63176000, 0x63dcc000, 0x681d0000, 0x69c0e000, 0x6a9fa000, 0x6ae5e000, 0x6d2ba000, 0x6e422000, 0x73f94000, 0x77932000, 0x78b24000, 0x794c1000, 0x795d2000, 0x7ae08000, 0x7b3ce000, 0x80000000, }, { 56, 47, 54, 62, 29, 43, 25, 59, 41, 7, 52, 63, 15, 21, 16, 14, 39, 17, 45, 11, 27, 24, 55, 31, 53, 4, 6, 2, 20, 23, 5, 37, 32, 58, 13, 51, 1, 8, 3, 57, 46, 30, 35, 49, 18, 40, 9, 22, 42, 38, 34, 0, 19, 33, 26, 60, 10, 48, 36, 61, 44, 12, 50, 28, }, 0x3e9c5e14d18c9e65 }; const pattern_t pat25 = { { 0xcb000, 0x22bf000, 0x2461000, 0x246b000, 0x5c6f000, 0x5fb4000, 0x69a9000, 0x718c000, 0x92e6000, 0xbb2e000, 0xd916000, 0xf3dc000, 0xf568000, 0x10246000, 0x12d53000, 0x14dfd000, 0x1598a000, 0x1956a000, 0x1b01b000, 0x1b3b8000, 0x1ce06000, 0x20bc5000, 0x21351000, 0x233b0000, 0x23f2b000, 0x24e41000, 0x29cca000, 0x2b5bd000, 0x2ba68000, 0x2bf7f000, 0x31a58000, 0x34570000, 0x39941000, 0x3b765000, 0x3cd13000, 0x3d251000, 0x3fa05000, 0x40745000, 0x45c68000, 0x4a282000, 0x4ad19000, 0x4b4aa000, 0x4ca18000, 0x4e0b8000, 0x4eb97000, 0x4f68b000, 0x4fca2000, 0x52466000, 0x52edf000, 0x5602a000, 0x57f60000, 0x5cc18000, 0x5cee3000, 0x5da37000, 0x5dba4000, 0x64b77000, 0x66e9f000, 0x68b9d000, 0x6aac9000, 0x6d873000, 0x6f7e6000, 0x71036000, 0x75a54000, 0x80000000, }, { 1, 58, 13, 5, 62, 10, 49, 48, 19, 24, 54, 57, 20, 39, 35, 41, 28, 42, 6, 44, 34, 45, 55, 3, 2, 60, 38, 36, 30, 25, 7, 23, 53, 50, 61, 29, 40, 47, 22, 12, 27, 0, 52, 31, 8, 15, 37, 11, 46, 32, 4, 56, 17, 33, 26, 43, 51, 16, 9, 59, 63, 21, 14, 18, }, 0x7bae8ea344ec83e }; const pattern_t pat26 = { { 0x1f4e000, 0x46f7000, 0x90a7000, 0xafe3000, 0xb2a8000, 0xb8b0000, 0xc480000, 0xc4e1000, 0xf03c000, 0xf075000, 0x14dbd000, 0x17728000, 0x1a146000, 0x1ab02000, 0x1af49000, 0x1be7a000, 0x1dc7a000, 0x1de5e000, 0x1f4f9000, 0x2092b000, 0x20a63000, 0x22937000, 0x22fe3000, 0x23e1c000, 0x28c46000, 0x294d6000, 0x2ad19000, 0x2b18b000, 0x2b233000, 0x2b685000, 0x2c792000, 0x2e6c2000, 0x2fa86000, 0x3320f000, 0x36f17000, 0x38406000, 0x38b1b000, 0x3a132000, 0x3b269000, 0x3cc43000, 0x3e2a2000, 0x3e3bb000, 0x3e83b000, 0x3ea14000, 0x4035d000, 0x4137f000, 0x4615b000, 0x50531000, 0x517c8000, 0x519e6000, 0x55ebc000, 0x594f8000, 0x5a732000, 0x5d2cb000, 0x5e409000, 0x5f394000, 0x5f3a8000, 0x60dc6000, 0x61373000, 0x6ebd6000, 0x6fd61000, 0x77161000, 0x7ce81000, 0x80000000, }, { 61, 48, 12, 55, 3, 58, 51, 56, 15, 29, 54, 11, 31, 49, 40, 37, 7, 4, 23, 35, 25, 18, 27, 43, 6, 41, 17, 45, 52, 53, 47, 16, 42, 0, 30, 13, 38, 62, 1, 8, 21, 28, 57, 9, 60, 19, 44, 50, 14, 36, 22, 2, 32, 59, 34, 10, 63, 39, 5, 24, 33, 20, 46, 26, }, 0x465275bfa2868e8b }; const pattern_t pat27 = { { 0xa6a000, 0x4c7a000, 0x5183000, 0x8dda000, 0x9cbd000, 0xb860000, 0x10c24000, 0x12dda000, 0x147ab000, 0x14aa4000, 0x16c8f000, 0x17d5b000, 0x18b5c000, 0x1a163000, 0x1b0a1000, 0x24221000, 0x25ef8000, 0x267f1000, 0x268b7000, 0x26b07000, 0x273ad000, 0x27bc2000, 0x2856c000, 0x29896000, 0x2efeb000, 0x331a7000, 0x348e8000, 0x3707f000, 0x3f444000, 0x3fe2a000, 0x433b3000, 0x435d3000, 0x46d82000, 0x4a9d3000, 0x4c6cf000, 0x4ca36000, 0x4ec42000, 0x4f79c000, 0x53cd3000, 0x58c78000, 0x5d910000, 0x616cc000, 0x62800000, 0x65ded000, 0x68831000, 0x6b321000, 0x6cd46000, 0x6d0fa000, 0x6d2f9000, 0x6e353000, 0x6fd5e000, 0x706c5000, 0x7249f000, 0x75d6c000, 0x77528000, 0x783ad000, 0x79738000, 0x79bfe000, 0x79ee9000, 0x7b74a000, 0x7bb41000, 0x7bbeb000, 0x7bbfb000, 0x80000000, }, { 61, 53, 12, 15, 26, 30, 32, 2, 16, 5, 39, 43, 20, 21, 49, 37, 11, 51, 18, 44, 31, 19, 24, 40, 1, 35, 50, 6, 57, 14, 46, 17, 22, 48, 29, 7, 34, 45, 10, 63, 23, 41, 54, 38, 4, 25, 42, 13, 56, 62, 36, 28, 33, 59, 55, 3, 9, 0, 58, 60, 47, 8, 52, 27, }, 0x5ba5aa760ec14c3e }; const pattern_t pat28 = { { 0x439a000, 0x6860000, 0xd252000, 0x1105c000, 0x113c8000, 0x1429a000, 0x14922000, 0x15f32000, 0x1992f000, 0x1a1db000, 0x1a87c000, 0x1b260000, 0x1b292000, 0x1c253000, 0x1ea33000, 0x20bbc000, 0x215ae000, 0x25249000, 0x27c89000, 0x27e36000, 0x28bf2000, 0x29c27000, 0x2a575000, 0x2c6fa000, 0x31639000, 0x3184a000, 0x319c3000, 0x348a7000, 0x38aa8000, 0x39dd5000, 0x3a067000, 0x3c0dd000, 0x3cfd4000, 0x3ebb6000, 0x43259000, 0x46494000, 0x46fcb000, 0x4a050000, 0x4b5c4000, 0x4cff3000, 0x4edaa000, 0x4f025000, 0x542e1000, 0x55364000, 0x56338000, 0x56ef8000, 0x5711b000, 0x573d1000, 0x5943b000, 0x5b912000, 0x61ce2000, 0x65211000, 0x65dca000, 0x6dee2000, 0x6df30000, 0x7334d000, 0x73e76000, 0x7473a000, 0x75846000, 0x75fd0000, 0x77174000, 0x773e9000, 0x7a8db000, 0x80000000, }, { 43, 11, 8, 56, 5, 22, 42, 55, 14, 32, 2, 47, 24, 51, 35, 25, 15, 58, 41, 27, 33, 37, 4, 36, 7, 53, 26, 48, 38, 19, 29, 28, 40, 10, 1, 46, 59, 63, 61, 62, 60, 30, 21, 39, 44, 57, 20, 18, 17, 54, 49, 52, 3, 12, 45, 13, 50, 9, 16, 23, 0, 6, 31, 34, }, 0x6236b5e97869acb }; const pattern_t pat29 = { { 0x363000, 0x9bc000, 0x1907000, 0x41d5000, 0x5a6e000, 0x9f36000, 0xa3ee000, 0x14b98000, 0x1845c000, 0x188ea000, 0x1b297000, 0x1c024000, 0x1e1eb000, 0x1f3a4000, 0x2047f000, 0x2420a000, 0x28871000, 0x296dd000, 0x2c92c000, 0x2dd42000, 0x3444f000, 0x35b90000, 0x3683c000, 0x3d8ea000, 0x3fe6b000, 0x4200e000, 0x421cf000, 0x42a46000, 0x44463000, 0x44e61000, 0x45c82000, 0x485f8000, 0x48fe8000, 0x4a532000, 0x4a6fd000, 0x4c8f9000, 0x4dbd7000, 0x5052a000, 0x512bb000, 0x5281d000, 0x5315d000, 0x5a202000, 0x5a9fc000, 0x5c11a000, 0x6010b000, 0x62aa3000, 0x63d05000, 0x6774c000, 0x6776d000, 0x68105000, 0x699d5000, 0x69bc2000, 0x6b1b9000, 0x704d5000, 0x73d5c000, 0x73d94000, 0x78483000, 0x78c8c000, 0x78cc5000, 0x7ac8d000, 0x7ae00000, 0x7b597000, 0x7e6ab000, 0x80000000, }, { 52, 40, 59, 29, 42, 34, 63, 44, 33, 37, 51, 23, 5, 36, 38, 43, 9, 4, 28, 55, 1, 6, 21, 26, 13, 24, 30, 15, 35, 17, 46, 20, 16, 10, 49, 48, 39, 62, 19, 14, 61, 27, 53, 2, 57, 58, 45, 7, 56, 50, 54, 25, 31, 11, 22, 47, 3, 0, 32, 12, 8, 41, 60, 18, }, 0xa3cfc2e527b1c191 }; const pattern_t pat30 = { { 0x45c5000, 0x6bf3000, 0xc293000, 0xe470000, 0xe5b7000, 0x1256c000, 0x1444d000, 0x15699000, 0x16e86000, 0x1a4d5000, 0x1b803000, 0x1dcf9000, 0x1dd6f000, 0x1f57f000, 0x22879000, 0x263e9000, 0x29423000, 0x2a1a9000, 0x2a699000, 0x2c8fb000, 0x2d2e0000, 0x2ec5e000, 0x317a4000, 0x35a64000, 0x36967000, 0x37299000, 0x37c07000, 0x3b9bb000, 0x3c054000, 0x3ccbc000, 0x3d94a000, 0x3e2e9000, 0x3e7a4000, 0x40b98000, 0x44658000, 0x44738000, 0x44fe3000, 0x451d9000, 0x4536c000, 0x46df2000, 0x48855000, 0x503ce000, 0x53104000, 0x531fc000, 0x54c1b000, 0x56086000, 0x5642b000, 0x573a4000, 0x5887f000, 0x5a871000, 0x5c970000, 0x5e566000, 0x62b8f000, 0x642ce000, 0x65ee5000, 0x66db3000, 0x6727c000, 0x6a9a2000, 0x74a8f000, 0x7c29a000, 0x7cc57000, 0x7f221000, 0x7f28f000, 0x80000000, }, { 29, 35, 8, 49, 30, 55, 27, 38, 58, 61, 0, 28, 15, 39, 5, 37, 32, 42, 46, 54, 12, 14, 1, 31, 59, 11, 47, 9, 13, 50, 2, 62, 60, 18, 20, 51, 23, 24, 53, 6, 25, 48, 41, 3, 33, 57, 44, 19, 22, 52, 4, 45, 10, 21, 56, 36, 17, 43, 7, 63, 16, 34, 26, 40, }, 0xf2ae48cdd4d05e58 }; const pattern_t pat31 = { { 0x143f000, 0x2068000, 0x328c000, 0x70a6000, 0x92a7000, 0x93dd000, 0xa3a8000, 0xbe51000, 0xbfc8000, 0xe353000, 0x1272f000, 0x143a4000, 0x16825000, 0x20bf8000, 0x20d9f000, 0x21e32000, 0x22426000, 0x2246b000, 0x22cea000, 0x25dc2000, 0x29324000, 0x29cd1000, 0x2aa44000, 0x2cd84000, 0x2dafb000, 0x2e74b000, 0x2f5b1000, 0x3a7a9000, 0x3bb38000, 0x3c11a000, 0x3c30a000, 0x3e2f1000, 0x4187b000, 0x42190000, 0x44e34000, 0x4d850000, 0x53ceb000, 0x540db000, 0x54937000, 0x5530a000, 0x5a111000, 0x5c280000, 0x5ef17000, 0x5fccf000, 0x64434000, 0x6498e000, 0x662c4000, 0x6a7e2000, 0x6b5a1000, 0x6c11f000, 0x6dd97000, 0x6ef1b000, 0x6f44e000, 0x7084f000, 0x73b53000, 0x7872c000, 0x78ed7000, 0x7935b000, 0x79bf9000, 0x7a6af000, 0x7b6fd000, 0x7bd42000, 0x7f233000, 0x80000000, }, { 6, 25, 28, 44, 27, 43, 58, 33, 23, 21, 16, 48, 30, 26, 5, 20, 49, 38, 2, 45, 11, 61, 17, 0, 53, 13, 7, 52, 40, 31, 36, 4, 10, 8, 24, 22, 42, 63, 35, 60, 47, 29, 46, 19, 1, 3, 34, 55, 59, 14, 39, 12, 32, 50, 62, 54, 56, 51, 57, 15, 41, 18, 37, 9, }, 0xc8cbea4e3899aca5 }; const pattern_t* patterns[] = {&trivial_pattern, &pat0, &pat1, &pat2, &pat3, &pat4, &pat5, &pat6, &pat7, &pat8, &pat9, &pat10, &pat11, &pat12, &pat13, &pat14, &pat15, &pat16, &pat17, &pat18, &pat19, &pat20, &pat21, &pat22, &pat23, &pat24, &pat25, &pat26, &pat27, &pat28, &pat29, &pat30, &pat31}; //static variables used by the worker threads static int outfd = 0; static sem_t chunk_sems[NUM_CHUNKS]; static phase_t phase; #if USE_MMAP static void* p_file; #endif static void usage() { (void) fprintf(stderr, "usage: txg_integrity \n"); exit(2); } /* Fills a buffer with a special marker. The marker contains information about * the file offset where this buffer is supposed to go, and whether it will * be written by a leader or a follower */ static void marker_fill(uint64_t* buf, int file_ofs, size_t len, int is_follower){ int ofs; uint32_t lead_mark = 0x4441454c; //"LEAD" in little endian uint32_t follow_mark = 0x4c4c4f46; //"FOLL" in little endian for (ofs = file_ofs; ofs < file_ofs + len; ofs += sizeof(uint64_t)){ uint64_t mark = ((is_follower ? (uint64_t)follow_mark : (uint64_t)lead_mark) << (uint64_t)32) | htonl((ofs & 0xFFFFFFFF)); int buf_idx = (ofs - file_ofs) / sizeof(uint64_t); buf[buf_idx] = mark; } } static int verify_file(int fd, const pattern_t* p_pat){ int chunk_idx; int good_data = 1; int err = 0; for(chunk_idx=0; chunk_idx < NUM_CHUNKS; chunk_idx++){ int i; uint32_t chunk_start, chunk_end; get_chunk_range(p_pat, chunk_idx, &chunk_start, &chunk_end); size_t size = chunk_end - chunk_start; uint64_t* desired_buf = malloc(size); uint64_t* actual_buf = malloc(size); if ((1 << chunk_idx) & p_pat->follower_chunks){ marker_fill(desired_buf, chunk_start, size, 1); } else{ marker_fill(desired_buf, chunk_start, size, 0); } //read the actual data from the file if( read(fd, actual_buf, size) <= 0 ){ perror("read"); exit(1); } //verify the data for(i=0; i < size / sizeof(uint64_t); i++){ int chunk_offset = sizeof(uint64_t) * i; int file_offset = chunk_start + chunk_offset; if (good_data && (actual_buf[i] != desired_buf[i])){ fprintf(stderr, "txg_integrity: miscompare at " "chunk %i, chunk offset %x, file offset %x\n", chunk_idx, chunk_offset, file_offset); fprintf(stderr, "Expected %16lx, got %16lx\n", desired_buf[i], actual_buf[i]); err = 1; good_data = 0; } else if (!good_data && (actual_buf[i] == desired_buf[i])) { fprintf(stderr, "txg_integrity: miscompare ends at " "chunk %i, chunk offset %x, file offset %x\n", chunk_idx, chunk_offset, file_offset); good_data = 1; } } free(desired_buf); free(actual_buf); } return (err); } /* Writes a special marker to every byte within the chunk */ static void write_chunk(pattern_t* p_pat, int chunk_idx, int is_follower) { uint32_t chunk_start, chunk_end; get_chunk_range(p_pat, chunk_idx, &chunk_start, &chunk_end); size_t size = chunk_end - chunk_start; uint64_t* buf = malloc(size); marker_fill(buf, chunk_start, size, is_follower); #if USE_MMAP memcpy((void*)( (char*)p_file + chunk_start ), (void*)buf, size); #else pwrite(outfd, (void*)buf, size, chunk_start); #endif free(buf); } static void my_sync(int fd){ //FreeBSD's msync(2) recommends that msync is obsolete and fsync should //be used instead, even for memory-mapped files if (fsync(fd)){ perror("fsync"); exit(1); } } static void* follower(void* data) { int perm_idx; pattern_t* p_pat = (pattern_t*)data; /* printf("Follower started\n");*/ for(perm_idx = 0; perm_idx < NUM_CHUNKS; perm_idx++) { int chunk_idx = p_pat->permutation[perm_idx]; if (perm_idx == NUM_CHUNKS / 2 && phase == follower_syncs){ /* printf("about to sync in follower\n");*/ my_sync(outfd); } if ( (1 << chunk_idx) & p_pat->follower_chunks){ /* printf("about to pend on semaphore\n");*/ #if USE_THREADS if (-1 == sem_wait(&chunk_sems[chunk_idx])){ perror("sem_wait"); exit(1); } #endif /* printf("about to write chunk in follower\n");*/ write_chunk(p_pat, chunk_idx, 1); } } return 0; } static void* leader(void* data) { int perm_idx; pattern_t* p_pat = (pattern_t*)data; /* printf("Leader started\n");*/ for(perm_idx = 0; perm_idx < NUM_CHUNKS; perm_idx++) { int chunk_idx = p_pat->permutation[perm_idx]; if (perm_idx == NUM_CHUNKS / 2 && phase == leader_syncs){ //printf("about to sync in leader\n"); my_sync(outfd); } //printf("about to write chunk in leader\n"); write_chunk(p_pat, chunk_idx, 0); //printf("about to post semaphore\n"); #if USE_THREADS if (sem_post(&chunk_sems[chunk_idx]) == -1){ perror("sem_post"); exit(1); } #endif } return 0; } int main(int argc, char** argv) { int rep; int pat; #if USE_THREADS pthread_t leader_th, follower_th; #endif if (argc != 2){ usage(); } //follower_chunks bitmap must have enough space to represent every chunk assert(NUM_CHUNKS <= 8 * sizeof(((pattern_t*) 0)->follower_chunks)); for(rep=0; rep < NUM_REPETITIONS; rep++){ printf("Starting repetition %d\n", rep); for(pat=0; pat < sizeof(patterns) / sizeof(patterns[0]); pat++){ void *pat_p = (void *)(uintptr_t)(const void *)patterns[pat]; for(phase=leader_syncs; phase < NUM_PHASES; phase++){ int sem_idx; int ofs=0; /* printf("Starting on patterns[%d]\n" , pat);*/ outfd = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, 0644); if (outfd == -1){ perror("open"); exit(1); } //set the file size if ( ftruncate(outfd, FSIZE)){ perror("ftruncate"); exit(1); } //Zero-fill the file to avoid fragmentation, as recommended by mmap(2). for(ofs=0; ofs < FSIZE; ofs+=CLUSTERSIZE){ char buffer[CLUSTERSIZE]; bzero(buffer, CLUSTERSIZE); if ( -1 == write(outfd, buffer, CLUSTERSIZE)){ perror("write"); exit(1); } } //Return the file pointer to the beginning prior to mmap if (-1 == lseek(outfd, 0, SEEK_SET)){ perror("lseek"); } #if USE_MMAP //mmap the file p_file = mmap(0, FSIZE, PROT_READ | PROT_WRITE, MAP_SHARED, outfd, 0); if (p_file == MAP_FAILED){ perror("mmap"); exit(1); } #endif #if USE_THREADS //Create the semaphores for(sem_idx=0; sem_idx < NUM_CHUNKS; sem_idx++){ if (sem_init(&chunk_sems[sem_idx], 0, 0)){ perror("sem_init"); exit(1); } } //Create the worker threads if (pthread_create(&follower_th, NULL, follower, pat_p)){ perror("pthread_create follower"); exit(1); } if (pthread_create(&leader_th, NULL, leader, pat_p)){ perror("pthread_create leader"); exit(1); } //Join the threads if (pthread_join(leader_th, NULL)){ perror("pthread_join leader"); exit(1); } /* printf("Joined leader\n");*/ if (pthread_join(follower_th, NULL)){ perror("pthread_join follower"); exit(1); } /* printf("Joined follower\n");*/ //destroy the semaphores for(sem_idx=0; sem_idx < NUM_CHUNKS; sem_idx++){ if (sem_destroy(&chunk_sems[sem_idx])){ perror("sem_destory"); exit(1); } } //printf("destroyed semaphores\n"); #else leader(pat_p); follower(pat_p); #endif #if USE_MMAP //unmap the file prior to verifying it if (msync(p_file, 0, 0)){ perror("msync"); exit(1); } //printf("finished msync\n"); if (munmap(p_file, FSIZE)){ perror("munmap"); exit(1); } //printf("finished munmap\n"); #endif //Verify the contents of the file. if (verify_file(outfd, patterns[pat])) { exit(1); } //printf("finished verify_file\n"); //close the file: if (close(outfd)){ perror("close"); exit(1); } } } } return 0; } diff --git a/tests/sys/geom/class/eli/hmac_test.c b/tests/sys/geom/class/eli/hmac_test.c index 5f4e795cd5a5..6e22c23fb41b 100644 --- a/tests/sys/geom/class/eli/hmac_test.c +++ b/tests/sys/geom/class/eli/hmac_test.c @@ -1,41 +1,40 @@ /* - * $FreeBSD$ */ #include #include #include const struct { char *salt; size_t saltlen; char *passwd; int iterations; char *hmacout; size_t hmaclen; } testdata[] = { #include "testvect.h" }; ATF_TC_WITHOUT_HEAD(hmactest); ATF_TC_BODY(hmactest, tc) { size_t i; uint8_t hmacout[64]; for (i = 0; i < nitems(testdata); i++) { pkcs5v2_genkey(hmacout, testdata[i].hmaclen, (uint8_t *)testdata[i].salt, testdata[i].saltlen, testdata[i].passwd, testdata[i].iterations); ATF_REQUIRE(bcmp(hmacout, testdata[i].hmacout, testdata[i].hmaclen) == 0); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, hmactest); return (atf_no_error()); } diff --git a/tests/sys/kern/pipe/pipe_fstat_bug_test.c b/tests/sys/kern/pipe/pipe_fstat_bug_test.c index 89060a2f0495..fec7797a55dc 100644 --- a/tests/sys/kern/pipe/pipe_fstat_bug_test.c +++ b/tests/sys/kern/pipe/pipe_fstat_bug_test.c @@ -1,156 +1,155 @@ /* Copyright (C) 2004 Michael J. Silbersack. 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. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include /* - * $FreeBSD$ * The goal of this program is to see if fstat reports the correct * data count for a pipe. Prior to revision 1.172 of sys_pipe.c, * 0 would be returned once the pipe entered direct write mode. * * Linux (2.6) always returns zero, so it's not a valuable platform * for comparison. */ int main(void) { char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; int desc[2], ipc_coord[2]; struct kevent event, ke; ssize_t error; int successes = 0; struct stat status; pid_t new_pid; int kq; error = pipe(desc); if (error == -1) err(1, "Couldn't allocate data pipe"); error = pipe(ipc_coord); if (error == -1) err(1, "Couldn't allocate IPC coordination pipe"); new_pid = fork(); assert(new_pid != -1); close(new_pid == 0 ? desc[0] : desc[1]); #define SYNC_R(i, _buf) do { \ int _error = errno; \ warnx("%d: waiting for synchronization", __LINE__); \ if (read(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "parent" : "child")); \ errno = _error; \ } while(0) #define SYNC_W(i, _buf) do { \ int _error = errno; \ warnx("%d: sending synchronization", __LINE__); \ if (write(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "child" : "parent")); \ errno = _error; \ } while(0) #define WRITE(s) do { \ ssize_t _size; \ if ((_size = write(desc[1], &buffer, s)) != s) \ warn("short write; wrote %zd, expected %d", _size, s); \ } while(0) if (new_pid == 0) { SYNC_R(0, go); WRITE(145); SYNC_W(0, go2); SYNC_R(0, go); WRITE(2048); SYNC_W(0, go2); SYNC_R(0, go); WRITE(4096); SYNC_W(0, go2); SYNC_R(0, go); WRITE(8191); SYNC_W(0, go2); SYNC_R(0, go); SYNC_W(0, go2); /* XXX: why is this required? */ WRITE(8192); SYNC_W(0, go2); close(ipc_coord[0]); close(ipc_coord[1]); _exit(0); } kq = kqueue(); if (kq == -1) _exit(1); EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL); /* Attach event to the kqueue. */ if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0) _exit(2); while (successes < 5) { SYNC_W(1, go); SYNC_R(1, go2); /* Ensure data is available to read */ if (kevent(kq, NULL, 0, &event, 1, NULL) != 1) _exit(3); fstat(desc[0], &status); error = read(desc[0], &buffer2, sizeof(buffer2)); if (status.st_size != error) err(1, "FAILURE: stat size %jd read size %zd", (intmax_t)status.st_size, error); if (error > 0) { printf("SUCCESS at stat size %jd read size %zd\n", (intmax_t)status.st_size, error); successes++; } } exit(0); } diff --git a/tests/sys/kern/pipe/pipe_ino_test.c b/tests/sys/kern/pipe/pipe_ino_test.c index c31e4d5cfa53..08efbc37b189 100644 --- a/tests/sys/kern/pipe/pipe_ino_test.c +++ b/tests/sys/kern/pipe/pipe_ino_test.c @@ -1,67 +1,66 @@ /*- * Copyright (c) 2011 Giovanni Trematerra * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* - * $FreeBSD$ * Test conformance to stat(2) SUSv4 description: * "For all other file types defined in this volume of POSIX.1-2008, the * structure members st_mode, st_ino, st_dev, st_uid, st_gid, st_atim, * st_ctim, and st_mtim shall have meaningful values ...". * Check that st_dev and st_ino are meaningful. */ #include #include #include #include #include int main(void) { int pipefd[2]; struct stat st1, st2; if (pipe(pipefd) == -1) err(1, "FAIL: pipe"); if (fstat(pipefd[0], &st1) == -1) err(1, "FAIL: fstat st1"); if (fstat(pipefd[1], &st2) == -1) err(1, "FAIL: fstat st2"); if (st1.st_dev != st2.st_dev || st1.st_dev == 0 || st2.st_dev == 0) errx(1, "FAIL: wrong dev number %ju %ju", (uintmax_t)st1.st_dev, (uintmax_t)st2.st_dev); if (st1.st_ino == st2.st_ino) errx(1, "FAIL: inode numbers are equal: %ju", (uintmax_t)st1.st_ino); close(pipefd[0]); close(pipefd[1]); printf("PASS\n"); return (0); } diff --git a/tests/sys/kern/pipe/pipe_overcommit1_test.c b/tests/sys/kern/pipe/pipe_overcommit1_test.c index 4e40be7c699e..eac414bfdd2f 100644 --- a/tests/sys/kern/pipe/pipe_overcommit1_test.c +++ b/tests/sys/kern/pipe/pipe_overcommit1_test.c @@ -1,51 +1,50 @@ /*- * Copyright (C) 2005 Michael J. Silbersack * 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(s), this list of conditions and the following disclaimer as * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. */ #include #include #include #include /* - * $FreeBSD$ * This program just allocates as many pipes as it can to ensure * that using up all pipe memory doesn't cause a panic. */ int main(void) { int pipes[10000]; unsigned int i; for (i = 0; i < nitems(pipes); i++) (void)pipe(&pipes[i]); printf("PASS\n"); exit(0); } diff --git a/tests/sys/kern/pipe/pipe_overcommit2_test.c b/tests/sys/kern/pipe/pipe_overcommit2_test.c index ee1e714d0d8a..d88d32c32575 100644 --- a/tests/sys/kern/pipe/pipe_overcommit2_test.c +++ b/tests/sys/kern/pipe/pipe_overcommit2_test.c @@ -1,83 +1,82 @@ /*- * Copyright (C) 2005 Michael J. Silbersack * 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(s), this list of conditions and the following disclaimer as * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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. */ #include #include #include #include #include #include #include /* - * $FreeBSD$ * This program tests how sys_pipe.c handles the case where there * is ample memory to allocate a pipe, but the file descriptor * limit for that user has been exceeded. */ int main(void) { char template[] = "pipe.XXXXXXXXXX"; int lastfd, pipes[10000], returnval; unsigned int i; lastfd = -1; if (mkstemp(template) == -1) err(1, "mkstemp failed"); for (i = 0; i < nitems(pipes); i++) { returnval = open(template, O_RDONLY); if (returnval == -1 && (errno == ENFILE || errno == EMFILE)) break; /* All descriptors exhausted. */ else lastfd = returnval; } /* First falloc failure case in sys_pipe.c:pipe() */ for (i = 0; i < 1000; i++) { returnval = pipe(&pipes[i]); } /* * Free just one FD so that the second falloc failure * case will occur. */ close(lastfd); for (i = 0; i < 1000; i++) { returnval = pipe(&pipes[i]); } printf("PASS\n"); unlink(template); exit(0); } diff --git a/tests/sys/kern/pipe/pipe_reverse_test.c b/tests/sys/kern/pipe/pipe_reverse_test.c index fd4518d76fbb..0ca481558765 100644 --- a/tests/sys/kern/pipe/pipe_reverse_test.c +++ b/tests/sys/kern/pipe/pipe_reverse_test.c @@ -1,149 +1,148 @@ /* Copyright (C) 2004 Michael J. Silbersack. 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. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include /* - * $FreeBSD$ * This program simply tests writing through the reverse direction of * a pipe. Nothing too fancy, it's only needed because most pipe-using * programs never touch the reverse direction (it doesn't exist on * Linux.) */ int main(void) { char buffer[65535], buffer2[65535], go[] = "go", go2[] = "go2"; int desc[2], ipc_coord[2]; size_t i; ssize_t total; int buggy, error; pid_t new_pid; buggy = 0; total = 0; error = pipe(desc); if (error == -1) err(1, "Couldn't allocate data pipe"); error = pipe(ipc_coord); if (error == -1) err(1, "Couldn't allocate IPC coordination pipe"); buffer[0] = 'A'; for (i = 1; i < (int)sizeof(buffer); i++) { buffer[i] = buffer[i - 1] + 1; if (buffer[i] > 'Z') buffer[i] = 'A'; } new_pid = fork(); assert(new_pid != -1); #define SYNC_R(i, _buf) do { \ int _error = errno; \ warnx("%d: waiting for synchronization", __LINE__); \ if (read(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "parent" : "child")); \ errno = _error; \ } while(0) #define SYNC_W(i, _buf) do { \ int _error = errno; \ warnx("%d: sending synchronization", __LINE__); \ if (write(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "child" : "parent")); \ errno = _error; \ } while(0) #define WRITE(s) do { \ ssize_t _size; \ if ((_size = write(desc[1], &buffer[total], s)) != s) \ warn("short write; wrote %zd, expected %d", _size, s); \ total += _size; \ } while(0) if (new_pid == 0) { SYNC_R(0, go); for (i = 0; i < 8; i++) WRITE(4096); SYNC_W(0, go2); SYNC_R(0, go); for (i = 0; i < 2; i++) WRITE(4096); SYNC_W(0, go2); _exit(0); } SYNC_W(1, go); SYNC_R(1, go2); error = read(desc[0], &buffer2, 8 * 4096); total += error; printf("Read %d bytes\n", error); SYNC_W(1, go); SYNC_R(1, go2); error = read(desc[0], &buffer2[total], 2 * 4096); total += error; printf("Read %d bytes, done\n", error); if (memcmp(buffer, buffer2, total) != 0) { for (i = 0; i < (size_t)total; i++) { if (buffer[i] != buffer2[i]) { buggy = 1; printf("Location %zu input: %hhx " "output: %hhx\n", i, buffer[i], buffer2[i]); } } } waitpid(new_pid, NULL, 0); if ((buggy == 1) || (total != 10 * 4096)) errx(1, "FAILED"); else printf("SUCCESS\n"); exit(0); } diff --git a/tests/sys/kern/pipe/pipe_wraparound_test.c b/tests/sys/kern/pipe/pipe_wraparound_test.c index 1ee02035aa70..178f0fd2d0eb 100644 --- a/tests/sys/kern/pipe/pipe_wraparound_test.c +++ b/tests/sys/kern/pipe/pipe_wraparound_test.c @@ -1,140 +1,139 @@ /* Copyright (C) 2004 Michael J. Silbersack. 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. THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include /* - * $FreeBSD$ * This program tests to make sure that wraparound writes and reads * are working, assuming that 16K socket buffers are used. In order * to really stress the pipe code with this test, kernel modifications * nay be necessary. */ int main (void) { char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2"; int desc[2], ipc_coord[2]; ssize_t error, total; int buggy, i; pid_t new_pid; buggy = 0; total = 0; error = pipe(desc); if (error == -1) err(1, "Couldn't allocate data pipe"); error = pipe(ipc_coord); if (error == -1) err(1, "Couldn't allocate IPC coordination pipe"); buffer[0] = 'A'; for (i = 1; i < (int)sizeof(buffer); i++) { buffer[i] = buffer[i - 1] + 1; if (buffer[i] > 'Z') buffer[i] = 'A'; } new_pid = fork(); assert(new_pid != -1); #define SYNC_R(i, _buf) do { \ int _error = errno; \ warnx("%d: waiting for synchronization", __LINE__); \ if (read(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "parent" : "child")); \ errno = _error; \ } while(0) #define SYNC_W(i, _buf) do { \ int _error = errno; \ warnx("%d: sending synchronization", __LINE__); \ if (write(ipc_coord[i], &_buf, sizeof(_buf)) != sizeof(_buf)) \ err(1, "failed to synchronize (%s)", (i == 0 ? "child" : "parent")); \ errno = _error; \ } while(0) #define WRITE(s) do { \ ssize_t _size; \ if ((_size = write(desc[1], &buffer[total], s)) != s) \ warn("short write; wrote %zd, expected %d", _size, s); \ total += _size; \ } while(0) if (new_pid == 0) { WRITE(4096); WRITE(4096); WRITE(4000); SYNC_W(0, go2); SYNC_R(0, go); WRITE(3000); WRITE(3000); SYNC_W(0, go2); _exit(0); } SYNC_R(1, go2); error = read(desc[0], &buffer2, 8192); total += error; printf("Read %zd bytes\n", error); SYNC_W(1, go); SYNC_R(1, go2); error = read(desc[0], &buffer2[total], 16384); total += error; printf("Read %zd bytes, done\n", error); if (memcmp(buffer, buffer2, total) != 0) { for (i = 0; i < total; i++) { if (buffer[i] != buffer2[i]) { buggy = 1; printf("Location %d input: %hhx output: %hhx\n", i, buffer[i], buffer2[i]); } } } waitpid(new_pid, NULL, 0); if (buggy) errx(1, "FAILURE"); printf("SUCCESS\n"); exit(0); } diff --git a/tools/build/dummy.c b/tools/build/dummy.c index b656a0305a97..8aff747b3f7e 100644 --- a/tools/build/dummy.c +++ b/tools/build/dummy.c @@ -1,5 +1,4 @@ /* - * $FreeBSD$ * * Empty file to keep linker happy. */ diff --git a/tools/regression/p1003_1b/prutil.c b/tools/regression/p1003_1b/prutil.c index 2910b7fdd2c3..be8c6588e1a9 100644 --- a/tools/regression/p1003_1b/prutil.c +++ b/tools/regression/p1003_1b/prutil.c @@ -1,62 +1,61 @@ #include #include #include #include #include #include #include #include "prutil.h" /* - * $FreeBSD$ */ void quit(const char *text) { err(errno, "%s", text); } char *sched_text(int scheduler) { switch(scheduler) { case SCHED_FIFO: return "SCHED_FIFO"; case SCHED_RR: return "SCHED_RR"; case SCHED_OTHER: return "SCHED_OTHER"; default: return "Illegal scheduler value"; } } int sched_is(int line, struct sched_param *p, int shouldbe) { int scheduler; struct sched_param param; /* What scheduler are we running now? */ errno = 0; scheduler = sched_getscheduler(0); if (sched_getparam(0, ¶m)) quit("sched_getparam"); if (p) *p = param; if (shouldbe != -1 && scheduler != shouldbe) { fprintf(stderr, "At line %d the scheduler should be %s yet it is %s.\n", line, sched_text(shouldbe), sched_text(scheduler)); exit(-1); } return scheduler; } diff --git a/tools/regression/p1003_1b/prutil.h b/tools/regression/p1003_1b/prutil.h index 3387b994b151..5eaaa784920a 100644 --- a/tools/regression/p1003_1b/prutil.h +++ b/tools/regression/p1003_1b/prutil.h @@ -1,14 +1,13 @@ #ifndef _PRUTIL_H_ #define _PRUTIL_H_ /* - * $FreeBSD$ */ struct sched_param; void quit(const char *); char *sched_text(int); int sched_is(int line, struct sched_param *, int); #endif /* _PRUTIL_H_ */ diff --git a/tools/regression/p1003_1b/sched.c b/tools/regression/p1003_1b/sched.c index ea6fcc7a461f..b9340db89235 100644 --- a/tools/regression/p1003_1b/sched.c +++ b/tools/regression/p1003_1b/sched.c @@ -1,294 +1,293 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1996-1999 * HD Associates, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by HD Associates, Inc * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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. - * $FreeBSD$ * */ /* XXX: The spec says that if _POSIX_C_SOURCE is defined then * _POSIX_SOURCE is ignored. However, this is similar to * the code in the O'Reilly "POSIX.4" book */ #define _POSIX_VERSION 199309L #define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L #include #include #include #include #include #include #define __XSI_VISIBLE 1 #include #undef __XSI_VISIBLE #include #include #include "prutil.h" static FILE *verbose; static void checkpris(int sched) { int smin; int smax; errno = 0; if ( (smin = sched_get_priority_min(sched)) == -1 && errno) quit("sched_get_priority_min"); if ( (smax = sched_get_priority_max(sched)) == -1 && errno) quit("sched_get_priority_max"); if (smax - smin + 1 < 32 || smax < smin) { fprintf(stderr, "Illegal priority range for %s: %d to %d\n", sched_text(sched), smin, smax); exit(-1); } if (verbose) fprintf(verbose, "%12s: sched_min %2d sched_max %2d\n", sched_text(sched), smin, smax); } /* Set "try_anyway" to quit if you don't want to go on when * it doesn't look like something should work. */ static void try_anyway(const char *s) { fputs(s, stderr); fprintf(stderr, "(trying anyway)\n"); errno = 0; } static void q(int line, int code, const char *text) { if (code == -1) { fprintf(stderr, "Error at line %d:\n", line); perror(text); exit(errno); } } int sched(int ac, char *av[]) { int fifo_schedmin, fifo_schedmax; int i; struct sched_param rt_param; int n_instances = 10; int sched; verbose = 0; #if _POSIX_VERSION < 199309 try_anyway("The _POSIX_VERSION predates P1003.1B\n"); #endif #if !defined(_POSIX_PRIORITY_SCHEDULING) try_anyway( "The environment does not claim to support Posix scheduling.\n"); #endif /* Is priority scheduling configured? */ errno = 0; if (sysconf(_SC_PRIORITY_SCHEDULING) == -1) { if (errno != 0) { /* This isn't valid - may be a standard violation */ quit("(should not happen) sysconf(_SC_PRIORITY_SCHEDULING)"); } else { try_anyway( "The environment does not have run-time " "support for Posix scheduling.\n"); } } /* Check that the priorities seem reasonable. */ checkpris(SCHED_FIFO); checkpris(SCHED_RR); checkpris(SCHED_OTHER); /* BSD extensions? */ #if defined(SCHED_IDLE) checkpris(SCHED_IDLE); #endif fifo_schedmin = sched_get_priority_min(SCHED_FIFO); fifo_schedmax = sched_get_priority_max(SCHED_FIFO); /* Make sure we can do some basic schedule switching: */ { struct sched_param orig_param, shouldbe; int orig_scheduler = sched_is(__LINE__, &orig_param, -1); if (verbose) fprintf(verbose, "The original scheduler is %s and the priority is %d.\n", sched_text(orig_scheduler), orig_param.sched_priority); /* Basic check: Try to set current settings: */ q(__LINE__, sched_setscheduler(0, orig_scheduler, &orig_param), "sched_setscheduler: Can't set original scheduler"); rt_param.sched_priority = fifo_schedmin; q(__LINE__, sched_setscheduler(0, SCHED_FIFO, &rt_param), "sched_setscheduler SCHED_FIFO"); (void)sched_is(__LINE__, 0, SCHED_FIFO); q(__LINE__, sched_getparam(0, &shouldbe), "sched_getparam"); if (shouldbe.sched_priority != fifo_schedmin) quit("sched_setscheduler wrong priority (min)"); rt_param.sched_priority = fifo_schedmin; q(__LINE__, sched_setparam(0, &rt_param), "sched_setparam to fifo_schedmin"); rt_param.sched_priority = fifo_schedmin + 1; q(__LINE__, sched_setparam(0, &rt_param), "sched_setparam to fifo_schedmin + 1"); q(__LINE__, sched_getparam(0, &shouldbe), "sched_getparam"); if (shouldbe.sched_priority != fifo_schedmin + 1) quit("sched_setscheduler wrong priority (min + 1)"); q(__LINE__, sched_setscheduler(0, SCHED_RR, &rt_param), "sched_setscheduler SCHED_RR"); (void)sched_is(__LINE__, 0, SCHED_RR); q(__LINE__, sched_setscheduler(0, orig_scheduler, &orig_param), "sched_setscheduler restoring original scheduler"); (void)sched_is(__LINE__, 0, orig_scheduler); } { char nam[] = "P1003_1b_schedXXXXXX"; int fd; pid_t p; pid_t *lastrun; fd = mkstemp(nam); if (fd == -1) q(__LINE__, errno, "mkstemp failed"); (void)unlink(nam); p = (pid_t)0; write(fd, &p, sizeof(p)); q(__LINE__, (int)(lastrun = mmap(0, sizeof(*lastrun), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)), "mmap"); /* Set our priority at the highest: */ sched = SCHED_FIFO; rt_param.sched_priority = fifo_schedmax; q(__LINE__, sched_setscheduler(0, sched, &rt_param), "sched_setscheduler sched"); for (i = 0; i < n_instances; i++) { pid_t me; /* XXX This is completely bogus. The children never run. */ if ((me = fork()) != 0) { /* Parent. */ (void)sched_is(__LINE__, 0, sched); /* Lower our priority: */ rt_param.sched_priority--; q(__LINE__, sched_setscheduler(0, sched, &rt_param), "sched_setscheduler sched"); while (1) { q(__LINE__, sched_getparam(0, &rt_param), "sched_getparam"); rt_param.sched_priority--; if (rt_param.sched_priority < fifo_schedmin) exit(0); *lastrun = me; q(__LINE__, sched_setparam(0, &rt_param), "sched_setparam"); if (*lastrun == me) { /* The child will run twice * at the end: */ if (!me || rt_param.sched_priority != 0) { fprintf(stderr, "ran process %ld twice at priority %d\n", (long)me, rt_param.sched_priority + 1); exit(-1); } } } } } } return 0; } #ifdef STANDALONE_TESTS int main(int argc, char *argv[]) { return sched(argc, argv); } #endif diff --git a/tools/regression/p1003_1b/yield.c b/tools/regression/p1003_1b/yield.c index 479ce50ef886..f25e71b48b31 100644 --- a/tools/regression/p1003_1b/yield.c +++ b/tools/regression/p1003_1b/yield.c @@ -1,199 +1,198 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1996-1999 * HD Associates, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by HD Associates, Inc * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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. - * $FreeBSD$ * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "prutil.h" /* buzz: busy wait a random amount of time. */ static void buzz(int n) { volatile int i; int m = random() & 0x0ffff; for (i = 0; i < m; i++) ; } /* Yield: Verify that "sched_yield" works for the FIFO case. * This runs several processes and verifies that the yield seems * to permit the next one on the ready queue to run. */ int yield(int argc, char *argv[]) { volatile int *p; int i; int nslaves, n; int master, slave; pid_t youngest = !0; /* Our youngest child */ struct sched_param set, got; int nloops = 1000; errno = 0; set.sched_priority = sched_get_priority_max(SCHED_FIFO); if (set.sched_priority == -1 && errno) { perror("sched_get_priority_max"); exit(errno); } if (argc == 1) n = nslaves = 10; else if (argc != 2) { fprintf(stderr, "usage: prog [n_instances]\n"); exit(-1); } else n = nslaves = atoi(argv[1]); p = (int *)mmap(0, sizeof(int), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); if (p == (int *)-1) err(errno, "mmap"); *p = 0; if (sched_setscheduler(0, SCHED_FIFO, &set) == -1) err(errno, "sched_setscheduler"); /* I better still be SCHED_FIFO and RT_PRIO_MAX: */ (void)sched_is(__LINE__, &got, SCHED_FIFO); if (got.sched_priority != set.sched_priority) { fprintf(stderr, "line %d: scheduler screwup\n", __LINE__); exit(-1); } slave = 0; master = 1; /* Fork off the slaves. */ for (i = 0; i < nslaves; i++) { if ((youngest = fork()) == 0) { /* I better still be SCHED_FIFO and RT_PRIO_MAX: */ (void)sched_is(__LINE__, &got, SCHED_FIFO); if (got.sched_priority != set.sched_priority) { fprintf(stderr, "line %d: scheduler screwup\n", __LINE__); exit(-1); } master = 0; /* I'm a slave */ slave = i + 1; /* With this flag */ *p = slave; /* And I live */ break; } } if (master) { /* If we conform the slave processes haven't run yet. * The master must yield to let the first slave run. */ if (*p != 0) { fprintf(stderr, "Error at line %d: Writer %d has run\n", __LINE__, *p); exit(-1); } } /* Now the master yields, the first slave runs, and yields, * next runs, yields, ... * * So the master should get through this first. */ if (sched_yield() == -1) err(errno, "sched_yield"); if (master) { int status; /* The final slave process should be the last one started. */ if (*p != nslaves) { fprintf(stderr, "Error at line %d: Final slave is %d not %d.\n", __LINE__, *p, nslaves); exit(-1); } /* Wait for our youngest to exit: */ waitpid(youngest, &status, 0); exit(WEXITSTATUS(status)); /* Let the slaves continue */ } /* Now the first one has started up. */ for (i = 0; i < nloops; i++) { if (((*p) % nslaves) != ((slave + nslaves - 1) % nslaves)) { fprintf(stderr, "%d ran before %d on iteration %d.\n", *p, slave, i); exit(-1); } *p = slave; /* Delay some random amount of time. */ buzz(slave); if (sched_yield() == -1) err(errno, "sched_yield"); } exit(0); } #ifdef STANDALONE_TESTS int main(int argc, char *argv[]) { return yield(argc, argv); } #endif diff --git a/tools/regression/pthread/unwind/cond_wait_cancel2.cpp b/tools/regression/pthread/unwind/cond_wait_cancel2.cpp index ba71289fad98..1763e115435b 100644 --- a/tools/regression/pthread/unwind/cond_wait_cancel2.cpp +++ b/tools/regression/pthread/unwind/cond_wait_cancel2.cpp @@ -1,56 +1,55 @@ /* - * $FreeBSD$ * * Test stack unwinding for mixed pthread_cleanup_push/pop and C++ * object, both should work together. * */ #include #include #include #include #include "Test.cpp" static pthread_mutex_t mtx; static pthread_cond_t cv; static void f() { Test t; pthread_mutex_lock(&mtx); pthread_cond_wait(&cv, &mtx); pthread_mutex_unlock(&mtx); printf("Bug, thread shouldn't be here.\n"); } static void g() { f(); } static void * thr(void *arg __unused) { pthread_cleanup_push(cleanup_handler, NULL); g(); pthread_cleanup_pop(0); return (0); } int main() { pthread_t td; pthread_mutex_init(&mtx, NULL); pthread_cond_init(&cv, NULL); pthread_create(&td, NULL, thr, NULL); sleep(1); pthread_cancel(td); pthread_join(td, NULL); check_destruct2(); return (0); } diff --git a/tools/regression/sysvmsg/msgtest.c b/tools/regression/sysvmsg/msgtest.c index 058a32106642..164fcf692017 100644 --- a/tools/regression/sysvmsg/msgtest.c +++ b/tools/regression/sysvmsg/msgtest.c @@ -1,344 +1,343 @@ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * NASA Ames Research Center. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. * * Obtained from: $NetBSD: msgtest.c,v 1.7 2002/07/20 08:36:25 grant Exp $ - * $FreeBSD$ */ /* * Test the SVID-compatible Message Queue facility. */ #include #include #include #include #include #include #include #include #include #include #include #include void print_msqid_ds (struct msqid_ds *, mode_t); void sigsys_handler(int); void sigchld_handler (int); void cleanup (void); void receiver (void); void usage (void); #define MESSAGE_TEXT_LEN 255 /* * Define it as test_mymsg because we already have struct mymsg and we dont * want to conflict with it. Also, regression fails when the default mymsg * struct is used, because mtext[] array is '1', so the passed string cannot * be processed. */ struct test_mymsg { long mtype; char mtext[MESSAGE_TEXT_LEN]; }; const char *m1_str = "California is overrated."; const char *m2_str = "The quick brown fox jumped over the lazy dog."; #define MTYPE_1 1 #define MTYPE_1_ACK 2 #define MTYPE_2 3 #define MTYPE_2_ACK 4 int sender_msqid = -1; pid_t child_pid; key_t msgkey; int main(int argc, char *argv[]) { struct sigaction sa; struct msqid_ds m_ds; struct test_mymsg m; sigset_t sigmask; if (argc != 2) usage(); /* * Install a SIGSYS handler so that we can exit gracefully if * System V Message Queue support isn't in the kernel. */ sa.sa_handler = sigsys_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGSYS, &sa, NULL) == -1) err(1, "sigaction SIGSYS"); /* * Install and SIGCHLD handler to deal with all possible exit * conditions of the receiver. */ sa.sa_handler = sigchld_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGCHLD, &sa, NULL) == -1) err(1, "sigaction SIGCHLD"); msgkey = ftok(argv[1], 4160); /* * Initialize child_pid to ourselves to that the cleanup function * works before we create the receiver. */ child_pid = getpid(); /* * Make sure that when the sender exits, the message queue is * removed. */ if (atexit(cleanup) == -1) err(1, "atexit"); if ((sender_msqid = msgget(msgkey, IPC_CREAT | 0640)) == -1) err(1, "msgget"); if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) err(1, "msgctl IPC_STAT"); print_msqid_ds(&m_ds, 0640); m_ds.msg_perm.mode = (m_ds.msg_perm.mode & ~0777) | 0600; if (msgctl(sender_msqid, IPC_SET, &m_ds) == -1) err(1, "msgctl IPC_SET"); bzero(&m_ds, sizeof m_ds); if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) err(1, "msgctl IPC_STAT"); if ((m_ds.msg_perm.mode & 0777) != 0600) err(1, "IPC_SET of mode didn't hold"); print_msqid_ds(&m_ds, 0600); switch ((child_pid = fork())) { case -1: err(1, "fork"); /* NOTREACHED */ case 0: receiver(); break; default: break; } /* * Send the first message to the receiver and wait for the ACK. */ m.mtype = MTYPE_1; strcpy(m.mtext, m1_str); if (msgsnd(sender_msqid, &m, strlen(m1_str) + 1, 0) == -1) err(1, "sender: msgsnd 1"); if (msgrcv(sender_msqid, &m, sizeof(m.mtext), MTYPE_1_ACK, 0) != strlen(m1_str) + 1) err(1, "sender: msgrcv 1 ack"); print_msqid_ds(&m_ds, 0600); /* * Send the second message to the receiver and wait for the ACK. */ m.mtype = MTYPE_2; strcpy(m.mtext, m2_str); if (msgsnd(sender_msqid, &m, strlen(m2_str) + 1, 0) == -1) err(1, "sender: msgsnd 2"); if (msgrcv(sender_msqid, &m, sizeof(m.mtext), MTYPE_2_ACK, 0) != strlen(m2_str) + 1) err(1, "sender: msgrcv 2 ack"); /* * Suspend forever; when we get SIGCHLD, the handler will exit. */ sigemptyset(&sigmask); (void) sigsuspend(&sigmask); /* * ...and any other signal is an unexpected error. */ errx(1, "sender: received unexpected signal"); } void sigsys_handler(int signo) { errx(1, "System V Message Queue support is not present in the kernel"); } void sigchld_handler(int signo) { struct msqid_ds m_ds; int cstatus; /* * Reap the child; if it exited successfully, then the test passed! */ if (waitpid(child_pid, &cstatus, 0) != child_pid) err(1, "waitpid"); if (WIFEXITED(cstatus) == 0) errx(1, "receiver exited abnormally"); if (WEXITSTATUS(cstatus) != 0) errx(1, "receiver exited with status %d", WEXITSTATUS(cstatus)); /* * If we get here, the child has exited normally, and thus * we should exit normally too. First, tho, we print out * the final stats for the message queue. */ if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) err(1, "msgctl IPC_STAT"); print_msqid_ds(&m_ds, 0600); exit(0); } void cleanup() { /* * If we're the sender, and it exists, remove the message queue. */ if (child_pid != 0 && sender_msqid != -1) { if (msgctl(sender_msqid, IPC_RMID, NULL) == -1) warn("msgctl IPC_RMID"); } } void print_msqid_ds(struct msqid_ds *mp, mode_t mode) { uid_t uid = geteuid(); gid_t gid = getegid(); printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", mp->msg_perm.uid, mp->msg_perm.gid, mp->msg_perm.cuid, mp->msg_perm.cgid, mp->msg_perm.mode & 0777); printf("qnum %lu, qbytes %lu, lspid %d, lrpid %d\n", mp->msg_qnum, (u_long)mp->msg_qbytes, mp->msg_lspid, mp->msg_lrpid); printf("stime: %s", ctime(&mp->msg_stime)); printf("rtime: %s", ctime(&mp->msg_rtime)); printf("ctime: %s", ctime(&mp->msg_ctime)); /* * Sanity check a few things. */ if (mp->msg_perm.uid != uid || mp->msg_perm.cuid != uid) errx(1, "uid mismatch"); if (mp->msg_perm.gid != gid || mp->msg_perm.cgid != gid) errx(1, "gid mismatch"); if ((mp->msg_perm.mode & 0777) != mode) errx(1, "mode mismatch"); } void usage() { fprintf(stderr, "usage: %s keypath\n", getprogname()); exit(1); } void receiver() { struct test_mymsg m; int msqid; if ((msqid = msgget(msgkey, 0)) == -1) err(1, "receiver: msgget"); /* * Receive the first message, print it, and send an ACK. */ if (msgrcv(msqid, &m, sizeof(m.mtext), MTYPE_1, 0) != strlen(m1_str) + 1) err(1, "receiver: msgrcv 1"); printf("%s\n", m.mtext); if (strcmp(m.mtext, m1_str) != 0) err(1, "receiver: message 1 data isn't correct"); m.mtype = MTYPE_1_ACK; if (msgsnd(msqid, &m, strlen(m1_str) + 1, 0) == -1) err(1, "receiver: msgsnd ack 1"); /* * Receive the second message, print it, and send an ACK. */ if (msgrcv(msqid, &m, sizeof(m.mtext), MTYPE_2, 0) != strlen(m2_str) + 1) err(1, "receiver: msgrcv 2"); printf("%s\n", m.mtext); if (strcmp(m.mtext, m2_str) != 0) err(1, "receiver: message 2 data isn't correct"); m.mtype = MTYPE_2_ACK; if (msgsnd(msqid, &m, strlen(m2_str) + 1, 0) == -1) err(1, "receiver: msgsnd ack 2"); exit(0); } diff --git a/tools/regression/sysvsem/semtest.c b/tools/regression/sysvsem/semtest.c index 39c416403c63..f4ab8e876ec4 100644 --- a/tools/regression/sysvsem/semtest.c +++ b/tools/regression/sysvsem/semtest.c @@ -1,350 +1,349 @@ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * NASA Ames Research Center. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. * * Obtained from: $NetBSD: semtest.c,v 1.4 2002/07/20 08:36:25 grant Exp $ - * $FreeBSD$ */ /* * Test the SVID-compatible Semaphore facility. */ #include #include #include #include #include #include #include #include #include #include #include #include int main (int, char *[]); void print_semid_ds (struct semid_ds *, mode_t); void sigsys_handler (int); void sigchld_handler(int); void cleanup (void); void waiter (void); void usage (void); int sender_semid = -1; pid_t child_pid; int child_count; int signal_was_sigchld; key_t semkey; /* * This is the original semun union used by the sysvsem utility. * It is deliberately kept here under #if 0'ed condition for future * reference. PLEASE DO NOT REMOVE. The {SET,GET}ALL in FreeBSD * are signed values, so the default version in sys/sem.h suffices. */ #if 0 union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_{STAT,SET} */ u_short *array; /* array for GETALL & SETALL */ }; #endif int main(int argc, char *argv[]) { struct sigaction sa; union semun sun; struct semid_ds s_ds; sigset_t sigmask; int i; if (argc != 2) usage(); /* * Install a SIGSYS handler so that we can exit gracefully if * System V Semaphore support isn't in the kernel. */ sa.sa_handler = sigsys_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGSYS, &sa, NULL) == -1) err(1, "sigaction SIGSYS"); /* * Install and SIGCHLD handler to deal with all possible exit * conditions of the receiver. */ sa.sa_handler = sigchld_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGCHLD, &sa, NULL) == -1) err(1, "sigaction SIGCHLD"); semkey = ftok(argv[1], 4160); /* * Initialize child_pid to ourselves to that the cleanup function * works before we create the receiver. */ child_pid = getpid(); /* * Make sure that when the sender exits, the message queue is * removed. */ if (atexit(cleanup) == -1) err(1, "atexit"); if ((sender_semid = semget(semkey, 1, IPC_CREAT | 0640)) == -1) err(1, "semget"); sun.buf = &s_ds; if (semctl(sender_semid, 0, IPC_STAT, sun) == -1) err(1, "semctl IPC_STAT"); print_semid_ds(&s_ds, 0640); s_ds.sem_perm.mode = (s_ds.sem_perm.mode & ~0777) | 0600; sun.buf = &s_ds; if (semctl(sender_semid, 0, IPC_SET, sun) == -1) err(1, "semctl IPC_SET"); memset(&s_ds, 0, sizeof(s_ds)); sun.buf = &s_ds; if (semctl(sender_semid, 0, IPC_STAT, sun) == -1) err(1, "semctl IPC_STAT"); if ((s_ds.sem_perm.mode & 0777) != 0600) err(1, "IPC_SET of mode didn't hold"); print_semid_ds(&s_ds, 0600); errno = 0; if (semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600) != -1 || errno != EEXIST) err(1, "semget IPC_EXCL 1 did not fail with [EEXIST]"); errno = 0; if (semget(semkey, 2, IPC_CREAT | IPC_EXCL | 0600) != -1 || errno != EEXIST) err(1, "semget IPC_EXCL 2 did not fail with [EEXIST]"); for (child_count = 0; child_count < 5; child_count++) { switch ((child_pid = fork())) { case -1: err(1, "fork"); /* NOTREACHED */ case 0: waiter(); break; default: break; } } /* * Wait for all of the waiters to be attempting to acquire the * semaphore. */ for (;;) { i = semctl(sender_semid, 0, GETNCNT); if (i == -1) err(1, "semctl GETNCNT"); if (i == 5) break; } /* * Now set the thundering herd in motion by initializing the * semaphore to the value 1. */ sun.val = 1; if (semctl(sender_semid, 0, SETVAL, sun) == -1) err(1, "sender: semctl SETVAL to 1"); /* * Suspend forever; when we get SIGCHLD, the handler will exit. */ sigemptyset(&sigmask); for (;;) { (void) sigsuspend(&sigmask); if (signal_was_sigchld) signal_was_sigchld = 0; else break; } /* * ...and any other signal is an unexpected error. */ errx(1, "sender: received unexpected signal"); } void sigsys_handler(int signo) { errx(1, "System V Semaphore support is not present in the kernel"); } void sigchld_handler(int signo) { union semun sun; struct semid_ds s_ds; int cstatus; /* * Reap the child; if it exited successfully, then we're on the * right track! */ if (wait(&cstatus) == -1) err(1, "wait"); if (WIFEXITED(cstatus) == 0) errx(1, "receiver exited abnormally"); if (WEXITSTATUS(cstatus) != 0) errx(1, "receiver exited with status %d", WEXITSTATUS(cstatus)); /* * If we get here, the child has exited normally, and we should * decrement the child count. If the child_count reaches 0, we * should exit. */ sun.buf = &s_ds; if (semctl(sender_semid, 0, IPC_STAT, sun) == -1) err(1, "semctl IPC_STAT"); print_semid_ds(&s_ds, 0600); if (--child_count != 0) { signal_was_sigchld = 1; return; } exit(0); } void cleanup() { /* * If we're the sender, and it exists, remove the message queue. */ if (child_pid != 0 && sender_semid != -1) { if (semctl(sender_semid, 0, IPC_RMID) == -1) warn("semctl IPC_RMID"); } } void print_semid_ds(struct semid_ds *sp, mode_t mode) { uid_t uid = geteuid(); gid_t gid = getegid(); printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", sp->sem_perm.uid, sp->sem_perm.gid, sp->sem_perm.cuid, sp->sem_perm.cgid, sp->sem_perm.mode & 0777); printf("nsems %u\n", sp->sem_nsems); printf("otime: %s", ctime(&sp->sem_otime)); printf("ctime: %s", ctime(&sp->sem_ctime)); /* * Sanity check a few things. */ if (sp->sem_perm.uid != uid || sp->sem_perm.cuid != uid) errx(1, "uid mismatch"); if (sp->sem_perm.gid != gid || sp->sem_perm.cgid != gid) errx(1, "gid mismatch"); if ((sp->sem_perm.mode & 0777) != mode) errx(1, "mode mismatch %o != %o", (sp->sem_perm.mode & 0777), mode); } void usage() { fprintf(stderr, "usage: %s keypath\n", getprogname()); exit(1); } void waiter() { struct sembuf s; int semid; if ((semid = semget(semkey, 1, 0)) == -1) err(1, "waiter: semget"); /* * Attempt to acquire the semaphore. */ s.sem_num = 0; s.sem_op = -1; s.sem_flg = SEM_UNDO; if (semop(semid, &s, 1) == -1) err(1, "waiter: semop -1"); printf("WOO! GOT THE SEMAPHORE!\n"); sleep(1); /* * Release the semaphore and exit. */ s.sem_num = 0; s.sem_op = 1; s.sem_flg = SEM_UNDO; if (semop(semid, &s, 1) == -1) err(1, "waiter: semop +1"); exit(0); } diff --git a/tools/regression/sysvshm/shmtest.c b/tools/regression/sysvshm/shmtest.c index c84ddfd7657d..edac85b21bda 100644 --- a/tools/regression/sysvshm/shmtest.c +++ b/tools/regression/sysvshm/shmtest.c @@ -1,281 +1,280 @@ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, * NASA Ames Research Center. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. * * Obtained from: $NetBSD: shmtest.c,v 1.3 2002/07/20 08:36:26 grant Exp $ - * $FreeBSD$ */ /* * Test the SVID-compatible Shared Memory facility. */ #include #include #include #include #include #include #include #include #include #include #include #include static void print_shmid_ds(struct shmid_ds *, mode_t); static void sigsys_handler(int); static void sigchld_handler(int); static void cleanup(void); static void receiver(void); static void usage(void) __dead2; static const char *m_str = "The quick brown fox jumped over the lazy dog."; static int sender_shmid = -1; static pid_t child_pid; static key_t shmkey; static size_t pgsize; int main(int argc, char *argv[]) { struct sigaction sa; struct shmid_ds s_ds; sigset_t sigmask; char *shm_buf; if (argc != 2) usage(); /* * Install a SIGSYS handler so that we can exit gracefully if * System V Shared Memory support isn't in the kernel. */ sa.sa_handler = sigsys_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGSYS, &sa, NULL) == -1) err(1, "sigaction SIGSYS"); /* * Install and SIGCHLD handler to deal with all possible exit * conditions of the receiver. */ sa.sa_handler = sigchld_handler; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGCHLD, &sa, NULL) == -1) err(1, "sigaction SIGCHLD"); pgsize = sysconf(_SC_PAGESIZE); shmkey = ftok(argv[1], 4160); /* * Initialize child_pid to ourselves to that the cleanup function * works before we create the receiver. */ child_pid = getpid(); /* * Make sure that when the sender exits, the message queue is * removed. */ if (atexit(cleanup) == -1) err(1, "atexit"); if ((sender_shmid = shmget(shmkey, pgsize, IPC_CREAT | 0640)) == -1) err(1, "shmget"); if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1) err(1, "shmctl IPC_STAT"); print_shmid_ds(&s_ds, 0640); s_ds.shm_perm.mode = (s_ds.shm_perm.mode & ~0777) | 0600; if (shmctl(sender_shmid, IPC_SET, &s_ds) == -1) err(1, "shmctl IPC_SET"); memset(&s_ds, 0, sizeof(s_ds)); if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1) err(1, "shmctl IPC_STAT"); if ((s_ds.shm_perm.mode & 0777) != 0600) err(1, "IPC_SET of mode didn't hold"); print_shmid_ds(&s_ds, 0600); if ((shm_buf = shmat(sender_shmid, NULL, 0)) == (void *) -1) err(1, "sender: shmat"); /* * Write the test pattern into the shared memory buffer. */ strcpy(shm_buf, m_str); switch ((child_pid = fork())) { case -1: err(1, "fork"); /* NOTREACHED */ case 0: receiver(); break; default: break; } /* * Suspend forever; when we get SIGCHLD, the handler will exit. */ sigemptyset(&sigmask); (void) sigsuspend(&sigmask); /* * ...and any other signal is an unexpected error. */ errx(1, "sender: received unexpected signal"); } static void sigsys_handler(int signo __unused) { errx(1, "System V Shared Memory support is not present in the kernel"); } static void sigchld_handler(int signo __unused) { struct shmid_ds s_ds; int cstatus; /* * Reap the child; if it exited successfully, then the test passed! */ if (waitpid(child_pid, &cstatus, 0) != child_pid) err(1, "waitpid"); if (WIFEXITED(cstatus) == 0) errx(1, "receiver exited abnormally"); if (WEXITSTATUS(cstatus) != 0) errx(1, "receiver exited with status %d", WEXITSTATUS(cstatus)); /* * If we get here, the child has exited normally, and thus * we should exit normally too. First, tho, we print out * the final stats for the message queue. */ if (shmctl(sender_shmid, IPC_STAT, &s_ds) == -1) err(1, "shmctl IPC_STAT"); print_shmid_ds(&s_ds, 0600); exit(0); } static void cleanup(void) { /* * If we're the sender, and it exists, remove the shared memory area. */ if (child_pid != 0 && sender_shmid != -1) { if (shmctl(sender_shmid, IPC_RMID, NULL) == -1) warn("shmctl IPC_RMID"); } } static void print_shmid_ds(struct shmid_ds *sp, mode_t mode) { uid_t uid = geteuid(); gid_t gid = getegid(); printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", sp->shm_perm.uid, sp->shm_perm.gid, sp->shm_perm.cuid, sp->shm_perm.cgid, sp->shm_perm.mode & 0777); printf("segsz %lu, lpid %d, cpid %d, nattch %u\n", (u_long)sp->shm_segsz, sp->shm_lpid, sp->shm_cpid, sp->shm_nattch); printf("atime: %s", ctime(&sp->shm_atime)); printf("dtime: %s", ctime(&sp->shm_dtime)); printf("ctime: %s", ctime(&sp->shm_ctime)); /* * Sanity check a few things. */ if (sp->shm_perm.uid != uid || sp->shm_perm.cuid != uid) errx(1, "uid mismatch"); if (sp->shm_perm.gid != gid || sp->shm_perm.cgid != gid) errx(1, "gid mismatch"); if ((sp->shm_perm.mode & 0777) != mode) errx(1, "mode mismatch"); } static void usage(void) { fprintf(stderr, "usage: %s keypath\n", getprogname()); exit(1); } static void receiver(void) { int shmid; void *shm_buf; if ((shmid = shmget(shmkey, pgsize, 0)) == -1) err(1, "receiver: shmget"); if ((shm_buf = shmat(shmid, NULL, 0)) == (void *) -1) err(1, "receiver: shmat"); printf("%s\n", (const char *)shm_buf); if (strcmp((const char *)shm_buf, m_str) != 0) err(1, "receiver: data isn't correct"); exit(0); } diff --git a/tools/test/popss/popss.c b/tools/test/popss/popss.c index 56c5f7896023..004ccb29c546 100644 --- a/tools/test/popss/popss.c +++ b/tools/test/popss/popss.c @@ -1,183 +1,182 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2018 The FreeBSD Foundation * All rights reserved. * * This software was developed by Konstantin Belousov * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: popss.c,v 1.28 2018/05/09 21:35:29 kostik Exp kostik $ - * $FreeBSD$ * * cc -m32 -Wall -Wextra -O2 -g -o popss popss.c * Use as "popss ", where instruction is one of * bound, into, int1, int3, int80, syscall, sysenter. */ #include #include #include #include #include #include #include #include #include #include static u_long *stk; #define ITERATIONS 4 static void setup(pid_t child) { struct reg r; struct dbreg dbr; int error, i, status; error = waitpid(child, &status, WTRAPPED | WEXITED); if (error == -1) err(1, "waitpid 1"); error = ptrace(PT_GETREGS, child, (caddr_t)&r, 0); if (error == -1) err(1, "ptrace PT_GETREGS"); printf("child %d stopped eip %#x esp %#x\n", child, r.r_eip, r.r_esp); error = ptrace(PT_GETDBREGS, child, (caddr_t)&dbr, 0); if (error != 0) err(1, "ptrace PT_GETDBREGS"); dbr.dr[7] &= ~DBREG_DR7_MASK(0); dbr.dr[7] |= DBREG_DR7_SET(0, DBREG_DR7_LEN_4, DBREG_DR7_RDWR, DBREG_DR7_LOCAL_ENABLE | DBREG_DR7_GLOBAL_ENABLE); dbr.dr[0] = (uintptr_t)stk; error = ptrace(PT_SETDBREGS, child, (caddr_t)&dbr, 0); if (error != 0) err(1, "ptrace PT_SETDBREGS"); error = ptrace(PT_CONTINUE, child, (caddr_t)1, 0); if (error != 0) err(1, "ptrace PT_CONTINUE fire"); for (i = 0; i < ITERATIONS; i++) { error = waitpid(child, &status, WTRAPPED | WEXITED); if (error == -1) err(1, "waitpid 2"); if (WIFEXITED(status)) break; error = ptrace(PT_GETREGS, child, (caddr_t)&r, 0); if (error == -1) err(1, "ptrace PT_GETREGS"); error = ptrace(PT_GETDBREGS, child, (caddr_t)&dbr, 0); if (error != 0) err(1, "ptrace PT_GETDBREGS"); printf("child %d stopped eip %#x esp %#x dr0 %#x " "dr6 %#x dr7 %#x\n", child, r.r_eip, r.r_esp, dbr.dr[0], dbr.dr[6], dbr.dr[7]); error = ptrace(PT_CONTINUE, child, (caddr_t)1, 0); if (error == -1) err(1, "ptrace PT_CONTINUE tail"); } if (i == ITERATIONS) { kill(child, SIGKILL); ptrace(PT_DETACH, child, NULL, 0); } } static u_long tmpstk[1024 * 128]; static u_int read_ss(void) { u_int res; __asm volatile("movl\t%%ss,%0" : "=r" (res)); return (res); } #define PROLOGUE "int3;movl\t%0,%%esp;popl\t%%ss;" static void act(const char *cmd) { int error; static const int boundx[2] = {0, 1}; printf("child pid %d, stk at %p\n", getpid(), stk); *stk = read_ss(); error = ptrace(PT_TRACE_ME, 0, NULL, 0); if (error != 0) err(1, "ptrace PT_TRACE_ME"); if (strcmp(cmd, "bound") == 0) { /* XXX BOUND args order clang ias bug */ __asm volatile("int3;movl\t$11,%%eax;" "movl\t%0,%%esp;popl\t%%ss;bound\t%1,%%eax" : : "r" (stk), "m" (boundx) : "memory"); } else if (strcmp(cmd, "int1") == 0) { __asm volatile(PROLOGUE ".byte 0xf1" : : "r" (stk) : "memory"); } else if (strcmp(cmd, "int3") == 0) { __asm volatile(PROLOGUE "int3" : : "r" (stk) : "memory"); } else if (strcmp(cmd, "into") == 0) { __asm volatile("int3;movl\t$0x80000000,%%eax;" "addl\t%%eax,%%eax;movl\t%0,%%esp;popl\t%%ss;into" : : "r" (stk) : "memory"); } else if (strcmp(cmd, "int80") == 0) { __asm volatile(PROLOGUE "int\t$0x80" : : "r" (stk) : "memory"); } else if (strcmp(cmd, "syscall") == 0) { __asm volatile(PROLOGUE "syscall" : : "r" (stk) : "memory"); } else if (strcmp(cmd, "sysenter") == 0) { __asm volatile(PROLOGUE "sysenter" : : "r" (stk) : "memory"); } else { fprintf(stderr, "unknown instruction\n"); exit(1); } printf("ho\n"); } int main(int argc, char *argv[]) { int child; if (argc != 2) { printf( "Usage: popss [bound|int1|int3|into|int80|syscall|sysenter]\n"); exit(1); } stk = &tmpstk[nitems(tmpstk) - 1]; child = fork(); if (child == -1) err(1, "fork"); if (child == 0) act(argv[1]); else setup(child); } diff --git a/tools/tools/cxgbtool/reg_defs.c b/tools/tools/cxgbtool/reg_defs.c index 687bb75cee9f..fc65a652601a 100644 --- a/tools/tools/cxgbtool/reg_defs.c +++ b/tools/tools/cxgbtool/reg_defs.c @@ -1,837 +1,836 @@ /* - * $FreeBSD$ */ /* This file is automatically generated --- do not edit */ struct reg_info sge_regs[] = { { "SG_CONTROL", 0x0, 0 }, { "CmdQ0_Enable", 0, 1 }, { "CmdQ1_Enable", 1, 1 }, { "FL0_Enable", 2, 1 }, { "FL1_Enable", 3, 1 }, { "CPL_Enable", 4, 1 }, { "Response_Queue_Enable", 5, 1 }, { "CmdQ_Priority", 6, 2 }, { "Disable_CmdQ0_GTS", 8, 1 }, { "Disable_CmdQ1_GTS", 9, 1 }, { "Disable_FL0_GTS", 10, 1 }, { "Disable_FL1_GTS", 11, 1 }, { "Enable_Big_Endian", 12, 1 }, { "FL_Selection_Criteria", 13, 1 }, { "iSCSI_Coalesce", 14, 1 }, { "RX_Pkt_Offset", 15, 3 }, { "VLAN_Xtract", 18, 1 }, { "SG_DOORBELL", 0x4, 0 }, { "CmdQ0_Enable", 0, 1 }, { "CmdQ1_Enable", 1, 1 }, { "FL0_Enable", 2, 1 }, { "FL1_Enable", 3, 1 }, { "SG_CMD0BASELWR", 0x8, 0 }, { "SG_CMD0BASEUPR", 0xc, 0 }, { "SG_CMD1BASELWR", 0x10, 0 }, { "SG_CMD1BASEUPR", 0x14, 0 }, { "SG_FL0BASELWR", 0x18, 0 }, { "SG_FL0BASEUPR", 0x1c, 0 }, { "SG_FL1BASELWR", 0x20, 0 }, { "SG_FL1BASEUPR", 0x24, 0 }, { "SG_CMD0SIZE", 0x28, 0 }, { "CmdQ0_Size", 0, 17 }, { "SG_FL0SIZE", 0x2c, 0 }, { "FL0_Size", 0, 17 }, { "SG_RSPSIZE", 0x30, 0 }, { "RespQ_Size", 0, 17 }, { "SG_RSPBASELWR", 0x34, 0 }, { "SG_RSPBASEUPR", 0x38, 0 }, { "SG_FLTHRESHOLD", 0x3c, 0 }, { "FL_Threshold", 0, 16 }, { "SG_RSPQUEUECREDIT", 0x40, 0 }, { "RespQ_Credit", 0, 17 }, { "SG_DEBUGTXDATAL", 0x44, 0 }, { "SG_SLEEPING", 0x48, 0 }, { "Sleeping", 0, 16 }, { "SG_INTRTIMER", 0x4c, 0 }, { "Interrupt_Timer_Count", 0, 24 }, { "SG_CMD0PTR", 0x50, 0 }, { "CmdQ0_Pointer", 0, 16 }, { "Current_Generation_Bit", 16, 1 }, { "SG_CMD1PTR", 0x54, 0 }, { "CmdQ1_Pointer", 0, 16 }, { "Current_Generation_Bit", 16, 1 }, { "SG_FL0PTR", 0x58, 0 }, { "FL0_Pointer", 0, 16 }, { "Current_Generation_Bit", 16, 1 }, { "SG_FL1PTR", 0x5c, 0 }, { "FL1_Pointer", 0, 16 }, { "Current_Generation_Bit", 16, 1 }, { "SG_DEBUGTXDATAH", 0x60, 0 }, { "SG_DEBUGRXDATAL", 0x64, 0 }, { "SG_DEBUGRXDATAH", 0x68, 0 }, { "SG_VERSION", 0x6c, 0 }, { "Day", 0, 5 }, { "Month", 5, 4 }, { "SG_DEBUGRXSOP", 0x70, 0 }, { "SG_DEBUGTXSOP", 0x74, 0 }, { "SG_LA_RDPTR0", 0x78, 0 }, { "Logic_Analyzer0_Read_Pointer", 0, 9 }, { "SG_LA_RDDATA0", 0x7c, 0 }, { "SG_LA_WRPTR0", 0x80, 0 }, { "SG_DEBUGRXEOP", 0x84, 0 }, { "SG_DEBUGTXEOP", 0x88, 0 }, { "SG_DEBUGRXSIZE", 0x8c, 0 }, { "SG_DEBUGTXSIZE", 0x90, 0 }, { "SG_NUMBER_LA", 0x94, 0 }, { "SG_LA_RDPTR1", 0x98, 0 }, { "Logic_Analyzer1_Read_Pointer", 0, 9 }, { "SG_LA_RDDATA1", 0x9c, 0 }, { "SG_LA_WRPTR1", 0xa0, 0 }, { "SG_LA_RDPTR2", 0xa4, 0 }, { "Logic_Analyzer2_Read_Pointer", 0, 9 }, { "SG_LA_RDDATA2", 0xa8, 0 }, { "SG_LA_WRPTR2", 0xac, 0 }, { "SG_CMD1SIZE", 0xb0, 0 }, { "CmdQ1_Size", 0, 17 }, { "SG_FL1SIZE", 0xb4, 0 }, { "FL1_Size", 0, 17 }, { "SG_INT_ENABLE", 0xb8, 0 }, { "RespQ_Exhausted", 0, 1 }, { "RespQ_Overflow", 1, 1 }, { "FL_Exhausted", 2, 1 }, { "Packet_Too_Big", 3, 1 }, { "Packet_Mismatch", 4, 1 }, { "SG_INT_CAUSE", 0xbc, 0 }, { "RespQ_Exhausted", 0, 1 }, { "RespQ_Overflow", 1, 1 }, { "FL_Exhausted", 2, 1 }, { "Packet_Too_Big", 3, 1 }, { "Packet_Mismatch", 4, 1 }, { "SG_RESPACCUTIMER", 0xc0, 0 }, { NULL, 0, 0 } }; struct reg_info mc3_regs[] = { { "MC3_CFG", 0x100, 0 }, { "Clk_Enable", 0, 1 }, { "Ready", 1, 1 }, { "Read_to_Write_Delay", 2, 3 }, { "Write_to_Read_Delay", 5, 3 }, { "MC3_Bank_Cycle", 8, 4 }, { "Refresh_Cycle", 12, 4 }, { "Precharge_Cycle", 16, 2 }, { "Active_to_Read_Write_Delay", 18, 1 }, { "Active_to_Precharge_Delay", 19, 3 }, { "Write_Recovery_Delay", 22, 2 }, { "Density", 24, 2 }, { "Organization", 26, 1 }, { "Banks", 27, 1 }, { "Unregistered", 28, 1 }, { "MC3_Width", 29, 2 }, { "MC3_Slow", 31, 1 }, { "MC3_MODE", 0x104, 0 }, { "MC3_Mode", 0, 14 }, { "Busy", 31, 1 }, { "MC3_EXT_MODE", 0x108, 0 }, { "MC3_Extended_Mode", 0, 14 }, { "Busy", 31, 1 }, { "MC3_PRECHARG", 0x10c, 0 }, { "Busy", 31, 1 }, { "MC3_REFRESH", 0x110, 0 }, { "Refresh_Enable", 0, 1 }, { "Refresh_Divisor", 1, 14 }, { "Busy", 31, 1 }, { "MC3_STROBE", 0x114, 0 }, { "Master_DLL_Reset", 0, 1 }, { "Master_DLL_Tap_Count", 1, 8 }, { "Master_DLL_Locked", 9, 1 }, { "Master_DLL_Max_Tap_Count", 10, 1 }, { "Master_DLL_Tap_Count_Offset", 11, 6 }, { "Slave_DLL_Reset", 11, 1 }, { "Slave_DLL_Delta", 12, 4 }, { "Slave_Delay_Line_Manual_Tap_Count", 17, 6 }, { "Slave_Delay_Line_Manual_Tap_Count_Enable", 23, 1 }, { "Slave_Delay_Line_Tap_Count", 24, 6 }, { "MC3_ECC_CNTL", 0x118, 0 }, { "ECC_Generation_Enable", 0, 1 }, { "ECC_Check_Enable", 1, 1 }, { "Correctable_Error_Count", 2, 8 }, { "Uncorrectable_Error_Count", 10, 8 }, { "MC3_CE_ADDR", 0x11c, 0 }, { "MC3_CE_Addr", 4, 28 }, { "MC3_CE_DATA0", 0x120, 0 }, { "MC3_CE_DATA1", 0x124, 0 }, { "MC3_CE_DATA2", 0x128, 0 }, { "MC3_CE_DATA3", 0x12c, 0 }, { "MC3_CE_DATA4", 0x130, 0 }, { "MC3_UE_ADDR", 0x134, 0 }, { "MC3_UE_Addr", 4, 28 }, { "MC3_UE_DATA0", 0x138, 0 }, { "MC3_UE_DATA1", 0x13c, 0 }, { "MC3_UE_DATA2", 0x140, 0 }, { "MC3_UE_DATA3", 0x144, 0 }, { "MC3_UE_DATA4", 0x148, 0 }, { "MC3_BD_ADDR", 0x14c, 0 }, { "MC3_BD_DATA0", 0x150, 0 }, { "MC3_BD_DATA1", 0x154, 0 }, { "MC3_BD_DATA2", 0x158, 0 }, { "MC3_BD_DATA3", 0x15c, 0 }, { "MC3_BD_DATA4", 0x160, 0 }, { "MC3_BD_OP", 0x164, 0 }, { "Back_Door_Operation", 0, 1 }, { "Busy", 31, 1 }, { "MC3_BIST_ADDR_BEG", 0x168, 0 }, { "MC3_BIST_ADDR_END", 0x16c, 0 }, { "MC3_BIST_DATA", 0x170, 0 }, { "MC3_BIST_OP", 0x174, 0 }, { "Op", 0, 1 }, { "Data_Pattern", 1, 2 }, { "Continuous", 3, 1 }, { "Busy", 31, 1 }, { "MC3_INT_ENABLE", 0x178, 0 }, { "MC3_Corr_Err", 0, 1 }, { "MC3_Uncorr_Err", 1, 1 }, { "MC3_Parity_Err", 2, 8 }, { "MC3_Addr_Err", 10, 1 }, { "MC3_INT_CAUSE", 0x17c, 0 }, { "MC3_Corr_Err", 0, 1 }, { "MC3_Uncorr_Err", 1, 1 }, { "MC3_Parity_Err", 2, 8 }, { "MC3_Addr_Err", 10, 1 }, { NULL, 0, 0 } }; struct reg_info mc4_regs[] = { { "MC4_CFG", 0x180, 0 }, { "Power_Up", 0, 1 }, { "Ready", 1, 1 }, { "Read_to_Write_Delay", 2, 3 }, { "Write_to_Read_Delay", 5, 3 }, { "MC4_Bank_Cycle", 8, 3 }, { "MC4_Narrow", 24, 1 }, { "MC4_Slow", 25, 1 }, { "MC4A_Width", 24, 2 }, { "MC4A_Slow", 26, 1 }, { "MC4_MODE", 0x184, 0 }, { "MC4_Mode", 0, 15 }, { "Busy", 31, 1 }, { "MC4_EXT_MODE", 0x188, 0 }, { "MC4_Extended_Mode", 0, 15 }, { "Busy", 31, 1 }, { "MC4_REFRESH", 0x190, 0 }, { "Refresh_Enable", 0, 1 }, { "Refresh_Divisor", 1, 14 }, { "Busy", 31, 1 }, { "MC4_STROBE", 0x194, 0 }, { "Master_DLL_Reset", 0, 1 }, { "Master_DLL_Tap_Count", 1, 8 }, { "Master_DLL_Locked", 9, 1 }, { "Master_DLL_Max_Tap_Count", 10, 1 }, { "Master_DLL_Tap_Count_Offset", 11, 6 }, { "Slave_DLL_Reset", 11, 1 }, { "Slave_DLL_Delta", 12, 4 }, { "Slave_Delay_Line_Manual_Tap_Count", 17, 6 }, { "Slave_Delay_Line_Manual_Tap_Count_Enable", 23, 1 }, { "Slave_Delay_Line_Tap_Count", 24, 6 }, { "MC4_ECC_CNTL", 0x198, 0 }, { "ECC_Generation_Enable", 0, 1 }, { "ECC_Check_Enable", 1, 1 }, { "Correctable_Error_Count", 2, 8 }, { "Uncorrectable_Error_Count", 10, 8 }, { "MC4_CE_ADDR", 0x19c, 0 }, { "MC4_CE_Addr", 4, 24 }, { "MC4_CE_DATA0", 0x1a0, 0 }, { "MC4_CE_DATA1", 0x1a4, 0 }, { "MC4_CE_DATA2", 0x1a8, 0 }, { "MC4_CE_DATA3", 0x1ac, 0 }, { "MC4_CE_DATA4", 0x1b0, 0 }, { "MC4_UE_ADDR", 0x1b4, 0 }, { "MC4_UE_Addr", 4, 24 }, { "MC4_UE_DATA0", 0x1b8, 0 }, { "MC4_UE_DATA1", 0x1bc, 0 }, { "MC4_UE_DATA2", 0x1c0, 0 }, { "MC4_UE_DATA3", 0x1c4, 0 }, { "MC4_UE_DATA4", 0x1c8, 0 }, { "MC4_BD_ADDR", 0x1cc, 0 }, { "MC4_Back_Door_Addr", 0, 28 }, { "MC4_BD_DATA0", 0x1d0, 0 }, { "MC4_BD_DATA1", 0x1d4, 0 }, { "MC4_BD_DATA2", 0x1d8, 0 }, { "MC4_BD_DATA3", 0x1dc, 0 }, { "MC4_BD_DATA4", 0x1e0, 0 }, { "MC4_BD_OP", 0x1e4, 0 }, { "Operation", 0, 1 }, { "Busy", 31, 1 }, { "MC4_BIST_ADDR_BEG", 0x1e8, 0 }, { "MC4_BIST_ADDR_END", 0x1ec, 0 }, { "MC4_BIST_DATA", 0x1f0, 0 }, { "MC4_BIST_OP", 0x1f4, 0 }, { "Op", 0, 1 }, { "Data_Pattern", 1, 2 }, { "Continuous", 3, 1 }, { "Busy", 31, 1 }, { "MC4_INT_ENABLE", 0x1f8, 0 }, { "MC4_Corr_Err", 0, 1 }, { "MC4_Uncorr_Err", 1, 1 }, { "MC4_Addr_Err", 2, 1 }, { "MC4_INT_CAUSE", 0x1fc, 0 }, { "MC4_Corr_Err", 0, 1 }, { "MC4_Uncorr_Err", 1, 1 }, { "MC4_Addr_Err", 2, 1 }, { NULL, 0, 0 } }; struct reg_info tpi_regs[] = { { "TPI_ADDR", 0x280, 0 }, { "TPI_ADDRESS", 0, 24 }, { "TPI_WR_DATA", 0x284, 0 }, { "TPI_RD_DATA", 0x288, 0 }, { "TPI_CSR", 0x28c, 0 }, { "TPIWR", 0, 1 }, { "TPIRDY", 1, 1 }, { "INT_DIR", 31, 1 }, { "TPI_PAR", 0x29c, 0 }, { "TPIPAR", 0, 7 }, { NULL, 0, 0 } }; struct reg_info tp_regs[] = { { "TP_IN_CONFIG", 0x300, 0 }, { "TP_IN_CSPI_Tunnel", 0, 1 }, { "TP_IN_CSPI_Ethernet", 1, 1 }, { "TP_IN_CSPI_CPL", 3, 1 }, { "TP_IN_CSPI_POS", 4, 1 }, { "TP_IN_CSPI_Check_IP_Csum", 5, 1 }, { "TP_IN_CSPI_Check_TCP_Csum", 6, 1 }, { "TP_IN_ESPI_Tunnel", 7, 1 }, { "TP_IN_ESPI_Ethernet", 8, 1 }, { "TP_IN_ESPI_CPL", 10, 1 }, { "TP_IN_ESPI_POS", 11, 1 }, { "TP_IN_ESPI_Check_IP_Csum", 12, 1 }, { "TP_IN_ESPI_Check_TCP_Csum", 13, 1 }, { "Offload_Disable", 14, 1 }, { "TP_OUT_CONFIG", 0x304, 0 }, { "TP_OUT_C_ETH", 0, 1 }, { "TP_OUT_CSPI_CPL", 2, 1 }, { "TP_OUT_CSPI_POS", 3, 1 }, { "TP_OUT_CSPI_Generate_IP_Csum", 4, 1 }, { "TP_OUT_CSPI_Generate_TCP_Csum", 5, 1 }, { "TP_OUT_ESPI_Ethernet", 6, 1 }, { "TP_OUT_ESPI_TAG_Ethernet", 7, 1 }, { "TP_OUT_ESPI_CPL", 8, 1 }, { "TP_OUT_ESPI_POS", 9, 1 }, { "TP_OUT_ESPI_Generate_IP_Csum", 10, 1 }, { "TP_OUT_ESPI_Generate_TCP_Csum", 11, 1 }, { "TP_GLOBAL_CONFIG", 0x308, 0 }, { "IP_TTL", 0, 8 }, { "TCAM_Server_Region_Usage", 8, 2 }, { "QOS_Mapping", 10, 1 }, { "TCP_Csum", 11, 1 }, { "UDP_Csum", 12, 1 }, { "IP_Csum", 13, 1 }, { "IP_ID_Split", 14, 1 }, { "Path_MTU", 15, 1 }, { "5Tuple_Lookup", 17, 2 }, { "IP_Fragment_Drop", 19, 1 }, { "Ping_Drop", 20, 1 }, { "Protect_Mode", 21, 1 }, { "SYN_Cookie_Algorithm", 22, 1 }, { "Attack_Filter", 23, 1 }, { "Interface_Type", 24, 1 }, { "Disable_RX_Flow_Control", 25, 1 }, { "SYN_Cookie_Parameter", 26, 6 }, { "TP_GLOBAL_RX_CREDITS", 0x30c, 0 }, { "TP_CM_SIZE", 0x310, 0 }, { "TP_CM_MM_BASE", 0x314, 0 }, { "CM_MemMgr_Base", 0, 28 }, { "TP_CM_TIMER_BASE", 0x318, 0 }, { "CM_Timer_Base", 0, 28 }, { "TP_PM_SIZE", 0x31c, 0 }, { "TP_PM_TX_BASE", 0x320, 0 }, { "TP_PM_DEFRAG_BASE", 0x324, 0 }, { "TP_PM_RX_BASE", 0x328, 0 }, { "TP_PM_RX_PG_SIZE", 0x32c, 0 }, { "TP_PM_RX_MAX_PGS", 0x330, 0 }, { "TP_PM_TX_PG_SIZE", 0x334, 0 }, { "TP_PM_TX_MAX_PGS", 0x338, 0 }, { "TP_TCP_OPTIONS", 0x340, 0 }, { "Timestamp", 0, 2 }, { "Window_Scale", 2, 2 }, { "SACK", 4, 2 }, { "ECN", 6, 2 }, { "SACK_Algorithm", 8, 2 }, { "MSS", 10, 1 }, { "Default_Peer_MSS", 16, 16 }, { "TP_DACK_CONFIG", 0x344, 0 }, { "DACK_Mode", 0, 1 }, { "DACK_Auto_Mgmt", 1, 1 }, { "DACK_Auto_Careful", 2, 1 }, { "DACK_MSS_Selector", 3, 2 }, { "DACK_Byte_Threshold", 5, 20 }, { "TP_PC_CONFIG", 0x348, 0 }, { "TP_Access_Latency", 0, 4 }, { "Held_FIN_Disable", 4, 1 }, { "DDP_FC_Enable", 5, 1 }, { "RDMA_Err_Enable", 6, 1 }, { "Fast_PDU_Delivery", 7, 1 }, { "Clear_FIN", 8, 1 }, { "TP_PC_Rev", 30, 2 }, { "TP_BACKOFF0", 0x350, 0 }, { "Element0", 0, 8 }, { "Element1", 8, 8 }, { "Element2", 16, 8 }, { "Element3", 24, 8 }, { "TP_BACKOFF1", 0x354, 0 }, { "Element0", 0, 8 }, { "Element1", 8, 8 }, { "Element2", 16, 8 }, { "Element3", 24, 8 }, { "TP_BACKOFF2", 0x358, 0 }, { "Element0", 0, 8 }, { "Element1", 8, 8 }, { "Element2", 16, 8 }, { "Element3", 24, 8 }, { "TP_BACKOFF3", 0x35c, 0 }, { "Element0", 0, 8 }, { "Element1", 8, 8 }, { "Element2", 16, 8 }, { "Element3", 24, 8 }, { "TP_PARA_REG0", 0x360, 0 }, { "Var_Mult", 0, 4 }, { "Var_Gain", 4, 4 }, { "SRTT_Gain", 8, 4 }, { "RTTVar_Init", 12, 4 }, { "Dup_Thresh", 20, 4 }, { "Init_Cong_Win", 24, 3 }, { "TP_PARA_REG1", 0x364, 0 }, { "Initial_Slow_Start_Threshold", 0, 16 }, { "Receive_Buffer_Size", 16, 16 }, { "TP_PARA_REG2", 0x368, 0 }, { "RX_Coalesce_Size", 0, 16 }, { "MAX_RX_Size", 16, 16 }, { "TP_PARA_REG3", 0x36c, 0 }, { "RX_Coalescing_PSH_Deliver", 0, 1 }, { "RX_Coalescing_Enable", 1, 1 }, { "Tahoe_Enable", 2, 1 }, { "MAX_Reorder_Fragments", 12, 3 }, { "TP_TIMER_RESOLUTION", 0x390, 0 }, { "Delayed_ACK_Timer_Resolution", 0, 6 }, { "Generic_Timer_Resolution", 16, 6 }, { "TP_2MSL", 0x394, 0 }, { "2MSL", 0, 30 }, { "TP_RXT_MIN", 0x398, 0 }, { "Retransmit_Timer_MIN", 0, 16 }, { "TP_RXT_MAX", 0x39c, 0 }, { "Retransmit_Timer_MAX", 0, 30 }, { "TP_PERS_MIN", 0x3a0, 0 }, { "Persist_Timer_MIN", 0, 16 }, { "TP_PERS_MAX", 0x3a4, 0 }, { "Persist_Timer_MAX", 0, 30 }, { "TP_KEEP_IDLE", 0x3ac, 0 }, { "Keep_Alive_Idle_Time", 0, 30 }, { "TP_KEEP_INTVL", 0x3b0, 0 }, { "Keep_Alive_Interval_Time", 0, 30 }, { "TP_INIT_SRTT", 0x3b4, 0 }, { "Initial_SRTT", 0, 16 }, { "TP_DACK_TIME", 0x3b8, 0 }, { "Delayed_ACK_Time", 0, 11 }, { "TP_FINWAIT2_TIME", 0x3bc, 0 }, { "FINWAIT2_TIME", 0, 30 }, { "TP_FAST_FINWAIT2_TIME", 0x3c0, 0 }, { "Fast_FINWAIT2_Time", 0, 30 }, { "TP_SHIFT_CNT", 0x3c4, 0 }, { "KeepAlive_MAX", 0, 8 }, { "WindowProbe_MAX", 8, 8 }, { "Retransmission_MAX", 16, 8 }, { "SYN_MAX", 24, 8 }, { "TP_QOS_REG0", 0x3e0, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG1", 0x3e4, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG2", 0x3e8, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG3", 0x3ec, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG4", 0x3f0, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG5", 0x3f4, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG6", 0x3f8, 0 }, { "L3_Value", 0, 6 }, { "TP_QOS_REG7", 0x3fc, 0 }, { "L3_Value", 0, 6 }, { "TP_MTU_REG0", 0x404, 0 }, { "TP_MTU_REG1", 0x408, 0 }, { "TP_MTU_REG2", 0x40c, 0 }, { "TP_MTU_REG3", 0x410, 0 }, { "TP_MTU_REG4", 0x414, 0 }, { "TP_MTU_REG5", 0x418, 0 }, { "TP_MTU_REG6", 0x41c, 0 }, { "TP_MTU_REG7", 0x420, 0 }, { "TP_RESET", 0x44c, 0 }, { "TP_Reset", 0, 1 }, { "CM_MemMgr_Init", 1, 1 }, { "TP_MIB_INDEX", 0x450, 0 }, { "TP_MIB_DATA", 0x454, 0 }, { "TP_SYNC_TIME_HI", 0x458, 0 }, { "TP_SYNC_TIME_LO", 0x45c, 0 }, { "TP_CM_MM_RX_FLST_BASE", 0x460, 0 }, { "CM_MemMgr_RX_Free_List_Base", 0, 28 }, { "TP_CM_MM_TX_FLST_BASE", 0x464, 0 }, { "CM_MemMgr_TX_Free_List_Base", 0, 28 }, { "TP_CM_MM_P_FLST_BASE", 0x468, 0 }, { "CM_MemMgr_PStruct_Free_List_Base", 0, 28 }, { "TP_CM_MM_MAX_P", 0x46c, 0 }, { "CM_MemMgr_MAX_PStruct", 0, 28 }, { "TP_INT_ENABLE", 0x470, 0 }, { "TX_Free_List_Empty", 0, 1 }, { "RX_Free_List_Empty", 1, 1 }, { "TP_INT_CAUSE", 0x474, 0 }, { "TX_Free_List_Empty", 0, 1 }, { "RX_Free_List_Empty", 1, 1 }, { "TP_FLM_FREE_PSTRUCT_CNT", 0x480, 0 }, { "TP_FLM_FREE_RX_PG_CNT", 0x484, 0 }, { "TP_FLM_FREE_TX_PG_CNT", 0x488, 0 }, { "TP_HEAP_PUSH_CNT", 0x48c, 0 }, { "TP_HEAP_POP_CNT", 0x490, 0 }, { "TP_DACK_PUSH_CNT", 0x494, 0 }, { "TP_DACK_POP_CNT", 0x498, 0 }, { "TP_MOD_PUSH_CNT", 0x49c, 0 }, { "TP_MOD_POP_CNT", 0x4a0, 0 }, { "TP_TIMER_SEPARATOR", 0x4a4, 0 }, { "Disable_Past_Timer_Insertion", 0, 1 }, { "Modulation_Timer_Separator", 1, 15 }, { "Global_Timer_Separator", 16, 16 }, { "TP_DEBUG_SEL", 0x4a8, 0 }, { "TP_CM_FC_MODE", 0x4b0, 0 }, { "TP_PC_CONGESTION_CNTL", 0x4b4, 0 }, { "TP_TX_DROP_CONFIG", 0x4b8, 0 }, { "ENABLE_TX_DROP", 31, 1 }, { "ENABLE_TX_ERROR", 30, 1 }, { "DROP_TICKS_CNT", 4, 26 }, { "NUM_PKTS_DROPPED", 0, 4 }, { "TP_TX_DROP_COUNT", 0x4bc, 0 }, { NULL, 0, 0 } }; struct reg_info rat_regs[] = { { "RAT_ROUTE_CONTROL", 0x580, 0 }, { "Use_Route_Table", 0, 1 }, { "Enable_CSPI", 1, 1 }, { "Enable_PCIX", 2, 1 }, { "RAT_ROUTE_TABLE_INDEX", 0x584, 0 }, { "Route_Table_Index", 0, 4 }, { "RAT_ROUTE_TABLE_DATA", 0x588, 0 }, { "RAT_NO_ROUTE", 0x58c, 0 }, { "CPL_Opcode", 0, 8 }, { "RAT_INTR_ENABLE", 0x590, 0 }, { "ZeroRouteError", 0, 1 }, { "CspiFramingError", 1, 1 }, { "SgeFramingError", 2, 1 }, { "TpFramingError", 3, 1 }, { "RAT_INTR_CAUSE", 0x594, 0 }, { "ZeroRouteError", 0, 1 }, { "CspiFramingError", 1, 1 }, { "SgeFramingError", 2, 1 }, { "TpFramingError", 3, 1 }, { NULL, 0, 0 } }; struct reg_info cspi_regs[] = { { "CSPI_RX_AE_WM", 0x810, 0 }, { "CSPI_RX_AF_WM", 0x814, 0 }, { "CSPI_CALENDAR_LEN", 0x818, 0 }, { "CalendarLength", 0, 16 }, { "CSPI_FIFO_STATUS_ENABLE", 0x820, 0 }, { "FifoStatusEnable", 0, 1 }, { "CSPI_MAXBURST1_MAXBURST2", 0x828, 0 }, { "MaxBurst1", 0, 16 }, { "MaxBurst2", 16, 16 }, { "CSPI_TRAIN", 0x82c, 0 }, { "CSPI_TRAIN_ALPHA", 0, 16 }, { "CSPI_TRAIN_DATA_MAXT", 16, 16 }, { "CSPI_INTR_STATUS", 0x848, 0 }, { "DIP4Err", 0, 1 }, { "RXDrop", 1, 1 }, { "TXDrop", 2, 1 }, { "RXOverflow", 3, 1 }, { "RAMParityErr", 4, 1 }, { "CSPI_INTR_ENABLE", 0x84c, 0 }, { "DIP4Err", 0, 1 }, { "RXDrop", 1, 1 }, { "TXDrop", 2, 1 }, { "RXOverflow", 3, 1 }, { "RAMParityErr", 4, 1 }, { NULL, 0, 0 } }; struct reg_info espi_regs[] = { { "ESPI_SCH_TOKEN0", 0x880, 0 }, { "SchToken0", 0, 16 }, { "ESPI_SCH_TOKEN1", 0x884, 0 }, { "SchToken1", 0, 16 }, { "ESPI_SCH_TOKEN2", 0x888, 0 }, { "SchToken2", 0, 16 }, { "ESPI_SCH_TOKEN3", 0x88c, 0 }, { "SchToken3", 0, 16 }, { "ESPI_RX_FIFO_ALMOST_EMPTY_WATERMARK", 0x890, 0 }, { "AlmostEmpty", 0, 16 }, { "ESPI_RX_FIFO_ALMOST_FULL_WATERMARK", 0x894, 0 }, { "AlmostFull", 0, 16 }, { "ESPI_CALENDAR_LENGTH", 0x898, 0 }, { "CalendarLength", 0, 16 }, { "PORT_CONFIG", 0x89c, 0 }, { "RX_NPorts", 0, 8 }, { "TX_NPorts", 8, 8 }, { "ESPI_FIFO_STATUS_ENABLE", 0x8a0, 0 }, { "RXStatusEnable", 0, 1 }, { "TXDropEnable", 1, 1 }, { "RXEndianMode", 2, 1 }, { "TXEndianMode", 3, 1 }, { "Intel1010Mode", 4, 1 }, { "ESPI_MAXBURST1_MAXBURST2", 0x8a8, 0 }, { "MaxBurst1", 0, 16 }, { "MaxBurst2", 16, 16 }, { "ESPI_TRAIN", 0x8ac, 0 }, { "MaxTrainAlpha", 0, 16 }, { "MaxTrainData", 16, 16 }, { "RAM_STATUS", 0x8b0, 0 }, { "RXFIFOParityError", 0, 10 }, { "TXFIFOParityError", 10, 10 }, { "RXFIFOOverflow", 20, 10 }, { "TX_DROP_COUNT0", 0x8b4, 0 }, { "TXPort0DropCnt", 0, 16 }, { "TxPort1DropCnt", 16, 16 }, { "TX_DROP_COUNT1", 0x8b8, 0 }, { "TXPort2DropCnt", 0, 16 }, { "TxPort3DropCnt", 16, 16 }, { "RX_DROP_COUNT0", 0x8bc, 0 }, { "RXPort0DropCnt", 0, 16 }, { "RxPort1DropCnt", 16, 16 }, { "RX_DROP_COUNT1", 0x8c0, 0 }, { "RXPort2DropCnt", 0, 16 }, { "RxPort3DropCnt", 16, 16 }, { "DIP4_ERROR_COUNT", 0x8c4, 0 }, { "Dip4ErrorCnt", 0, 12 }, { "Dip4ErrorCntShadow", 12, 12 }, { "TriCN_RX_Train_Err", 24, 1 }, { "TriCN_RX_Training", 25, 1 }, { "TriCN_RX_Train_OK", 26, 1 }, { "ESPI_INTR_STATUS", 0x8c8, 0 }, { "DIP4Err", 0, 1 }, { "RXDrop", 1, 1 }, { "TXDrop", 2, 1 }, { "RXOverflow", 3, 1 }, { "RAMParityErr", 4, 1 }, { "DIP2ParityErr", 5, 1 }, { "ESPI_INTR_ENABLE", 0x8cc, 0 }, { "DIP4Err", 0, 1 }, { "RXDrop", 1, 1 }, { "TXDrop", 2, 1 }, { "RXOverflow", 3, 1 }, { "RAMParityErr", 4, 1 }, { "DIP2ParityErr", 5, 1 }, { "RX_DROP_THRESHOLD", 0x8d0, 0 }, { "ESPI_RX_RESET", 0x8ec, 0 }, { "ESPI_RX_LNK_RST", 0, 1 }, { "ESPI_RX_CORE_RST", 1, 1 }, { "RX_CLK_STATUS", 2, 1 }, { "ESPI_MISC_CONTROL", 0x8f0, 0 }, { "Out_of_Sync_Count", 0, 4 }, { "DIP2_Count_Mode_Enable", 4, 1 }, { "DIP2_Parity_Err_Thres", 5, 4 }, { "DIP4_Thres", 9, 12 }, { "DIP4_Thres_Enable", 21, 1 }, { "Force_Disable_Status", 22, 1 }, { "Dynamic_Deskew", 23, 1 }, { "Monitored_Port_Num", 25, 2 }, { "Monitored_Direction", 27, 1 }, { "Monitored_Interface", 28, 1 }, { "ESPI_DIP2_ERR_COUNT", 0x8f4, 0 }, { "DIP2_Err_Cnt", 0, 4 }, { "ESPI_CMD_ADDR", 0x8f8, 0 }, { "Write_Data", 0, 8 }, { "Register_Offset", 8, 4 }, { "Channel_Addr", 12, 4 }, { "Module_Addr", 16, 2 }, { "Bundle_Addr", 20, 2 }, { "SPI4_Command", 24, 8 }, { "ESPI_GOSTAT", 0x8fc, 0 }, { "Read_Data", 0, 8 }, { "ESPI_Cmd_Busy", 8, 1 }, { "Error_Ack", 9, 1 }, { "Unmapped_Err", 10, 1 }, { "Transaction_Timer", 16, 8 }, { NULL, 0, 0 } }; struct reg_info ulp_regs[] = { { "ULP_ULIMIT", 0x980, 0 }, { "ULP_TAGMASK", 0x984, 0 }, { "ULP_HREG_INDEX", 0x988, 0 }, { "ULP_HREG_DATA", 0x98c, 0 }, { "ULP_INT_ENABLE", 0x990, 0 }, { "ULP_INT_CAUSE", 0x994, 0 }, { "Hreg_Par_Err", 0, 1 }, { "Egrs_Data_Par_Err", 1, 1 }, { "Ingrs_Data_Par_Err", 2, 1 }, { "Pm_Intr", 3, 1 }, { "Pm_E2C_Sync_Err", 4, 1 }, { "Pm_C2E_Sync_Err", 5, 1 }, { "Pm_E2C_Empty_Err", 6, 1 }, { "Pm_C2E_Empty_Err", 7, 1 }, { "Pm_Par_Err", 8, 16 }, { "Pm_E2C_Wrt_Full", 24, 1 }, { "Pm_C2E_Wrt_Full", 25, 1 }, { "ULP_PIO_CTRL", 0x998, 0 }, { NULL, 0, 0 } }; struct reg_info pl_regs[] = { { "PL_ENABLE", 0xa00, 0 }, { "PL_Intr_SGE_Err", 0, 1 }, { "PL_Intr_SGE_Data", 1, 1 }, { "PL_Intr_MC3", 2, 1 }, { "PL_Intr_MC4", 3, 1 }, { "PL_Intr_MC5", 4, 1 }, { "PL_Intr_RAT", 5, 1 }, { "PL_Intr_TP", 6, 1 }, { "PL_Intr_ULP", 7, 1 }, { "PL_Intr_ESPI", 8, 1 }, { "PL_Intr_CSPI", 9, 1 }, { "PL_Intr_PCIX", 10, 1 }, { "PL_Intr_EXT", 11, 1 }, { "PL_CAUSE", 0xa04, 0 }, { "PL_Intr_SGE_Err", 0, 1 }, { "PL_Intr_SGE_Data", 1, 1 }, { "PL_Intr_MC3", 2, 1 }, { "PL_Intr_MC4", 3, 1 }, { "PL_Intr_MC5", 4, 1 }, { "PL_Intr_RAT", 5, 1 }, { "PL_Intr_TP", 6, 1 }, { "PL_Intr_ULP", 7, 1 }, { "PL_Intr_ESPI", 8, 1 }, { "PL_Intr_CSPI", 9, 1 }, { "PL_Intr_PCIX", 10, 1 }, { "PL_Intr_EXT", 11, 1 }, { NULL, 0, 0 } }; struct reg_info mc5_regs[] = { { "MC5_CONFIG", 0xc04, 0 }, { "Mode", 0, 1 }, { "TCAM_Reset", 1, 1 }, { "TCAM_Ready", 2, 1 }, { "DBGI_Enable", 4, 1 }, { "M_Bus_Enable", 5, 1 }, { "Parity_Enable", 6, 1 }, { "SYN_Issue_Mode", 7, 2 }, { "Build", 16, 1 }, { "Compression_Enable", 17, 1 }, { "Num_LIP", 18, 6 }, { "TCAM_Part_Cnt", 24, 2 }, { "TCAM_Part_Type", 26, 2 }, { "TCAM_Part_Size", 28, 2 }, { "TCAM_Part_Type_HI", 30, 1 }, { "MC5_SIZE", 0xc08, 0 }, { "Size", 0, 22 }, { "MC5_ROUTING_TABLE_INDEX", 0xc0c, 0 }, { "Start_of_Routing_Table", 0, 22 }, { "MC5_SERVER_INDEX", 0xc14, 0 }, { "Start_of_Server_Index", 0, 22 }, { "MC5_LIP_RAM_ADDR", 0xc18, 0 }, { "Local_IP_RAM_Addr", 0, 6 }, { "RAM_Write_Enable", 8, 1 }, { "MC5_LIP_RAM_DATA", 0xc1c, 0 }, { "MC5_RSP_LATENCY", 0xc20, 0 }, { "Search_Response_Latency", 0, 5 }, { "Learn_Response_Latency", 8, 5 }, { "MC5_PARITY_LATENCY", 0xc24, 0 }, { "SRCHLAT", 0, 5 }, { "PARLAT", 8, 5 }, { "MC5_WR_LRN_VERIFY", 0xc28, 0 }, { "POVEREN", 0, 1 }, { "LRNVEREN", 1, 1 }, { "VWVEREN", 2, 1 }, { "MC5_PART_ID_INDEX", 0xc2c, 0 }, { "IDINDEX", 0, 4 }, { "MC5_RESET_MAX", 0xc30, 0 }, { "RSTMAX", 0, 9 }, { "MC5_INT_ENABLE", 0xc40, 0 }, { "MC5_Int_Hit_Out_Active_Region_Err", 0, 1 }, { "MC5_Int_Hit_In_Active_Region_Err", 1, 1 }, { "MC5_Int_Hit_In_RT_Region_Err", 2, 1 }, { "MC5_Int_Miss_Err", 3, 1 }, { "MC5_Int_LIP0_Err", 4, 1 }, { "MC5_Int_LIP_Miss_Err", 5, 1 }, { "MC5_Int_Parity_Err", 6, 1 }, { "MC5_Int_Active_Region_Full", 7, 1 }, { "MC5_Int_NFA_Srch_Err", 8, 1 }, { "MC5_Int_SYN_Cookie", 9, 1 }, { "MC5_Int_SYN_Cookie_Bad", 10, 1 }, { "MC5_Int_SYN_Cookie_Off", 11, 1 }, { "MC5_Int_Unknown_Cmd", 15, 1 }, { "MC5_Int_RequestQ_Parity_Err", 16, 1 }, { "MC5_Int_DispatchQ_Parity_Err", 17, 1 }, { "MC5_Int_Del_Act_Empty", 18, 1 }, { "MC5_INT_CAUSE", 0xc44, 0 }, { "MC5_Int_Hit_Out_Active_Region_Err", 0, 1 }, { "MC5_Int_Hit_In_Active_Region_Err", 1, 1 }, { "MC5_Int_Hit_In_RT_Region_Err", 2, 1 }, { "MC5_Int_Miss_Err", 3, 1 }, { "MC5_Int_LIP0_Err", 4, 1 }, { "MC5_Int_LIP_Miss_Err", 5, 1 }, { "MC5_Int_Parity_Err", 6, 1 }, { "MC5_Int_Active_Region_Full", 7, 1 }, { "MC5_Int_NFA_Srch_Err", 8, 1 }, { "MC5_Int_SYN_Cookie", 9, 1 }, { "MC5_Int_SYN_Cookie_Bad", 10, 1 }, { "MC5_Int_SYN_Cookie_Off", 11, 1 }, { "MC5_Int_Unknown_Cmd", 15, 1 }, { "MC5_Int_RequestQ_Parity_Err", 16, 1 }, { "MC5_Int_DispatchQ_Parity_Err", 17, 1 }, { "MC5_Int_Del_Act_Empty", 18, 1 }, { "MC5_INT_TID", 0xc48, 0 }, { "MC5_INT_PTID", 0xc4c, 0 }, { "MC5_DBGI_CONFIG", 0xc74, 0 }, { "MC5_DBGI_REQ_CMD", 0xc78, 0 }, { "CmdMode", 0, 3 }, { "SADRSEL", 4, 1 }, { "Write_Burst_Size", 22, 10 }, { "MC5_DBGI_REQ_ADDR0", 0xc7c, 0 }, { "MC5_DBGI_REQ_ADDR1", 0xc80, 0 }, { "MC5_DBGI_REQ_ADDR2", 0xc84, 0 }, { "MC5_DBGI_REQ_DATA0", 0xc88, 0 }, { "MC5_DBGI_REQ_DATA1", 0xc8c, 0 }, { "MC5_DBGI_REQ_DATA2", 0xc90, 0 }, { "MC5_DBGI_REQ_DATA3", 0xc94, 0 }, { "MC5_DBGI_REQ_DATA4", 0xc98, 0 }, { "MC5_DBGI_REQ_MASK0", 0xc9c, 0 }, { "MC5_DBGI_REQ_MASK1", 0xca0, 0 }, { "MC5_DBGI_REQ_MASK2", 0xca4, 0 }, { "MC5_DBGI_REQ_MASK3", 0xca8, 0 }, { "MC5_DBGI_REQ_MASK4", 0xcac, 0 }, { "MC5_DBGI_RSP_STATUS", 0xcb0, 0 }, { "DBGI_Rsp_Valid", 0, 1 }, { "DBGI_Rsp_Hit", 1, 1 }, { "DBGI_Rsp_Err", 2, 1 }, { "DBGI_Rsp_Err_Reason", 8, 3 }, { "MC5_DBGI_RSP_DATA0", 0xcb4, 0 }, { "MC5_DBGI_RSP_DATA1", 0xcb8, 0 }, { "MC5_DBGI_RSP_DATA2", 0xcbc, 0 }, { "MC5_DBGI_RSP_DATA3", 0xcc0, 0 }, { "MC5_DBGI_RSP_DATA4", 0xcc4, 0 }, { "MC5_DBGI_RSP_LAST_CMD", 0xcc8, 0 }, { "MC5_POPEN_DATA_WR_CMD", 0xccc, 0 }, { "MC5_POPEN_MASK_WR_CMD", 0xcd0, 0 }, { "MC5_AOPEN_SRCH_CMD", 0xcd4, 0 }, { "MC5_AOPEN_LRN_CMD", 0xcd8, 0 }, { "MC5_SYN_SRCH_CMD", 0xcdc, 0 }, { "MC5_SYN_LRN_CMD", 0xce0, 0 }, { "MC5_ACK_SRCH_CMD", 0xce4, 0 }, { "MC5_ACK_LRN_CMD", 0xce8, 0 }, { "MC5_ILOOKUP_CMD", 0xcec, 0 }, { "MC5_ELOOKUP_CMD", 0xcf0, 0 }, { "MC5_DATA_WRITE_CMD", 0xcf4, 0 }, { "MC5_DATA_READ_CMD", 0xcf8, 0 }, { "MC5_MASK_WRITE_CMD", 0xcfc, 0 }, { NULL, 0, 0 } }; diff --git a/tools/tools/cxgbtool/reg_defs_t3.c b/tools/tools/cxgbtool/reg_defs_t3.c index 6e9b8b1176f0..d4259b4e5434 100644 --- a/tools/tools/cxgbtool/reg_defs_t3.c +++ b/tools/tools/cxgbtool/reg_defs_t3.c @@ -1,2676 +1,2675 @@ /* - * $FreeBSD$ */ /* This file is automatically generated --- do not edit */ struct reg_info sge3_regs[] = { { "SG_CONTROL", 0x0, 0 }, { "EgrEnUpBp", 21, 1 }, { "DropPkt", 20, 1 }, { "EgrGenCtrl", 19, 1 }, { "UserSpaceSize", 14, 5 }, { "HostPageSize", 11, 3 }, { "PCIRelax", 10, 1 }, { "FLMode", 9, 1 }, { "PktShift", 6, 3 }, { "OneIntMultQ", 5, 1 }, { "FLPickAvail", 4, 1 }, { "BigEndianEgress", 3, 1 }, { "BigEndianIngress", 2, 1 }, { "IscsiCoalescing", 1, 1 }, { "GlobalEnable", 0, 1 }, { "SG_KDOORBELL", 0x4, 0 }, { "SelEgrCntx", 31, 1 }, { "EgrCntx", 0, 16 }, { "SG_GTS", 0x8, 0 }, { "RspQ", 29, 3 }, { "NewTimer", 16, 13 }, { "NewIndex", 0, 16 }, { "SG_CONTEXT_CMD", 0xc, 0 }, { "Opcode", 28, 4 }, { "Busy", 27, 1 }, { "CQ_credit", 20, 7 }, { "CQ", 19, 1 }, { "RspQ", 18, 1 }, { "Egress", 17, 1 }, { "FreeList", 16, 1 }, { "Context", 0, 16 }, { "SG_CONTEXT_DATA0", 0x10, 0 }, { "SG_CONTEXT_DATA1", 0x14, 0 }, { "SG_CONTEXT_DATA2", 0x18, 0 }, { "SG_CONTEXT_DATA3", 0x1c, 0 }, { "SG_CONTEXT_MASK0", 0x20, 0 }, { "SG_CONTEXT_MASK1", 0x24, 0 }, { "SG_CONTEXT_MASK2", 0x28, 0 }, { "SG_CONTEXT_MASK3", 0x2c, 0 }, { "SG_RSPQ_CREDIT_RETURN", 0x30, 0 }, { "RspQ", 29, 3 }, { "Data", 0, 16 }, { "SG_HI_DRB_HI_THRSH", 0x38, 0 }, { "HiDrbHiThrsh", 0, 10 }, { "SG_HI_DRB_LO_THRSH", 0x3c, 0 }, { "HiDrbLoThrsh", 0, 10 }, { "SG_LO_DRB_HI_THRSH", 0x40, 0 }, { "LoDrbHiThrsh", 0, 10 }, { "SG_LO_DRB_LO_THRSH", 0x44, 0 }, { "LoDrbLoThrsh", 0, 10 }, { "SG_ONE_INT_MULT_Q_COALESCING_TIMER", 0x48, 0 }, { "SG_RSPQ_FL_STATUS", 0x4c, 0 }, { "RspQ0Starved", 0, 1 }, { "RspQ1Starved", 1, 1 }, { "RspQ2Starved", 2, 1 }, { "RspQ3Starved", 3, 1 }, { "RspQ4Starved", 4, 1 }, { "RspQ5Starved", 5, 1 }, { "RspQ6Starved", 6, 1 }, { "RspQ7Starved", 7, 1 }, { "RspQ0Disabled", 8, 1 }, { "RspQ1Disabled", 9, 1 }, { "RspQ2Disabled", 10, 1 }, { "RspQ3Disabled", 11, 1 }, { "RspQ4Disabled", 12, 1 }, { "RspQ5Disabled", 13, 1 }, { "RspQ6Disabled", 14, 1 }, { "RspQ7Disabled", 15, 1 }, { "FL0Empty", 16, 1 }, { "FL1Empty", 17, 1 }, { "FL2Empty", 18, 1 }, { "FL3Empty", 19, 1 }, { "FL4Empty", 20, 1 }, { "FL5Empty", 21, 1 }, { "FL6Empty", 22, 1 }, { "FL7Empty", 23, 1 }, { "FL8Empty", 24, 1 }, { "FL9Empty", 25, 1 }, { "FL10Empty", 26, 1 }, { "FL11Empty", 27, 1 }, { "FL12Empty", 28, 1 }, { "FL13Empty", 29, 1 }, { "FL14Empty", 30, 1 }, { "FL15Empty", 31, 1 }, { "SG_EGR_PRI_CNT", 0x50, 0 }, { "EgrPriCnt", 0, 5 }, { "SG_EGR_RCQ_DRB_THRSH", 0x54, 0 }, { "HiRcqDrbThrsh", 16, 11 }, { "LoRcqDrbThrsh", 0, 11 }, { "SG_EGR_CNTX_BADDR", 0x58, 0 }, { "EgrCntxBAddr", 5, 27 }, { "SG_INT_CAUSE", 0x5c, 0 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_INT_ENABLE", 0x60, 0 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_CMDQ_CREDIT_TH", 0x64, 0 }, { "Timeout", 8, 24 }, { "Threshold", 0, 8 }, { "SG_TIMER_TICK", 0x68, 0 }, { "SG_CQ_CONTEXT_BADDR", 0x6c, 0 }, { "baseAddr", 5, 27 }, { "SG_OCO_BASE", 0x70, 0 }, { "Base1", 16, 16 }, { "Base0", 0, 16 }, { "SG_DRB_PRI_THRESH", 0x74, 0 }, { "DrbPriThrsh", 0, 16 }, { "SG_DEBUG_INDEX", 0x78, 0 }, { "SG_DEBUG_DATA", 0x7c, 0 }, { NULL, 0, 0 } }; struct reg_info pcix1_regs[] = { { "PCIX_INT_ENABLE", 0x80, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_INT_CAUSE", 0x84, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_CFG", 0x88, 0 }, { "CLIDecEn", 18, 1 }, { "LatTmrDis", 17, 1 }, { "LowPwrEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 8, 3 }, { "MaxSplTrnR", 5, 3 }, { "MaxWrByteCnt", 3, 2 }, { "WrReqAtomicEn", 2, 1 }, { "CRstWrmMode", 1, 1 }, { "PIOAck64En", 0, 1 }, { "PCIX_MODE", 0x8c, 0 }, { "PClkRange", 6, 2 }, { "PCIXInitPat", 2, 4 }, { "66MHz", 1, 1 }, { "64Bit", 0, 1 }, { "PCIX_CAL", 0x90, 0 }, { "Busy", 31, 1 }, { "PerCalDiv", 22, 8 }, { "PerCalEn", 21, 1 }, { "SglCalEn", 20, 1 }, { "ZInUpdMode", 19, 1 }, { "ZInSel", 18, 1 }, { "ZPDMan", 15, 3 }, { "ZPUMan", 12, 3 }, { "ZPDOut", 9, 3 }, { "ZPUOut", 6, 3 }, { "ZPDIn", 3, 3 }, { "ZPUIn", 0, 3 }, { "PCIX_WOL", 0x94, 0 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { NULL, 0, 0 } }; struct reg_info pcie0_regs[] = { { "PCIE_INT_ENABLE", 0x80, 0 }, { "BISTErr", 15, 8 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_INT_CAUSE", 0x84, 0 }, { "BISTErr", 15, 8 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_CFG", 0x88, 0 }, { "EnableLinkDwnDRst", 21, 1 }, { "EnableLinkDownRst", 20, 1 }, { "EnableHotRst", 19, 1 }, { "IniWaitForGnt", 18, 1 }, { "IniBEDis", 17, 1 }, { "CLIDecEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 7, 4 }, { "MaxSplTrnR", 1, 6 }, { "CRstWrmMode", 0, 1 }, { "PCIE_MODE", 0x8c, 0 }, { "LnkCntlState", 2, 8 }, { "VC0Up", 1, 1 }, { "LnkInitial", 0, 1 }, { "PCIE_CAL", 0x90, 0 }, { "CalBusy", 31, 1 }, { "CalFault", 30, 1 }, { "ZInSel", 11, 1 }, { "ZMan", 8, 3 }, { "ZOut", 3, 5 }, { "ZIn", 0, 3 }, { "PCIE_WOL", 0x94, 0 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { "PCIE_PEX_CTRL0", 0x98, 0 }, { "NumFstTrnSeq", 22, 8 }, { "ReplayLmt", 2, 20 }, { "TxPndChkEn", 1, 1 }, { "CplPndChkEn", 0, 1 }, { "PCIE_PEX_CTRL1", 0x9c, 0 }, { "DLLPTimeoutLmt", 11, 20 }, { "AckLat", 0, 11 }, { "PCIE_PEX_CTRL2", 0xa0, 0 }, { "PMExitL1Req", 29, 1 }, { "PMTxIdle", 28, 1 }, { "PCIModeLoop", 27, 1 }, { "L1ASPMTxRxL0sTime", 15, 12 }, { "L0sIdleTime", 4, 11 }, { "EnterL23", 3, 1 }, { "EnterL1ASPMEn", 2, 1 }, { "EnterL1En", 1, 1 }, { "EnterL0sEn", 0, 1 }, { "PCIE_PEX_ERR", 0xa4, 0 }, { "FlowCtlOFlowErr", 17, 1 }, { "ReplayTimeout", 16, 1 }, { "ReplayRollover", 15, 1 }, { "BadDLLP", 14, 1 }, { "DLLPErr", 13, 1 }, { "FlowCtlProtErr", 12, 1 }, { "CplTimeout", 11, 1 }, { "PHYRcvErr", 10, 1 }, { "DisTLP", 9, 1 }, { "BadECRC", 8, 1 }, { "BadTLP", 7, 1 }, { "MalTLP", 6, 1 }, { "UnxCpl", 5, 1 }, { "UnsReq", 4, 1 }, { "PsnReq", 3, 1 }, { "UnsCpl", 2, 1 }, { "CplAbt", 1, 1 }, { "PsnCpl", 0, 1 }, { "PCIE_PIPE_CTRL", 0xa8, 0 }, { "RecDetUsec", 19, 3 }, { "PLLLckCyc", 6, 13 }, { "ElecIdleDetCyc", 3, 3 }, { "UseCDRLOS", 2, 1 }, { "PClkReqInP1", 1, 1 }, { "PClkOffInP1", 0, 1 }, { "PCIE_SERDES_CTRL", 0xac, 0 }, { "ManMode", 31, 1 }, { "ManLpbkEn", 29, 2 }, { "ManTxRecDetEn", 28, 1 }, { "ManTxBeacon", 27, 1 }, { "ManTxEI", 26, 1 }, { "ManRxPolarity", 25, 1 }, { "ManTxRst", 24, 1 }, { "ManRxRst", 23, 1 }, { "ManTxEn", 22, 1 }, { "ManRxEn", 21, 1 }, { "ManEn", 20, 1 }, { "CMURange", 17, 3 }, { "BGEnb", 16, 1 }, { "EnSkpDrop", 15, 1 }, { "EnComma", 14, 1 }, { "En8B10B", 13, 1 }, { "EnElBuf", 12, 1 }, { "Gain", 7, 5 }, { "BandGap", 3, 4 }, { "RxComAdj", 2, 1 }, { "PreEmph", 0, 2 }, { "PCIE_SERDES_STATUS0", 0xb0, 0 }, { "RxErrLane7", 21, 3 }, { "RxErrLane6", 18, 3 }, { "RxErrLane5", 15, 3 }, { "RxErrLane4", 12, 3 }, { "RxErrLane3", 9, 3 }, { "RxErrLane2", 6, 3 }, { "RxErrLane1", 3, 3 }, { "RxErrLane0", 0, 3 }, { "PCIE_SERDES_STATUS1", 0xb4, 0 }, { "CMULock", 31, 1 }, { "RxKLockLane7", 23, 1 }, { "RxKLockLane6", 22, 1 }, { "RxKLockLane5", 21, 1 }, { "RxKLockLane4", 20, 1 }, { "RxKLockLane3", 19, 1 }, { "RxKLockLane2", 18, 1 }, { "RxKLockLane1", 17, 1 }, { "RxKLockLane0", 16, 1 }, { "RxUFlowLane7", 15, 1 }, { "RxUFlowLane6", 14, 1 }, { "RxUFlowLane5", 13, 1 }, { "RxUFlowLane4", 12, 1 }, { "RxUFlowLane3", 11, 1 }, { "RxUFlowLane2", 10, 1 }, { "RxUFlowLane1", 9, 1 }, { "RxUFlowLane0", 8, 1 }, { "RxOFlowLane7", 7, 1 }, { "RxOFlowLane6", 6, 1 }, { "RxOFlowLane5", 5, 1 }, { "RxOFlowLane4", 4, 1 }, { "RxOFlowLane3", 3, 1 }, { "RxOFlowLane2", 2, 1 }, { "RxOFlowLane1", 1, 1 }, { "RxOFlowLane0", 0, 1 }, { "PCIE_SERDES_STATUS2", 0xb8, 0 }, { "TxRecDetLane7", 31, 1 }, { "TxRecDetLane6", 30, 1 }, { "TxRecDetLane5", 29, 1 }, { "TxRecDetLane4", 28, 1 }, { "TxRecDetLane3", 27, 1 }, { "TxRecDetLane2", 26, 1 }, { "TxRecDetLane1", 25, 1 }, { "TxRecDetLane0", 24, 1 }, { "RxEIDLane7", 23, 1 }, { "RxEIDLane6", 22, 1 }, { "RxEIDLane5", 21, 1 }, { "RxEIDLane4", 20, 1 }, { "RxEIDLane3", 19, 1 }, { "RxEIDLane2", 18, 1 }, { "RxEIDLane1", 17, 1 }, { "RxEIDLane0", 16, 1 }, { "RxRemSkipLane7", 15, 1 }, { "RxRemSkipLane6", 14, 1 }, { "RxRemSkipLane5", 13, 1 }, { "RxRemSkipLane4", 12, 1 }, { "RxRemSkipLane3", 11, 1 }, { "RxRemSkipLane2", 10, 1 }, { "RxRemSkipLane1", 9, 1 }, { "RxRemSkipLane0", 8, 1 }, { "RxAddSkipLane7", 7, 1 }, { "RxAddSkipLane6", 6, 1 }, { "RxAddSkipLane5", 5, 1 }, { "RxAddSkipLane4", 4, 1 }, { "RxAddSkipLane3", 3, 1 }, { "RxAddSkipLane2", 2, 1 }, { "RxAddSkipLane1", 1, 1 }, { "RxAddSkipLane0", 0, 1 }, { "PCIE_SERDES_BIST", 0xbc, 0 }, { "BISTDone", 24, 8 }, { "BISTCycleThresh", 3, 16 }, { "BISTMode", 0, 3 }, { NULL, 0, 0 } }; struct reg_info t3dbg_regs[] = { { "T3DBG_DBG0_CFG", 0xc0, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG0_EN", 0xc4, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_DBG1_CFG", 0xc8, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG1_EN", 0xcc, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_GPIO_EN", 0xd0, 0 }, { "GPIO11_OEn", 27, 1 }, { "GPIO10_OEn", 26, 1 }, { "GPIO9_OEn", 25, 1 }, { "GPIO8_OEn", 24, 1 }, { "GPIO7_OEn", 23, 1 }, { "GPIO6_OEn", 22, 1 }, { "GPIO5_OEn", 21, 1 }, { "GPIO4_OEn", 20, 1 }, { "GPIO3_OEn", 19, 1 }, { "GPIO2_OEn", 18, 1 }, { "GPIO1_OEn", 17, 1 }, { "GPIO0_OEn", 16, 1 }, { "GPIO11_Out_Val", 11, 1 }, { "GPIO10_Out_Val", 10, 1 }, { "GPIO9_Out_Val", 9, 1 }, { "GPIO8_Out_Val", 8, 1 }, { "GPIO7_Out_Val", 7, 1 }, { "GPIO6_Out_Val", 6, 1 }, { "GPIO5_Out_Val", 5, 1 }, { "GPIO4_Out_Val", 4, 1 }, { "GPIO3_Out_Val", 3, 1 }, { "GPIO2_Out_Val", 2, 1 }, { "GPIO1_Out_Val", 1, 1 }, { "GPIO0_Out_Val", 0, 1 }, { "T3DBG_GPIO_IN", 0xd4, 0 }, { "GPIO11_IN", 11, 1 }, { "GPIO10_IN", 10, 1 }, { "GPIO9_IN", 9, 1 }, { "GPIO8_IN", 8, 1 }, { "GPIO7_IN", 7, 1 }, { "GPIO6_IN", 6, 1 }, { "GPIO5_IN", 5, 1 }, { "GPIO4_IN", 4, 1 }, { "GPIO3_IN", 3, 1 }, { "GPIO2_IN", 2, 1 }, { "GPIO1_IN", 1, 1 }, { "GPIO0_IN", 0, 1 }, { "T3DBG_INT_ENABLE", 0xd8, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "PE_LOCK", 16, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_INT_CAUSE", 0xdc, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "PE_LOCK", 16, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_DBG0_RST_VALUE", 0xe0, 0 }, { "DebugData", 0, 1 }, { "T3DBG_PLL_OCLK_PAD_EN", 0xe4, 0 }, { "PCIE_OCLK_En", 20, 1 }, { "PCIX_OCLK_En", 16, 1 }, { "U_OCLK_En", 12, 1 }, { "R_OCLK_En", 8, 1 }, { "M_OCLK_En", 4, 1 }, { "C_OCLK_En", 0, 1 }, { "T3DBG_PLL_LOCK", 0xe8, 0 }, { "PCIE_LOCK", 20, 1 }, { "PCIX_LOCK", 16, 1 }, { "U_LOCK", 12, 1 }, { "R_LOCK", 8, 1 }, { "M_LOCK", 4, 1 }, { "C_LOCK", 0, 1 }, { "T3DBG_SERDES_RBC_CFG", 0xec, 0 }, { "X_RBC_Lane_Sel", 16, 1 }, { "X_RBC_Dbg_En", 12, 1 }, { "X_Serdes_Sel", 8, 1 }, { "PE_RBC_Lane_Sel", 4, 1 }, { "PE_RBC_Dbg_En", 0, 1 }, { "T3DBG_GPIO_ACT_LOW", 0xf0, 0 }, { "C_LOCK_ACT_LOW", 21, 1 }, { "M_LOCK_ACT_LOW", 20, 1 }, { "U_LOCK_ACT_LOW", 19, 1 }, { "R_LOCK_ACT_LOW", 18, 1 }, { "PX_LOCK_ACT_LOW", 17, 1 }, { "PE_LOCK_ACT_LOW", 16, 1 }, { "GPIO11_ACT_LOW", 11, 1 }, { "GPIO10_ACT_LOW", 10, 1 }, { "GPIO9_ACT_LOW", 9, 1 }, { "GPIO8_ACT_LOW", 8, 1 }, { "GPIO7_ACT_LOW", 7, 1 }, { "GPIO6_ACT_LOW", 6, 1 }, { "GPIO5_ACT_LOW", 5, 1 }, { "GPIO4_ACT_LOW", 4, 1 }, { "GPIO3_ACT_LOW", 3, 1 }, { "GPIO2_ACT_LOW", 2, 1 }, { "GPIO1_ACT_LOW", 1, 1 }, { "GPIO0_ACT_LOW", 0, 1 }, { "T3DBG_PMON_CFG", 0xf4, 0 }, { "PMON_DONE", 29, 1 }, { "PMON_FAIL", 28, 1 }, { "PMON_FDEL_AUTO", 22, 1 }, { "PMON_CDEL_AUTO", 16, 1 }, { "PMON_FDEL_MANUAL", 10, 1 }, { "PMON_CDEL_MANUAL", 4, 1 }, { "PMON_MANUAL", 1, 1 }, { "PMON_AUTO", 0, 1 }, { NULL, 0, 0 } }; struct reg_info mc7_pmrx_regs[] = { { "MC7_CFG", 0x100, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x104, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x108, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x10c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x110, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x114, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x118, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x11c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x120, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x124, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x128, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ECC", 0x130, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x134, 0 }, { "MC7_CE_DATA0", 0x138, 0 }, { "MC7_CE_DATA1", 0x13c, 0 }, { "MC7_CE_DATA2", 0x140, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x144, 0 }, { "MC7_UE_DATA0", 0x148, 0 }, { "MC7_UE_DATA1", 0x14c, 0 }, { "MC7_UE_DATA2", 0x150, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x154, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x158, 0 }, { "MC7_BD_DATA1", 0x15c, 0 }, { "MC7_BD_DATA2", 0x160, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x164, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x168, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x16c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x170, 0 }, { "MC7_BIST_OP", 0x174, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x178, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x17c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info mc7_pmtx_regs[] = { { "MC7_CFG", 0x180, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x184, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x188, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x18c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x190, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x194, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x198, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x19c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x1a0, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x1a4, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x1a8, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ECC", 0x1b0, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x1b4, 0 }, { "MC7_CE_DATA0", 0x1b8, 0 }, { "MC7_CE_DATA1", 0x1bc, 0 }, { "MC7_CE_DATA2", 0x1c0, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x1c4, 0 }, { "MC7_UE_DATA0", 0x1c8, 0 }, { "MC7_UE_DATA1", 0x1cc, 0 }, { "MC7_UE_DATA2", 0x1d0, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x1d4, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x1d8, 0 }, { "MC7_BD_DATA1", 0x1dc, 0 }, { "MC7_BD_DATA2", 0x1e0, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x1e4, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x1e8, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x1ec, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x1f0, 0 }, { "MC7_BIST_OP", 0x1f4, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x1f8, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x1fc, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info mc7_cm_regs[] = { { "MC7_CFG", 0x200, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x204, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x208, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x20c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x210, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x214, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x218, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x21c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x220, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x224, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x228, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ECC", 0x230, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x234, 0 }, { "MC7_CE_DATA0", 0x238, 0 }, { "MC7_CE_DATA1", 0x23c, 0 }, { "MC7_CE_DATA2", 0x240, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x244, 0 }, { "MC7_UE_DATA0", 0x248, 0 }, { "MC7_UE_DATA1", 0x24c, 0 }, { "MC7_UE_DATA2", 0x250, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x254, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x258, 0 }, { "MC7_BD_DATA1", 0x25c, 0 }, { "MC7_BD_DATA2", 0x260, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x264, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x268, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x26c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x270, 0 }, { "MC7_BIST_OP", 0x274, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x278, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x27c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info cim_regs[] = { { "CIM_BOOT_CFG", 0x280, 0 }, { "BootAddr", 2, 30 }, { "BootSdram", 1, 1 }, { "uPCRst", 0, 1 }, { "CIM_FLASH_BASE_ADDR", 0x284, 0 }, { "FlashBaseAddr", 2, 22 }, { "CIM_FLASH_ADDR_SIZE", 0x288, 0 }, { "FlashAddrSize", 2, 22 }, { "CIM_SDRAM_BASE_ADDR", 0x28c, 0 }, { "SdramBaseAddr", 2, 30 }, { "CIM_SDRAM_ADDR_SIZE", 0x290, 0 }, { "SdramAddrSize", 2, 30 }, { "CIM_UP_SPARE_INT", 0x294, 0 }, { "uPSpareInt", 0, 3 }, { "CIM_HOST_INT_ENABLE", 0x298, 0 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_HOST_INT_CAUSE", 0x29c, 0 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_UP_INT_ENABLE", 0x2a0, 0 }, { "MstPlIntEn", 16, 1 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_UP_INT_CAUSE", 0x2a4, 0 }, { "MstPlInt", 16, 1 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_IBQ_FULLA_THRSH", 0x2a8, 0 }, { "Ibq0FullThrsh", 0, 9 }, { "Ibq1FullThrsh", 16, 9 }, { "CIM_IBQ_FULLB_THRSH", 0x2ac, 0 }, { "Ibq2FullThrsh", 0, 9 }, { "Ibq3FullThrsh", 16, 9 }, { "CIM_HOST_ACC_CTRL", 0x2b0, 0 }, { "HostBusy", 17, 1 }, { "HostWrite", 16, 1 }, { "HostAddr", 0, 16 }, { "CIM_HOST_ACC_DATA", 0x2b4, 0 }, { "CIM_IBQ_DBG_CFG", 0x2c0, 0 }, { "IbqDbgAddr", 16, 9 }, { "IbqDbgQID", 3, 2 }, { "IbqDbgWr", 2, 1 }, { "IbqDbgBusy", 1, 1 }, { "IbqDbgEn", 0, 1 }, { "CIM_OBQ_DBG_CFG", 0x2c4, 0 }, { "ObqDbgAddr", 16, 9 }, { "ObqDbgQID", 3, 2 }, { "ObqDbgWr", 2, 1 }, { "ObqDbgBusy", 1, 1 }, { "ObqDbgEn", 0, 1 }, { "CIM_IBQ_DBG_DATA", 0x2c8, 0 }, { "CIM_OBQ_DBG_DATA", 0x2cc, 0 }, { "CIM_CDEBUGDATA", 0x2d0, 0 }, { "CDebugDataH", 16, 16 }, { "CDebugDataL", 0, 16 }, { NULL, 0, 0 } }; struct reg_info tp1_regs[] = { { "TP_IN_CONFIG", 0x300, 0 }, { "RXFbArbPrio", 25, 1 }, { "TXFbArbPrio", 24, 1 }, { "DBMaxOpCnt", 16, 8 }, { "NICMode", 14, 1 }, { "EChecksumCheckTCP", 13, 1 }, { "EChecksumCheckIP", 12, 1 }, { "ECPL", 10, 1 }, { "EEthernet", 8, 1 }, { "ETunnel", 7, 1 }, { "CChecksumCheckTCP", 6, 1 }, { "CChecksumCheckIP", 5, 1 }, { "CCPL", 3, 1 }, { "CEthernet", 1, 1 }, { "CTunnel", 0, 1 }, { "TP_OUT_CONFIG", 0x304, 0 }, { "VLANExtractionEnable", 12, 1 }, { "EChecksumGenerateTCP", 11, 1 }, { "EChecksumGenerateIP", 10, 1 }, { "ECPL", 8, 1 }, { "EEthernet", 6, 1 }, { "CChecksumGenerateTCP", 5, 1 }, { "CChecksumGenerateIP", 4, 1 }, { "CCPL", 2, 1 }, { "CEthernet", 0, 1 }, { "TP_GLOBAL_CONFIG", 0x308, 0 }, { "RXFlowControlDisable", 25, 1 }, { "TXPacingEnable", 24, 1 }, { "AttackFilterEnable", 23, 1 }, { "SYNCookieNoOptions", 22, 1 }, { "ProtectedMode", 21, 1 }, { "PingDrop", 20, 1 }, { "FragmentDrop", 19, 1 }, { "FiveTupleLookup", 17, 2 }, { "PathMTU", 15, 1 }, { "IPIdentSplit", 14, 1 }, { "IPChecksumOffload", 13, 1 }, { "UDPChecksumOffload", 12, 1 }, { "TCPChecksumOffload", 11, 1 }, { "QOSMapping", 10, 1 }, { "TCAMServerUse", 8, 2 }, { "IPTTL", 0, 8 }, { "TP_GLOBAL_RX_CREDIT", 0x30c, 0 }, { "TP_CMM_SIZE", 0x310, 0 }, { "CMMemMgrSize", 0, 28 }, { "TP_CMM_MM_BASE", 0x314, 0 }, { "CMMemMgrBase", 0, 28 }, { "TP_CMM_TIMER_BASE", 0x318, 0 }, { "CMTimerBase", 0, 28 }, { "TP_PMM_SIZE", 0x31c, 0 }, { "PMSize", 0, 28 }, { "TP_PMM_TX_BASE", 0x320, 0 }, { "TP_PMM_DEFRAG_BASE", 0x324, 0 }, { "TP_PMM_RX_BASE", 0x328, 0 }, { "TP_PMM_RX_PAGE_SIZE", 0x32c, 0 }, { "TP_PMM_RX_MAX_PAGE", 0x330, 0 }, { "PMRxMaxPage", 0, 21 }, { "TP_PMM_TX_PAGE_SIZE", 0x334, 0 }, { "TP_PMM_TX_MAX_PAGE", 0x338, 0 }, { "PMTxMaxPage", 0, 21 }, { "TP_TCP_OPTIONS", 0x340, 0 }, { "MTUDefault", 16, 16 }, { "MTUEnable", 10, 1 }, { "SACKTx", 9, 1 }, { "SACKRx", 8, 1 }, { "SACKMode", 4, 2 }, { "WindowScaleMode", 2, 2 }, { "TimestampsMode", 0, 2 }, { "TP_DACK_CONFIG", 0x344, 0 }, { "AutoState3", 30, 2 }, { "AutoState2", 28, 2 }, { "AutoState1", 26, 2 }, { "ByteThreshold", 5, 20 }, { "MSSThreshold", 3, 2 }, { "AutoCareful", 2, 1 }, { "AutoEnable", 1, 1 }, { "Mode", 0, 1 }, { "TP_PC_CONFIG", 0x348, 0 }, { "TxTosQueueMapMode", 26, 1 }, { "RddpCongEn", 25, 1 }, { "EnableOnFlyPDU", 24, 1 }, { "EnableEPCMDAFull", 23, 1 }, { "ModulateUnionMode", 22, 1 }, { "TxDataAckRateEnable", 21, 1 }, { "TxDeferEnable", 20, 1 }, { "RxCongestionMode", 19, 1 }, { "HearbeatOnceDACK", 18, 1 }, { "HearbeatOnceHeap", 17, 1 }, { "HearbeatDACK", 16, 1 }, { "TxCongestionMode", 15, 1 }, { "AcceptLatestRcvAdv", 14, 1 }, { "DisableSYNData", 13, 1 }, { "DisableWindowPSH", 12, 1 }, { "DisableFINOldData", 11, 1 }, { "EnableFLMError", 10, 1 }, { "DisableFINOldDataFix", 9, 1 }, { "FilterPeerFIN", 8, 1 }, { "EnableFeedbackSend", 7, 1 }, { "EnableRDMAError", 6, 1 }, { "EnableDDPFlowControl", 5, 1 }, { "DisableHeldData", 4, 1 }, { "TableLatencyDelta", 0, 4 }, { "TP_TCP_BACKOFF_REG0", 0x350, 0 }, { "TimerBackoffIndex3", 24, 8 }, { "TimerBackoffIndex2", 16, 8 }, { "TimerBackoffIndex1", 8, 8 }, { "TimerBackoffIndex0", 0, 8 }, { "TP_TCP_BACKOFF_REG1", 0x354, 0 }, { "TimerBackoffIndex7", 24, 8 }, { "TimerBackoffIndex6", 16, 8 }, { "TimerBackoffIndex5", 8, 8 }, { "TimerBackoffIndex4", 0, 8 }, { "TP_TCP_BACKOFF_REG2", 0x358, 0 }, { "TimerBackoffIndex11", 24, 8 }, { "TimerBackoffIndex10", 16, 8 }, { "TimerBackoffIndex9", 8, 8 }, { "TimerBackoffIndex8", 0, 8 }, { "TP_TCP_BACKOFF_REG3", 0x35c, 0 }, { "TimerBackoffIndex15", 24, 8 }, { "TimerBackoffIndex14", 16, 8 }, { "TimerBackoffIndex13", 8, 8 }, { "TimerBackoffIndex12", 0, 8 }, { "TP_PARA_REG0", 0x360, 0 }, { "InitCwnd", 24, 3 }, { "DupAckThresh", 20, 4 }, { "TP_PARA_REG1", 0x364, 0 }, { "InitRwnd", 16, 16 }, { "InitialSSThresh", 0, 16 }, { "TP_PARA_REG2", 0x368, 0 }, { "MaxRxData", 16, 16 }, { "RxCoalesceSize", 0, 16 }, { "TP_PARA_REG3", 0x36c, 0 }, { "TunnelCngDrop1", 21, 1 }, { "TunnelCngDrop0", 20, 1 }, { "TxDataAckIdx", 16, 4 }, { "RxFragEnable", 12, 3 }, { "TxPaceFixedStrict", 11, 1 }, { "TxPaceAutoStrict", 10, 1 }, { "TxPaceFixed", 9, 1 }, { "TxPaceAuto", 8, 1 }, { "RxUrgMode", 5, 1 }, { "TxUrgMode", 4, 1 }, { "CngCtrlMode", 2, 2 }, { "RxCoalesceEnable", 1, 1 }, { "RxCoalescePshEn", 0, 1 }, { "TP_PARA_REG4", 0x370, 0 }, { "HighSpeedCfg", 24, 8 }, { "NewRenoCfg", 16, 8 }, { "TahoeCfg", 8, 8 }, { "RenoCfg", 0, 8 }, { "TP_PARA_REG5", 0x374, 0 }, { "IndicateSize", 16, 16 }, { "SchdEnable", 8, 1 }, { "OnFlyDDPEnable", 2, 1 }, { "DackTimerSpin", 1, 1 }, { "PushTimerEnable", 0, 1 }, { "TP_PARA_REG6", 0x378, 0 }, { "TxPDUSizeAdj", 16, 8 }, { "EnableEPDU", 14, 1 }, { "EnableESnd", 13, 1 }, { "EnableCSnd", 12, 1 }, { "EnableDeferACK", 9, 1 }, { "EnablePDUC", 8, 1 }, { "EnablePDUI", 7, 1 }, { "EnablePDUE", 6, 1 }, { "EnableDefer", 5, 1 }, { "EnableClearRxmtOos", 4, 1 }, { "DisablePDUCng", 3, 1 }, { "DisablePDUTimeout", 2, 1 }, { "DisablePDURxmt", 1, 1 }, { "DisablePDUxmt", 0, 1 }, { "TP_PARA_REG7", 0x37c, 0 }, { "PMMaxXferLen1", 16, 16 }, { "PMMaxXferLen0", 0, 16 }, { "TP_TIMER_RESOLUTION", 0x390, 0 }, { "TimerResolution", 16, 8 }, { "TimestampResolution", 8, 8 }, { "DelayedACKResolution", 0, 8 }, { "TP_MSL", 0x394, 0 }, { "MSL", 0, 30 }, { "TP_RXT_MIN", 0x398, 0 }, { "RxtMin", 0, 30 }, { "TP_RXT_MAX", 0x39c, 0 }, { "RxtMax", 0, 30 }, { "TP_PERS_MIN", 0x3a0, 0 }, { "PersMin", 0, 30 }, { "TP_PERS_MAX", 0x3a4, 0 }, { "PersMax", 0, 30 }, { "TP_KEEP_IDLE", 0x3a8, 0 }, { "KeepaliveIdle", 0, 30 }, { "TP_KEEP_INTVL", 0x3ac, 0 }, { "KeepaliveIntvl", 0, 30 }, { "TP_INIT_SRTT", 0x3b0, 0 }, { "InitSrtt", 0, 16 }, { "TP_DACK_TIMER", 0x3b4, 0 }, { "DackTime", 0, 12 }, { "TP_FINWAIT2_TIMER", 0x3b8, 0 }, { "Finwait2Time", 0, 30 }, { "TP_FAST_FINWAIT2_TIMER", 0x3bc, 0 }, { "FastFinwait2Time", 0, 30 }, { "TP_SHIFT_CNT", 0x3c0, 0 }, { "SynShiftMax", 24, 8 }, { "RxtShiftMaxR1", 20, 4 }, { "RxtShiftMaxR2", 16, 4 }, { "PerShiftBackoffMax", 12, 4 }, { "PerShiftMax", 8, 4 }, { "KeepaliveMax", 0, 8 }, { "TP_TIME_HI", 0x3c8, 0 }, { "TP_TIME_LO", 0x3cc, 0 }, { "TP_ULP_TABLE", 0x3d4, 0 }, { "ULPType7Field", 28, 4 }, { "ULPType6Field", 24, 4 }, { "ULPType5Field", 20, 4 }, { "ULPType4Field", 16, 4 }, { "ULPType3Field", 12, 4 }, { "ULPType2Field", 8, 4 }, { "ULPType1Field", 4, 4 }, { "ULPType0Field", 0, 4 }, { "TP_PACE_TABLE", 0x3d8, 0 }, { "TP_CCTRL_TABLE", 0x3dc, 0 }, { "TP_TOS_TABLE", 0x3e0, 0 }, { "TP_MTU_TABLE", 0x3e4, 0 }, { "TP_RSS_MAP_TABLE", 0x3e8, 0 }, { "TP_RSS_LKP_TABLE", 0x3ec, 0 }, { "TP_RSS_CONFIG", 0x3f0, 0 }, { "TNL4tupEn", 29, 1 }, { "TNL2tupEn", 28, 1 }, { "TNLprtEn", 26, 1 }, { "TNLMapEn", 25, 1 }, { "TNLLkpEn", 24, 1 }, { "OFD4tupEn", 21, 1 }, { "OFD2tupEn", 20, 1 }, { "OFDMapEn", 17, 1 }, { "OFDLkpEn", 16, 1 }, { "SYN4tupEn", 13, 1 }, { "SYN2tupEn", 12, 1 }, { "SYNMapEn", 9, 1 }, { "SYNLkpEn", 8, 1 }, { "RRCPLMapEn", 7, 1 }, { "RRCPLCPUSIZE", 4, 3 }, { "RQFeedbackEnable", 3, 1 }, { "HashToeplitz", 2, 1 }, { "HashSave", 1, 1 }, { "Disable", 0, 1 }, { "TP_RSS_CONFIG_TNL", 0x3f4, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_OFD", 0x3f8, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_SYN", 0x3fc, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_SECRET_KEY0", 0x400, 0 }, { "TP_RSS_SECRET_KEY1", 0x404, 0 }, { "TP_RSS_SECRET_KEY2", 0x408, 0 }, { "TP_RSS_SECRET_KEY3", 0x40c, 0 }, { "TP_TM_PIO_ADDR", 0x418, 0 }, { "TP_TM_PIO_DATA", 0x41c, 0 }, { "TP_TX_MOD_QUE_TABLE", 0x420, 0 }, { "TP_TX_RESOURCE_LIMIT", 0x424, 0 }, { "TX_RESOURCE_LIMIT_CH1_PC", 24, 8 }, { "TX_RESOURCE_LIMIT_CH1_NON_PC", 16, 8 }, { "TX_RESOURCE_LIMIT_CH0_PC", 8, 8 }, { "TX_RESOURCE_LIMIT_CH0_NON_PC", 0, 8 }, { "TP_TX_MOD_QUEUE_REQ_MAP", 0x428, 0 }, { "RX_MOD_WEIGHT", 24, 8 }, { "TX_MOD_WEIGHT", 16, 8 }, { "TX_MOD_TIMER_MODE", 8, 8 }, { "TX_MOD_QUEUE_REQ_MAP", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 0x42c, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT7", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT6", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT5", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT4", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0x430, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT3", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT2", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0, 8 }, { "TP_MOD_CHANNEL_WEIGHT", 0x434, 0 }, { "RX_MOD_CHANNEL_WEIGHT1", 24, 8 }, { "RX_MOD_CHANNEL_WEIGHT0", 16, 8 }, { "TX_MOD_CHANNEL_WEIGHT1", 8, 8 }, { "TX_MOD_CHANNEL_WEIGHT0", 0, 8 }, { "TP_MOD_RATE_LIMIT", 0x438, 0 }, { "RX_MOD_RATE_LIMIT_INC", 24, 8 }, { "RX_MOD_RATE_LIMIT_TICK", 16, 8 }, { "TX_MOD_RATE_LIMIT_INC", 8, 8 }, { "TX_MOD_RATE_LIMIT_TICK", 0, 8 }, { "TP_PIO_ADDR", 0x440, 0 }, { "TP_PIO_DATA", 0x444, 0 }, { "TP_RESET", 0x44c, 0 }, { "FlstInitEnable", 1, 1 }, { "TPReset", 0, 1 }, { "TP_MIB_INDEX", 0x450, 0 }, { "TP_MIB_RDATA", 0x454, 0 }, { "TP_SYNC_TIME_HI", 0x458, 0 }, { "TP_SYNC_TIME_LO", 0x45c, 0 }, { "TP_CMM_MM_RX_FLST_BASE", 0x460, 0 }, { "CMRxFlstBase", 0, 28 }, { "TP_CMM_MM_TX_FLST_BASE", 0x464, 0 }, { "CMTxFlstBase", 0, 28 }, { "TP_CMM_MM_PS_FLST_BASE", 0x468, 0 }, { "CMPsFlstBase", 0, 28 }, { "TP_CMM_MM_MAX_PSTRUCT", 0x46c, 0 }, { "CMMaxPstruct", 0, 21 }, { "TP_INT_ENABLE", 0x470, 0 }, { "TP_INT_CAUSE", 0x474, 0 }, { "TP_FLM_FREE_PS_CNT", 0x480, 0 }, { "FreePstructCount", 0, 21 }, { "TP_FLM_FREE_RX_CNT", 0x484, 0 }, { "FreeRxPageCount", 0, 21 }, { "TP_FLM_FREE_TX_CNT", 0x488, 0 }, { "FreeTxPageCount", 0, 21 }, { "TP_TM_HEAP_PUSH_CNT", 0x48c, 0 }, { "TP_TM_HEAP_POP_CNT", 0x490, 0 }, { "TP_TM_DACK_PUSH_CNT", 0x494, 0 }, { "TP_TM_DACK_POP_CNT", 0x498, 0 }, { "TP_TM_MOD_PUSH_CNT", 0x49c, 0 }, { "TP_MOD_POP_CNT", 0x4a0, 0 }, { "TP_TIMER_SEPARATOR", 0x4a4, 0 }, { "TP_DEBUG_SEL", 0x4a8, 0 }, { "TP_DEBUG_FLAGS", 0x4ac, 0 }, { "RXDebugFlags", 16, 16 }, { "TXDebugFlags", 0, 16 }, { "TP_CM_FLOW_CNTL_MODE", 0x4b0, 0 }, { "CMFlowCacheDisable", 0, 1 }, { "TP_PC_CONGESTION_CNTL", 0x4b4, 0 }, { "EDropTunnel", 19, 1 }, { "CDropTunnel", 18, 1 }, { "EThreshold", 12, 6 }, { "CThreshold", 6, 6 }, { "TxThreshold", 0, 6 }, { "TP_TX_DROP_COUNT", 0x4bc, 0 }, { "TP_CLEAR_DEBUG", 0x4c0, 0 }, { "ClrDebug", 0, 1 }, { "TP_DEBUG_VEC", 0x4c4, 0 }, { "TP_DEBUG_VEC2", 0x4c8, 0 }, { "TP_DEBUG_REG_SEL", 0x4cc, 0 }, { "TP_DEBUG", 0x4d0, 0 }, { "TP_DBG_LA_CONFIG", 0x4d4, 0 }, { "TP_DBG_LA_DATAH", 0x4d8, 0 }, { "TP_DBG_LA_DATAL", 0x4dc, 0 }, { "TP_EMBED_OP_FIELD0", 0x4e8, 0 }, { "TP_EMBED_OP_FIELD1", 0x4ec, 0 }, { "TP_EMBED_OP_FIELD2", 0x4f0, 0 }, { "TP_EMBED_OP_FIELD3", 0x4f4, 0 }, { "TP_EMBED_OP_FIELD4", 0x4f8, 0 }, { "TP_EMBED_OP_FIELD5", 0x4fc, 0 }, { NULL, 0, 0 } }; struct reg_info ulp2_rx_regs[] = { { "ULPRX_CTL", 0x500, 0 }, { "PCMD1Threshold", 24, 8 }, { "PCMD0Threshold", 16, 8 }, { "round_robin", 4, 1 }, { "RDMA_permissive_mode", 3, 1 }, { "PagePodME", 2, 1 }, { "IscsiTagTcb", 1, 1 }, { "TddpTagTcb", 0, 1 }, { "ULPRX_INT_ENABLE", 0x504, 0 }, { "ParErr", 0, 1 }, { "ULPRX_INT_CAUSE", 0x508, 0 }, { "ParErr", 0, 1 }, { "ULPRX_ISCSI_LLIMIT", 0x50c, 0 }, { "IscsiLlimit", 6, 26 }, { "ULPRX_ISCSI_ULIMIT", 0x510, 0 }, { "IscsiUlimit", 6, 26 }, { "ULPRX_ISCSI_TAGMASK", 0x514, 0 }, { "IscsiTagMask", 6, 26 }, { "ULPRX_ISCSI_PSZ", 0x518, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_TDDP_LLIMIT", 0x51c, 0 }, { "TddpLlimit", 6, 26 }, { "ULPRX_TDDP_ULIMIT", 0x520, 0 }, { "TddpUlimit", 6, 26 }, { "ULPRX_TDDP_TAGMASK", 0x524, 0 }, { "TddpTagMask", 6, 26 }, { "ULPRX_TDDP_PSZ", 0x528, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_STAG_LLIMIT", 0x52c, 0 }, { "ULPRX_STAG_ULIMIT", 0x530, 0 }, { "ULPRX_RQ_LLIMIT", 0x534, 0 }, { "ULPRX_RQ_ULIMIT", 0x538, 0 }, { "ULPRX_PBL_LLIMIT", 0x53c, 0 }, { "ULPRX_PBL_ULIMIT", 0x540, 0 }, { NULL, 0, 0 } }; struct reg_info ulp2_tx_regs[] = { { "ULPTX_CONFIG", 0x580, 0 }, { "CFG_RR_ARB", 0, 1 }, { "ULPTX_INT_ENABLE", 0x584, 0 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_INT_CAUSE", 0x588, 0 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_TPT_LLIMIT", 0x58c, 0 }, { "ULPTX_TPT_ULIMIT", 0x590, 0 }, { "ULPTX_PBL_LLIMIT", 0x594, 0 }, { "ULPTX_PBL_ULIMIT", 0x598, 0 }, { "ULPTX_CPL_ERR_OFFSET", 0x59c, 0 }, { "ULPTX_CPL_ERR_MASK", 0x5a0, 0 }, { "ULPTX_CPL_ERR_VALUE", 0x5a4, 0 }, { "ULPTX_CPL_PACK_SIZE", 0x5a8, 0 }, { "value", 24, 8 }, { "Ch1Size2", 24, 8 }, { "Ch1Size1", 16, 8 }, { "Ch0Size2", 8, 8 }, { "Ch0Size1", 0, 8 }, { "ULPTX_DMA_WEIGHT", 0x5ac, 0 }, { "D1_WEIGHT", 16, 16 }, { "D0_WEIGHT", 0, 16 }, { NULL, 0, 0 } }; struct reg_info pm1_rx_regs[] = { { "PM1_RX_CFG", 0x5c0, 0 }, { "PM1_RX_MODE", 0x5c4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_RX_STAT_CONFIG", 0x5c8, 0 }, { "PM1_RX_STAT_COUNT", 0x5cc, 0 }, { "PM1_RX_STAT_MSB", 0x5d0, 0 }, { "PM1_RX_STAT_LSB", 0x5d4, 0 }, { "PM1_RX_INT_ENABLE", 0x5d8, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { "PM1_RX_INT_CAUSE", 0x5dc, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info pm1_tx_regs[] = { { "PM1_TX_CFG", 0x5e0, 0 }, { "PM1_TX_MODE", 0x5e4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_TX_STAT_CONFIG", 0x5e8, 0 }, { "PM1_TX_STAT_COUNT", 0x5ec, 0 }, { "PM1_TX_STAT_MSB", 0x5f0, 0 }, { "PM1_TX_STAT_LSB", 0x5f4, 0 }, { "PM1_TX_INT_ENABLE", 0x5f8, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { "PM1_TX_INT_CAUSE", 0x5fc, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info mps0_regs[] = { { "MPS_CFG", 0x600, 0 }, { "SGETPQid", 8, 3 }, { "TPRxPortSize", 7, 1 }, { "TPTxPort1Size", 6, 1 }, { "TPTxPort0Size", 5, 1 }, { "TPRxPortEn", 4, 1 }, { "TPTxPort1En", 3, 1 }, { "TPTxPort0En", 2, 1 }, { "Port1Active", 1, 1 }, { "Port0Active", 0, 1 }, { "MPS_DRR_CFG1", 0x604, 0 }, { "RldWtTPD1", 11, 11 }, { "RldWtTPD0", 0, 11 }, { "MPS_DRR_CFG2", 0x608, 0 }, { "RldWtTotal", 0, 12 }, { "MPS_MCA_STATUS", 0x60c, 0 }, { "MCAPktCnt", 12, 20 }, { "MCADepth", 0, 12 }, { "MPS_TX0_TP_CNT", 0x610, 0 }, { "TX0TPDisCnt", 24, 8 }, { "TX0TPCnt", 0, 24 }, { "MPS_TX1_TP_CNT", 0x614, 0 }, { "TX1TPDisCnt", 24, 8 }, { "TX1TPCnt", 0, 24 }, { "MPS_RX_TP_CNT", 0x618, 0 }, { "RXTPDisCnt", 24, 8 }, { "RXTPCnt", 0, 24 }, { "MPS_INT_ENABLE", 0x61c, 0 }, { "MCAParErrEnb", 6, 3 }, { "RXTpParErrEnb", 4, 2 }, { "TX1TpParErrEnb", 2, 2 }, { "TX0TpParErrEnb", 0, 2 }, { "MPS_INT_CAUSE", 0x620, 0 }, { "MCAParErr", 6, 3 }, { "RXTpParErr", 4, 2 }, { "TX1TpParErr", 2, 2 }, { "TX0TpParErr", 0, 2 }, { NULL, 0, 0 } }; struct reg_info cpl_switch_regs[] = { { "CPL_SWITCH_CNTRL", 0x640, 0 }, { "cpl_pkt_tid", 8, 24 }, { "cpu_no_3F_CIM_enable", 3, 1 }, { "switch_table_enable", 2, 1 }, { "sge_enable", 1, 1 }, { "cim_enable", 0, 1 }, { "CPL_SWITCH_TBL_IDX", 0x644, 0 }, { "switch_tbl_idx", 0, 4 }, { "CPL_SWITCH_TBL_DATA", 0x648, 0 }, { "CPL_SWITCH_ZERO_ERROR", 0x64c, 0 }, { "zero_cmd", 0, 8 }, { "CPL_INTR_ENABLE", 0x650, 0 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_INTR_CAUSE", 0x654, 0 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_MAP_TBL_IDX", 0x658, 0 }, { "cpl_map_tbl_idx", 0, 8 }, { "CPL_MAP_TBL_DATA", 0x65c, 0 }, { "cpl_map_tbl_data", 0, 8 }, { NULL, 0, 0 } }; struct reg_info smb0_regs[] = { { "SMB_GLOBAL_TIME_CFG", 0x660, 0 }, { "LADbgWrPtr", 24, 8 }, { "LADbgRdPtr", 16, 8 }, { "LADbgEn", 13, 1 }, { "MacroCntCfg", 8, 5 }, { "MicroCntCfg", 0, 8 }, { "SMB_MST_TIMEOUT_CFG", 0x664, 0 }, { "DebugSelH", 28, 4 }, { "DebugSelL", 24, 4 }, { "MstTimeOutCfg", 0, 24 }, { "SMB_MST_CTL_CFG", 0x668, 0 }, { "MstFifoDbg", 31, 1 }, { "MstFifoDbgClr", 30, 1 }, { "MstRxByteCfg", 12, 6 }, { "MstTxByteCfg", 6, 6 }, { "MstReset", 1, 1 }, { "MstCtlEn", 0, 1 }, { "SMB_MST_CTL_STS", 0x66c, 0 }, { "MstRxByteCnt", 12, 6 }, { "MstTxByteCnt", 6, 6 }, { "MstBusySts", 0, 1 }, { "SMB_MST_TX_FIFO_RDWR", 0x670, 0 }, { "SMB_MST_RX_FIFO_RDWR", 0x674, 0 }, { "SMB_SLV_TIMEOUT_CFG", 0x678, 0 }, { "SlvTimeOutCfg", 0, 24 }, { "SMB_SLV_CTL_CFG", 0x67c, 0 }, { "SlvFifoDbg", 31, 1 }, { "SlvFifoDbgClr", 30, 1 }, { "SlvAddrCfg", 4, 7 }, { "SlvAlrtSet", 2, 1 }, { "SlvReset", 1, 1 }, { "SlvCtlEn", 0, 1 }, { "SMB_SLV_CTL_STS", 0x680, 0 }, { "SlvFifoTxCnt", 12, 6 }, { "SlvFifoCnt", 6, 6 }, { "SlvAlrtSts", 2, 1 }, { "SlvBusySts", 0, 1 }, { "SMB_SLV_FIFO_RDWR", 0x684, 0 }, { "SMB_SLV_CMD_FIFO_RDWR", 0x688, 0 }, { "SMB_INT_ENABLE", 0x68c, 0 }, { "SlvTimeOutIntEn", 7, 1 }, { "SlvErrIntEn", 6, 1 }, { "SlvDoneIntEn", 5, 1 }, { "SlvRxRdyIntEn", 4, 1 }, { "MstTimeOutIntEn", 3, 1 }, { "MstNAckIntEn", 2, 1 }, { "MstLostArbIntEn", 1, 1 }, { "MstDoneIntEn", 0, 1 }, { "SMB_INT_CAUSE", 0x690, 0 }, { "SlvTimeOutInt", 7, 1 }, { "SlvErrInt", 6, 1 }, { "SlvDoneInt", 5, 1 }, { "SlvRxRdyInt", 4, 1 }, { "MstTimeOutInt", 3, 1 }, { "MstNAckInt", 2, 1 }, { "MstLostArbInt", 1, 1 }, { "MstDoneInt", 0, 1 }, { "SMB_DEBUG_DATA", 0x694, 0 }, { "DebugDataH", 16, 16 }, { "DebugDataL", 0, 16 }, { "SMB_DEBUG_LA", 0x69c, 0 }, { "DebugLAReqAddr", 0, 10 }, { NULL, 0, 0 } }; struct reg_info i2cm0_regs[] = { { "I2C_CFG", 0x6a0, 0 }, { "ClkDiv", 0, 12 }, { "I2C_DATA", 0x6a4, 0 }, { "Data", 0, 8 }, { "I2C_OP", 0x6a8, 0 }, { "Busy", 31, 1 }, { "Ack", 30, 1 }, { "Cont", 1, 1 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info mi1_regs[] = { { "MI1_CFG", 0x6b0, 0 }, { "ClkDiv", 5, 8 }, { "St", 3, 2 }, { "PreEn", 2, 1 }, { "MDIInv", 1, 1 }, { "MDIEn", 0, 1 }, { "MI1_ADDR", 0x6b4, 0 }, { "PhyAddr", 5, 5 }, { "RegAddr", 0, 5 }, { "MI1_DATA", 0x6b8, 0 }, { "Data", 0, 16 }, { "MI1_OP", 0x6bc, 0 }, { "Busy", 31, 1 }, { "Inc", 2, 1 }, { "Op", 0, 2 }, { NULL, 0, 0 } }; struct reg_info jm1_regs[] = { { "JM_CFG", 0x6c0, 0 }, { "ClkDiv", 2, 8 }, { "TRst", 1, 1 }, { "En", 0, 1 }, { "JM_MODE", 0x6c4, 0 }, { "JM_DATA", 0x6c8, 0 }, { "JM_OP", 0x6cc, 0 }, { "Busy", 31, 1 }, { "Cnt", 0, 5 }, { NULL, 0, 0 } }; struct reg_info sf1_regs[] = { { "SF_DATA", 0x6d8, 0 }, { "SF_OP", 0x6dc, 0 }, { "Busy", 31, 1 }, { "Cont", 3, 1 }, { "ByteCnt", 1, 2 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info pl3_regs[] = { { "PL_INT_ENABLE0", 0x6e0, 0 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE0", 0x6e4, 0 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_ENABLE1", 0x6e8, 0 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE1", 0x6ec, 0 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_RST", 0x6f0, 0 }, { "CRstWrm", 1, 1 }, { "CRstWrmMode", 0, 1 }, { "PL_REV", 0x6f4, 0 }, { "Rev", 0, 4 }, { "PL_CLI", 0x6f8, 0 }, { NULL, 0, 0 } }; struct reg_info mc5a_regs[] = { { "MC5_BUF_CONFIG", 0x700, 0 }, { "term300_240", 31, 1 }, { "term150", 30, 1 }, { "term60", 29, 1 }, { "gddriii", 28, 1 }, { "gddrii", 27, 1 }, { "gddri", 26, 1 }, { "read", 25, 1 }, { "cal_imp_upd", 23, 1 }, { "cal_busy", 22, 1 }, { "cal_error", 21, 1 }, { "sgl_cal_en", 20, 1 }, { "imp_upd_mode", 19, 1 }, { "imp_sel", 18, 1 }, { "man_pu", 15, 3 }, { "man_pd", 12, 3 }, { "cal_pu", 9, 3 }, { "cal_pd", 6, 3 }, { "set_pu", 3, 3 }, { "set_pd", 0, 3 }, { "MC5_DB_CONFIG", 0x704, 0 }, { "TMCfgWrLock", 31, 1 }, { "TMTypeHi", 30, 1 }, { "TMPartSize", 28, 2 }, { "TMType", 26, 2 }, { "TMPartCount", 24, 2 }, { "nLIP", 18, 6 }, { "COMPEN", 17, 1 }, { "BUILD", 16, 1 }, { "TM_IO_PDOWN", 9, 1 }, { "SYNMode", 7, 2 }, { "PRTYEN", 6, 1 }, { "MBUSEN", 5, 1 }, { "DBGIEN", 4, 1 }, { "TMRDY", 2, 1 }, { "TMRST", 1, 1 }, { "TMMode", 0, 1 }, { "MC5_DB_ROUTING_TABLE_INDEX", 0x70c, 0 }, { "RTINDX", 0, 22 }, { "MC5_DB_SERVER_INDEX", 0x714, 0 }, { "SRINDX", 0, 22 }, { "MC5_DB_LIP_RAM_ADDR", 0x718, 0 }, { "RAMWR", 8, 1 }, { "RAMADDR", 0, 6 }, { "MC5_DB_LIP_RAM_DATA", 0x71c, 0 }, { "MC5_DB_RSP_LATENCY", 0x720, 0 }, { "RDLAT", 16, 5 }, { "LRNLAT", 8, 5 }, { "SRCHLAT", 0, 5 }, { "MC5_DB_PARITY_LATENCY", 0x724, 0 }, { "PARLAT", 0, 4 }, { "MC5_DB_WR_LRN_VERIFY", 0x728, 0 }, { "VWVEREN", 2, 1 }, { "LRNVEREN", 1, 1 }, { "POVEREN", 0, 1 }, { "MC5_DB_PART_ID_INDEX", 0x72c, 0 }, { "IDINDEX", 0, 4 }, { "MC5_DB_RESET_MAX", 0x730, 0 }, { "RSTMAX", 0, 4 }, { "MC5_DB_ACT_CNT", 0x734, 0 }, { "ACTCNT", 0, 20 }, { "MC5_DB_INT_ENABLE", 0x740, 0 }, { "MsgSel", 28, 4 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_CAUSE", 0x744, 0 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_TID", 0x748, 0 }, { "INTTID", 0, 20 }, { "MC5_DB_INT_PTID", 0x74c, 0 }, { "INTPTID", 0, 20 }, { "MC5_DB_DBGI_CONFIG", 0x774, 0 }, { "WRReqSize", 22, 10 }, { "SADRSel", 4, 1 }, { "CMDMode", 0, 3 }, { "MC5_DB_DBGI_REQ_CMD", 0x778, 0 }, { "MBusCmd", 0, 4 }, { "IDTCmdHi", 11, 3 }, { "IDTCmdLo", 0, 4 }, { "IDTCmd", 0, 20 }, { "LCMDB", 16, 11 }, { "LCMDA", 0, 11 }, { "MC5_DB_DBGI_REQ_ADDR0", 0x77c, 0 }, { "MC5_DB_DBGI_REQ_ADDR1", 0x780, 0 }, { "MC5_DB_DBGI_REQ_ADDR2", 0x784, 0 }, { "DBGIReqAdrHi", 0, 8 }, { "MC5_DB_DBGI_REQ_DATA0", 0x788, 0 }, { "MC5_DB_DBGI_REQ_DATA1", 0x78c, 0 }, { "MC5_DB_DBGI_REQ_DATA2", 0x790, 0 }, { "MC5_DB_DBGI_REQ_DATA3", 0x794, 0 }, { "MC5_DB_DBGI_REQ_DATA4", 0x798, 0 }, { "DBGIReqData4", 0, 16 }, { "MC5_DB_DBGI_REQ_MASK0", 0x79c, 0 }, { "MC5_DB_DBGI_REQ_MASK1", 0x7a0, 0 }, { "MC5_DB_DBGI_REQ_MASK2", 0x7a4, 0 }, { "MC5_DB_DBGI_REQ_MASK3", 0x7a8, 0 }, { "MC5_DB_DBGI_REQ_MASK4", 0x7ac, 0 }, { "DBGIReqMsk4", 0, 16 }, { "MC5_DB_DBGI_RSP_STATUS", 0x7b0, 0 }, { "DBGIRspMsg", 8, 4 }, { "DBGIRspMsgVld", 2, 1 }, { "DBGIRspHit", 1, 1 }, { "DBGIRspValid", 0, 1 }, { "MC5_DB_DBGI_RSP_DATA0", 0x7b4, 0 }, { "MC5_DB_DBGI_RSP_DATA1", 0x7b8, 0 }, { "MC5_DB_DBGI_RSP_DATA2", 0x7bc, 0 }, { "MC5_DB_DBGI_RSP_DATA3", 0x7c0, 0 }, { "MC5_DB_DBGI_RSP_DATA4", 0x7c4, 0 }, { "DBGIRspData3", 0, 16 }, { "MC5_DB_DBGI_RSP_LAST_CMD", 0x7c8, 0 }, { "LastCmdB", 16, 11 }, { "LastCmdA", 0, 11 }, { "MC5_DB_POPEN_DATA_WR_CMD", 0x7cc, 0 }, { "PO_DWR", 0, 20 }, { "MC5_DB_POPEN_MASK_WR_CMD", 0x7d0, 0 }, { "PO_MWR", 0, 20 }, { "MC5_DB_AOPEN_SRCH_CMD", 0x7d4, 0 }, { "AO_SRCH", 0, 20 }, { "MC5_DB_AOPEN_LRN_CMD", 0x7d8, 0 }, { "AO_LRN", 0, 20 }, { "MC5_DB_SYN_SRCH_CMD", 0x7dc, 0 }, { "SYN_SRCH", 0, 20 }, { "MC5_DB_SYN_LRN_CMD", 0x7e0, 0 }, { "SYN_LRN", 0, 20 }, { "MC5_DB_ACK_SRCH_CMD", 0x7e4, 0 }, { "ACK_SRCH", 0, 20 }, { "MC5_DB_ACK_LRN_CMD", 0x7e8, 0 }, { "ACK_LRN", 0, 20 }, { "MC5_DB_ILOOKUP_CMD", 0x7ec, 0 }, { "I_SRCH", 0, 20 }, { "MC5_DB_ELOOKUP_CMD", 0x7f0, 0 }, { "E_SRCH", 0, 20 }, { "MC5_DB_DATA_WRITE_CMD", 0x7f4, 0 }, { "Write", 0, 20 }, { "MC5_DB_DATA_READ_CMD", 0x7f8, 0 }, { "ReadCmd", 0, 20 }, { "MC5_DB_MASK_WRITE_CMD", 0x7fc, 0 }, { "MaskWr", 0, 16 }, { NULL, 0, 0 } }; struct reg_info xgmac0_0_regs[] = { { "XGM_TX_CTRL", 0x800, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0x804, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0x808, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0x80c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0x810, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0x814, 0 }, { "XGM_RX_HASH_HIGH", 0x818, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0x81c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0x820, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0x824, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0x828, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0x82c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0x830, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0x834, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0x838, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0x83c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0x840, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0x844, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0x848, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0x84c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0x850, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0x854, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0x858, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0x85c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0x860, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0x864, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0x868, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0x86c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0x870, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0x874, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0x878, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0x87c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0x880, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0x884, 0 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0x888, 0 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0x88c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_SERDES_CTRL", 0x890, 0 }, { "SERDESEn", 25, 1 }, { "SERDESReset_", 24, 1 }, { "CMURange", 21, 3 }, { "BGEnb", 20, 1 }, { "EnSkpDrop", 19, 1 }, { "EnComma", 18, 1 }, { "En8B10B", 17, 1 }, { "EnElBuf", 16, 1 }, { "Gain", 11, 5 }, { "BandGap", 7, 4 }, { "LpbkEn", 5, 2 }, { "RxEn", 4, 1 }, { "TxEn", 3, 1 }, { "RxComAdj", 2, 1 }, { "PreEmph", 0, 2 }, { "XGM_XAUI_PCS_TEST", 0x894, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0x898, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0x89c, 0 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_XAUI_IMP", 0x8a0, 0 }, { "CalBusy", 31, 1 }, { "CalFault", 29, 1 }, { "CalImp", 24, 5 }, { "XAUIImp", 0, 3 }, { "XGM_SERDES_BIST", 0x8a4, 0 }, { "BISTDone", 28, 4 }, { "BISTCycleThresh", 3, 17 }, { "BISTMode", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0x8a8, 0 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0x8ac, 0 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0x8b0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0x8b4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0x8b8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0x8c0, 0 }, { "XGM_EPIO_DATA1", 0x8c4, 0 }, { "XGM_EPIO_DATA2", 0x8c8, 0 }, { "XGM_EPIO_DATA3", 0x8cc, 0 }, { "XGM_EPIO_OP", 0x8d0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0x8d4, 0 }, { "SERDESCMULock_loss", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBIST_err", 8, 4 }, { "SERDES_los", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0x8d8, 0 }, { "SERDESCMULock_loss", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBIST_err", 8, 4 }, { "SERDES_los", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0x900, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0x904, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0x908, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0x90c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0x910, 0 }, { "XGM_STAT_TX_MCAST", 0x914, 0 }, { "XGM_STAT_TX_PAUSE", 0x918, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0x91c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0x920, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0x924, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0x928, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0x92c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0x930, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0x934, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0x938, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0x93c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0x940, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0x944, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0x948, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0x94c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0x950, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0x954, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0x958, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0x95c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0x960, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0x964, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0x968, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0x96c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0x970, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0x974, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0x978, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0x97c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0x980, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0x984, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0x988, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_SERDES_STATUS0", 0x98c, 0 }, { "RxErrLane3", 9, 3 }, { "RxErrLane2", 6, 3 }, { "RxErrLane1", 3, 3 }, { "RxErrLane0", 0, 3 }, { "XGM_SERDES_STATUS1", 0x990, 0 }, { "CMULock", 31, 1 }, { "RxKLockLane3", 11, 1 }, { "RxKLockLane2", 10, 1 }, { "RxKLockLane1", 9, 1 }, { "RxKLockLane0", 8, 1 }, { "RxUFlowLane3", 7, 1 }, { "RxUFlowLane2", 6, 1 }, { "RxUFlowLane1", 5, 1 }, { "RxUFlowLane0", 4, 1 }, { "RxOFlowLane3", 3, 1 }, { "RxOFlowLane2", 2, 1 }, { "RxOFlowLane1", 1, 1 }, { "RxOFlowLane0", 0, 1 }, { "XGM_SERDES_STATUS2", 0x994, 0 }, { "RxEIDLane3", 11, 1 }, { "RxEIDLane2", 10, 1 }, { "RxEIDLane1", 9, 1 }, { "RxEIDLane0", 8, 1 }, { "RxRemSkipLane3", 7, 1 }, { "RxRemSkipLane2", 6, 1 }, { "RxRemSkipLane1", 5, 1 }, { "RxRemSkipLane0", 4, 1 }, { "RxAddSkipLane3", 3, 1 }, { "RxAddSkipLane2", 2, 1 }, { "RxAddSkipLane1", 1, 1 }, { "RxAddSkipLane0", 0, 1 }, { "XGM_XAUI_PCS_ERR", 0x998, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0x99c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0x9a0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0x9a4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0x9a8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0x9ac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; struct reg_info xgmac0_1_regs[] = { { "XGM_TX_CTRL", 0xa00, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0xa04, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0xa08, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0xa0c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0xa10, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0xa14, 0 }, { "XGM_RX_HASH_HIGH", 0xa18, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0xa1c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0xa20, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0xa24, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0xa28, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0xa2c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0xa30, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0xa34, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0xa38, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0xa3c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0xa40, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0xa44, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0xa48, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0xa4c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0xa50, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0xa54, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0xa58, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0xa5c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0xa60, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0xa64, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0xa68, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0xa6c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0xa70, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0xa74, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0xa78, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0xa7c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0xa80, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0xa84, 0 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0xa88, 0 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0xa8c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_SERDES_CTRL", 0xa90, 0 }, { "SERDESEn", 25, 1 }, { "SERDESReset_", 24, 1 }, { "CMURange", 21, 3 }, { "BGEnb", 20, 1 }, { "EnSkpDrop", 19, 1 }, { "EnComma", 18, 1 }, { "En8B10B", 17, 1 }, { "EnElBuf", 16, 1 }, { "Gain", 11, 5 }, { "BandGap", 7, 4 }, { "LpbkEn", 5, 2 }, { "RxEn", 4, 1 }, { "TxEn", 3, 1 }, { "RxComAdj", 2, 1 }, { "PreEmph", 0, 2 }, { "XGM_XAUI_PCS_TEST", 0xa94, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0xa98, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0xa9c, 0 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_XAUI_IMP", 0xaa0, 0 }, { "CalBusy", 31, 1 }, { "CalFault", 29, 1 }, { "CalImp", 24, 5 }, { "XAUIImp", 0, 3 }, { "XGM_SERDES_BIST", 0xaa4, 0 }, { "BISTDone", 28, 4 }, { "BISTCycleThresh", 3, 17 }, { "BISTMode", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0xaa8, 0 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0xaac, 0 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0xab0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0xab4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0xab8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0xac0, 0 }, { "XGM_EPIO_DATA1", 0xac4, 0 }, { "XGM_EPIO_DATA2", 0xac8, 0 }, { "XGM_EPIO_DATA3", 0xacc, 0 }, { "XGM_EPIO_OP", 0xad0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0xad4, 0 }, { "SERDESCMULock_loss", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBIST_err", 8, 4 }, { "SERDES_los", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0xad8, 0 }, { "SERDESCMULock_loss", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBIST_err", 8, 4 }, { "SERDES_los", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0xb00, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0xb04, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0xb08, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0xb0c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0xb10, 0 }, { "XGM_STAT_TX_MCAST", 0xb14, 0 }, { "XGM_STAT_TX_PAUSE", 0xb18, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0xb1c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0xb20, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0xb24, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0xb28, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0xb2c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0xb30, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0xb34, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0xb38, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0xb3c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0xb40, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0xb44, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0xb48, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0xb4c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0xb50, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0xb54, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0xb58, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0xb5c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0xb60, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0xb64, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0xb68, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0xb6c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0xb70, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0xb74, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0xb78, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0xb7c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0xb80, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0xb84, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0xb88, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_SERDES_STATUS0", 0xb8c, 0 }, { "RxErrLane3", 9, 3 }, { "RxErrLane2", 6, 3 }, { "RxErrLane1", 3, 3 }, { "RxErrLane0", 0, 3 }, { "XGM_SERDES_STATUS1", 0xb90, 0 }, { "CMULock", 31, 1 }, { "RxKLockLane3", 11, 1 }, { "RxKLockLane2", 10, 1 }, { "RxKLockLane1", 9, 1 }, { "RxKLockLane0", 8, 1 }, { "RxUFlowLane3", 7, 1 }, { "RxUFlowLane2", 6, 1 }, { "RxUFlowLane1", 5, 1 }, { "RxUFlowLane0", 4, 1 }, { "RxOFlowLane3", 3, 1 }, { "RxOFlowLane2", 2, 1 }, { "RxOFlowLane1", 1, 1 }, { "RxOFlowLane0", 0, 1 }, { "XGM_SERDES_STATUS2", 0xb94, 0 }, { "RxEIDLane3", 11, 1 }, { "RxEIDLane2", 10, 1 }, { "RxEIDLane1", 9, 1 }, { "RxEIDLane0", 8, 1 }, { "RxRemSkipLane3", 7, 1 }, { "RxRemSkipLane2", 6, 1 }, { "RxRemSkipLane1", 5, 1 }, { "RxRemSkipLane0", 4, 1 }, { "RxAddSkipLane3", 3, 1 }, { "RxAddSkipLane2", 2, 1 }, { "RxAddSkipLane1", 1, 1 }, { "RxAddSkipLane0", 0, 1 }, { "XGM_XAUI_PCS_ERR", 0xb98, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0xb9c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0xba0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0xba4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0xba8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0xbac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; diff --git a/tools/tools/cxgbtool/reg_defs_t3b.c b/tools/tools/cxgbtool/reg_defs_t3b.c index cd85d840a1dd..31942e335ebc 100644 --- a/tools/tools/cxgbtool/reg_defs_t3b.c +++ b/tools/tools/cxgbtool/reg_defs_t3b.c @@ -1,2832 +1,2831 @@ /* - * $FreeBSD$ */ /* This file is automatically generated --- do not edit */ struct reg_info t3b_sge3_regs[] = { { "SG_CONTROL", 0x0, 0 }, { "UrgTnl", 26, 1 }, { "NewNotify", 25, 1 }, { "AvoidCqOvfl", 24, 1 }, { "OptOneIntMultQ", 23, 1 }, { "CQCrdtCtrl", 22, 1 }, { "EgrEnUpBp", 21, 1 }, { "DropPkt", 20, 1 }, { "EgrGenCtrl", 19, 1 }, { "UserSpaceSize", 14, 5 }, { "HostPageSize", 11, 3 }, { "PCIRelax", 10, 1 }, { "FLMode", 9, 1 }, { "PktShift", 6, 3 }, { "OneIntMultQ", 5, 1 }, { "FLPickAvail", 4, 1 }, { "BigEndianEgress", 3, 1 }, { "BigEndianIngress", 2, 1 }, { "IscsiCoalescing", 1, 1 }, { "GlobalEnable", 0, 1 }, { "SG_KDOORBELL", 0x4, 0 }, { "SelEgrCntx", 31, 1 }, { "EgrCntx", 0, 16 }, { "SG_GTS", 0x8, 0 }, { "RspQ", 29, 3 }, { "NewTimer", 16, 13 }, { "NewIndex", 0, 16 }, { "SG_CONTEXT_CMD", 0xc, 0 }, { "Opcode", 28, 4 }, { "Busy", 27, 1 }, { "CQ_credit", 20, 7 }, { "CQ", 19, 1 }, { "RspQ", 18, 1 }, { "Egress", 17, 1 }, { "FreeList", 16, 1 }, { "Context", 0, 16 }, { "SG_CONTEXT_DATA0", 0x10, 0 }, { "SG_CONTEXT_DATA1", 0x14, 0 }, { "SG_CONTEXT_DATA2", 0x18, 0 }, { "SG_CONTEXT_DATA3", 0x1c, 0 }, { "SG_CONTEXT_MASK0", 0x20, 0 }, { "SG_CONTEXT_MASK1", 0x24, 0 }, { "SG_CONTEXT_MASK2", 0x28, 0 }, { "SG_CONTEXT_MASK3", 0x2c, 0 }, { "SG_RSPQ_CREDIT_RETURN", 0x30, 0 }, { "RspQ", 29, 3 }, { "Data", 0, 16 }, { "SG_DATA_INTR", 0x34, 0 }, { "ErrIntr", 31, 1 }, { "DataIntr", 0, 8 }, { "SG_HI_DRB_HI_THRSH", 0x38, 0 }, { "HiDrbHiThrsh", 0, 10 }, { "SG_HI_DRB_LO_THRSH", 0x3c, 0 }, { "HiDrbLoThrsh", 0, 10 }, { "SG_LO_DRB_HI_THRSH", 0x40, 0 }, { "LoDrbHiThrsh", 0, 10 }, { "SG_LO_DRB_LO_THRSH", 0x44, 0 }, { "LoDrbLoThrsh", 0, 10 }, { "SG_ONE_INT_MULT_Q_COALESCING_TIMER", 0x48, 0 }, { "SG_RSPQ_FL_STATUS", 0x4c, 0 }, { "RspQ0Starved", 0, 1 }, { "RspQ1Starved", 1, 1 }, { "RspQ2Starved", 2, 1 }, { "RspQ3Starved", 3, 1 }, { "RspQ4Starved", 4, 1 }, { "RspQ5Starved", 5, 1 }, { "RspQ6Starved", 6, 1 }, { "RspQ7Starved", 7, 1 }, { "RspQ0Disabled", 8, 1 }, { "RspQ1Disabled", 9, 1 }, { "RspQ2Disabled", 10, 1 }, { "RspQ3Disabled", 11, 1 }, { "RspQ4Disabled", 12, 1 }, { "RspQ5Disabled", 13, 1 }, { "RspQ6Disabled", 14, 1 }, { "RspQ7Disabled", 15, 1 }, { "FL0Empty", 16, 1 }, { "FL1Empty", 17, 1 }, { "FL2Empty", 18, 1 }, { "FL3Empty", 19, 1 }, { "FL4Empty", 20, 1 }, { "FL5Empty", 21, 1 }, { "FL6Empty", 22, 1 }, { "FL7Empty", 23, 1 }, { "FL8Empty", 24, 1 }, { "FL9Empty", 25, 1 }, { "FL10Empty", 26, 1 }, { "FL11Empty", 27, 1 }, { "FL12Empty", 28, 1 }, { "FL13Empty", 29, 1 }, { "FL14Empty", 30, 1 }, { "FL15Empty", 31, 1 }, { "SG_EGR_PRI_CNT", 0x50, 0 }, { "EgrErrOpCode", 24, 8 }, { "EgrHiOpCode", 16, 8 }, { "EgrLoOpCode", 8, 8 }, { "EgrPriCnt", 0, 5 }, { "SG_EGR_RCQ_DRB_THRSH", 0x54, 0 }, { "HiRcqDrbThrsh", 16, 11 }, { "LoRcqDrbThrsh", 0, 11 }, { "SG_EGR_CNTX_BADDR", 0x58, 0 }, { "EgrCntxBAddr", 5, 27 }, { "SG_INT_CAUSE", 0x5c, 0 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_INT_ENABLE", 0x60, 0 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_CMDQ_CREDIT_TH", 0x64, 0 }, { "Timeout", 8, 24 }, { "Threshold", 0, 8 }, { "SG_TIMER_TICK", 0x68, 0 }, { "SG_CQ_CONTEXT_BADDR", 0x6c, 0 }, { "baseAddr", 5, 27 }, { "SG_OCO_BASE", 0x70, 0 }, { "Base1", 16, 16 }, { "Base0", 0, 16 }, { "SG_DRB_PRI_THRESH", 0x74, 0 }, { "DrbPriThrsh", 0, 16 }, { "SG_DEBUG_INDEX", 0x78, 0 }, { "SG_DEBUG_DATA", 0x7c, 0 }, { NULL, 0, 0 } }; struct reg_info t3b_pcix1_regs[] = { { "PCIX_INT_ENABLE", 0x80, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_INT_CAUSE", 0x84, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_CFG", 0x88, 0 }, { "CLIDecEn", 18, 1 }, { "LatTmrDis", 17, 1 }, { "LowPwrEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 8, 3 }, { "MaxSplTrnR", 5, 3 }, { "MaxWrByteCnt", 3, 2 }, { "WrReqAtomicEn", 2, 1 }, { "CRstWrmMode", 1, 1 }, { "PIOAck64En", 0, 1 }, { "PCIX_MODE", 0x8c, 0 }, { "PClkRange", 6, 2 }, { "PCIXInitPat", 2, 4 }, { "66MHz", 1, 1 }, { "64Bit", 0, 1 }, { "PCIX_CAL", 0x90, 0 }, { "Busy", 31, 1 }, { "PerCalDiv", 22, 8 }, { "PerCalEn", 21, 1 }, { "SglCalEn", 20, 1 }, { "ZInUpdMode", 19, 1 }, { "ZInSel", 18, 1 }, { "ZPDMan", 15, 3 }, { "ZPUMan", 12, 3 }, { "ZPDOut", 9, 3 }, { "ZPUOut", 6, 3 }, { "ZPDIn", 3, 3 }, { "ZPUIn", 0, 3 }, { "PCIX_WOL", 0x94, 0 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_pcie0_regs[] = { { "PCIE_INT_ENABLE", 0x80, 0 }, { "BISTErr", 15, 8 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_INT_CAUSE", 0x84, 0 }, { "BISTErr", 15, 8 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_CFG", 0x88, 0 }, { "PriorityINTA", 23, 1 }, { "IniFullPkt", 22, 1 }, { "EnableLinkDwnDRst", 21, 1 }, { "EnableLinkDownRst", 20, 1 }, { "EnableHotRst", 19, 1 }, { "IniWaitForGnt", 18, 1 }, { "IniBEDis", 17, 1 }, { "CLIDecEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 7, 4 }, { "MaxSplTrnR", 1, 6 }, { "CRstWrmMode", 0, 1 }, { "PCIE_MODE", 0x8c, 0 }, { "NumFstTrnSeqRx", 10, 8 }, { "LnkCntlState", 2, 8 }, { "VC0Up", 1, 1 }, { "LnkInitial", 0, 1 }, { "PCIE_WOL", 0x94, 0 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { "PCIE_PEX_CTRL0", 0x98, 0 }, { "CplTimeoutRetry", 31, 1 }, { "StrictTSMN", 30, 1 }, { "NumFstTrnSeq", 22, 8 }, { "ReplayLmt", 2, 20 }, { "TxPndChkEn", 1, 1 }, { "CplPndChkEn", 0, 1 }, { "PCIE_PEX_CTRL1", 0x9c, 0 }, { "RxPhyErrEn", 31, 1 }, { "DLLPTimeoutLmt", 13, 18 }, { "AckLat", 0, 13 }, { "PCIE_PEX_CTRL2", 0xa0, 0 }, { "LnkCntlDetDir", 30, 1 }, { "EnterL1rEn", 29, 1 }, { "PMExitL1Req", 28, 1 }, { "PMTxIdle", 27, 1 }, { "PCIModeLoop", 26, 1 }, { "L1ASPMTxRxL0sTime", 14, 12 }, { "L0sIdleTime", 3, 11 }, { "EnterL1ASPMEn", 2, 1 }, { "EnterL1En", 1, 1 }, { "EnterL0sEn", 0, 1 }, { "PCIE_PEX_ERR", 0xa4, 0 }, { "CplTimeoutID", 18, 7 }, { "FlowCtlOFlowErr", 17, 1 }, { "ReplayTimeout", 16, 1 }, { "ReplayRollover", 15, 1 }, { "BadDLLP", 14, 1 }, { "DLLPErr", 13, 1 }, { "FlowCtlProtErr", 12, 1 }, { "CplTimeout", 11, 1 }, { "PHYRcvErr", 10, 1 }, { "DisTLP", 9, 1 }, { "BadECRC", 8, 1 }, { "BadTLP", 7, 1 }, { "MalTLP", 6, 1 }, { "UnxCpl", 5, 1 }, { "UnsReq", 4, 1 }, { "PsnReq", 3, 1 }, { "UnsCpl", 2, 1 }, { "CplAbt", 1, 1 }, { "PsnCpl", 0, 1 }, { "PCIE_SERDES_CTRL", 0xa8, 0 }, { "PMASel", 3, 1 }, { "Lane", 0, 3 }, { "PCIE_SERDES_QUAD_CTRL0", 0xac, 0 }, { "TestSig", 10, 19 }, { "Offset", 2, 8 }, { "OffsetEn", 1, 1 }, { "IDDQb", 0, 1 }, { "PCIE_SERDES_QUAD_CTRL1", 0xb0, 0 }, { "FastInit", 28, 1 }, { "CTCDisable", 27, 1 }, { "ManResetPLL", 26, 1 }, { "ManL2Pwrdn", 25, 1 }, { "ManQuadEn", 24, 1 }, { "RxEqCtl", 22, 2 }, { "HiVMode", 21, 1 }, { "RefSel", 19, 2 }, { "RxTermAdj", 17, 2 }, { "TxTermAdj", 15, 2 }, { "Deq", 11, 4 }, { "Dtx", 7, 4 }, { "LoDrv", 6, 1 }, { "HiDrv", 5, 1 }, { "IntParReset", 4, 1 }, { "IntParLPBK", 3, 1 }, { "IntSerLPBKwDrv", 2, 1 }, { "PW", 1, 1 }, { "PClkDetect", 0, 1 }, { "PCIE_SERDES_LANE_CTRL", 0xb4, 0 }, { "ExtBISTChkErrClr", 22, 1 }, { "ExtBISTChkEn", 21, 1 }, { "ExtBISTGenEn", 20, 1 }, { "ExtBISTPat", 17, 3 }, { "ExtParReset", 16, 1 }, { "ExtParLPBK", 15, 1 }, { "ManRxTermEn", 14, 1 }, { "ManBeaconTxEn", 13, 1 }, { "ManRxDetectEn", 12, 1 }, { "ManTxIdleEn", 11, 1 }, { "ManRxIdleEn", 10, 1 }, { "ManL1Pwrdn", 9, 1 }, { "ManReset", 8, 1 }, { "ManFmOffset", 3, 5 }, { "ManFmOffsetEn", 2, 1 }, { "ManLaneEn", 1, 1 }, { "IntSerLPBK", 0, 1 }, { "PCIE_SERDES_LANE_STAT", 0xb8, 0 }, { "ExtBISTChkErrCnt", 8, 24 }, { "ExtBISTChkFmd", 7, 1 }, { "BeaconDetectChg", 6, 1 }, { "RxDetectChg", 5, 1 }, { "TxIdleDetectChg", 4, 1 }, { "BeaconDetect", 2, 1 }, { "RxDetect", 1, 1 }, { "TxIdleDetect", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_t3dbg_regs[] = { { "T3DBG_DBG0_CFG", 0xc0, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG0_EN", 0xc4, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_DBG1_CFG", 0xc8, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG1_EN", 0xcc, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_GPIO_EN", 0xd0, 0 }, { "GPIO11_OEn", 27, 1 }, { "GPIO10_OEn", 26, 1 }, { "GPIO9_OEn", 25, 1 }, { "GPIO8_OEn", 24, 1 }, { "GPIO7_OEn", 23, 1 }, { "GPIO6_OEn", 22, 1 }, { "GPIO5_OEn", 21, 1 }, { "GPIO4_OEn", 20, 1 }, { "GPIO3_OEn", 19, 1 }, { "GPIO2_OEn", 18, 1 }, { "GPIO1_OEn", 17, 1 }, { "GPIO0_OEn", 16, 1 }, { "GPIO11_Out_Val", 11, 1 }, { "GPIO10_Out_Val", 10, 1 }, { "GPIO9_Out_Val", 9, 1 }, { "GPIO8_Out_Val", 8, 1 }, { "GPIO7_Out_Val", 7, 1 }, { "GPIO6_Out_Val", 6, 1 }, { "GPIO5_Out_Val", 5, 1 }, { "GPIO4_Out_Val", 4, 1 }, { "GPIO3_Out_Val", 3, 1 }, { "GPIO2_Out_Val", 2, 1 }, { "GPIO1_Out_Val", 1, 1 }, { "GPIO0_Out_Val", 0, 1 }, { "T3DBG_GPIO_IN", 0xd4, 0 }, { "GPIO11_CHG_DET", 27, 1 }, { "GPIO10_CHG_DET", 26, 1 }, { "GPIO9_CHG_DET", 25, 1 }, { "GPIO8_CHG_DET", 24, 1 }, { "GPIO7_CHG_DET", 23, 1 }, { "GPIO6_CHG_DET", 22, 1 }, { "GPIO5_CHG_DET", 21, 1 }, { "GPIO4_CHG_DET", 20, 1 }, { "GPIO3_CHG_DET", 19, 1 }, { "GPIO2_CHG_DET", 18, 1 }, { "GPIO1_CHG_DET", 17, 1 }, { "GPIO0_CHG_DET", 16, 1 }, { "GPIO11_IN", 11, 1 }, { "GPIO10_IN", 10, 1 }, { "GPIO9_IN", 9, 1 }, { "GPIO8_IN", 8, 1 }, { "GPIO7_IN", 7, 1 }, { "GPIO6_IN", 6, 1 }, { "GPIO5_IN", 5, 1 }, { "GPIO4_IN", 4, 1 }, { "GPIO3_IN", 3, 1 }, { "GPIO2_IN", 2, 1 }, { "GPIO1_IN", 1, 1 }, { "GPIO0_IN", 0, 1 }, { "T3DBG_INT_ENABLE", 0xd8, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_INT_CAUSE", 0xdc, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_DBG0_RST_VALUE", 0xe0, 0 }, { "DebugData", 0, 8 }, { "T3DBG_PLL_OCLK_PAD_EN", 0xe4, 0 }, { "PCIE_OCLK_En", 20, 1 }, { "PClkTree_DBG_En", 17, 1 }, { "PCIX_OCLK_En", 16, 1 }, { "U_OCLK_En", 12, 1 }, { "R_OCLK_En", 8, 1 }, { "M_OCLK_En", 4, 1 }, { "C_OCLK_En", 0, 1 }, { "T3DBG_PLL_LOCK", 0xe8, 0 }, { "PCIX_LOCK", 16, 1 }, { "U_LOCK", 12, 1 }, { "R_LOCK", 8, 1 }, { "M_LOCK", 4, 1 }, { "C_LOCK", 0, 1 }, { "T3DBG_SERDES_RBC_CFG", 0xec, 0 }, { "X_RBC_Lane_Sel", 16, 2 }, { "X_RBC_Dbg_En", 12, 1 }, { "X_Serdes_Sel", 8, 1 }, { "PE_RBC_Lane_Sel", 4, 3 }, { "PE_RBC_Dbg_En", 0, 1 }, { "T3DBG_GPIO_ACT_LOW", 0xf0, 0 }, { "C_LOCK_ACT_LOW", 21, 1 }, { "M_LOCK_ACT_LOW", 20, 1 }, { "U_LOCK_ACT_LOW", 19, 1 }, { "R_LOCK_ACT_LOW", 18, 1 }, { "PX_LOCK_ACT_LOW", 17, 1 }, { "GPIO11_ACT_LOW", 11, 1 }, { "GPIO10_ACT_LOW", 10, 1 }, { "GPIO9_ACT_LOW", 9, 1 }, { "GPIO8_ACT_LOW", 8, 1 }, { "GPIO7_ACT_LOW", 7, 1 }, { "GPIO6_ACT_LOW", 6, 1 }, { "GPIO5_ACT_LOW", 5, 1 }, { "GPIO4_ACT_LOW", 4, 1 }, { "GPIO3_ACT_LOW", 3, 1 }, { "GPIO2_ACT_LOW", 2, 1 }, { "GPIO1_ACT_LOW", 1, 1 }, { "GPIO0_ACT_LOW", 0, 1 }, { "T3DBG_PMON_CFG", 0xf4, 0 }, { "PMON_DONE", 29, 1 }, { "PMON_FAIL", 28, 1 }, { "PMON_FDEL_AUTO", 22, 6 }, { "PMON_CDEL_AUTO", 16, 6 }, { "PMON_FDEL_MANUAL", 10, 6 }, { "PMON_CDEL_MANUAL", 4, 6 }, { "PMON_MANUAL", 1, 1 }, { "PMON_AUTO", 0, 1 }, { "T3DBG_SERDES_REFCLK_CFG", 0xf8, 0 }, { "PE_REFCLK_DBG_EN", 12, 1 }, { "X_REFCLK_DBG_EN", 8, 1 }, { "PE_REFCLK_TERMADJ", 5, 2 }, { "PE_REFCLK_PD", 4, 1 }, { "X_REFCLK_TERMADJ", 1, 2 }, { "X_REFCLK_PD", 0, 1 }, { "T3DBG_PCIE_PMA_BSPIN_CFG", 0xfc, 0 }, { "BSModeQuad1", 31, 1 }, { "BSInSelLane7", 29, 2 }, { "BSEnLane7", 28, 1 }, { "BSInSelLane6", 25, 2 }, { "BSEnLane6", 24, 1 }, { "BSInSelLane5", 21, 2 }, { "BSEnLane5", 20, 1 }, { "BSInSelLane4", 17, 2 }, { "BSEnLane4", 16, 1 }, { "BSModeQuad0", 15, 1 }, { "BSInSelLane3", 13, 2 }, { "BSEnLane3", 12, 1 }, { "BSInSelLane2", 9, 2 }, { "BSEnLane2", 8, 1 }, { "BSInSelLane1", 5, 2 }, { "BSEnLane1", 4, 1 }, { "BSInSelLane0", 1, 2 }, { "BSEnLane0", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_mc7_pmrx_regs[] = { { "MC7_CFG", 0x100, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x104, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x108, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x10c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x110, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x114, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x118, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x11c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x120, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x124, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x128, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x12c, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x130, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x134, 0 }, { "MC7_CE_DATA0", 0x138, 0 }, { "MC7_CE_DATA1", 0x13c, 0 }, { "MC7_CE_DATA2", 0x140, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x144, 0 }, { "MC7_UE_DATA0", 0x148, 0 }, { "MC7_UE_DATA1", 0x14c, 0 }, { "MC7_UE_DATA2", 0x150, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x154, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x158, 0 }, { "MC7_BD_DATA1", 0x15c, 0 }, { "MC7_BD_DATA2", 0x160, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x164, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x168, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x16c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x170, 0 }, { "MC7_BIST_OP", 0x174, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x178, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x17c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_mc7_pmtx_regs[] = { { "MC7_CFG", 0x180, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x184, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x188, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x18c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x190, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x194, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x198, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x19c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x1a0, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x1a4, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x1a8, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x1ac, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x1b0, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x1b4, 0 }, { "MC7_CE_DATA0", 0x1b8, 0 }, { "MC7_CE_DATA1", 0x1bc, 0 }, { "MC7_CE_DATA2", 0x1c0, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x1c4, 0 }, { "MC7_UE_DATA0", 0x1c8, 0 }, { "MC7_UE_DATA1", 0x1cc, 0 }, { "MC7_UE_DATA2", 0x1d0, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x1d4, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x1d8, 0 }, { "MC7_BD_DATA1", 0x1dc, 0 }, { "MC7_BD_DATA2", 0x1e0, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x1e4, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x1e8, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x1ec, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x1f0, 0 }, { "MC7_BIST_OP", 0x1f4, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x1f8, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x1fc, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_mc7_cm_regs[] = { { "MC7_CFG", 0x200, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x204, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x208, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x20c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x210, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x214, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x218, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x21c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x220, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x224, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x228, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x22c, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x230, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x234, 0 }, { "MC7_CE_DATA0", 0x238, 0 }, { "MC7_CE_DATA1", 0x23c, 0 }, { "MC7_CE_DATA2", 0x240, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x244, 0 }, { "MC7_UE_DATA0", 0x248, 0 }, { "MC7_UE_DATA1", 0x24c, 0 }, { "MC7_UE_DATA2", 0x250, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x254, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x258, 0 }, { "MC7_BD_DATA1", 0x25c, 0 }, { "MC7_BD_DATA2", 0x260, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x264, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x268, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x26c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x270, 0 }, { "MC7_BIST_OP", 0x274, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x278, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x27c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_cim_regs[] = { { "CIM_BOOT_CFG", 0x280, 0 }, { "BootAddr", 2, 30 }, { "BootSdram", 1, 1 }, { "uPCRst", 0, 1 }, { "CIM_FLASH_BASE_ADDR", 0x284, 0 }, { "FlashBaseAddr", 2, 22 }, { "CIM_FLASH_ADDR_SIZE", 0x288, 0 }, { "FlashAddrSize", 2, 22 }, { "CIM_SDRAM_BASE_ADDR", 0x28c, 0 }, { "SdramBaseAddr", 2, 30 }, { "CIM_SDRAM_ADDR_SIZE", 0x290, 0 }, { "SdramAddrSize", 2, 30 }, { "CIM_UP_SPARE_INT", 0x294, 0 }, { "uPSpareInt", 0, 3 }, { "CIM_HOST_INT_ENABLE", 0x298, 0 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_HOST_INT_CAUSE", 0x29c, 0 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_UP_INT_ENABLE", 0x2a0, 0 }, { "MstPlIntEn", 16, 1 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_UP_INT_CAUSE", 0x2a4, 0 }, { "MstPlInt", 16, 1 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_IBQ_FULLA_THRSH", 0x2a8, 0 }, { "Ibq0FullThrsh", 0, 9 }, { "Ibq1FullThrsh", 16, 9 }, { "CIM_IBQ_FULLB_THRSH", 0x2ac, 0 }, { "Ibq2FullThrsh", 0, 9 }, { "Ibq3FullThrsh", 16, 9 }, { "CIM_HOST_ACC_CTRL", 0x2b0, 0 }, { "HostBusy", 17, 1 }, { "HostWrite", 16, 1 }, { "HostAddr", 0, 16 }, { "CIM_HOST_ACC_DATA", 0x2b4, 0 }, { "CIM_IBQ_DBG_CFG", 0x2c0, 0 }, { "IbqDbgAddr", 16, 9 }, { "IbqDbgQID", 3, 2 }, { "IbqDbgWr", 2, 1 }, { "IbqDbgBusy", 1, 1 }, { "IbqDbgEn", 0, 1 }, { "CIM_OBQ_DBG_CFG", 0x2c4, 0 }, { "ObqDbgAddr", 16, 9 }, { "ObqDbgQID", 3, 2 }, { "ObqDbgWr", 2, 1 }, { "ObqDbgBusy", 1, 1 }, { "ObqDbgEn", 0, 1 }, { "CIM_IBQ_DBG_DATA", 0x2c8, 0 }, { "CIM_OBQ_DBG_DATA", 0x2cc, 0 }, { "CIM_CDEBUGDATA", 0x2d0, 0 }, { "CDebugDataH", 16, 16 }, { "CDebugDataL", 0, 16 }, { "CIM_DEBUGCFG", 0x2e0, 0 }, { "POLADbgRdPtr", 23, 9 }, { "PILADbgRdPtr", 14, 9 }, { "LADbgEn", 12, 1 }, { "DebugSelH", 5, 5 }, { "DebugSelL", 0, 5 }, { "CIM_DEBUGSTS", 0x2e4, 0 }, { "POLADbgWrPtr", 16, 9 }, { "PILADbgWrPtr", 0, 9 }, { "CIM_PO_LA_DEBUGDATA", 0x2e8, 0 }, { "CIM_PI_LA_DEBUGDATA", 0x2ec, 0 }, { NULL, 0, 0 } }; struct reg_info t3b_tp1_regs[] = { { "TP_IN_CONFIG", 0x300, 0 }, { "RXFbArbPrio", 25, 1 }, { "TXFbArbPrio", 24, 1 }, { "DBMaxOpCnt", 16, 8 }, { "IPv6Enable", 15, 1 }, { "NICMode", 14, 1 }, { "EChecksumCheckTCP", 13, 1 }, { "EChecksumCheckIP", 12, 1 }, { "ECPL", 10, 1 }, { "EEthernet", 8, 1 }, { "ETunnel", 7, 1 }, { "CChecksumCheckTCP", 6, 1 }, { "CChecksumCheckIP", 5, 1 }, { "CCPL", 3, 1 }, { "CEthernet", 1, 1 }, { "CTunnel", 0, 1 }, { "TP_OUT_CONFIG", 0x304, 0 }, { "IPIDSplitMode", 16, 1 }, { "VLANExtractionEnable2ndPort", 13, 1 }, { "VLANExtractionEnable", 12, 1 }, { "EChecksumGenerateTCP", 11, 1 }, { "EChecksumGenerateIP", 10, 1 }, { "ECPL", 8, 1 }, { "EEthernet", 6, 1 }, { "CChecksumGenerateTCP", 5, 1 }, { "CChecksumGenerateIP", 4, 1 }, { "CCPL", 2, 1 }, { "CEthernet", 0, 1 }, { "TP_GLOBAL_CONFIG", 0x308, 0 }, { "SYNCookieParams", 26, 6 }, { "RXFlowControlDisable", 25, 1 }, { "TXPacingEnable", 24, 1 }, { "AttackFilterEnable", 23, 1 }, { "SYNCookieNoOptions", 22, 1 }, { "ProtectedMode", 21, 1 }, { "PingDrop", 20, 1 }, { "FragmentDrop", 19, 1 }, { "FiveTupleLookup", 17, 2 }, { "PathMTU", 15, 1 }, { "IPIdentSplit", 14, 1 }, { "IPChecksumOffload", 13, 1 }, { "UDPChecksumOffload", 12, 1 }, { "TCPChecksumOffload", 11, 1 }, { "QOSMapping", 10, 1 }, { "TCAMServerUse", 8, 2 }, { "IPTTL", 0, 8 }, { "TP_GLOBAL_RX_CREDIT", 0x30c, 0 }, { "TP_CMM_SIZE", 0x310, 0 }, { "CMMemMgrSize", 0, 28 }, { "TP_CMM_MM_BASE", 0x314, 0 }, { "CMMemMgrBase", 0, 28 }, { "TP_CMM_TIMER_BASE", 0x318, 0 }, { "CMTimerMaxNum", 28, 2 }, { "CMTimerBase", 0, 28 }, { "TP_PMM_SIZE", 0x31c, 0 }, { "PMSize", 0, 28 }, { "TP_PMM_TX_BASE", 0x320, 0 }, { "TP_PMM_DEFRAG_BASE", 0x324, 0 }, { "TP_PMM_RX_BASE", 0x328, 0 }, { "TP_PMM_RX_PAGE_SIZE", 0x32c, 0 }, { "TP_PMM_RX_MAX_PAGE", 0x330, 0 }, { "PMRxMaxPage", 0, 21 }, { "TP_PMM_TX_PAGE_SIZE", 0x334, 0 }, { "TP_PMM_TX_MAX_PAGE", 0x338, 0 }, { "PMTxMaxPage", 0, 21 }, { "TP_TCP_OPTIONS", 0x340, 0 }, { "MTUDefault", 16, 16 }, { "MTUEnable", 10, 1 }, { "SACKTx", 9, 1 }, { "SACKRx", 8, 1 }, { "SACKMode", 4, 2 }, { "WindowScaleMode", 2, 2 }, { "TimestampsMode", 0, 2 }, { "TP_DACK_CONFIG", 0x344, 0 }, { "AutoState3", 30, 2 }, { "AutoState2", 28, 2 }, { "AutoState1", 26, 2 }, { "ByteThreshold", 5, 20 }, { "MSSThreshold", 3, 2 }, { "AutoCareful", 2, 1 }, { "AutoEnable", 1, 1 }, { "Mode", 0, 1 }, { "TP_PC_CONFIG", 0x348, 0 }, { "CMCacheDisable", 31, 1 }, { "EnableOcspiFull", 30, 1 }, { "EnableFLMErrorDDP", 29, 1 }, { "LockTid", 28, 1 }, { "FixRcvWnd", 27, 1 }, { "TxTosQueueMapMode", 26, 1 }, { "RddpCongEn", 25, 1 }, { "EnableOnFlyPDU", 24, 1 }, { "EnableEPCMDAFull", 23, 1 }, { "ModulateUnionMode", 22, 1 }, { "TxDataAckRateEnable", 21, 1 }, { "TxDeferEnable", 20, 1 }, { "RxCongestionMode", 19, 1 }, { "HearbeatOnceDACK", 18, 1 }, { "HearbeatOnceHeap", 17, 1 }, { "HearbeatDACK", 16, 1 }, { "TxCongestionMode", 15, 1 }, { "AcceptLatestRcvAdv", 14, 1 }, { "DisableSYNData", 13, 1 }, { "DisableWindowPSH", 12, 1 }, { "DisableFINOldData", 11, 1 }, { "EnableFLMError", 10, 1 }, { "DisableNextMtu", 9, 1 }, { "FilterPeerFIN", 8, 1 }, { "EnableFeedbackSend", 7, 1 }, { "EnableRDMAError", 6, 1 }, { "EnableDDPFlowControl", 5, 1 }, { "DisableHeldFIN", 4, 1 }, { "TableLatencyDelta", 0, 4 }, { "TP_PC_CONFIG2", 0x34c, 0 }, { "EnableDropRQEmptyPkt", 10, 1 }, { "EnableTxPortfromDA2", 9, 1 }, { "EnableRxPktTmstpRss", 8, 1 }, { "EnableSndUnaInRxData", 7, 1 }, { "EnableRxPortFromAddr", 6, 1 }, { "EnableTxPortfromDA", 5, 1 }, { "CHdrAFull", 4, 1 }, { "EnableNonOfdScbBit", 3, 1 }, { "EnableNonOfdTidRss", 2, 1 }, { "EnableNonOfdTcbRss", 1, 1 }, { "EnableOldRxForward", 0, 1 }, { "TP_TCP_BACKOFF_REG0", 0x350, 0 }, { "TimerBackoffIndex3", 24, 8 }, { "TimerBackoffIndex2", 16, 8 }, { "TimerBackoffIndex1", 8, 8 }, { "TimerBackoffIndex0", 0, 8 }, { "TP_TCP_BACKOFF_REG1", 0x354, 0 }, { "TimerBackoffIndex7", 24, 8 }, { "TimerBackoffIndex6", 16, 8 }, { "TimerBackoffIndex5", 8, 8 }, { "TimerBackoffIndex4", 0, 8 }, { "TP_TCP_BACKOFF_REG2", 0x358, 0 }, { "TimerBackoffIndex11", 24, 8 }, { "TimerBackoffIndex10", 16, 8 }, { "TimerBackoffIndex9", 8, 8 }, { "TimerBackoffIndex8", 0, 8 }, { "TP_TCP_BACKOFF_REG3", 0x35c, 0 }, { "TimerBackoffIndex15", 24, 8 }, { "TimerBackoffIndex14", 16, 8 }, { "TimerBackoffIndex13", 8, 8 }, { "TimerBackoffIndex12", 0, 8 }, { "TP_PARA_REG0", 0x360, 0 }, { "InitCwnd", 24, 3 }, { "DupAckThresh", 20, 4 }, { "TP_PARA_REG1", 0x364, 0 }, { "InitRwnd", 16, 16 }, { "InitialSSThresh", 0, 16 }, { "TP_PARA_REG2", 0x368, 0 }, { "MaxRxData", 16, 16 }, { "RxCoalesceSize", 0, 16 }, { "TP_PARA_REG3", 0x36c, 0 }, { "TunnelCngDrop1", 21, 1 }, { "TunnelCngDrop0", 20, 1 }, { "TxDataAckIdx", 16, 4 }, { "RxFragEnable", 12, 3 }, { "TxPaceFixedStrict", 11, 1 }, { "TxPaceAutoStrict", 10, 1 }, { "TxPaceFixed", 9, 1 }, { "TxPaceAuto", 8, 1 }, { "RxUrgTunnel", 6, 1 }, { "RxUrgMode", 5, 1 }, { "TxUrgMode", 4, 1 }, { "CngCtrlMode", 2, 2 }, { "RxCoalesceEnable", 1, 1 }, { "RxCoalescePshEn", 0, 1 }, { "TP_PARA_REG4", 0x370, 0 }, { "HighSpeedCfg", 24, 8 }, { "NewRenoCfg", 16, 8 }, { "TahoeCfg", 8, 8 }, { "RenoCfg", 0, 8 }, { "TP_PARA_REG5", 0x374, 0 }, { "IndicateSize", 16, 16 }, { "SchdEnable", 8, 1 }, { "OnFlyDDPEnable", 2, 1 }, { "DackTimerSpin", 1, 1 }, { "PushTimerEnable", 0, 1 }, { "TP_PARA_REG6", 0x378, 0 }, { "TxPDUSizeAdj", 16, 8 }, { "EnableDeferACK", 12, 1 }, { "EnableESnd", 11, 1 }, { "EnableCSnd", 10, 1 }, { "EnablePDUE", 9, 1 }, { "EnablePDUC", 8, 1 }, { "EnableBUFI", 7, 1 }, { "EnableBUFE", 6, 1 }, { "EnableDefer", 5, 1 }, { "EnableClearRxmtOos", 4, 1 }, { "DisablePDUCng", 3, 1 }, { "DisablePDUTimeout", 2, 1 }, { "DisablePDURxmt", 1, 1 }, { "DisablePDUxmt", 0, 1 }, { "TP_PARA_REG7", 0x37c, 0 }, { "PMMaxXferLen1", 16, 16 }, { "PMMaxXferLen0", 0, 16 }, { "TP_TIMER_RESOLUTION", 0x390, 0 }, { "TimerResolution", 16, 8 }, { "TimestampResolution", 8, 8 }, { "DelayedACKResolution", 0, 8 }, { "TP_MSL", 0x394, 0 }, { "MSL", 0, 30 }, { "TP_RXT_MIN", 0x398, 0 }, { "RxtMin", 0, 30 }, { "TP_RXT_MAX", 0x39c, 0 }, { "RxtMax", 0, 30 }, { "TP_PERS_MIN", 0x3a0, 0 }, { "PersMin", 0, 30 }, { "TP_PERS_MAX", 0x3a4, 0 }, { "PersMax", 0, 30 }, { "TP_KEEP_IDLE", 0x3a8, 0 }, { "KeepaliveIdle", 0, 30 }, { "TP_KEEP_INTVL", 0x3ac, 0 }, { "KeepaliveIntvl", 0, 30 }, { "TP_INIT_SRTT", 0x3b0, 0 }, { "InitSrtt", 0, 16 }, { "TP_DACK_TIMER", 0x3b4, 0 }, { "DackTime", 0, 12 }, { "TP_FINWAIT2_TIMER", 0x3b8, 0 }, { "Finwait2Time", 0, 30 }, { "TP_FAST_FINWAIT2_TIMER", 0x3bc, 0 }, { "FastFinwait2Time", 0, 30 }, { "TP_SHIFT_CNT", 0x3c0, 0 }, { "SynShiftMax", 24, 8 }, { "RxtShiftMaxR1", 20, 4 }, { "RxtShiftMaxR2", 16, 4 }, { "PerShiftBackoffMax", 12, 4 }, { "PerShiftMax", 8, 4 }, { "KeepaliveMax", 0, 8 }, { "TP_TIME_HI", 0x3c8, 0 }, { "TP_TIME_LO", 0x3cc, 0 }, { "TP_MTU_PORT_TABLE", 0x3d0, 0 }, { "Port1MTUValue", 16, 16 }, { "Port0MTUValue", 0, 16 }, { "TP_ULP_TABLE", 0x3d4, 0 }, { "ULPType7Field", 28, 4 }, { "ULPType6Field", 24, 4 }, { "ULPType5Field", 20, 4 }, { "ULPType4Field", 16, 4 }, { "ULPType3Field", 12, 4 }, { "ULPType2Field", 8, 4 }, { "ULPType1Field", 4, 4 }, { "ULPType0Field", 0, 4 }, { "TP_PACE_TABLE", 0x3d8, 0 }, { "TP_CCTRL_TABLE", 0x3dc, 0 }, { "TP_TOS_TABLE", 0x3e0, 0 }, { "TP_MTU_TABLE", 0x3e4, 0 }, { "TP_RSS_MAP_TABLE", 0x3e8, 0 }, { "TP_RSS_LKP_TABLE", 0x3ec, 0 }, { "TP_RSS_CONFIG", 0x3f0, 0 }, { "TNL4tupEn", 29, 1 }, { "TNL2tupEn", 28, 1 }, { "TNLprtEn", 26, 1 }, { "TNLMapEn", 25, 1 }, { "TNLLkpEn", 24, 1 }, { "OFD4tupEn", 21, 1 }, { "OFD2tupEn", 20, 1 }, { "OFDMapEn", 17, 1 }, { "OFDLkpEn", 16, 1 }, { "SYN4tupEn", 13, 1 }, { "SYN2tupEn", 12, 1 }, { "SYNMapEn", 9, 1 }, { "SYNLkpEn", 8, 1 }, { "RRCPLMapEn", 7, 1 }, { "RRCPLCPUSIZE", 4, 3 }, { "RQFeedbackEnable", 3, 1 }, { "HashToeplitz", 2, 1 }, { "HashSave", 1, 1 }, { "Disable", 0, 1 }, { "TP_RSS_CONFIG_TNL", 0x3f4, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_OFD", 0x3f8, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_SYN", 0x3fc, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_SECRET_KEY0", 0x400, 0 }, { "TP_RSS_SECRET_KEY1", 0x404, 0 }, { "TP_RSS_SECRET_KEY2", 0x408, 0 }, { "TP_RSS_SECRET_KEY3", 0x40c, 0 }, { "TP_TM_PIO_ADDR", 0x418, 0 }, { "TP_TM_PIO_DATA", 0x41c, 0 }, { "TP_TX_MOD_QUE_TABLE", 0x420, 0 }, { "TP_TX_RESOURCE_LIMIT", 0x424, 0 }, { "TX_RESOURCE_LIMIT_CH1_PC", 24, 8 }, { "TX_RESOURCE_LIMIT_CH1_NON_PC", 16, 8 }, { "TX_RESOURCE_LIMIT_CH0_PC", 8, 8 }, { "TX_RESOURCE_LIMIT_CH0_NON_PC", 0, 8 }, { "TP_TX_MOD_QUEUE_REQ_MAP", 0x428, 0 }, { "RX_MOD_WEIGHT", 24, 8 }, { "TX_MOD_WEIGHT", 16, 8 }, { "TX_MOD_TIMER_MODE", 8, 8 }, { "TX_MOD_QUEUE_REQ_MAP", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 0x42c, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT7", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT6", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT5", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT4", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0x430, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT3", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT2", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0, 8 }, { "TP_MOD_CHANNEL_WEIGHT", 0x434, 0 }, { "RX_MOD_CHANNEL_WEIGHT1", 24, 8 }, { "RX_MOD_CHANNEL_WEIGHT0", 16, 8 }, { "TX_MOD_CHANNEL_WEIGHT1", 8, 8 }, { "TX_MOD_CHANNEL_WEIGHT0", 0, 8 }, { "TP_MOD_RATE_LIMIT", 0x438, 0 }, { "RX_MOD_RATE_LIMIT_INC", 24, 8 }, { "RX_MOD_RATE_LIMIT_TICK", 16, 8 }, { "TX_MOD_RATE_LIMIT_INC", 8, 8 }, { "TX_MOD_RATE_LIMIT_TICK", 0, 8 }, { "TP_PIO_ADDR", 0x440, 0 }, { "TP_PIO_DATA", 0x444, 0 }, { "TP_RESET", 0x44c, 0 }, { "FlstInitEnable", 1, 1 }, { "TPReset", 0, 1 }, { "TP_MIB_INDEX", 0x450, 0 }, { "TP_MIB_RDATA", 0x454, 0 }, { "TP_SYNC_TIME_HI", 0x458, 0 }, { "TP_SYNC_TIME_LO", 0x45c, 0 }, { "TP_CMM_MM_RX_FLST_BASE", 0x460, 0 }, { "CMRxFlstBase", 0, 28 }, { "TP_CMM_MM_TX_FLST_BASE", 0x464, 0 }, { "CMTxFlstBase", 0, 28 }, { "TP_CMM_MM_PS_FLST_BASE", 0x468, 0 }, { "CMPsFlstBase", 0, 28 }, { "TP_CMM_MM_MAX_PSTRUCT", 0x46c, 0 }, { "CMMaxPstruct", 0, 21 }, { "TP_INT_ENABLE", 0x470, 0 }, { "TP_INT_CAUSE", 0x474, 0 }, { "TP_FLM_FREE_PS_CNT", 0x480, 0 }, { "FreePstructCount", 0, 21 }, { "TP_FLM_FREE_RX_CNT", 0x484, 0 }, { "FreeRxPageCount", 0, 21 }, { "TP_FLM_FREE_TX_CNT", 0x488, 0 }, { "FreeTxPageCount", 0, 21 }, { "TP_TM_HEAP_PUSH_CNT", 0x48c, 0 }, { "TP_TM_HEAP_POP_CNT", 0x490, 0 }, { "TP_TM_DACK_PUSH_CNT", 0x494, 0 }, { "TP_TM_DACK_POP_CNT", 0x498, 0 }, { "TP_TM_MOD_PUSH_CNT", 0x49c, 0 }, { "TP_MOD_POP_CNT", 0x4a0, 0 }, { "TP_TIMER_SEPARATOR", 0x4a4, 0 }, { "TP_DEBUG_SEL", 0x4a8, 0 }, { "TP_DEBUG_FLAGS", 0x4ac, 0 }, { "RxTimerDackFirst", 26, 1 }, { "RxTimerDack", 25, 1 }, { "RxTimerHeartbeat", 24, 1 }, { "RxPawsDrop", 23, 1 }, { "RxUrgDataDrop", 22, 1 }, { "RxFutureData", 21, 1 }, { "RxRcvRxmData", 20, 1 }, { "RxRcvOooDataFin", 19, 1 }, { "RxRcvOooData", 18, 1 }, { "RxRcvWndZero", 17, 1 }, { "RxRcvWndLtMss", 16, 1 }, { "TxDupAckInc", 11, 1 }, { "TxRxmUrg", 10, 1 }, { "TxRxmFin", 9, 1 }, { "TxRxmSyn", 8, 1 }, { "TxRxmNewReno", 7, 1 }, { "TxRxmFast", 6, 1 }, { "TxRxmTimer", 5, 1 }, { "TxRxmTimerKeepalive", 4, 1 }, { "TxRxmTimerPersist", 3, 1 }, { "TxRcvAdvShrunk", 2, 1 }, { "TxRcvAdvZero", 1, 1 }, { "TxRcvAdvLtMss", 0, 1 }, { "TP_PROXY_FLOW_CNTL", 0x4b0, 0 }, { "TP_PC_CONGESTION_CNTL", 0x4b4, 0 }, { "EDropTunnel", 19, 1 }, { "CDropTunnel", 18, 1 }, { "EThreshold", 12, 6 }, { "CThreshold", 6, 6 }, { "TxThreshold", 0, 6 }, { "TP_TX_DROP_COUNT", 0x4bc, 0 }, { "TP_CLEAR_DEBUG", 0x4c0, 0 }, { "ClrDebug", 0, 1 }, { "TP_DEBUG_VEC", 0x4c4, 0 }, { "TP_DEBUG_VEC2", 0x4c8, 0 }, { "TP_DEBUG_REG_SEL", 0x4cc, 0 }, { "TP_DEBUG", 0x4d0, 0 }, { "TP_DBG_LA_CONFIG", 0x4d4, 0 }, { "TP_DBG_LA_DATAH", 0x4d8, 0 }, { "TP_DBG_LA_DATAL", 0x4dc, 0 }, { "TP_EMBED_OP_FIELD0", 0x4e8, 0 }, { "TP_EMBED_OP_FIELD1", 0x4ec, 0 }, { "TP_EMBED_OP_FIELD2", 0x4f0, 0 }, { "TP_EMBED_OP_FIELD3", 0x4f4, 0 }, { "TP_EMBED_OP_FIELD4", 0x4f8, 0 }, { "TP_EMBED_OP_FIELD5", 0x4fc, 0 }, { NULL, 0, 0 } }; struct reg_info t3b_ulp2_rx_regs[] = { { "ULPRX_CTL", 0x500, 0 }, { "PCMD1Threshold", 24, 8 }, { "PCMD0Threshold", 16, 8 }, { "round_robin", 4, 1 }, { "RDMA_permissive_mode", 3, 1 }, { "PagePodME", 2, 1 }, { "IscsiTagTcb", 1, 1 }, { "TddpTagTcb", 0, 1 }, { "ULPRX_INT_ENABLE", 0x504, 0 }, { "ParErr", 0, 1 }, { "ULPRX_INT_CAUSE", 0x508, 0 }, { "ParErr", 0, 1 }, { "ULPRX_ISCSI_LLIMIT", 0x50c, 0 }, { "IscsiLlimit", 6, 26 }, { "ULPRX_ISCSI_ULIMIT", 0x510, 0 }, { "IscsiUlimit", 6, 26 }, { "ULPRX_ISCSI_TAGMASK", 0x514, 0 }, { "IscsiTagMask", 6, 26 }, { "ULPRX_ISCSI_PSZ", 0x518, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_TDDP_LLIMIT", 0x51c, 0 }, { "TddpLlimit", 6, 26 }, { "ULPRX_TDDP_ULIMIT", 0x520, 0 }, { "TddpUlimit", 6, 26 }, { "ULPRX_TDDP_TAGMASK", 0x524, 0 }, { "TddpTagMask", 6, 26 }, { "ULPRX_TDDP_PSZ", 0x528, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_STAG_LLIMIT", 0x52c, 0 }, { "ULPRX_STAG_ULIMIT", 0x530, 0 }, { "ULPRX_RQ_LLIMIT", 0x534, 0 }, { "ULPRX_RQ_ULIMIT", 0x538, 0 }, { "ULPRX_PBL_LLIMIT", 0x53c, 0 }, { "ULPRX_PBL_ULIMIT", 0x540, 0 }, { NULL, 0, 0 } }; struct reg_info t3b_ulp2_tx_regs[] = { { "ULPTX_CONFIG", 0x580, 0 }, { "CFG_RR_ARB", 0, 1 }, { "ULPTX_INT_ENABLE", 0x584, 0 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_INT_CAUSE", 0x588, 0 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_TPT_LLIMIT", 0x58c, 0 }, { "ULPTX_TPT_ULIMIT", 0x590, 0 }, { "ULPTX_PBL_LLIMIT", 0x594, 0 }, { "ULPTX_PBL_ULIMIT", 0x598, 0 }, { "ULPTX_CPL_ERR_OFFSET", 0x59c, 0 }, { "ULPTX_CPL_ERR_MASK", 0x5a0, 0 }, { "ULPTX_CPL_ERR_VALUE", 0x5a4, 0 }, { "ULPTX_CPL_PACK_SIZE", 0x5a8, 0 }, { "value", 24, 8 }, { "Ch1Size2", 24, 8 }, { "Ch1Size1", 16, 8 }, { "Ch0Size2", 8, 8 }, { "Ch0Size1", 0, 8 }, { "ULPTX_DMA_WEIGHT", 0x5ac, 0 }, { "D1_WEIGHT", 16, 16 }, { "D0_WEIGHT", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3b_pm1_rx_regs[] = { { "PM1_RX_CFG", 0x5c0, 0 }, { "PM1_RX_MODE", 0x5c4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_RX_STAT_CONFIG", 0x5c8, 0 }, { "PM1_RX_STAT_COUNT", 0x5cc, 0 }, { "PM1_RX_STAT_MSB", 0x5d0, 0 }, { "PM1_RX_STAT_LSB", 0x5d4, 0 }, { "PM1_RX_INT_ENABLE", 0x5d8, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { "PM1_RX_INT_CAUSE", 0x5dc, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info t3b_pm1_tx_regs[] = { { "PM1_TX_CFG", 0x5e0, 0 }, { "PM1_TX_MODE", 0x5e4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_TX_STAT_CONFIG", 0x5e8, 0 }, { "PM1_TX_STAT_COUNT", 0x5ec, 0 }, { "PM1_TX_STAT_MSB", 0x5f0, 0 }, { "PM1_TX_STAT_LSB", 0x5f4, 0 }, { "PM1_TX_INT_ENABLE", 0x5f8, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { "PM1_TX_INT_CAUSE", 0x5fc, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info t3b_mps0_regs[] = { { "MPS_CFG", 0x600, 0 }, { "EnForcePkt", 11, 1 }, { "SGETPQid", 8, 3 }, { "TPRxPortSize", 7, 1 }, { "TPTxPort1Size", 6, 1 }, { "TPTxPort0Size", 5, 1 }, { "TPRxPortEn", 4, 1 }, { "TPTxPort1En", 3, 1 }, { "TPTxPort0En", 2, 1 }, { "Port1Active", 1, 1 }, { "Port0Active", 0, 1 }, { "MPS_DRR_CFG1", 0x604, 0 }, { "RldWtTPD1", 11, 11 }, { "RldWtTPD0", 0, 11 }, { "MPS_DRR_CFG2", 0x608, 0 }, { "RldWtTotal", 0, 12 }, { "MPS_MCA_STATUS", 0x60c, 0 }, { "MCAPktCnt", 12, 20 }, { "MCADepth", 0, 12 }, { "MPS_TX0_TP_CNT", 0x610, 0 }, { "TX0TPDisCnt", 24, 8 }, { "TX0TPCnt", 0, 24 }, { "MPS_TX1_TP_CNT", 0x614, 0 }, { "TX1TPDisCnt", 24, 8 }, { "TX1TPCnt", 0, 24 }, { "MPS_RX_TP_CNT", 0x618, 0 }, { "RXTPDisCnt", 24, 8 }, { "RXTPCnt", 0, 24 }, { "MPS_INT_ENABLE", 0x61c, 0 }, { "MCAParErrEnb", 6, 3 }, { "RXTpParErrEnb", 4, 2 }, { "TX1TpParErrEnb", 2, 2 }, { "TX0TpParErrEnb", 0, 2 }, { "MPS_INT_CAUSE", 0x620, 0 }, { "MCAParErr", 6, 3 }, { "RXTpParErr", 4, 2 }, { "TX1TpParErr", 2, 2 }, { "TX0TpParErr", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3b_cpl_switch_regs[] = { { "CPL_SWITCH_CNTRL", 0x640, 0 }, { "cpl_pkt_tid", 8, 24 }, { "cpu_no_3F_CIM_enable", 3, 1 }, { "switch_table_enable", 2, 1 }, { "sge_enable", 1, 1 }, { "cim_enable", 0, 1 }, { "CPL_SWITCH_TBL_IDX", 0x644, 0 }, { "switch_tbl_idx", 0, 4 }, { "CPL_SWITCH_TBL_DATA", 0x648, 0 }, { "CPL_SWITCH_ZERO_ERROR", 0x64c, 0 }, { "zero_cmd", 0, 8 }, { "CPL_INTR_ENABLE", 0x650, 0 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_INTR_CAUSE", 0x654, 0 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_MAP_TBL_IDX", 0x658, 0 }, { "cpl_map_tbl_idx", 0, 8 }, { "CPL_MAP_TBL_DATA", 0x65c, 0 }, { "cpl_map_tbl_data", 0, 8 }, { NULL, 0, 0 } }; struct reg_info t3b_smb0_regs[] = { { "SMB_GLOBAL_TIME_CFG", 0x660, 0 }, { "LADbgWrPtr", 24, 8 }, { "LADbgRdPtr", 16, 8 }, { "LADbgEn", 13, 1 }, { "MacroCntCfg", 8, 5 }, { "MicroCntCfg", 0, 8 }, { "SMB_MST_TIMEOUT_CFG", 0x664, 0 }, { "DebugSelH", 28, 4 }, { "DebugSelL", 24, 4 }, { "MstTimeOutCfg", 0, 24 }, { "SMB_MST_CTL_CFG", 0x668, 0 }, { "MstFifoDbg", 31, 1 }, { "MstFifoDbgClr", 30, 1 }, { "MstRxByteCfg", 12, 6 }, { "MstTxByteCfg", 6, 6 }, { "MstReset", 1, 1 }, { "MstCtlEn", 0, 1 }, { "SMB_MST_CTL_STS", 0x66c, 0 }, { "MstRxByteCnt", 12, 6 }, { "MstTxByteCnt", 6, 6 }, { "MstBusySts", 0, 1 }, { "SMB_MST_TX_FIFO_RDWR", 0x670, 0 }, { "SMB_MST_RX_FIFO_RDWR", 0x674, 0 }, { "SMB_SLV_TIMEOUT_CFG", 0x678, 0 }, { "SlvTimeOutCfg", 0, 24 }, { "SMB_SLV_CTL_CFG", 0x67c, 0 }, { "SlvFifoDbg", 31, 1 }, { "SlvFifoDbgClr", 30, 1 }, { "SlvAddrCfg", 4, 7 }, { "SlvAlrtSet", 2, 1 }, { "SlvReset", 1, 1 }, { "SlvCtlEn", 0, 1 }, { "SMB_SLV_CTL_STS", 0x680, 0 }, { "SlvFifoTxCnt", 12, 6 }, { "SlvFifoCnt", 6, 6 }, { "SlvAlrtSts", 2, 1 }, { "SlvBusySts", 0, 1 }, { "SMB_SLV_FIFO_RDWR", 0x684, 0 }, { "SMB_SLV_CMD_FIFO_RDWR", 0x688, 0 }, { "SMB_INT_ENABLE", 0x68c, 0 }, { "SlvTimeOutIntEn", 7, 1 }, { "SlvErrIntEn", 6, 1 }, { "SlvDoneIntEn", 5, 1 }, { "SlvRxRdyIntEn", 4, 1 }, { "MstTimeOutIntEn", 3, 1 }, { "MstNAckIntEn", 2, 1 }, { "MstLostArbIntEn", 1, 1 }, { "MstDoneIntEn", 0, 1 }, { "SMB_INT_CAUSE", 0x690, 0 }, { "SlvTimeOutInt", 7, 1 }, { "SlvErrInt", 6, 1 }, { "SlvDoneInt", 5, 1 }, { "SlvRxRdyInt", 4, 1 }, { "MstTimeOutInt", 3, 1 }, { "MstNAckInt", 2, 1 }, { "MstLostArbInt", 1, 1 }, { "MstDoneInt", 0, 1 }, { "SMB_DEBUG_DATA", 0x694, 0 }, { "DebugDataH", 16, 16 }, { "DebugDataL", 0, 16 }, { "SMB_DEBUG_LA", 0x69c, 0 }, { "DebugLAReqAddr", 0, 10 }, { NULL, 0, 0 } }; struct reg_info t3b_i2cm0_regs[] = { { "I2C_CFG", 0x6a0, 0 }, { "ClkDiv", 0, 12 }, { "I2C_DATA", 0x6a4, 0 }, { "Data", 0, 8 }, { "I2C_OP", 0x6a8, 0 }, { "Busy", 31, 1 }, { "Ack", 30, 1 }, { "Cont", 1, 1 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_mi1_regs[] = { { "MI1_CFG", 0x6b0, 0 }, { "ClkDiv", 5, 8 }, { "St", 3, 2 }, { "PreEn", 2, 1 }, { "MDIInv", 1, 1 }, { "MDIEn", 0, 1 }, { "MI1_ADDR", 0x6b4, 0 }, { "PhyAddr", 5, 5 }, { "RegAddr", 0, 5 }, { "MI1_DATA", 0x6b8, 0 }, { "Data", 0, 16 }, { "MI1_OP", 0x6bc, 0 }, { "Busy", 31, 1 }, { "Inc", 2, 1 }, { "Op", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3b_jm1_regs[] = { { "JM_CFG", 0x6c0, 0 }, { "ClkDiv", 2, 8 }, { "TRst", 1, 1 }, { "En", 0, 1 }, { "JM_MODE", 0x6c4, 0 }, { "JM_DATA", 0x6c8, 0 }, { "JM_OP", 0x6cc, 0 }, { "Busy", 31, 1 }, { "Cnt", 0, 5 }, { NULL, 0, 0 } }; struct reg_info t3b_sf1_regs[] = { { "SF_DATA", 0x6d8, 0 }, { "SF_OP", 0x6dc, 0 }, { "Busy", 31, 1 }, { "Cont", 3, 1 }, { "ByteCnt", 1, 2 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3b_pl3_regs[] = { { "PL_INT_ENABLE0", 0x6e0, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE0", 0x6e4, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_ENABLE1", 0x6e8, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE1", 0x6ec, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_RST", 0x6f0, 0 }, { "SWInt1", 3, 1 }, { "SWInt0", 2, 1 }, { "CRstWrm", 1, 1 }, { "CRstWrmMode", 0, 1 }, { "PL_REV", 0x6f4, 0 }, { "Rev", 0, 4 }, { "PL_CLI", 0x6f8, 0 }, { "PL_LCK", 0x6fc, 0 }, { "Lck", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3b_mc5a_regs[] = { { "MC5_BUF_CONFIG", 0x700, 0 }, { "term300_240", 31, 1 }, { "term150", 30, 1 }, { "term60", 29, 1 }, { "gddriii", 28, 1 }, { "gddrii", 27, 1 }, { "gddri", 26, 1 }, { "read", 25, 1 }, { "imp_set_update", 24, 1 }, { "cal_update", 23, 1 }, { "cal_busy", 22, 1 }, { "cal_error", 21, 1 }, { "sgl_cal_en", 20, 1 }, { "imp_upd_mode", 19, 1 }, { "imp_sel", 18, 1 }, { "man_pu", 15, 3 }, { "man_pd", 12, 3 }, { "cal_pu", 9, 3 }, { "cal_pd", 6, 3 }, { "set_pu", 3, 3 }, { "set_pd", 0, 3 }, { "MC5_DB_CONFIG", 0x704, 0 }, { "TMCfgWrLock", 31, 1 }, { "TMTypeHi", 30, 1 }, { "TMPartSize", 28, 2 }, { "TMType", 26, 2 }, { "TMPartCount", 24, 2 }, { "nLIP", 18, 6 }, { "COMPEN", 17, 1 }, { "BUILD", 16, 1 }, { "FilterEn", 11, 1 }, { "CLIPUpdate", 10, 1 }, { "TM_IO_PDOWN", 9, 1 }, { "SYNMode", 7, 2 }, { "PRTYEN", 6, 1 }, { "MBUSEN", 5, 1 }, { "DBGIEN", 4, 1 }, { "TcmCfgOvr", 3, 1 }, { "TMRDY", 2, 1 }, { "TMRST", 1, 1 }, { "TMMode", 0, 1 }, { "MC5_MISC", 0x708, 0 }, { "LIP_Cmp_Unavailable", 0, 4 }, { "MC5_DB_ROUTING_TABLE_INDEX", 0x70c, 0 }, { "RTINDX", 0, 22 }, { "MC5_DB_FILTER_TABLE", 0x710, 0 }, { "SRINDX", 0, 22 }, { "MC5_DB_SERVER_INDEX", 0x714, 0 }, { "SRINDX", 0, 22 }, { "MC5_DB_LIP_RAM_ADDR", 0x718, 0 }, { "RAMWR", 8, 1 }, { "RAMADDR", 0, 6 }, { "MC5_DB_LIP_RAM_DATA", 0x71c, 0 }, { "MC5_DB_RSP_LATENCY", 0x720, 0 }, { "RDLAT", 16, 5 }, { "LRNLAT", 8, 5 }, { "SRCHLAT", 0, 5 }, { "MC5_DB_PARITY_LATENCY", 0x724, 0 }, { "PARLAT", 0, 4 }, { "MC5_DB_WR_LRN_VERIFY", 0x728, 0 }, { "VWVEREN", 2, 1 }, { "LRNVEREN", 1, 1 }, { "POVEREN", 0, 1 }, { "MC5_DB_PART_ID_INDEX", 0x72c, 0 }, { "IDINDEX", 0, 4 }, { "MC5_DB_RESET_MAX", 0x730, 0 }, { "RSTMAX", 0, 4 }, { "MC5_DB_ACT_CNT", 0x734, 0 }, { "ACTCNT", 0, 20 }, { "MC5_DB_CLIP_MAP", 0x738, 0 }, { "CLIPMapOp", 31, 1 }, { "CLIPMapVal", 16, 6 }, { "CLIPMapAddr", 0, 6 }, { "MC5_DB_INT_ENABLE", 0x740, 0 }, { "MsgSel", 28, 4 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_CAUSE", 0x744, 0 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_TID", 0x748, 0 }, { "INTTID", 0, 20 }, { "MC5_DB_INT_PTID", 0x74c, 0 }, { "INTPTID", 0, 20 }, { "MC5_DB_DBGI_CONFIG", 0x774, 0 }, { "WRReqSize", 22, 10 }, { "SADRSel", 4, 1 }, { "CMDMode", 0, 3 }, { "MC5_DB_DBGI_REQ_CMD", 0x778, 0 }, { "MBusCmd", 0, 4 }, { "IDTCmdHi", 11, 3 }, { "IDTCmdLo", 0, 4 }, { "IDTCmd", 0, 20 }, { "LCMDB", 16, 11 }, { "LCMDA", 0, 11 }, { "MC5_DB_DBGI_REQ_ADDR0", 0x77c, 0 }, { "MC5_DB_DBGI_REQ_ADDR1", 0x780, 0 }, { "MC5_DB_DBGI_REQ_ADDR2", 0x784, 0 }, { "DBGIReqAdrHi", 0, 8 }, { "MC5_DB_DBGI_REQ_DATA0", 0x788, 0 }, { "MC5_DB_DBGI_REQ_DATA1", 0x78c, 0 }, { "MC5_DB_DBGI_REQ_DATA2", 0x790, 0 }, { "MC5_DB_DBGI_REQ_DATA3", 0x794, 0 }, { "MC5_DB_DBGI_REQ_DATA4", 0x798, 0 }, { "DBGIReqData4", 0, 16 }, { "MC5_DB_DBGI_REQ_MASK0", 0x79c, 0 }, { "MC5_DB_DBGI_REQ_MASK1", 0x7a0, 0 }, { "MC5_DB_DBGI_REQ_MASK2", 0x7a4, 0 }, { "MC5_DB_DBGI_REQ_MASK3", 0x7a8, 0 }, { "MC5_DB_DBGI_REQ_MASK4", 0x7ac, 0 }, { "DBGIReqMsk4", 0, 16 }, { "MC5_DB_DBGI_RSP_STATUS", 0x7b0, 0 }, { "DBGIRspMsg", 8, 4 }, { "DBGIRspMsgVld", 2, 1 }, { "DBGIRspHit", 1, 1 }, { "DBGIRspValid", 0, 1 }, { "MC5_DB_DBGI_RSP_DATA0", 0x7b4, 0 }, { "MC5_DB_DBGI_RSP_DATA1", 0x7b8, 0 }, { "MC5_DB_DBGI_RSP_DATA2", 0x7bc, 0 }, { "MC5_DB_DBGI_RSP_DATA3", 0x7c0, 0 }, { "MC5_DB_DBGI_RSP_DATA4", 0x7c4, 0 }, { "DBGIRspData3", 0, 16 }, { "MC5_DB_DBGI_RSP_LAST_CMD", 0x7c8, 0 }, { "LastCmdB", 16, 11 }, { "LastCmdA", 0, 11 }, { "MC5_DB_POPEN_DATA_WR_CMD", 0x7cc, 0 }, { "PO_DWR", 0, 20 }, { "MC5_DB_POPEN_MASK_WR_CMD", 0x7d0, 0 }, { "PO_MWR", 0, 20 }, { "MC5_DB_AOPEN_SRCH_CMD", 0x7d4, 0 }, { "AO_SRCH", 0, 20 }, { "MC5_DB_AOPEN_LRN_CMD", 0x7d8, 0 }, { "AO_LRN", 0, 20 }, { "MC5_DB_SYN_SRCH_CMD", 0x7dc, 0 }, { "SYN_SRCH", 0, 20 }, { "MC5_DB_SYN_LRN_CMD", 0x7e0, 0 }, { "SYN_LRN", 0, 20 }, { "MC5_DB_ACK_SRCH_CMD", 0x7e4, 0 }, { "ACK_SRCH", 0, 20 }, { "MC5_DB_ACK_LRN_CMD", 0x7e8, 0 }, { "ACK_LRN", 0, 20 }, { "MC5_DB_ILOOKUP_CMD", 0x7ec, 0 }, { "I_SRCH", 0, 20 }, { "MC5_DB_ELOOKUP_CMD", 0x7f0, 0 }, { "E_SRCH", 0, 20 }, { "MC5_DB_DATA_WRITE_CMD", 0x7f4, 0 }, { "Write", 0, 20 }, { "MC5_DB_DATA_READ_CMD", 0x7f8, 0 }, { "ReadCmd", 0, 20 }, { "MC5_DB_MASK_WRITE_CMD", 0x7fc, 0 }, { "MaskWr", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3b_xgmac0_0_regs[] = { { "XGM_TX_CTRL", 0x800, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0x804, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0x808, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0x80c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0x810, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0x814, 0 }, { "XGM_RX_HASH_HIGH", 0x818, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0x81c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0x820, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0x824, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0x828, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0x82c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0x830, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0x834, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0x838, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0x83c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0x840, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0x844, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0x848, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0x84c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0x850, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0x854, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0x858, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0x85c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0x860, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0x864, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0x868, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0x86c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0x870, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0x874, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0x878, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0x87c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0x880, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0x884, 0 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0x888, 0 }, { "EnDropPkt", 21, 1 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0x88c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_PAUSE_TIMER", 0x890, 0 }, { "PauseTimer", 0, 20 }, { "XGM_XAUI_PCS_TEST", 0x894, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0x898, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0x89c, 0 }, { "CalReset", 8, 1 }, { "CalUpdate", 7, 1 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0x8a8, 0 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0x8ac, 0 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0x8b0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0x8b4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0x8b8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0x8c0, 0 }, { "XGM_EPIO_DATA1", 0x8c4, 0 }, { "XGM_EPIO_DATA2", 0x8c8, 0 }, { "XGM_EPIO_DATA3", 0x8cc, 0 }, { "XGM_EPIO_OP", 0x8d0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0x8d4, 0 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0x8d8, 0 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_XAUI_ACT_CTRL", 0x8dc, 0 }, { "TxEn", 1, 1 }, { "RxEn", 0, 1 }, { "XGM_SERDES_CTRL0", 0x8e0, 0 }, { "IntSerLPBK3", 27, 1 }, { "IntSerLPBK2", 26, 1 }, { "IntSerLPBK1", 25, 1 }, { "IntSerLPBK0", 24, 1 }, { "Reset3", 23, 1 }, { "Reset2", 22, 1 }, { "Reset1", 21, 1 }, { "Reset0", 20, 1 }, { "Pwrdn3", 19, 1 }, { "Pwrdn2", 18, 1 }, { "Pwrdn1", 17, 1 }, { "Pwrdn0", 16, 1 }, { "ResetPLL23", 15, 1 }, { "ResetPLL01", 14, 1 }, { "PW23", 12, 2 }, { "PW01", 10, 2 }, { "Deq", 6, 4 }, { "Dtx", 2, 4 }, { "LoDrv", 1, 1 }, { "HiDrv", 0, 1 }, { "XGM_SERDES_CTRL1", 0x8e4, 0 }, { "FmOffset3", 19, 5 }, { "FmOffsetEn3", 18, 1 }, { "FmOffset2", 13, 5 }, { "FmOffsetEn2", 12, 1 }, { "FmOffset1", 7, 5 }, { "FmOffsetEn1", 6, 1 }, { "FmOffset0", 1, 5 }, { "FmOffsetEn0", 0, 1 }, { "XGM_SERDES_CTRL2", 0x8e8, 0 }, { "DnIn3", 11, 1 }, { "UpIn3", 10, 1 }, { "RxSlave3", 9, 1 }, { "DnIn2", 8, 1 }, { "UpIn2", 7, 1 }, { "RxSlave2", 6, 1 }, { "DnIn1", 5, 1 }, { "UpIn1", 4, 1 }, { "RxSlave1", 3, 1 }, { "DnIn0", 2, 1 }, { "UpIn0", 1, 1 }, { "RxSlave0", 0, 1 }, { "XGM_SERDES_CTRL3", 0x8ec, 0 }, { "ExtBISTChkErrClr3", 31, 1 }, { "ExtBISTChkEn3", 30, 1 }, { "ExtBISTGenEn3", 29, 1 }, { "ExtBISTPat3", 26, 3 }, { "ExtParReset3", 25, 1 }, { "ExtParLPBK3", 24, 1 }, { "ExtBISTChkErrClr2", 23, 1 }, { "ExtBISTChkEn2", 22, 1 }, { "ExtBISTGenEn2", 21, 1 }, { "ExtBISTPat2", 18, 3 }, { "ExtParReset2", 17, 1 }, { "ExtParLPBK2", 16, 1 }, { "ExtBISTChkErrClr1", 15, 1 }, { "ExtBISTChkEn1", 14, 1 }, { "ExtBISTGenEn1", 13, 1 }, { "ExtBISTPat1", 10, 3 }, { "ExtParReset1", 9, 1 }, { "ExtParLPBK1", 8, 1 }, { "ExtBISTChkErrClr0", 7, 1 }, { "ExtBISTChkEn0", 6, 1 }, { "ExtBISTGenEn0", 5, 1 }, { "ExtBISTPat0", 2, 3 }, { "ExtParReset0", 1, 1 }, { "ExtParLPBK0", 0, 1 }, { "XGM_SERDES_STAT0", 0x8f0, 0 }, { "ExtBISTChkErrCnt0", 4, 24 }, { "ExtBISTChkFmd0", 3, 1 }, { "LowSig0", 0, 1 }, { "XGM_SERDES_STAT1", 0x8f4, 0 }, { "ExtBISTChkErrCnt1", 4, 24 }, { "ExtBISTChkFmd1", 3, 1 }, { "LowSig1", 0, 1 }, { "XGM_SERDES_STAT2", 0x8f8, 0 }, { "ExtBISTChkErrCnt2", 4, 24 }, { "ExtBISTChkFmd2", 3, 1 }, { "LowSig2", 0, 1 }, { "XGM_SERDES_STAT3", 0x8fc, 0 }, { "ExtBISTChkErrCnt3", 4, 24 }, { "ExtBISTChkFmd3", 3, 1 }, { "LowSig3", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0x900, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0x904, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0x908, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0x90c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0x910, 0 }, { "XGM_STAT_TX_MCAST", 0x914, 0 }, { "XGM_STAT_TX_PAUSE", 0x918, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0x91c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0x920, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0x924, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0x928, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0x92c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0x930, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0x934, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0x938, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0x93c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0x940, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0x944, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0x948, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0x94c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0x950, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0x954, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0x958, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0x95c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0x960, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0x964, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0x968, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0x96c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0x970, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0x974, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0x978, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0x97c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0x980, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0x984, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0x988, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_XAUI_PCS_ERR", 0x998, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0x99c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0x9a0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0x9a4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0x9a8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0x9ac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3b_xgmac0_1_regs[] = { { "XGM_TX_CTRL", 0xa00, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0xa04, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0xa08, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0xa0c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0xa10, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0xa14, 0 }, { "XGM_RX_HASH_HIGH", 0xa18, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0xa1c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0xa20, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0xa24, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0xa28, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0xa2c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0xa30, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0xa34, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0xa38, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0xa3c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0xa40, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0xa44, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0xa48, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0xa4c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0xa50, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0xa54, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0xa58, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0xa5c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0xa60, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0xa64, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0xa68, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0xa6c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0xa70, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0xa74, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0xa78, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0xa7c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0xa80, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0xa84, 0 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0xa88, 0 }, { "EnDropPkt", 21, 1 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0xa8c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_PAUSE_TIMER", 0xa90, 0 }, { "PauseTimer", 0, 20 }, { "XGM_XAUI_PCS_TEST", 0xa94, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0xa98, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0xa9c, 0 }, { "CalReset", 8, 1 }, { "CalUpdate", 7, 1 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0xaa8, 0 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0xaac, 0 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0xab0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0xab4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0xab8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0xac0, 0 }, { "XGM_EPIO_DATA1", 0xac4, 0 }, { "XGM_EPIO_DATA2", 0xac8, 0 }, { "XGM_EPIO_DATA3", 0xacc, 0 }, { "XGM_EPIO_OP", 0xad0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0xad4, 0 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0xad8, 0 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_XAUI_ACT_CTRL", 0xadc, 0 }, { "TxEn", 1, 1 }, { "RxEn", 0, 1 }, { "XGM_SERDES_CTRL0", 0xae0, 0 }, { "IntSerLPBK3", 27, 1 }, { "IntSerLPBK2", 26, 1 }, { "IntSerLPBK1", 25, 1 }, { "IntSerLPBK0", 24, 1 }, { "Reset3", 23, 1 }, { "Reset2", 22, 1 }, { "Reset1", 21, 1 }, { "Reset0", 20, 1 }, { "Pwrdn3", 19, 1 }, { "Pwrdn2", 18, 1 }, { "Pwrdn1", 17, 1 }, { "Pwrdn0", 16, 1 }, { "ResetPLL23", 15, 1 }, { "ResetPLL01", 14, 1 }, { "PW23", 12, 2 }, { "PW01", 10, 2 }, { "Deq", 6, 4 }, { "Dtx", 2, 4 }, { "LoDrv", 1, 1 }, { "HiDrv", 0, 1 }, { "XGM_SERDES_CTRL1", 0xae4, 0 }, { "FmOffset3", 19, 5 }, { "FmOffsetEn3", 18, 1 }, { "FmOffset2", 13, 5 }, { "FmOffsetEn2", 12, 1 }, { "FmOffset1", 7, 5 }, { "FmOffsetEn1", 6, 1 }, { "FmOffset0", 1, 5 }, { "FmOffsetEn0", 0, 1 }, { "XGM_SERDES_CTRL2", 0xae8, 0 }, { "DnIn3", 11, 1 }, { "UpIn3", 10, 1 }, { "RxSlave3", 9, 1 }, { "DnIn2", 8, 1 }, { "UpIn2", 7, 1 }, { "RxSlave2", 6, 1 }, { "DnIn1", 5, 1 }, { "UpIn1", 4, 1 }, { "RxSlave1", 3, 1 }, { "DnIn0", 2, 1 }, { "UpIn0", 1, 1 }, { "RxSlave0", 0, 1 }, { "XGM_SERDES_CTRL3", 0xaec, 0 }, { "ExtBISTChkErrClr3", 31, 1 }, { "ExtBISTChkEn3", 30, 1 }, { "ExtBISTGenEn3", 29, 1 }, { "ExtBISTPat3", 26, 3 }, { "ExtParReset3", 25, 1 }, { "ExtParLPBK3", 24, 1 }, { "ExtBISTChkErrClr2", 23, 1 }, { "ExtBISTChkEn2", 22, 1 }, { "ExtBISTGenEn2", 21, 1 }, { "ExtBISTPat2", 18, 3 }, { "ExtParReset2", 17, 1 }, { "ExtParLPBK2", 16, 1 }, { "ExtBISTChkErrClr1", 15, 1 }, { "ExtBISTChkEn1", 14, 1 }, { "ExtBISTGenEn1", 13, 1 }, { "ExtBISTPat1", 10, 3 }, { "ExtParReset1", 9, 1 }, { "ExtParLPBK1", 8, 1 }, { "ExtBISTChkErrClr0", 7, 1 }, { "ExtBISTChkEn0", 6, 1 }, { "ExtBISTGenEn0", 5, 1 }, { "ExtBISTPat0", 2, 3 }, { "ExtParReset0", 1, 1 }, { "ExtParLPBK0", 0, 1 }, { "XGM_SERDES_STAT0", 0xaf0, 0 }, { "ExtBISTChkErrCnt0", 4, 24 }, { "ExtBISTChkFmd0", 3, 1 }, { "LowSig0", 0, 1 }, { "XGM_SERDES_STAT1", 0xaf4, 0 }, { "ExtBISTChkErrCnt1", 4, 24 }, { "ExtBISTChkFmd1", 3, 1 }, { "LowSig1", 0, 1 }, { "XGM_SERDES_STAT2", 0xaf8, 0 }, { "ExtBISTChkErrCnt2", 4, 24 }, { "ExtBISTChkFmd2", 3, 1 }, { "LowSig2", 0, 1 }, { "XGM_SERDES_STAT3", 0xafc, 0 }, { "ExtBISTChkErrCnt3", 4, 24 }, { "ExtBISTChkFmd3", 3, 1 }, { "LowSig3", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0xb00, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0xb04, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0xb08, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0xb0c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0xb10, 0 }, { "XGM_STAT_TX_MCAST", 0xb14, 0 }, { "XGM_STAT_TX_PAUSE", 0xb18, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0xb1c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0xb20, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0xb24, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0xb28, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0xb2c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0xb30, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0xb34, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0xb38, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0xb3c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0xb40, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0xb44, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0xb48, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0xb4c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0xb50, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0xb54, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0xb58, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0xb5c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0xb60, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0xb64, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0xb68, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0xb6c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0xb70, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0xb74, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0xb78, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0xb7c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0xb80, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0xb84, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0xb88, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_XAUI_PCS_ERR", 0xb98, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0xb9c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0xba0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0xba4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0xba8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0xbac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; diff --git a/tools/tools/cxgbtool/reg_defs_t3c.c b/tools/tools/cxgbtool/reg_defs_t3c.c index b9181b68e9a9..75c89a90b0b9 100644 --- a/tools/tools/cxgbtool/reg_defs_t3c.c +++ b/tools/tools/cxgbtool/reg_defs_t3c.c @@ -1,3119 +1,3118 @@ /* - * $FreeBSD$ */ /* This file is automatically generated --- do not edit */ struct reg_info t3c_sge3_regs[] = { { "SG_CONTROL", 0x0, 0 }, { "CongMode", 29, 1 }, { "TnlFLMode", 28, 1 }, { "FatlPerrEn", 27, 1 }, { "UrgTnl", 26, 1 }, { "NewNotify", 25, 1 }, { "AvoidCqOvfl", 24, 1 }, { "OptOneIntMultQ", 23, 1 }, { "CQCrdtCtrl", 22, 1 }, { "EgrEnUpBp", 21, 1 }, { "DropPkt", 20, 1 }, { "EgrGenCtrl", 19, 1 }, { "UserSpaceSize", 14, 5 }, { "HostPageSize", 11, 3 }, { "PCIRelax", 10, 1 }, { "FLMode", 9, 1 }, { "PktShift", 6, 3 }, { "OneIntMultQ", 5, 1 }, { "FLPickAvail", 4, 1 }, { "BigEndianEgress", 3, 1 }, { "BigEndianIngress", 2, 1 }, { "IscsiCoalescing", 1, 1 }, { "GlobalEnable", 0, 1 }, { "SG_KDOORBELL", 0x4, 0 }, { "SelEgrCntx", 31, 1 }, { "EgrCntx", 0, 16 }, { "SG_GTS", 0x8, 0 }, { "RspQ", 29, 3 }, { "NewTimer", 16, 13 }, { "NewIndex", 0, 16 }, { "SG_CONTEXT_CMD", 0xc, 0 }, { "Opcode", 28, 4 }, { "Busy", 27, 1 }, { "CQ_credit", 20, 7 }, { "CQ", 19, 1 }, { "RspQ", 18, 1 }, { "Egress", 17, 1 }, { "FreeList", 16, 1 }, { "Context", 0, 16 }, { "SG_CONTEXT_DATA0", 0x10, 0 }, { "SG_CONTEXT_DATA1", 0x14, 0 }, { "SG_CONTEXT_DATA2", 0x18, 0 }, { "SG_CONTEXT_DATA3", 0x1c, 0 }, { "SG_CONTEXT_MASK0", 0x20, 0 }, { "SG_CONTEXT_MASK1", 0x24, 0 }, { "SG_CONTEXT_MASK2", 0x28, 0 }, { "SG_CONTEXT_MASK3", 0x2c, 0 }, { "SG_RSPQ_CREDIT_RETURN", 0x30, 0 }, { "RspQ", 29, 3 }, { "Data", 0, 16 }, { "SG_DATA_INTR", 0x34, 0 }, { "ErrIntr", 31, 1 }, { "DataIntr", 0, 8 }, { "SG_HI_DRB_HI_THRSH", 0x38, 0 }, { "HiDrbHiThrsh", 0, 10 }, { "SG_HI_DRB_LO_THRSH", 0x3c, 0 }, { "HiDrbLoThrsh", 0, 10 }, { "SG_LO_DRB_HI_THRSH", 0x40, 0 }, { "LoDrbHiThrsh", 0, 10 }, { "SG_LO_DRB_LO_THRSH", 0x44, 0 }, { "LoDrbLoThrsh", 0, 10 }, { "SG_ONE_INT_MULT_Q_COALESCING_TIMER", 0x48, 0 }, { "SG_RSPQ_FL_STATUS", 0x4c, 0 }, { "RspQ0Starved", 0, 1 }, { "RspQ1Starved", 1, 1 }, { "RspQ2Starved", 2, 1 }, { "RspQ3Starved", 3, 1 }, { "RspQ4Starved", 4, 1 }, { "RspQ5Starved", 5, 1 }, { "RspQ6Starved", 6, 1 }, { "RspQ7Starved", 7, 1 }, { "RspQ0Disabled", 8, 1 }, { "RspQ1Disabled", 9, 1 }, { "RspQ2Disabled", 10, 1 }, { "RspQ3Disabled", 11, 1 }, { "RspQ4Disabled", 12, 1 }, { "RspQ5Disabled", 13, 1 }, { "RspQ6Disabled", 14, 1 }, { "RspQ7Disabled", 15, 1 }, { "FL0Empty", 16, 1 }, { "FL1Empty", 17, 1 }, { "FL2Empty", 18, 1 }, { "FL3Empty", 19, 1 }, { "FL4Empty", 20, 1 }, { "FL5Empty", 21, 1 }, { "FL6Empty", 22, 1 }, { "FL7Empty", 23, 1 }, { "FL8Empty", 24, 1 }, { "FL9Empty", 25, 1 }, { "FL10Empty", 26, 1 }, { "FL11Empty", 27, 1 }, { "FL12Empty", 28, 1 }, { "FL13Empty", 29, 1 }, { "FL14Empty", 30, 1 }, { "FL15Empty", 31, 1 }, { "SG_EGR_PRI_CNT", 0x50, 0 }, { "EgrErrOpCode", 24, 8 }, { "EgrHiOpCode", 16, 8 }, { "EgrLoOpCode", 8, 8 }, { "EgrPriCnt", 0, 5 }, { "SG_EGR_RCQ_DRB_THRSH", 0x54, 0 }, { "HiRcqDrbThrsh", 16, 11 }, { "LoRcqDrbThrsh", 0, 11 }, { "SG_EGR_CNTX_BADDR", 0x58, 0 }, { "EgrCntxBAddr", 5, 27 }, { "SG_INT_CAUSE", 0x5c, 0 }, { "HiRcqParityError", 31, 1 }, { "LoRcqParityError", 30, 1 }, { "HiDrbParityError", 29, 1 }, { "LoDrbParityError", 28, 1 }, { "FlParityError", 22, 6 }, { "ItParityError", 20, 2 }, { "IrParityError", 19, 1 }, { "RcParityError", 18, 1 }, { "OcParityError", 17, 1 }, { "CpParityError", 16, 1 }, { "R_Req_FramingError", 15, 1 }, { "UC_Req_FramingError", 14, 1 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_INT_ENABLE", 0x60, 0 }, { "HiRcqParityError", 31, 1 }, { "LoRcqParityError", 30, 1 }, { "HiDrbParityError", 29, 1 }, { "LoDrbParityError", 28, 1 }, { "FlParityError", 22, 6 }, { "ItParityError", 20, 2 }, { "IrParityError", 19, 1 }, { "RcParityError", 18, 1 }, { "OcParityError", 17, 1 }, { "CpParityError", 16, 1 }, { "R_Req_FramingError", 15, 1 }, { "UC_Req_FramingError", 14, 1 }, { "HiCtlDrbDropErr", 13, 1 }, { "LoCtlDrbDropErr", 12, 1 }, { "HiPioDrbDropErr", 11, 1 }, { "LoPioDrbDropErr", 10, 1 }, { "HiCrdtUndFlowErr", 9, 1 }, { "LoCrdtUndFlowErr", 8, 1 }, { "HiPriorityDBFull", 7, 1 }, { "HiPriorityDBEmpty", 6, 1 }, { "LoPriorityDBFull", 5, 1 }, { "LoPriorityDBEmpty", 4, 1 }, { "RspQDisabled", 3, 1 }, { "RspQCreditOverfow", 2, 1 }, { "FlEmpty", 1, 1 }, { "RspQStarve", 0, 1 }, { "SG_CMDQ_CREDIT_TH", 0x64, 0 }, { "Timeout", 8, 24 }, { "Threshold", 0, 8 }, { "SG_TIMER_TICK", 0x68, 0 }, { "SG_CQ_CONTEXT_BADDR", 0x6c, 0 }, { "baseAddr", 5, 27 }, { "SG_OCO_BASE", 0x70, 0 }, { "Base1", 16, 16 }, { "Base0", 0, 16 }, { "SG_DRB_PRI_THRESH", 0x74, 0 }, { "DrbPriThrsh", 0, 16 }, { "SG_DEBUG_INDEX", 0x78, 0 }, { "SG_DEBUG_DATA", 0x7c, 0 }, { NULL, 0, 0 } }; struct reg_info t3c_pcix1_regs[] = { { "PCIX_INT_ENABLE", 0x80, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_INT_CAUSE", 0x84, 0 }, { "MSIXParErr", 22, 3 }, { "CFParErr", 18, 4 }, { "RFParErr", 14, 4 }, { "WFParErr", 12, 2 }, { "PIOParErr", 11, 1 }, { "DetUncECCErr", 10, 1 }, { "DetCorECCErr", 9, 1 }, { "RcvSplCmpErr", 8, 1 }, { "UnxSplCmp", 7, 1 }, { "SplCmpDis", 6, 1 }, { "DetParErr", 5, 1 }, { "SigSysErr", 4, 1 }, { "RcvMstAbt", 3, 1 }, { "RcvTarAbt", 2, 1 }, { "SigTarAbt", 1, 1 }, { "MstDetParErr", 0, 1 }, { "PCIX_CFG", 0x88, 0 }, { "DMAStopEn", 19, 1 }, { "CLIDecEn", 18, 1 }, { "LatTmrDis", 17, 1 }, { "LowPwrEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 8, 3 }, { "MaxSplTrnR", 5, 3 }, { "MaxWrByteCnt", 3, 2 }, { "WrReqAtomicEn", 2, 1 }, { "CRstWrmMode", 1, 1 }, { "PIOAck64En", 0, 1 }, { "PCIX_MODE", 0x8c, 0 }, { "PClkRange", 6, 2 }, { "PCIXInitPat", 2, 4 }, { "66MHz", 1, 1 }, { "64Bit", 0, 1 }, { "PCIX_CAL", 0x90, 0 }, { "Busy", 31, 1 }, { "PerCalDiv", 22, 8 }, { "PerCalEn", 21, 1 }, { "SglCalEn", 20, 1 }, { "ZInUpdMode", 19, 1 }, { "ZInSel", 18, 1 }, { "ZPDMan", 15, 3 }, { "ZPUMan", 12, 3 }, { "ZPDOut", 9, 3 }, { "ZPUOut", 6, 3 }, { "ZPDIn", 3, 3 }, { "ZPUIn", 0, 3 }, { "PCIX_WOL", 0x94, 0 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { "PCIX_STAT0", 0x98, 0 }, { "PIOReqFifoLevel", 26, 6 }, { "RFIniSt", 24, 2 }, { "RFRespRdSt", 22, 2 }, { "TarCSt", 19, 3 }, { "TarXSt", 16, 3 }, { "WFReqWrSt", 13, 3 }, { "WFRespFifoEmpty", 12, 1 }, { "WFReqFifoEmpty", 11, 1 }, { "RFRespFifoEmpty", 10, 1 }, { "RFReqFifoEmpty", 9, 1 }, { "PIORespFifoLevel", 7, 2 }, { "CFRespFifoEmpty", 6, 1 }, { "CFReqFifoEmpty", 5, 1 }, { "VPDRespFifoEmpty", 4, 1 }, { "VPDReqFifoEmpty", 3, 1 }, { "PIO_RspPnd", 2, 1 }, { "DlyTrnPnd", 1, 1 }, { "SplTrnPnd", 0, 1 }, { "PCIX_STAT1", 0x9c, 0 }, { "WFIniSt", 26, 4 }, { "ArbSt", 23, 3 }, { "PMISt", 21, 2 }, { "CalSt", 19, 2 }, { "CFReqRdSt", 17, 2 }, { "CFIniSt", 15, 2 }, { "CFRespRdSt", 13, 2 }, { "IniCSt", 10, 3 }, { "IniXSt", 7, 3 }, { "IntSt", 4, 3 }, { "PIOSt", 2, 2 }, { "RFReqRdSt", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3c_pcie0_regs[] = { { "PCIE_INT_ENABLE", 0x80, 0 }, { "BISTErr", 19, 8 }, { "TxParErr", 18, 1 }, { "RxParErr", 17, 1 }, { "RetryLUTParErr", 16, 1 }, { "RetryBUFParErr", 15, 1 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_INT_CAUSE", 0x84, 0 }, { "BISTErr", 19, 8 }, { "TxParErr", 18, 1 }, { "RxParErr", 17, 1 }, { "RetryLUTParErr", 16, 1 }, { "RetryBUFParErr", 15, 1 }, { "MSIXParErr", 12, 3 }, { "CFParErr", 11, 1 }, { "RFParErr", 10, 1 }, { "WFParErr", 9, 1 }, { "PIOParErr", 8, 1 }, { "UnxSplCplErrC", 7, 1 }, { "UnxSplCplErrR", 6, 1 }, { "VPDAddrChng", 5, 1 }, { "BusMstrEn", 4, 1 }, { "PMStChng", 3, 1 }, { "PEXMsg", 2, 1 }, { "ZeroLenRd", 1, 1 }, { "PEXErr", 0, 1 }, { "PCIE_CFG", 0x88, 0 }, { "DMAStopEn", 24, 1 }, { "PriorityINTA", 23, 1 }, { "IniFullPkt", 22, 1 }, { "EnableLinkDwnDRst", 21, 1 }, { "EnableLinkDownRst", 20, 1 }, { "EnableHotRst", 19, 1 }, { "IniWaitForGnt", 18, 1 }, { "IniBEDis", 17, 1 }, { "CLIDecEn", 16, 1 }, { "AsyncIntVec", 11, 5 }, { "MaxSplTrnC", 7, 4 }, { "MaxSplTrnR", 1, 6 }, { "CRstWrmMode", 0, 1 }, { "PCIE_MODE", 0x8c, 0 }, { "TAR_State", 29, 3 }, { "RF_StateIni", 26, 3 }, { "CF_StateIni", 23, 3 }, { "PIO_StatePL", 20, 3 }, { "PIO_StateISC", 18, 2 }, { "NumFstTrnSeqRx", 10, 8 }, { "LnkCntlState", 2, 8 }, { "VC0Up", 1, 1 }, { "LnkInitial", 0, 1 }, { "PCIE_STAT", 0x90, 0 }, { "INI_State", 28, 4 }, { "WF_StateIni", 24, 4 }, { "PLM_ReqFIFOCnt", 22, 2 }, { "ER_ReqFIFOEmpty", 21, 1 }, { "WF_RspFIFOEmpty", 20, 1 }, { "WF_ReqFIFOEmpty", 19, 1 }, { "RF_RspFIFOEmpty", 18, 1 }, { "RF_ReqFIFOEmpty", 17, 1 }, { "RF_ActEmpty", 16, 1 }, { "PIO_RspFIFOCnt", 11, 5 }, { "PIO_ReqFIFOCnt", 5, 6 }, { "CF_RspFIFOEmpty", 4, 1 }, { "CF_ReqFIFOEmpty", 3, 1 }, { "CF_ActEmpty", 2, 1 }, { "VPD_RspFIFOEmpty", 1, 1 }, { "VPD_ReqFIFOEmpty", 0, 1 }, { "PCIE_WOL", 0x94, 0 }, { "CF_RspState", 12, 2 }, { "RF_RspState", 10, 2 }, { "PME_State", 7, 3 }, { "INT_State", 4, 3 }, { "WakeUp1", 3, 1 }, { "WakeUp0", 2, 1 }, { "SleepMode1", 1, 1 }, { "SleepMode0", 0, 1 }, { "PCIE_PEX_CTRL0", 0x98, 0 }, { "CplTimeoutRetry", 31, 1 }, { "StrictTSMN", 30, 1 }, { "NumFstTrnSeq", 22, 8 }, { "ReplayLmt", 2, 20 }, { "TxPndChkEn", 1, 1 }, { "CplPndChkEn", 0, 1 }, { "PCIE_PEX_CTRL1", 0x9c, 0 }, { "RxPhyErrEn", 31, 1 }, { "DLLPTimeoutLmt", 13, 18 }, { "AckLat", 0, 13 }, { "PCIE_PEX_CTRL2", 0xa0, 0 }, { "LnkCntlDetDir", 30, 1 }, { "EnterL1rEn", 29, 1 }, { "PMExitL1Req", 28, 1 }, { "PMTxIdle", 27, 1 }, { "PCIModeLoop", 26, 1 }, { "L1ASPMTxRxL0sTime", 14, 12 }, { "L0sIdleTime", 3, 11 }, { "EnterL1ASPMEn", 2, 1 }, { "EnterL1En", 1, 1 }, { "EnterL0sEn", 0, 1 }, { "PCIE_PEX_ERR", 0xa4, 0 }, { "CplTimeoutID", 18, 7 }, { "FlowCtlOFlowErr", 17, 1 }, { "ReplayTimeout", 16, 1 }, { "ReplayRollover", 15, 1 }, { "BadDLLP", 14, 1 }, { "DLLPErr", 13, 1 }, { "FlowCtlProtErr", 12, 1 }, { "CplTimeout", 11, 1 }, { "PHYRcvErr", 10, 1 }, { "DisTLP", 9, 1 }, { "BadECRC", 8, 1 }, { "BadTLP", 7, 1 }, { "MalTLP", 6, 1 }, { "UnxCpl", 5, 1 }, { "UnsReq", 4, 1 }, { "PsnReq", 3, 1 }, { "UnsCpl", 2, 1 }, { "CplAbt", 1, 1 }, { "PsnCpl", 0, 1 }, { "PCIE_SERDES_CTRL", 0xa8, 0 }, { "PMASel", 3, 1 }, { "Lane", 0, 3 }, { "PCIE_SERDES_QUAD_CTRL0", 0xac, 0 }, { "TestSig", 10, 19 }, { "Offset", 2, 8 }, { "OffsetEn", 1, 1 }, { "IDDQb", 0, 1 }, { "PCIE_SERDES_QUAD_CTRL1", 0xb0, 0 }, { "FastInit", 28, 1 }, { "CTCDisable", 27, 1 }, { "ManResetPLL", 26, 1 }, { "ManL2Pwrdn", 25, 1 }, { "ManQuadEn", 24, 1 }, { "RxEqCtl", 22, 2 }, { "HiVMode", 21, 1 }, { "RefSel", 19, 2 }, { "RxTermAdj", 17, 2 }, { "TxTermAdj", 15, 2 }, { "Deq", 11, 4 }, { "Dtx", 7, 4 }, { "LoDrv", 6, 1 }, { "HiDrv", 5, 1 }, { "IntParReset", 4, 1 }, { "IntParLPBK", 3, 1 }, { "IntSerLPBKwDrv", 2, 1 }, { "PW", 1, 1 }, { "PClkDetect", 0, 1 }, { "PCIE_SERDES_LANE_CTRL", 0xb4, 0 }, { "ExtBISTChkErrClr", 22, 1 }, { "ExtBISTChkEn", 21, 1 }, { "ExtBISTGenEn", 20, 1 }, { "ExtBISTPat", 17, 3 }, { "ExtParReset", 16, 1 }, { "ExtParLPBK", 15, 1 }, { "ManRxTermEn", 14, 1 }, { "ManBeaconTxEn", 13, 1 }, { "ManRxDetectEn", 12, 1 }, { "ManTxIdleEn", 11, 1 }, { "ManRxIdleEn", 10, 1 }, { "ManL1Pwrdn", 9, 1 }, { "ManReset", 8, 1 }, { "ManFmOffset", 3, 5 }, { "ManFmOffsetEn", 2, 1 }, { "ManLaneEn", 1, 1 }, { "IntSerLPBK", 0, 1 }, { "PCIE_SERDES_LANE_STAT", 0xb8, 0 }, { "ExtBISTChkErrCnt", 8, 24 }, { "ExtBISTChkFmd", 7, 1 }, { "BeaconDetectChg", 6, 1 }, { "RxDetectChg", 5, 1 }, { "TxIdleDetectChg", 4, 1 }, { "BeaconDetect", 2, 1 }, { "RxDetect", 1, 1 }, { "TxIdleDetect", 0, 1 }, { "PCIE_PEX_WMARK", 0xbc, 0 }, { "P_WMark", 18, 11 }, { "NP_WMark", 11, 7 }, { "CPL_WMark", 0, 11 }, { NULL, 0, 0 } }; struct reg_info t3c_t3dbg_regs[] = { { "T3DBG_DBG0_CFG", 0xc0, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG0_EN", 0xc4, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_DBG1_CFG", 0xc8, 0 }, { "RegSelect", 9, 8 }, { "ModuleSelect", 4, 5 }, { "ClkSelect", 0, 4 }, { "T3DBG_DBG1_EN", 0xcc, 0 }, { "SDRByte0", 8, 1 }, { "DDREn", 4, 1 }, { "PortEn", 0, 1 }, { "T3DBG_GPIO_EN", 0xd0, 0 }, { "GPIO11_OEn", 27, 1 }, { "GPIO10_OEn", 26, 1 }, { "GPIO9_OEn", 25, 1 }, { "GPIO8_OEn", 24, 1 }, { "GPIO7_OEn", 23, 1 }, { "GPIO6_OEn", 22, 1 }, { "GPIO5_OEn", 21, 1 }, { "GPIO4_OEn", 20, 1 }, { "GPIO3_OEn", 19, 1 }, { "GPIO2_OEn", 18, 1 }, { "GPIO1_OEn", 17, 1 }, { "GPIO0_OEn", 16, 1 }, { "GPIO11_Out_Val", 11, 1 }, { "GPIO10_Out_Val", 10, 1 }, { "GPIO9_Out_Val", 9, 1 }, { "GPIO8_Out_Val", 8, 1 }, { "GPIO7_Out_Val", 7, 1 }, { "GPIO6_Out_Val", 6, 1 }, { "GPIO5_Out_Val", 5, 1 }, { "GPIO4_Out_Val", 4, 1 }, { "GPIO3_Out_Val", 3, 1 }, { "GPIO2_Out_Val", 2, 1 }, { "GPIO1_Out_Val", 1, 1 }, { "GPIO0_Out_Val", 0, 1 }, { "T3DBG_GPIO_IN", 0xd4, 0 }, { "GPIO11_CHG_DET", 27, 1 }, { "GPIO10_CHG_DET", 26, 1 }, { "GPIO9_CHG_DET", 25, 1 }, { "GPIO8_CHG_DET", 24, 1 }, { "GPIO7_CHG_DET", 23, 1 }, { "GPIO6_CHG_DET", 22, 1 }, { "GPIO5_CHG_DET", 21, 1 }, { "GPIO4_CHG_DET", 20, 1 }, { "GPIO3_CHG_DET", 19, 1 }, { "GPIO2_CHG_DET", 18, 1 }, { "GPIO1_CHG_DET", 17, 1 }, { "GPIO0_CHG_DET", 16, 1 }, { "GPIO11_IN", 11, 1 }, { "GPIO10_IN", 10, 1 }, { "GPIO9_IN", 9, 1 }, { "GPIO8_IN", 8, 1 }, { "GPIO7_IN", 7, 1 }, { "GPIO6_IN", 6, 1 }, { "GPIO5_IN", 5, 1 }, { "GPIO4_IN", 4, 1 }, { "GPIO3_IN", 3, 1 }, { "GPIO2_IN", 2, 1 }, { "GPIO1_IN", 1, 1 }, { "GPIO0_IN", 0, 1 }, { "T3DBG_INT_ENABLE", 0xd8, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_INT_CAUSE", 0xdc, 0 }, { "C_LOCK", 21, 1 }, { "M_LOCK", 20, 1 }, { "U_LOCK", 19, 1 }, { "R_LOCK", 18, 1 }, { "PX_LOCK", 17, 1 }, { "GPIO11", 11, 1 }, { "GPIO10", 10, 1 }, { "GPIO9", 9, 1 }, { "GPIO8", 8, 1 }, { "GPIO7", 7, 1 }, { "GPIO6", 6, 1 }, { "GPIO5", 5, 1 }, { "GPIO4", 4, 1 }, { "GPIO3", 3, 1 }, { "GPIO2", 2, 1 }, { "GPIO1", 1, 1 }, { "GPIO0", 0, 1 }, { "T3DBG_DBG0_RST_VALUE", 0xe0, 0 }, { "DebugData", 0, 8 }, { "T3DBG_PLL_OCLK_PAD_EN", 0xe4, 0 }, { "PCIE_OCLK_En", 20, 1 }, { "PClkTree_DBG_En", 17, 1 }, { "PCIX_OCLK_En", 16, 1 }, { "U_OCLK_En", 12, 1 }, { "R_OCLK_En", 8, 1 }, { "M_OCLK_En", 4, 1 }, { "C_OCLK_En", 0, 1 }, { "T3DBG_PLL_LOCK", 0xe8, 0 }, { "PCIX_LOCK", 16, 1 }, { "U_LOCK", 12, 1 }, { "R_LOCK", 8, 1 }, { "M_LOCK", 4, 1 }, { "C_LOCK", 0, 1 }, { "T3DBG_SERDES_RBC_CFG", 0xec, 0 }, { "X_RBC_Lane_Sel", 16, 2 }, { "X_RBC_Dbg_En", 12, 1 }, { "X_Serdes_Sel", 8, 1 }, { "PE_RBC_Lane_Sel", 4, 3 }, { "PE_RBC_Dbg_En", 0, 1 }, { "T3DBG_GPIO_ACT_LOW", 0xf0, 0 }, { "C_LOCK_ACT_LOW", 21, 1 }, { "M_LOCK_ACT_LOW", 20, 1 }, { "U_LOCK_ACT_LOW", 19, 1 }, { "R_LOCK_ACT_LOW", 18, 1 }, { "PX_LOCK_ACT_LOW", 17, 1 }, { "GPIO11_ACT_LOW", 11, 1 }, { "GPIO10_ACT_LOW", 10, 1 }, { "GPIO9_ACT_LOW", 9, 1 }, { "GPIO8_ACT_LOW", 8, 1 }, { "GPIO7_ACT_LOW", 7, 1 }, { "GPIO6_ACT_LOW", 6, 1 }, { "GPIO5_ACT_LOW", 5, 1 }, { "GPIO4_ACT_LOW", 4, 1 }, { "GPIO3_ACT_LOW", 3, 1 }, { "GPIO2_ACT_LOW", 2, 1 }, { "GPIO1_ACT_LOW", 1, 1 }, { "GPIO0_ACT_LOW", 0, 1 }, { "T3DBG_PMON_CFG", 0xf4, 0 }, { "PMON_DONE", 29, 1 }, { "PMON_FAIL", 28, 1 }, { "PMON_FDEL_AUTO", 22, 6 }, { "PMON_CDEL_AUTO", 16, 6 }, { "PMON_FDEL_MANUAL", 10, 6 }, { "PMON_CDEL_MANUAL", 4, 6 }, { "PMON_MANUAL", 1, 1 }, { "PMON_AUTO", 0, 1 }, { "T3DBG_SERDES_REFCLK_CFG", 0xf8, 0 }, { "PE_REFCLK_DBG_EN", 12, 1 }, { "X_REFCLK_DBG_EN", 8, 1 }, { "PE_REFCLK_TERMADJ", 5, 2 }, { "PE_REFCLK_PD", 4, 1 }, { "X_REFCLK_TERMADJ", 1, 2 }, { "X_REFCLK_PD", 0, 1 }, { "T3DBG_PCIE_PMA_BSPIN_CFG", 0xfc, 0 }, { "BSModeQuad1", 31, 1 }, { "BSInSelLane7", 29, 2 }, { "BSEnLane7", 28, 1 }, { "BSInSelLane6", 25, 2 }, { "BSEnLane6", 24, 1 }, { "BSInSelLane5", 21, 2 }, { "BSEnLane5", 20, 1 }, { "BSInSelLane4", 17, 2 }, { "BSEnLane4", 16, 1 }, { "BSModeQuad0", 15, 1 }, { "BSInSelLane3", 13, 2 }, { "BSEnLane3", 12, 1 }, { "BSInSelLane2", 9, 2 }, { "BSEnLane2", 8, 1 }, { "BSInSelLane1", 5, 2 }, { "BSEnLane1", 4, 1 }, { "BSInSelLane0", 1, 2 }, { "BSEnLane0", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_mc7_pmrx_regs[] = { { "MC7_CFG", 0x100, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x104, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x108, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x10c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x110, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x114, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x118, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x11c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x120, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x124, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x128, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x12c, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x130, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x134, 0 }, { "MC7_CE_DATA0", 0x138, 0 }, { "MC7_CE_DATA1", 0x13c, 0 }, { "MC7_CE_DATA2", 0x140, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x144, 0 }, { "MC7_UE_DATA0", 0x148, 0 }, { "MC7_UE_DATA1", 0x14c, 0 }, { "MC7_UE_DATA2", 0x150, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x154, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x158, 0 }, { "MC7_BD_DATA1", 0x15c, 0 }, { "MC7_BD_DATA2", 0x160, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x164, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x168, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x16c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x170, 0 }, { "MC7_BIST_OP", 0x174, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x178, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x17c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_mc7_pmtx_regs[] = { { "MC7_CFG", 0x180, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x184, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x188, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x18c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x190, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x194, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x198, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x19c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x1a0, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x1a4, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x1a8, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x1ac, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x1b0, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x1b4, 0 }, { "MC7_CE_DATA0", 0x1b8, 0 }, { "MC7_CE_DATA1", 0x1bc, 0 }, { "MC7_CE_DATA2", 0x1c0, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x1c4, 0 }, { "MC7_UE_DATA0", 0x1c8, 0 }, { "MC7_UE_DATA1", 0x1cc, 0 }, { "MC7_UE_DATA2", 0x1d0, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x1d4, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x1d8, 0 }, { "MC7_BD_DATA1", 0x1dc, 0 }, { "MC7_BD_DATA2", 0x1e0, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x1e4, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x1e8, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x1ec, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x1f0, 0 }, { "MC7_BIST_OP", 0x1f4, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x1f8, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x1fc, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_mc7_cm_regs[] = { { "MC7_CFG", 0x200, 0 }, { "ImpSetUpdate", 14, 1 }, { "IFEn", 13, 1 }, { "TERM300", 12, 1 }, { "TERM150", 11, 1 }, { "Slow", 10, 1 }, { "Width", 8, 2 }, { "ODTEn", 7, 1 }, { "Bks", 6, 1 }, { "Org", 5, 1 }, { "Den", 2, 3 }, { "Rdy", 1, 1 }, { "ClkEn", 0, 1 }, { "MC7_MODE", 0x204, 0 }, { "Busy", 31, 1 }, { "Mode", 0, 16 }, { "MC7_EXT_MODE1", 0x208, 0 }, { "Busy", 31, 1 }, { "OCDAdjustMode", 20, 1 }, { "OCDCode", 16, 4 }, { "ExtMode1", 0, 16 }, { "MC7_EXT_MODE2", 0x20c, 0 }, { "Busy", 31, 1 }, { "ExtMode2", 0, 16 }, { "MC7_EXT_MODE3", 0x210, 0 }, { "Busy", 31, 1 }, { "ExtMode3", 0, 16 }, { "MC7_PRE", 0x214, 0 }, { "Busy", 31, 1 }, { "MC7_REF", 0x218, 0 }, { "Busy", 31, 1 }, { "PreRefDiv", 1, 14 }, { "PerRefEn", 0, 1 }, { "MC7_DLL", 0x21c, 0 }, { "DLLLock", 31, 1 }, { "DLLDelta", 24, 7 }, { "ManDelta", 3, 7 }, { "DLLDeltaSel", 2, 1 }, { "DLLEnb", 1, 1 }, { "DLLRst", 0, 1 }, { "MC7_PARM", 0x220, 0 }, { "ActToPreDly", 26, 4 }, { "ActToRdWrDly", 23, 3 }, { "PreCyc", 20, 3 }, { "RefCyc", 13, 7 }, { "BkCyc", 8, 5 }, { "WrToRdDly", 4, 4 }, { "RdToWrDly", 0, 4 }, { "MC7_HWM_WRR", 0x224, 0 }, { "MEM_HWM", 26, 6 }, { "ULP_HWM", 22, 4 }, { "TOT_RLD_WT", 14, 8 }, { "MEM_RLD_WT", 7, 7 }, { "ULP_RLD_WT", 0, 7 }, { "MC7_CAL", 0x228, 0 }, { "BUSY", 31, 1 }, { "CAL_FAULT", 30, 1 }, { "PER_CAL_DIV", 22, 8 }, { "PER_CAL_EN", 21, 1 }, { "SGL_CAL_EN", 20, 1 }, { "IMP_UPD_MODE", 19, 1 }, { "IMP_SEL", 18, 1 }, { "IMP_MAN_PD", 15, 3 }, { "IMP_MAN_PU", 12, 3 }, { "IMP_CAL_PD", 9, 3 }, { "IMP_CAL_PU", 6, 3 }, { "IMP_SET_PD", 3, 3 }, { "IMP_SET_PU", 0, 3 }, { "MC7_ERR_ADDR", 0x22c, 0 }, { "ErrAddress", 3, 29 }, { "ErrAgent", 1, 2 }, { "ErrOp", 0, 1 }, { "MC7_ECC", 0x230, 0 }, { "UECnt", 10, 8 }, { "CECnt", 2, 8 }, { "ECCChkEn", 1, 1 }, { "ECCGenEn", 0, 1 }, { "MC7_CE_ADDR", 0x234, 0 }, { "MC7_CE_DATA0", 0x238, 0 }, { "MC7_CE_DATA1", 0x23c, 0 }, { "MC7_CE_DATA2", 0x240, 0 }, { "Data", 0, 8 }, { "MC7_UE_ADDR", 0x244, 0 }, { "MC7_UE_DATA0", 0x248, 0 }, { "MC7_UE_DATA1", 0x24c, 0 }, { "MC7_UE_DATA2", 0x250, 0 }, { "Data", 0, 8 }, { "MC7_BD_ADDR", 0x254, 0 }, { "Addr", 3, 29 }, { "MC7_BD_DATA0", 0x258, 0 }, { "MC7_BD_DATA1", 0x25c, 0 }, { "MC7_BD_DATA2", 0x260, 0 }, { "Data", 0, 8 }, { "MC7_BD_OP", 0x264, 0 }, { "Busy", 31, 1 }, { "Op", 0, 1 }, { "MC7_BIST_ADDR_BEG", 0x268, 0 }, { "AddrBeg", 5, 27 }, { "MC7_BIST_ADDR_END", 0x26c, 0 }, { "AddrEnd", 5, 27 }, { "MC7_BIST_DATA", 0x270, 0 }, { "MC7_BIST_OP", 0x274, 0 }, { "Busy", 31, 1 }, { "Gap", 4, 5 }, { "Cont", 3, 1 }, { "DataPat", 1, 2 }, { "Op", 0, 1 }, { "MC7_INT_ENABLE", 0x278, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { "MC7_INT_CAUSE", 0x27c, 0 }, { "AE", 17, 1 }, { "PE", 2, 15 }, { "UE", 1, 1 }, { "CE", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_cim_regs[] = { { "CIM_BOOT_CFG", 0x280, 0 }, { "BootAddr", 2, 30 }, { "BootSdram", 1, 1 }, { "uPCRst", 0, 1 }, { "CIM_FLASH_BASE_ADDR", 0x284, 0 }, { "FlashBaseAddr", 2, 22 }, { "CIM_FLASH_ADDR_SIZE", 0x288, 0 }, { "FlashAddrSize", 2, 22 }, { "CIM_SDRAM_BASE_ADDR", 0x28c, 0 }, { "SdramBaseAddr", 2, 30 }, { "CIM_SDRAM_ADDR_SIZE", 0x290, 0 }, { "SdramAddrSize", 2, 30 }, { "CIM_UP_SPARE_INT", 0x294, 0 }, { "uPSpareInt", 0, 3 }, { "CIM_HOST_INT_ENABLE", 0x298, 0 }, { "DTagParErr", 28, 1 }, { "ITagParErr", 27, 1 }, { "IBQTPParErr", 26, 1 }, { "IBQULPParErr", 25, 1 }, { "IBQSGEHIParErr", 24, 1 }, { "IBQSGELOParErr", 23, 1 }, { "OBQULPLOParErr", 22, 1 }, { "OBQULPHIParErr", 21, 1 }, { "OBQSGEParErr", 20, 1 }, { "DCacheParErr", 19, 1 }, { "ICacheParErr", 18, 1 }, { "DRamParErr", 17, 1 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_HOST_INT_CAUSE", 0x29c, 0 }, { "DTagParErr", 28, 1 }, { "ITagParErr", 27, 1 }, { "IBQTPParErr", 26, 1 }, { "IBQULPParErr", 25, 1 }, { "IBQSGEHIParErr", 24, 1 }, { "IBQSGELOParErr", 23, 1 }, { "OBQULPLOParErr", 22, 1 }, { "OBQULPHIParErr", 21, 1 }, { "OBQSGEParErr", 20, 1 }, { "DCacheParErr", 19, 1 }, { "ICacheParErr", 18, 1 }, { "DRamParErr", 17, 1 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_UP_INT_ENABLE", 0x2a0, 0 }, { "DTagParErr", 28, 1 }, { "ITagParErr", 27, 1 }, { "IBQTPParErr", 26, 1 }, { "IBQULPParErr", 25, 1 }, { "IBQSGEHIParErr", 24, 1 }, { "IBQSGELOParErr", 23, 1 }, { "OBQULPLOParErr", 22, 1 }, { "OBQULPHIParErr", 21, 1 }, { "OBQSGEParErr", 20, 1 }, { "DCacheParErr", 19, 1 }, { "ICacheParErr", 18, 1 }, { "DRamParErr", 17, 1 }, { "MstPlIntEn", 16, 1 }, { "Timer1IntEn", 15, 1 }, { "Timer0IntEn", 14, 1 }, { "PrefDropIntEn", 13, 1 }, { "BlkWrPlIntEn", 12, 1 }, { "BlkRdPlIntEn", 11, 1 }, { "BlkWrCtlIntEn", 10, 1 }, { "BlkRdCtlIntEn", 9, 1 }, { "BlkWrFlashIntEn", 8, 1 }, { "BlkRdFlashIntEn", 7, 1 }, { "SglWrFlashIntEn", 6, 1 }, { "WrBlkFlashIntEn", 5, 1 }, { "BlkWrBootIntEn", 4, 1 }, { "BlkRdBootIntEn", 3, 1 }, { "FlashRangeIntEn", 2, 1 }, { "SdramRangeIntEn", 1, 1 }, { "RsvdSpaceIntEn", 0, 1 }, { "CIM_UP_INT_CAUSE", 0x2a4, 0 }, { "DTagParErr", 28, 1 }, { "ITagParErr", 27, 1 }, { "IBQTPParErr", 26, 1 }, { "IBQULPParErr", 25, 1 }, { "IBQSGEHIParErr", 24, 1 }, { "IBQSGELOParErr", 23, 1 }, { "OBQULPLOParErr", 22, 1 }, { "OBQULPHIParErr", 21, 1 }, { "OBQSGEParErr", 20, 1 }, { "DCacheParErr", 19, 1 }, { "ICacheParErr", 18, 1 }, { "DRamParErr", 17, 1 }, { "MstPlInt", 16, 1 }, { "Timer1Int", 15, 1 }, { "Timer0Int", 14, 1 }, { "PrefDropInt", 13, 1 }, { "BlkWrPlInt", 12, 1 }, { "BlkRdPlInt", 11, 1 }, { "BlkWrCtlInt", 10, 1 }, { "BlkRdCtlInt", 9, 1 }, { "BlkWrFlashInt", 8, 1 }, { "BlkRdFlashInt", 7, 1 }, { "SglWrFlashInt", 6, 1 }, { "WrBlkFlashInt", 5, 1 }, { "BlkWrBootInt", 4, 1 }, { "BlkRdBootInt", 3, 1 }, { "FlashRangeInt", 2, 1 }, { "SdramRangeInt", 1, 1 }, { "RsvdSpaceInt", 0, 1 }, { "CIM_IBQ_FULLA_THRSH", 0x2a8, 0 }, { "Ibq0FullThrsh", 0, 9 }, { "Ibq1FullThrsh", 16, 9 }, { "CIM_IBQ_FULLB_THRSH", 0x2ac, 0 }, { "Ibq2FullThrsh", 0, 9 }, { "Ibq3FullThrsh", 16, 9 }, { "CIM_HOST_ACC_CTRL", 0x2b0, 0 }, { "HostBusy", 17, 1 }, { "HostWrite", 16, 1 }, { "HostAddr", 0, 16 }, { "CIM_HOST_ACC_DATA", 0x2b4, 0 }, { "CIM_IBQ_DBG_CFG", 0x2c0, 0 }, { "IbqDbgAddr", 16, 9 }, { "IbqDbgQID", 3, 2 }, { "IbqDbgWr", 2, 1 }, { "IbqDbgBusy", 1, 1 }, { "IbqDbgEn", 0, 1 }, { "CIM_OBQ_DBG_CFG", 0x2c4, 0 }, { "ObqDbgAddr", 16, 9 }, { "ObqDbgQID", 3, 2 }, { "ObqDbgWr", 2, 1 }, { "ObqDbgBusy", 1, 1 }, { "ObqDbgEn", 0, 1 }, { "CIM_IBQ_DBG_DATA", 0x2c8, 0 }, { "CIM_OBQ_DBG_DATA", 0x2cc, 0 }, { "CIM_CDEBUGDATA", 0x2d0, 0 }, { "CDebugDataH", 16, 16 }, { "CDebugDataL", 0, 16 }, { "CIM_DEBUGCFG", 0x2e0, 0 }, { "POLADbgRdPtr", 23, 9 }, { "PILADbgRdPtr", 14, 9 }, { "LADbgEn", 12, 1 }, { "DebugSelH", 5, 5 }, { "DebugSelL", 0, 5 }, { "CIM_DEBUGSTS", 0x2e4, 0 }, { "POLADbgWrPtr", 16, 9 }, { "PILADbgWrPtr", 0, 9 }, { "CIM_PO_LA_DEBUGDATA", 0x2e8, 0 }, { "CIM_PI_LA_DEBUGDATA", 0x2ec, 0 }, { NULL, 0, 0 } }; struct reg_info t3c_tp1_regs[] = { { "TP_IN_CONFIG", 0x300, 0 }, { "RXFbArbPrio", 25, 1 }, { "TXFbArbPrio", 24, 1 }, { "DBMaxOpCnt", 16, 8 }, { "IPv6Enable", 15, 1 }, { "NICMode", 14, 1 }, { "EChecksumCheckTCP", 13, 1 }, { "EChecksumCheckIP", 12, 1 }, { "ECPL", 10, 1 }, { "EEthernet", 8, 1 }, { "ETunnel", 7, 1 }, { "CChecksumCheckTCP", 6, 1 }, { "CChecksumCheckIP", 5, 1 }, { "CCPL", 3, 1 }, { "CEthernet", 1, 1 }, { "CTunnel", 0, 1 }, { "TP_OUT_CONFIG", 0x304, 0 }, { "IPIDSplitMode", 16, 1 }, { "VLANExtractionEnable2ndPort", 13, 1 }, { "VLANExtractionEnable", 12, 1 }, { "EChecksumGenerateTCP", 11, 1 }, { "EChecksumGenerateIP", 10, 1 }, { "ECPL", 8, 1 }, { "EEthernet", 6, 1 }, { "CChecksumGenerateTCP", 5, 1 }, { "CChecksumGenerateIP", 4, 1 }, { "CCPL", 2, 1 }, { "CEthernet", 0, 1 }, { "TP_GLOBAL_CONFIG", 0x308, 0 }, { "SYNCookieParams", 26, 6 }, { "RXFlowControlDisable", 25, 1 }, { "TXPacingEnable", 24, 1 }, { "AttackFilterEnable", 23, 1 }, { "SYNCookieNoOptions", 22, 1 }, { "ProtectedMode", 21, 1 }, { "PingDrop", 20, 1 }, { "FragmentDrop", 19, 1 }, { "FiveTupleLookup", 17, 2 }, { "PathMTU", 15, 1 }, { "IPIdentSplit", 14, 1 }, { "IPChecksumOffload", 13, 1 }, { "UDPChecksumOffload", 12, 1 }, { "TCPChecksumOffload", 11, 1 }, { "QOSMapping", 10, 1 }, { "TCAMServerUse", 8, 2 }, { "IPTTL", 0, 8 }, { "TP_GLOBAL_RX_CREDIT", 0x30c, 0 }, { "TP_CMM_SIZE", 0x310, 0 }, { "CMMemMgrSize", 0, 28 }, { "TP_CMM_MM_BASE", 0x314, 0 }, { "CMMemMgrBase", 0, 28 }, { "TP_CMM_TIMER_BASE", 0x318, 0 }, { "CMTimerMaxNum", 28, 2 }, { "CMTimerBase", 0, 28 }, { "TP_PMM_SIZE", 0x31c, 0 }, { "PMSize", 0, 28 }, { "TP_PMM_TX_BASE", 0x320, 0 }, { "TP_PMM_DEFRAG_BASE", 0x324, 0 }, { "TP_PMM_RX_BASE", 0x328, 0 }, { "TP_PMM_RX_PAGE_SIZE", 0x32c, 0 }, { "TP_PMM_RX_MAX_PAGE", 0x330, 0 }, { "PMRxMaxPage", 0, 21 }, { "TP_PMM_TX_PAGE_SIZE", 0x334, 0 }, { "TP_PMM_TX_MAX_PAGE", 0x338, 0 }, { "PMTxMaxPage", 0, 21 }, { "TP_TCP_OPTIONS", 0x340, 0 }, { "MTUDefault", 16, 16 }, { "MTUEnable", 10, 1 }, { "SACKTx", 9, 1 }, { "SACKRx", 8, 1 }, { "SACKMode", 4, 2 }, { "WindowScaleMode", 2, 2 }, { "TimestampsMode", 0, 2 }, { "TP_DACK_CONFIG", 0x344, 0 }, { "AutoState3", 30, 2 }, { "AutoState2", 28, 2 }, { "AutoState1", 26, 2 }, { "ByteThreshold", 5, 20 }, { "MSSThreshold", 3, 2 }, { "AutoCareful", 2, 1 }, { "AutoEnable", 1, 1 }, { "Mode", 0, 1 }, { "TP_PC_CONFIG", 0x348, 0 }, { "CMCacheDisable", 31, 1 }, { "EnableOcspiFull", 30, 1 }, { "EnableFLMErrorDDP", 29, 1 }, { "LockTid", 28, 1 }, { "FixRcvWnd", 27, 1 }, { "TxTosQueueMapMode", 26, 1 }, { "RddpCongEn", 25, 1 }, { "EnableOnFlyPDU", 24, 1 }, { "EnableEPCMDAFull", 23, 1 }, { "ModulateUnionMode", 22, 1 }, { "TxDataAckRateEnable", 21, 1 }, { "TxDeferEnable", 20, 1 }, { "RxCongestionMode", 19, 1 }, { "HearbeatOnceDACK", 18, 1 }, { "HearbeatOnceHeap", 17, 1 }, { "HearbeatDACK", 16, 1 }, { "TxCongestionMode", 15, 1 }, { "AcceptLatestRcvAdv", 14, 1 }, { "DisableSYNData", 13, 1 }, { "DisableWindowPSH", 12, 1 }, { "DisableFINOldData", 11, 1 }, { "EnableFLMError", 10, 1 }, { "DisableNextMtu", 9, 1 }, { "FilterPeerFIN", 8, 1 }, { "EnableFeedbackSend", 7, 1 }, { "EnableRDMAError", 6, 1 }, { "EnableDDPFlowControl", 5, 1 }, { "DisableHeldFIN", 4, 1 }, { "TableLatencyDelta", 0, 4 }, { "TP_PC_CONFIG2", 0x34c, 0 }, { "DisbleDaParbit0", 15, 1 }, { "EnableArpMiss", 13, 1 }, { "EnableNonOfdTnlSyn", 12, 1 }, { "EnableIPv6RSS", 11, 1 }, { "EnableDropRQEmptyPkt", 10, 1 }, { "EnableTxPortfromDA2", 9, 1 }, { "EnableRxPktTmstpRss", 8, 1 }, { "EnableSndUnaInRxData", 7, 1 }, { "EnableRxPortFromAddr", 6, 1 }, { "EnableTxPortfromDA", 5, 1 }, { "EnableCHdrAFull", 4, 1 }, { "EnableNonOfdScbBit", 3, 1 }, { "EnableNonOfdTidRss", 2, 1 }, { "EnableNonOfdTcbRss", 1, 1 }, { "EnableOldRxForward", 0, 1 }, { "TP_TCP_BACKOFF_REG0", 0x350, 0 }, { "TimerBackoffIndex3", 24, 8 }, { "TimerBackoffIndex2", 16, 8 }, { "TimerBackoffIndex1", 8, 8 }, { "TimerBackoffIndex0", 0, 8 }, { "TP_TCP_BACKOFF_REG1", 0x354, 0 }, { "TimerBackoffIndex7", 24, 8 }, { "TimerBackoffIndex6", 16, 8 }, { "TimerBackoffIndex5", 8, 8 }, { "TimerBackoffIndex4", 0, 8 }, { "TP_TCP_BACKOFF_REG2", 0x358, 0 }, { "TimerBackoffIndex11", 24, 8 }, { "TimerBackoffIndex10", 16, 8 }, { "TimerBackoffIndex9", 8, 8 }, { "TimerBackoffIndex8", 0, 8 }, { "TP_TCP_BACKOFF_REG3", 0x35c, 0 }, { "TimerBackoffIndex15", 24, 8 }, { "TimerBackoffIndex14", 16, 8 }, { "TimerBackoffIndex13", 8, 8 }, { "TimerBackoffIndex12", 0, 8 }, { "TP_PARA_REG0", 0x360, 0 }, { "InitCwnd", 24, 3 }, { "DupAckThresh", 20, 4 }, { "TP_PARA_REG1", 0x364, 0 }, { "InitRwnd", 16, 16 }, { "InitialSSThresh", 0, 16 }, { "TP_PARA_REG2", 0x368, 0 }, { "MaxRxData", 16, 16 }, { "RxCoalesceSize", 0, 16 }, { "TP_PARA_REG3", 0x36c, 0 }, { "TunnelCngDrop1", 21, 1 }, { "TunnelCngDrop0", 20, 1 }, { "TxDataAckIdx", 16, 4 }, { "RxFragEnable", 12, 3 }, { "TxPaceFixedStrict", 11, 1 }, { "TxPaceAutoStrict", 10, 1 }, { "TxPaceFixed", 9, 1 }, { "TxPaceAuto", 8, 1 }, { "RxUrgTunnel", 6, 1 }, { "RxUrgMode", 5, 1 }, { "TxUrgMode", 4, 1 }, { "CngCtrlMode", 2, 2 }, { "RxCoalesceEnable", 1, 1 }, { "RxCoalescePshEn", 0, 1 }, { "TP_PARA_REG4", 0x370, 0 }, { "HighSpeedCfg", 24, 8 }, { "NewRenoCfg", 16, 8 }, { "TahoeCfg", 8, 8 }, { "RenoCfg", 0, 8 }, { "TP_PARA_REG5", 0x374, 0 }, { "IndicateSize", 16, 16 }, { "SchdEnable", 8, 1 }, { "RxDdpOffInit", 3, 1 }, { "OnFlyDDPEnable", 2, 1 }, { "DackTimerSpin", 1, 1 }, { "PushTimerEnable", 0, 1 }, { "TP_PARA_REG6", 0x378, 0 }, { "TxPDUSizeAdj", 16, 8 }, { "EnableDeferACK", 12, 1 }, { "EnableESnd", 11, 1 }, { "EnableCSnd", 10, 1 }, { "EnablePDUE", 9, 1 }, { "EnablePDUC", 8, 1 }, { "EnableBUFI", 7, 1 }, { "EnableBUFE", 6, 1 }, { "EnableDefer", 5, 1 }, { "EnableClearRxmtOos", 4, 1 }, { "DisablePDUCng", 3, 1 }, { "DisablePDUTimeout", 2, 1 }, { "DisablePDURxmt", 1, 1 }, { "DisablePDUxmt", 0, 1 }, { "TP_PARA_REG7", 0x37c, 0 }, { "PMMaxXferLen1", 16, 16 }, { "PMMaxXferLen0", 0, 16 }, { "TP_TIMER_RESOLUTION", 0x390, 0 }, { "TimerResolution", 16, 8 }, { "TimestampResolution", 8, 8 }, { "DelayedACKResolution", 0, 8 }, { "TP_MSL", 0x394, 0 }, { "MSL", 0, 30 }, { "TP_RXT_MIN", 0x398, 0 }, { "RxtMin", 0, 30 }, { "TP_RXT_MAX", 0x39c, 0 }, { "RxtMax", 0, 30 }, { "TP_PERS_MIN", 0x3a0, 0 }, { "PersMin", 0, 30 }, { "TP_PERS_MAX", 0x3a4, 0 }, { "PersMax", 0, 30 }, { "TP_KEEP_IDLE", 0x3a8, 0 }, { "KeepaliveIdle", 0, 30 }, { "TP_KEEP_INTVL", 0x3ac, 0 }, { "KeepaliveIntvl", 0, 30 }, { "TP_INIT_SRTT", 0x3b0, 0 }, { "InitSrtt", 0, 16 }, { "TP_DACK_TIMER", 0x3b4, 0 }, { "DackTime", 0, 12 }, { "TP_FINWAIT2_TIMER", 0x3b8, 0 }, { "Finwait2Time", 0, 30 }, { "TP_FAST_FINWAIT2_TIMER", 0x3bc, 0 }, { "FastFinwait2Time", 0, 30 }, { "TP_SHIFT_CNT", 0x3c0, 0 }, { "SynShiftMax", 24, 8 }, { "RxtShiftMaxR1", 20, 4 }, { "RxtShiftMaxR2", 16, 4 }, { "PerShiftBackoffMax", 12, 4 }, { "PerShiftMax", 8, 4 }, { "KeepaliveMax", 0, 8 }, { "TP_TIME_HI", 0x3c8, 0 }, { "TP_TIME_LO", 0x3cc, 0 }, { "TP_MTU_PORT_TABLE", 0x3d0, 0 }, { "Port1MTUValue", 16, 16 }, { "Port0MTUValue", 0, 16 }, { "TP_ULP_TABLE", 0x3d4, 0 }, { "ULPType7Field", 28, 4 }, { "ULPType6Field", 24, 4 }, { "ULPType5Field", 20, 4 }, { "ULPType4Field", 16, 4 }, { "ULPType3Field", 12, 4 }, { "ULPType2Field", 8, 4 }, { "ULPType1Field", 4, 4 }, { "ULPType0Field", 0, 4 }, { "TP_PACE_TABLE", 0x3d8, 0 }, { "TP_CCTRL_TABLE", 0x3dc, 0 }, { "TP_TOS_TABLE", 0x3e0, 0 }, { "TP_MTU_TABLE", 0x3e4, 0 }, { "TP_RSS_MAP_TABLE", 0x3e8, 0 }, { "TP_RSS_LKP_TABLE", 0x3ec, 0 }, { "TP_RSS_CONFIG", 0x3f0, 0 }, { "TNL4tupEn", 29, 1 }, { "TNL2tupEn", 28, 1 }, { "TNLprtEn", 26, 1 }, { "TNLMapEn", 25, 1 }, { "TNLLkpEn", 24, 1 }, { "OFD4tupEn", 21, 1 }, { "OFD2tupEn", 20, 1 }, { "OFDMapEn", 17, 1 }, { "OFDLkpEn", 16, 1 }, { "SYN4tupEn", 13, 1 }, { "SYN2tupEn", 12, 1 }, { "SYNMapEn", 9, 1 }, { "SYNLkpEn", 8, 1 }, { "RRCPLMapEn", 7, 1 }, { "RRCPLCPUSIZE", 4, 3 }, { "RQFeedbackEnable", 3, 1 }, { "HashToeplitz", 2, 1 }, { "HashSave", 1, 1 }, { "Disable", 0, 1 }, { "TP_RSS_CONFIG_TNL", 0x3f4, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_OFD", 0x3f8, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_CONFIG_SYN", 0x3fc, 0 }, { "MaskSize", 28, 3 }, { "DefaultCPUBase", 22, 6 }, { "DefaultCPU", 16, 6 }, { "DefaultQueue", 0, 16 }, { "TP_RSS_SECRET_KEY0", 0x400, 0 }, { "TP_RSS_SECRET_KEY1", 0x404, 0 }, { "TP_RSS_SECRET_KEY2", 0x408, 0 }, { "TP_RSS_SECRET_KEY3", 0x40c, 0 }, { "TP_TM_PIO_ADDR", 0x418, 0 }, { "TP_TM_PIO_DATA", 0x41c, 0 }, { "TP_TX_MOD_QUE_TABLE", 0x420, 0 }, { "TP_TX_RESOURCE_LIMIT", 0x424, 0 }, { "TX_RESOURCE_LIMIT_CH1_PC", 24, 8 }, { "TX_RESOURCE_LIMIT_CH1_NON_PC", 16, 8 }, { "TX_RESOURCE_LIMIT_CH0_PC", 8, 8 }, { "TX_RESOURCE_LIMIT_CH0_NON_PC", 0, 8 }, { "TP_TX_MOD_QUEUE_REQ_MAP", 0x428, 0 }, { "RX_MOD_WEIGHT", 24, 8 }, { "TX_MOD_WEIGHT", 16, 8 }, { "TX_MOD_TIMER_MODE", 8, 8 }, { "TX_MOD_QUEUE_REQ_MAP", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 0x42c, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT7", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT6", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT5", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT4", 0, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0x430, 0 }, { "TP_TX_MOD_QUEUE_WEIGHT3", 24, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT2", 16, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT1", 8, 8 }, { "TP_TX_MOD_QUEUE_WEIGHT0", 0, 8 }, { "TP_MOD_CHANNEL_WEIGHT", 0x434, 0 }, { "RX_MOD_CHANNEL_WEIGHT1", 24, 8 }, { "RX_MOD_CHANNEL_WEIGHT0", 16, 8 }, { "TX_MOD_CHANNEL_WEIGHT1", 8, 8 }, { "TX_MOD_CHANNEL_WEIGHT0", 0, 8 }, { "TP_MOD_RATE_LIMIT", 0x438, 0 }, { "RX_MOD_RATE_LIMIT_INC", 24, 8 }, { "RX_MOD_RATE_LIMIT_TICK", 16, 8 }, { "TX_MOD_RATE_LIMIT_INC", 8, 8 }, { "TX_MOD_RATE_LIMIT_TICK", 0, 8 }, { "TP_PIO_ADDR", 0x440, 0 }, { "TP_PIO_DATA", 0x444, 0 }, { "TP_RESET", 0x44c, 0 }, { "FlstInitEnable", 1, 1 }, { "TPReset", 0, 1 }, { "TP_MIB_INDEX", 0x450, 0 }, { "TP_MIB_RDATA", 0x454, 0 }, { "TP_SYNC_TIME_HI", 0x458, 0 }, { "TP_SYNC_TIME_LO", 0x45c, 0 }, { "TP_CMM_MM_RX_FLST_BASE", 0x460, 0 }, { "CMRxFlstBase", 0, 28 }, { "TP_CMM_MM_TX_FLST_BASE", 0x464, 0 }, { "CMTxFlstBase", 0, 28 }, { "TP_CMM_MM_PS_FLST_BASE", 0x468, 0 }, { "CMPsFlstBase", 0, 28 }, { "TP_CMM_MM_MAX_PSTRUCT", 0x46c, 0 }, { "CMMaxPstruct", 0, 21 }, { "TP_INT_ENABLE", 0x470, 0 }, { "FlmTxFlstEmpty", 30, 1 }, { "FlmRxFlstEmpty", 29, 1 }, { "FlmPerrSet", 28, 1 }, { "ProtocolSramPerr", 27, 1 }, { "ArpLutPerr", 26, 1 }, { "CmRcfOpPerr", 25, 1 }, { "CmCachePerr", 24, 1 }, { "CmRcfDataPerr", 23, 1 }, { "DbL2tLutPerr", 22, 1 }, { "DbTxTidPerr", 21, 1 }, { "DbExtPerr", 20, 1 }, { "DbOpPerr", 19, 1 }, { "TmCachePerr", 18, 1 }, { "ETpOutCplFifoPerr", 17, 1 }, { "ETpOutTcpFifoPerr", 16, 1 }, { "ETpOutIpFifoPerr", 15, 1 }, { "ETpOutEthFifoPerr", 14, 1 }, { "ETpInCplFifoPerr", 13, 1 }, { "ETpInTcpOptFifoPerr", 12, 1 }, { "ETpInTcpFifoPerr", 11, 1 }, { "ETpInIpFifoPerr", 10, 1 }, { "ETpInEthFifoPerr", 9, 1 }, { "CTpOutCplFifoPerr", 8, 1 }, { "CTpOutTcpFifoPerr", 7, 1 }, { "CTpOutIpFifoPerr", 6, 1 }, { "CTpOutEthFifoPerr", 5, 1 }, { "CTpInCplFifoPerr", 4, 1 }, { "CTpInTcpOpFifoPerr", 3, 1 }, { "CTpInTcpFifoPerr", 2, 1 }, { "CTpInIpFifoPerr", 1, 1 }, { "CTpInEthFifoPerr", 0, 1 }, { "TP_INT_CAUSE", 0x474, 0 }, { "FlmTxFlstEmpty", 30, 1 }, { "FlmRxFlstEmpty", 29, 1 }, { "FlmPerrSet", 28, 1 }, { "ProtocolSramPerr", 27, 1 }, { "ArpLutPerr", 26, 1 }, { "CmRcfOpPerr", 25, 1 }, { "CmCachePerr", 24, 1 }, { "CmRcfDataPerr", 23, 1 }, { "DbL2tLutPerr", 22, 1 }, { "DbTxTidPerr", 21, 1 }, { "DbExtPerr", 20, 1 }, { "DbOpPerr", 19, 1 }, { "TmCachePerr", 18, 1 }, { "ETpOutCplFifoPerr", 17, 1 }, { "ETpOutTcpFifoPerr", 16, 1 }, { "ETpOutIpFifoPerr", 15, 1 }, { "ETpOutEthFifoPerr", 14, 1 }, { "ETpInCplFifoPerr", 13, 1 }, { "ETpInTcpOptFifoPerr", 12, 1 }, { "ETpInTcpFifoPerr", 11, 1 }, { "ETpInIpFifoPerr", 10, 1 }, { "ETpInEthFifoPerr", 9, 1 }, { "CTpOutCplFifoPerr", 8, 1 }, { "CTpOutTcpFifoPerr", 7, 1 }, { "CTpOutIpFifoPerr", 6, 1 }, { "CTpOutEthFifoPerr", 5, 1 }, { "CTpInCplFifoPerr", 4, 1 }, { "CTpInTcpOpFifoPerr", 3, 1 }, { "CTpInTcpFifoPerr", 2, 1 }, { "CTpInIpFifoPerr", 1, 1 }, { "CTpInEthFifoPerr", 0, 1 }, { "TP_FLM_FREE_PS_CNT", 0x480, 0 }, { "FreePstructCount", 0, 21 }, { "TP_FLM_FREE_RX_CNT", 0x484, 0 }, { "FreeRxPageCount", 0, 21 }, { "TP_FLM_FREE_TX_CNT", 0x488, 0 }, { "FreeTxPageCount", 0, 21 }, { "TP_TM_HEAP_PUSH_CNT", 0x48c, 0 }, { "TP_TM_HEAP_POP_CNT", 0x490, 0 }, { "TP_TM_DACK_PUSH_CNT", 0x494, 0 }, { "TP_TM_DACK_POP_CNT", 0x498, 0 }, { "TP_TM_MOD_PUSH_CNT", 0x49c, 0 }, { "TP_MOD_POP_CNT", 0x4a0, 0 }, { "TP_TIMER_SEPARATOR", 0x4a4, 0 }, { "TP_DEBUG_SEL", 0x4a8, 0 }, { "TP_DEBUG_FLAGS", 0x4ac, 0 }, { "RxTimerDackFirst", 26, 1 }, { "RxTimerDack", 25, 1 }, { "RxTimerHeartbeat", 24, 1 }, { "RxPawsDrop", 23, 1 }, { "RxUrgDataDrop", 22, 1 }, { "RxFutureData", 21, 1 }, { "RxRcvRxmData", 20, 1 }, { "RxRcvOooDataFin", 19, 1 }, { "RxRcvOooData", 18, 1 }, { "RxRcvWndZero", 17, 1 }, { "RxRcvWndLtMss", 16, 1 }, { "TxDupAckInc", 11, 1 }, { "TxRxmUrg", 10, 1 }, { "TxRxmFin", 9, 1 }, { "TxRxmSyn", 8, 1 }, { "TxRxmNewReno", 7, 1 }, { "TxRxmFast", 6, 1 }, { "TxRxmTimer", 5, 1 }, { "TxRxmTimerKeepalive", 4, 1 }, { "TxRxmTimerPersist", 3, 1 }, { "TxRcvAdvShrunk", 2, 1 }, { "TxRcvAdvZero", 1, 1 }, { "TxRcvAdvLtMss", 0, 1 }, { "TP_PROXY_FLOW_CNTL", 0x4b0, 0 }, { "TP_PC_CONGESTION_CNTL", 0x4b4, 0 }, { "EDropTunnel", 19, 1 }, { "CDropTunnel", 18, 1 }, { "EThreshold", 12, 6 }, { "CThreshold", 6, 6 }, { "TxThreshold", 0, 6 }, { "TP_TX_DROP_COUNT", 0x4bc, 0 }, { "TP_CLEAR_DEBUG", 0x4c0, 0 }, { "ClrDebug", 0, 1 }, { "TP_DEBUG_VEC", 0x4c4, 0 }, { "TP_DEBUG_VEC2", 0x4c8, 0 }, { "TP_DEBUG_REG_SEL", 0x4cc, 0 }, { "TP_DEBUG", 0x4d0, 0 }, { "TP_DBG_LA_CONFIG", 0x4d4, 0 }, { "TP_DBG_LA_DATAH", 0x4d8, 0 }, { "TP_DBG_LA_DATAL", 0x4dc, 0 }, { "TP_EMBED_OP_FIELD0", 0x4e8, 0 }, { "TP_EMBED_OP_FIELD1", 0x4ec, 0 }, { "TP_EMBED_OP_FIELD2", 0x4f0, 0 }, { "TP_EMBED_OP_FIELD3", 0x4f4, 0 }, { "TP_EMBED_OP_FIELD4", 0x4f8, 0 }, { "TP_EMBED_OP_FIELD5", 0x4fc, 0 }, { NULL, 0, 0 } }; struct reg_info t3c_ulp2_rx_regs[] = { { "ULPRX_CTL", 0x500, 0 }, { "PCMD1Threshold", 24, 8 }, { "PCMD0Threshold", 16, 8 }, { "round_robin", 4, 1 }, { "RDMA_permissive_mode", 3, 1 }, { "PagePodME", 2, 1 }, { "IscsiTagTcb", 1, 1 }, { "TddpTagTcb", 0, 1 }, { "ULPRX_INT_ENABLE", 0x504, 0 }, { "DataSelFrameErr0", 7, 1 }, { "DataSelFrameErr1", 6, 1 }, { "PcmdMuxPerr", 5, 1 }, { "ArbFPerr", 4, 1 }, { "ArbPF0Perr", 3, 1 }, { "ArbPF1Perr", 2, 1 }, { "ParErrPcmd", 1, 1 }, { "ParErrData", 0, 1 }, { "ULPRX_INT_CAUSE", 0x508, 0 }, { "DataSelFrameErr0", 7, 1 }, { "DataSelFrameErr1", 6, 1 }, { "PcmdMuxPerr", 5, 1 }, { "ArbFPerr", 4, 1 }, { "ArbPF0Perr", 3, 1 }, { "ArbPF1Perr", 2, 1 }, { "ParErrPcmd", 1, 1 }, { "ParErrData", 0, 1 }, { "ULPRX_ISCSI_LLIMIT", 0x50c, 0 }, { "IscsiLlimit", 6, 26 }, { "ULPRX_ISCSI_ULIMIT", 0x510, 0 }, { "IscsiUlimit", 6, 26 }, { "ULPRX_ISCSI_TAGMASK", 0x514, 0 }, { "IscsiTagMask", 6, 26 }, { "ULPRX_ISCSI_PSZ", 0x518, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_TDDP_LLIMIT", 0x51c, 0 }, { "TddpLlimit", 6, 26 }, { "ULPRX_TDDP_ULIMIT", 0x520, 0 }, { "TddpUlimit", 6, 26 }, { "ULPRX_TDDP_TAGMASK", 0x524, 0 }, { "TddpTagMask", 6, 26 }, { "ULPRX_TDDP_PSZ", 0x528, 0 }, { "Hpz3", 24, 4 }, { "Hpz2", 16, 4 }, { "Hpz1", 8, 4 }, { "Hpz0", 0, 4 }, { "ULPRX_STAG_LLIMIT", 0x52c, 0 }, { "ULPRX_STAG_ULIMIT", 0x530, 0 }, { "ULPRX_RQ_LLIMIT", 0x534, 0 }, { "ULPRX_RQ_ULIMIT", 0x538, 0 }, { "ULPRX_PBL_LLIMIT", 0x53c, 0 }, { "ULPRX_PBL_ULIMIT", 0x540, 0 }, { NULL, 0, 0 } }; struct reg_info t3c_ulp2_tx_regs[] = { { "ULPTX_CONFIG", 0x580, 0 }, { "CFG_CQE_SOP_MASK", 1, 1 }, { "CFG_RR_ARB", 0, 1 }, { "ULPTX_INT_ENABLE", 0x584, 0 }, { "cmd_fifo_perr_set1", 7, 1 }, { "cmd_fifo_perr_set0", 6, 1 }, { "lso_hdr_sram_perr_set1", 5, 1 }, { "lso_hdr_sram_perr_set0", 4, 1 }, { "imm_data_perr_set_ch1", 3, 1 }, { "imm_data_perr_set_ch0", 2, 1 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_INT_CAUSE", 0x588, 0 }, { "cmd_fifo_perr_set1", 7, 1 }, { "cmd_fifo_perr_set0", 6, 1 }, { "lso_hdr_sram_perr_set1", 5, 1 }, { "lso_hdr_sram_perr_set0", 4, 1 }, { "imm_data_perr_set_ch1", 3, 1 }, { "imm_data_perr_set_ch0", 2, 1 }, { "Pbl_bound_err_ch1", 1, 1 }, { "Pbl_bound_err_ch0", 0, 1 }, { "ULPTX_TPT_LLIMIT", 0x58c, 0 }, { "ULPTX_TPT_ULIMIT", 0x590, 0 }, { "ULPTX_PBL_LLIMIT", 0x594, 0 }, { "ULPTX_PBL_ULIMIT", 0x598, 0 }, { "ULPTX_CPL_ERR_OFFSET", 0x59c, 0 }, { "ULPTX_CPL_ERR_MASK", 0x5a0, 0 }, { "ULPTX_CPL_ERR_VALUE", 0x5a4, 0 }, { "ULPTX_CPL_PACK_SIZE", 0x5a8, 0 }, { "value", 24, 8 }, { "Ch1Size2", 24, 8 }, { "Ch1Size1", 16, 8 }, { "Ch0Size2", 8, 8 }, { "Ch0Size1", 0, 8 }, { "ULPTX_DMA_WEIGHT", 0x5ac, 0 }, { "D1_WEIGHT", 16, 16 }, { "D0_WEIGHT", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3c_pm1_rx_regs[] = { { "PM1_RX_CFG", 0x5c0, 0 }, { "PM1_RX_MODE", 0x5c4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_RX_STAT_CONFIG", 0x5c8, 0 }, { "PM1_RX_STAT_COUNT", 0x5cc, 0 }, { "PM1_RX_STAT_MSB", 0x5d0, 0 }, { "PM1_RX_STAT_LSB", 0x5d4, 0 }, { "PM1_RX_INT_ENABLE", 0x5d8, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { "PM1_RX_INT_CAUSE", 0x5dc, 0 }, { "zero_e_cmd_error", 18, 1 }, { "iespi0_fifo2x_Rx_framing_error", 17, 1 }, { "iespi1_fifo2x_Rx_framing_error", 16, 1 }, { "iespi0_Rx_framing_error", 15, 1 }, { "iespi1_Rx_framing_error", 14, 1 }, { "iespi0_Tx_framing_error", 13, 1 }, { "iespi1_Tx_framing_error", 12, 1 }, { "ocspi0_Rx_framing_error", 11, 1 }, { "ocspi1_Rx_framing_error", 10, 1 }, { "ocspi0_Tx_framing_error", 9, 1 }, { "ocspi1_Tx_framing_error", 8, 1 }, { "ocspi0_ofifo2x_Tx_framing_error", 7, 1 }, { "ocspi1_ofifo2x_Tx_framing_error", 6, 1 }, { "iespi_par_error", 3, 3 }, { "ocspi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info t3c_pm1_tx_regs[] = { { "PM1_TX_CFG", 0x5e0, 0 }, { "PM1_TX_MODE", 0x5e4, 0 }, { "stat_channel", 1, 1 }, { "priority_ch", 0, 1 }, { "PM1_TX_STAT_CONFIG", 0x5e8, 0 }, { "PM1_TX_STAT_COUNT", 0x5ec, 0 }, { "PM1_TX_STAT_MSB", 0x5f0, 0 }, { "PM1_TX_STAT_LSB", 0x5f4, 0 }, { "PM1_TX_INT_ENABLE", 0x5f8, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { "PM1_TX_INT_CAUSE", 0x5fc, 0 }, { "zero_c_cmd_error", 18, 1 }, { "icspi0_fifo2x_Rx_framing_error", 17, 1 }, { "icspi1_fifo2x_Rx_framing_error", 16, 1 }, { "icspi0_Rx_framing_error", 15, 1 }, { "icspi1_Rx_framing_error", 14, 1 }, { "icspi0_Tx_framing_error", 13, 1 }, { "icspi1_Tx_framing_error", 12, 1 }, { "oespi0_Rx_framing_error", 11, 1 }, { "oespi1_Rx_framing_error", 10, 1 }, { "oespi0_Tx_framing_error", 9, 1 }, { "oespi1_Tx_framing_error", 8, 1 }, { "oespi0_ofifo2x_Tx_framing_error", 7, 1 }, { "oespi1_ofifo2x_Tx_framing_error", 6, 1 }, { "icspi_par_error", 3, 3 }, { "oespi_par_error", 0, 3 }, { NULL, 0, 0 } }; struct reg_info t3c_mps0_regs[] = { { "MPS_CFG", 0x600, 0 }, { "EnForcePkt", 11, 1 }, { "SGETPQid", 8, 3 }, { "TPRxPortSize", 7, 1 }, { "TPTxPort1Size", 6, 1 }, { "TPTxPort0Size", 5, 1 }, { "TPRxPortEn", 4, 1 }, { "TPTxPort1En", 3, 1 }, { "TPTxPort0En", 2, 1 }, { "Port1Active", 1, 1 }, { "Port0Active", 0, 1 }, { "MPS_DRR_CFG1", 0x604, 0 }, { "RldWtTPD1", 11, 11 }, { "RldWtTPD0", 0, 11 }, { "MPS_DRR_CFG2", 0x608, 0 }, { "RldWtTotal", 0, 12 }, { "MPS_MCA_STATUS", 0x60c, 0 }, { "MCAPktCnt", 12, 20 }, { "MCADepth", 0, 12 }, { "MPS_TX0_TP_CNT", 0x610, 0 }, { "TX0TPDisCnt", 24, 8 }, { "TX0TPCnt", 0, 24 }, { "MPS_TX1_TP_CNT", 0x614, 0 }, { "TX1TPDisCnt", 24, 8 }, { "TX1TPCnt", 0, 24 }, { "MPS_RX_TP_CNT", 0x618, 0 }, { "RXTPDisCnt", 24, 8 }, { "RXTPCnt", 0, 24 }, { "MPS_INT_ENABLE", 0x61c, 0 }, { "MCAParErrEnb", 6, 3 }, { "RXTpParErrEnb", 4, 2 }, { "TX1TpParErrEnb", 2, 2 }, { "TX0TpParErrEnb", 0, 2 }, { "MPS_INT_CAUSE", 0x620, 0 }, { "MCAParErr", 6, 3 }, { "RXTpParErr", 4, 2 }, { "TX1TpParErr", 2, 2 }, { "TX0TpParErr", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3c_cpl_switch_regs[] = { { "CPL_SWITCH_CNTRL", 0x640, 0 }, { "cpl_pkt_tid", 8, 24 }, { "cim_to_up_full_size", 4, 1 }, { "cpu_no_3F_CIM_enable", 3, 1 }, { "switch_table_enable", 2, 1 }, { "sge_enable", 1, 1 }, { "cim_enable", 0, 1 }, { "CPL_SWITCH_TBL_IDX", 0x644, 0 }, { "switch_tbl_idx", 0, 4 }, { "CPL_SWITCH_TBL_DATA", 0x648, 0 }, { "CPL_SWITCH_ZERO_ERROR", 0x64c, 0 }, { "zero_cmd", 0, 8 }, { "CPL_INTR_ENABLE", 0x650, 0 }, { "cim_op_map_perr", 5, 1 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_INTR_CAUSE", 0x654, 0 }, { "cim_op_map_perr", 5, 1 }, { "cim_ovfl_error", 4, 1 }, { "tp_framing_error", 3, 1 }, { "sge_framing_error", 2, 1 }, { "cim_framing_error", 1, 1 }, { "zero_switch_error", 0, 1 }, { "CPL_MAP_TBL_IDX", 0x658, 0 }, { "cpl_map_tbl_idx", 0, 8 }, { "CPL_MAP_TBL_DATA", 0x65c, 0 }, { "cpl_map_tbl_data", 0, 8 }, { NULL, 0, 0 } }; struct reg_info t3c_smb0_regs[] = { { "SMB_GLOBAL_TIME_CFG", 0x660, 0 }, { "LADbgWrPtr", 24, 8 }, { "LADbgRdPtr", 16, 8 }, { "LADbgEn", 13, 1 }, { "MacroCntCfg", 8, 5 }, { "MicroCntCfg", 0, 8 }, { "SMB_MST_TIMEOUT_CFG", 0x664, 0 }, { "DebugSelH", 28, 4 }, { "DebugSelL", 24, 4 }, { "MstTimeOutCfg", 0, 24 }, { "SMB_MST_CTL_CFG", 0x668, 0 }, { "MstFifoDbg", 31, 1 }, { "MstFifoDbgClr", 30, 1 }, { "MstRxByteCfg", 12, 6 }, { "MstTxByteCfg", 6, 6 }, { "MstReset", 1, 1 }, { "MstCtlEn", 0, 1 }, { "SMB_MST_CTL_STS", 0x66c, 0 }, { "MstRxByteCnt", 12, 6 }, { "MstTxByteCnt", 6, 6 }, { "MstBusySts", 0, 1 }, { "SMB_MST_TX_FIFO_RDWR", 0x670, 0 }, { "SMB_MST_RX_FIFO_RDWR", 0x674, 0 }, { "SMB_SLV_TIMEOUT_CFG", 0x678, 0 }, { "SlvTimeOutCfg", 0, 24 }, { "SMB_SLV_CTL_CFG", 0x67c, 0 }, { "SlvFifoDbg", 31, 1 }, { "SlvFifoDbgClr", 30, 1 }, { "SlvAddrCfg", 4, 7 }, { "SlvAlrtSet", 2, 1 }, { "SlvReset", 1, 1 }, { "SlvCtlEn", 0, 1 }, { "SMB_SLV_CTL_STS", 0x680, 0 }, { "SlvFifoTxCnt", 12, 6 }, { "SlvFifoCnt", 6, 6 }, { "SlvAlrtSts", 2, 1 }, { "SlvBusySts", 0, 1 }, { "SMB_SLV_FIFO_RDWR", 0x684, 0 }, { "SMB_SLV_CMD_FIFO_RDWR", 0x688, 0 }, { "SMB_INT_ENABLE", 0x68c, 0 }, { "SlvTimeOutIntEn", 7, 1 }, { "SlvErrIntEn", 6, 1 }, { "SlvDoneIntEn", 5, 1 }, { "SlvRxRdyIntEn", 4, 1 }, { "MstTimeOutIntEn", 3, 1 }, { "MstNAckIntEn", 2, 1 }, { "MstLostArbIntEn", 1, 1 }, { "MstDoneIntEn", 0, 1 }, { "SMB_INT_CAUSE", 0x690, 0 }, { "SlvTimeOutInt", 7, 1 }, { "SlvErrInt", 6, 1 }, { "SlvDoneInt", 5, 1 }, { "SlvRxRdyInt", 4, 1 }, { "MstTimeOutInt", 3, 1 }, { "MstNAckInt", 2, 1 }, { "MstLostArbInt", 1, 1 }, { "MstDoneInt", 0, 1 }, { "SMB_DEBUG_DATA", 0x694, 0 }, { "DebugDataH", 16, 16 }, { "DebugDataL", 0, 16 }, { "SMB_DEBUG_LA", 0x69c, 0 }, { "DebugLAReqAddr", 0, 10 }, { NULL, 0, 0 } }; struct reg_info t3c_i2cm0_regs[] = { { "I2C_CFG", 0x6a0, 0 }, { "ClkDiv", 0, 12 }, { "I2C_DATA", 0x6a4, 0 }, { "Data", 0, 8 }, { "I2C_OP", 0x6a8, 0 }, { "Busy", 31, 1 }, { "Ack", 30, 1 }, { "Cont", 1, 1 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_mi1_regs[] = { { "MI1_CFG", 0x6b0, 0 }, { "ClkDiv", 5, 8 }, { "St", 3, 2 }, { "PreEn", 2, 1 }, { "MDIInv", 1, 1 }, { "MDIEn", 0, 1 }, { "MI1_ADDR", 0x6b4, 0 }, { "PhyAddr", 5, 5 }, { "RegAddr", 0, 5 }, { "MI1_DATA", 0x6b8, 0 }, { "Data", 0, 16 }, { "MI1_OP", 0x6bc, 0 }, { "Busy", 31, 1 }, { "Inc", 2, 1 }, { "Op", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3c_jm1_regs[] = { { "JM_CFG", 0x6c0, 0 }, { "ClkDiv", 2, 8 }, { "TRst", 1, 1 }, { "En", 0, 1 }, { "JM_MODE", 0x6c4, 0 }, { "JM_DATA", 0x6c8, 0 }, { "JM_OP", 0x6cc, 0 }, { "Busy", 31, 1 }, { "Cnt", 0, 5 }, { NULL, 0, 0 } }; struct reg_info t3c_sf1_regs[] = { { "SF_DATA", 0x6d8, 0 }, { "SF_OP", 0x6dc, 0 }, { "Busy", 31, 1 }, { "Cont", 3, 1 }, { "ByteCnt", 1, 2 }, { "Op", 0, 1 }, { NULL, 0, 0 } }; struct reg_info t3c_pl3_regs[] = { { "PL_INT_ENABLE0", 0x6e0, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE0", 0x6e4, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_ENABLE1", 0x6e8, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_INT_CAUSE1", 0x6ec, 0 }, { "SW", 25, 1 }, { "EXT", 24, 1 }, { "T3DBG", 23, 1 }, { "XGMAC0_1", 20, 1 }, { "XGMAC0_0", 19, 1 }, { "MC5A", 18, 1 }, { "SF1", 17, 1 }, { "SMB0", 15, 1 }, { "I2CM0", 14, 1 }, { "MI1", 13, 1 }, { "CPL_SWITCH", 12, 1 }, { "MPS0", 11, 1 }, { "PM1_TX", 10, 1 }, { "PM1_RX", 9, 1 }, { "ULP2_TX", 8, 1 }, { "ULP2_RX", 7, 1 }, { "TP1", 6, 1 }, { "CIM", 5, 1 }, { "MC7_CM", 4, 1 }, { "MC7_PMTX", 3, 1 }, { "MC7_PMRX", 2, 1 }, { "PCIM0", 1, 1 }, { "SGE3", 0, 1 }, { "PL_RST", 0x6f0, 0 }, { "FatalPerrEn", 4, 1 }, { "SWInt1", 3, 1 }, { "SWInt0", 2, 1 }, { "CRstWrm", 1, 1 }, { "CRstWrmMode", 0, 1 }, { "PL_REV", 0x6f4, 0 }, { "Rev", 0, 4 }, { "PL_CLI", 0x6f8, 0 }, { "PL_LCK", 0x6fc, 0 }, { "Lck", 0, 2 }, { NULL, 0, 0 } }; struct reg_info t3c_mc5a_regs[] = { { "MC5_BUF_CONFIG", 0x700, 0 }, { "term300_240", 31, 1 }, { "term150", 30, 1 }, { "term60", 29, 1 }, { "gddriii", 28, 1 }, { "gddrii", 27, 1 }, { "gddri", 26, 1 }, { "read", 25, 1 }, { "imp_set_update", 24, 1 }, { "cal_update", 23, 1 }, { "cal_busy", 22, 1 }, { "cal_error", 21, 1 }, { "sgl_cal_en", 20, 1 }, { "imp_upd_mode", 19, 1 }, { "imp_sel", 18, 1 }, { "man_pu", 15, 3 }, { "man_pd", 12, 3 }, { "cal_pu", 9, 3 }, { "cal_pd", 6, 3 }, { "set_pu", 3, 3 }, { "set_pd", 0, 3 }, { "MC5_DB_CONFIG", 0x704, 0 }, { "TMCfgWrLock", 31, 1 }, { "TMTypeHi", 30, 1 }, { "TMPartSize", 28, 2 }, { "TMType", 26, 2 }, { "TMPartCount", 24, 2 }, { "nLIP", 18, 6 }, { "COMPEN", 17, 1 }, { "BUILD", 16, 1 }, { "FilterEn", 11, 1 }, { "CLIPUpdate", 10, 1 }, { "TM_IO_PDOWN", 9, 1 }, { "SYNMode", 7, 2 }, { "PRTYEN", 6, 1 }, { "MBUSEN", 5, 1 }, { "DBGIEN", 4, 1 }, { "TcmCfgOvr", 3, 1 }, { "TMRDY", 2, 1 }, { "TMRST", 1, 1 }, { "TMMode", 0, 1 }, { "MC5_MISC", 0x708, 0 }, { "LIP_Cmp_Unavailable", 0, 4 }, { "MC5_DB_ROUTING_TABLE_INDEX", 0x70c, 0 }, { "RTINDX", 0, 22 }, { "MC5_DB_FILTER_TABLE", 0x710, 0 }, { "SRINDX", 0, 22 }, { "MC5_DB_SERVER_INDEX", 0x714, 0 }, { "SRINDX", 0, 22 }, { "MC5_DB_LIP_RAM_ADDR", 0x718, 0 }, { "RAMWR", 8, 1 }, { "RAMADDR", 0, 6 }, { "MC5_DB_LIP_RAM_DATA", 0x71c, 0 }, { "MC5_DB_RSP_LATENCY", 0x720, 0 }, { "RDLAT", 16, 5 }, { "LRNLAT", 8, 5 }, { "SRCHLAT", 0, 5 }, { "MC5_DB_PARITY_LATENCY", 0x724, 0 }, { "PARLAT", 0, 4 }, { "MC5_DB_WR_LRN_VERIFY", 0x728, 0 }, { "VWVEREN", 2, 1 }, { "LRNVEREN", 1, 1 }, { "POVEREN", 0, 1 }, { "MC5_DB_PART_ID_INDEX", 0x72c, 0 }, { "IDINDEX", 0, 4 }, { "MC5_DB_RESET_MAX", 0x730, 0 }, { "RSTMAX", 0, 4 }, { "MC5_DB_ACT_CNT", 0x734, 0 }, { "ACTCNT", 0, 20 }, { "MC5_DB_CLIP_MAP", 0x738, 0 }, { "CLIPMapOp", 31, 1 }, { "CLIPMapVal", 16, 6 }, { "CLIPMapAddr", 0, 6 }, { "MC5_DB_SIZE", 0x73c, 0 }, { "MC5_DB_INT_ENABLE", 0x740, 0 }, { "MsgSel", 28, 4 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_CAUSE", 0x744, 0 }, { "DelActEmpty", 18, 1 }, { "DispQParErr", 17, 1 }, { "ReqQParErr", 16, 1 }, { "UnknownCmd", 15, 1 }, { "SYNCookieOff", 11, 1 }, { "SYNCookieBad", 10, 1 }, { "SYNCookie", 9, 1 }, { "NFASrchFail", 8, 1 }, { "ActRgnFull", 7, 1 }, { "ParityErr", 6, 1 }, { "LIPMiss", 5, 1 }, { "LIP0", 4, 1 }, { "Miss", 3, 1 }, { "RoutingHit", 2, 1 }, { "ActiveHit", 1, 1 }, { "ActiveOutHit", 0, 1 }, { "MC5_DB_INT_TID", 0x748, 0 }, { "INTTID", 0, 20 }, { "MC5_DB_INT_PTID", 0x74c, 0 }, { "INTPTID", 0, 20 }, { "MC5_DB_DBGI_CONFIG", 0x774, 0 }, { "WRReqSize", 22, 10 }, { "SADRSel", 4, 1 }, { "CMDMode", 0, 3 }, { "MC5_DB_DBGI_REQ_CMD", 0x778, 0 }, { "MBusCmd", 0, 4 }, { "IDTCmdHi", 11, 3 }, { "IDTCmdLo", 0, 4 }, { "IDTCmd", 0, 20 }, { "LCMDB", 16, 11 }, { "LCMDA", 0, 11 }, { "MC5_DB_DBGI_REQ_ADDR0", 0x77c, 0 }, { "MC5_DB_DBGI_REQ_ADDR1", 0x780, 0 }, { "MC5_DB_DBGI_REQ_ADDR2", 0x784, 0 }, { "DBGIReqAdrHi", 0, 8 }, { "MC5_DB_DBGI_REQ_DATA0", 0x788, 0 }, { "MC5_DB_DBGI_REQ_DATA1", 0x78c, 0 }, { "MC5_DB_DBGI_REQ_DATA2", 0x790, 0 }, { "MC5_DB_DBGI_REQ_DATA3", 0x794, 0 }, { "MC5_DB_DBGI_REQ_DATA4", 0x798, 0 }, { "DBGIReqData4", 0, 16 }, { "MC5_DB_DBGI_REQ_MASK0", 0x79c, 0 }, { "MC5_DB_DBGI_REQ_MASK1", 0x7a0, 0 }, { "MC5_DB_DBGI_REQ_MASK2", 0x7a4, 0 }, { "MC5_DB_DBGI_REQ_MASK3", 0x7a8, 0 }, { "MC5_DB_DBGI_REQ_MASK4", 0x7ac, 0 }, { "DBGIReqMsk4", 0, 16 }, { "MC5_DB_DBGI_RSP_STATUS", 0x7b0, 0 }, { "DBGIRspMsg", 8, 4 }, { "DBGIRspMsgVld", 2, 1 }, { "DBGIRspHit", 1, 1 }, { "DBGIRspValid", 0, 1 }, { "MC5_DB_DBGI_RSP_DATA0", 0x7b4, 0 }, { "MC5_DB_DBGI_RSP_DATA1", 0x7b8, 0 }, { "MC5_DB_DBGI_RSP_DATA2", 0x7bc, 0 }, { "MC5_DB_DBGI_RSP_DATA3", 0x7c0, 0 }, { "MC5_DB_DBGI_RSP_DATA4", 0x7c4, 0 }, { "DBGIRspData3", 0, 16 }, { "MC5_DB_DBGI_RSP_LAST_CMD", 0x7c8, 0 }, { "LastCmdB", 16, 11 }, { "LastCmdA", 0, 11 }, { "MC5_DB_POPEN_DATA_WR_CMD", 0x7cc, 0 }, { "PO_DWR", 0, 20 }, { "MC5_DB_POPEN_MASK_WR_CMD", 0x7d0, 0 }, { "PO_MWR", 0, 20 }, { "MC5_DB_AOPEN_SRCH_CMD", 0x7d4, 0 }, { "AO_SRCH", 0, 20 }, { "MC5_DB_AOPEN_LRN_CMD", 0x7d8, 0 }, { "AO_LRN", 0, 20 }, { "MC5_DB_SYN_SRCH_CMD", 0x7dc, 0 }, { "SYN_SRCH", 0, 20 }, { "MC5_DB_SYN_LRN_CMD", 0x7e0, 0 }, { "SYN_LRN", 0, 20 }, { "MC5_DB_ACK_SRCH_CMD", 0x7e4, 0 }, { "ACK_SRCH", 0, 20 }, { "MC5_DB_ACK_LRN_CMD", 0x7e8, 0 }, { "ACK_LRN", 0, 20 }, { "MC5_DB_ILOOKUP_CMD", 0x7ec, 0 }, { "I_SRCH", 0, 20 }, { "MC5_DB_ELOOKUP_CMD", 0x7f0, 0 }, { "E_SRCH", 0, 20 }, { "MC5_DB_DATA_WRITE_CMD", 0x7f4, 0 }, { "Write", 0, 20 }, { "MC5_DB_DATA_READ_CMD", 0x7f8, 0 }, { "ReadCmd", 0, 20 }, { "MC5_DB_MASK_WRITE_CMD", 0x7fc, 0 }, { "MaskWr", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3c_xgmac0_0_regs[] = { { "XGM_TX_CTRL", 0x800, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0x804, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0x808, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0x80c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0x810, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0x814, 0 }, { "XGM_RX_HASH_HIGH", 0x818, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0x81c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0x820, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0x824, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0x828, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0x82c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0x830, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0x834, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0x838, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0x83c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0x840, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0x844, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0x848, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0x84c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0x850, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0x854, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0x858, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0x85c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0x860, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0x864, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0x868, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0x86c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0x870, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0x874, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0x878, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0x87c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0x880, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0x884, 0 }, { "RxFIFO_empty", 31, 1 }, { "RxFIFO_full", 30, 1 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0x888, 0 }, { "TxFIFO_empty", 31, 1 }, { "TxFIFO_full", 30, 1 }, { "UnderunFix", 22, 1 }, { "EnDropPkt", 21, 1 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0x88c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_PAUSE_TIMER", 0x890, 0 }, { "PauseTimer", 0, 20 }, { "XGM_XAUI_PCS_TEST", 0x894, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0x898, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0x89c, 0 }, { "CalReset", 8, 1 }, { "CalUpdate", 7, 1 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0x8a8, 0 }, { "RxMaxFramerSize", 17, 14 }, { "RxEnErrorGather", 16, 1 }, { "RxEnSingleFlit", 15, 1 }, { "RxEnFramer", 14, 1 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0x8ac, 0 }, { "XGMAC_STOP_EN", 4, 1 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0x8b0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0x8b4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0x8b8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0x8c0, 0 }, { "XGM_EPIO_DATA1", 0x8c4, 0 }, { "XGM_EPIO_DATA2", 0x8c8, 0 }, { "XGM_EPIO_DATA3", 0x8cc, 0 }, { "XGM_EPIO_OP", 0x8d0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0x8d4, 0 }, { "XAUIPCSDECErr", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0x8d8, 0 }, { "XAUIPCSDECErr", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_XAUI_ACT_CTRL", 0x8dc, 0 }, { "TxEn", 1, 1 }, { "RxEn", 0, 1 }, { "XGM_SERDES_CTRL0", 0x8e0, 0 }, { "IntSerLPBK3", 27, 1 }, { "IntSerLPBK2", 26, 1 }, { "IntSerLPBK1", 25, 1 }, { "IntSerLPBK0", 24, 1 }, { "Reset3", 23, 1 }, { "Reset2", 22, 1 }, { "Reset1", 21, 1 }, { "Reset0", 20, 1 }, { "Pwrdn3", 19, 1 }, { "Pwrdn2", 18, 1 }, { "Pwrdn1", 17, 1 }, { "Pwrdn0", 16, 1 }, { "ResetPLL23", 15, 1 }, { "ResetPLL01", 14, 1 }, { "PW23", 12, 2 }, { "PW01", 10, 2 }, { "Deq", 6, 4 }, { "Dtx", 2, 4 }, { "LoDrv", 1, 1 }, { "HiDrv", 0, 1 }, { "XGM_SERDES_CTRL1", 0x8e4, 0 }, { "FmOffset3", 19, 5 }, { "FmOffsetEn3", 18, 1 }, { "FmOffset2", 13, 5 }, { "FmOffsetEn2", 12, 1 }, { "FmOffset1", 7, 5 }, { "FmOffsetEn1", 6, 1 }, { "FmOffset0", 1, 5 }, { "FmOffsetEn0", 0, 1 }, { "XGM_SERDES_CTRL2", 0x8e8, 0 }, { "DnIn3", 11, 1 }, { "UpIn3", 10, 1 }, { "RxSlave3", 9, 1 }, { "DnIn2", 8, 1 }, { "UpIn2", 7, 1 }, { "RxSlave2", 6, 1 }, { "DnIn1", 5, 1 }, { "UpIn1", 4, 1 }, { "RxSlave1", 3, 1 }, { "DnIn0", 2, 1 }, { "UpIn0", 1, 1 }, { "RxSlave0", 0, 1 }, { "XGM_SERDES_CTRL3", 0x8ec, 0 }, { "ExtBISTChkErrClr3", 31, 1 }, { "ExtBISTChkEn3", 30, 1 }, { "ExtBISTGenEn3", 29, 1 }, { "ExtBISTPat3", 26, 3 }, { "ExtParReset3", 25, 1 }, { "ExtParLPBK3", 24, 1 }, { "ExtBISTChkErrClr2", 23, 1 }, { "ExtBISTChkEn2", 22, 1 }, { "ExtBISTGenEn2", 21, 1 }, { "ExtBISTPat2", 18, 3 }, { "ExtParReset2", 17, 1 }, { "ExtParLPBK2", 16, 1 }, { "ExtBISTChkErrClr1", 15, 1 }, { "ExtBISTChkEn1", 14, 1 }, { "ExtBISTGenEn1", 13, 1 }, { "ExtBISTPat1", 10, 3 }, { "ExtParReset1", 9, 1 }, { "ExtParLPBK1", 8, 1 }, { "ExtBISTChkErrClr0", 7, 1 }, { "ExtBISTChkEn0", 6, 1 }, { "ExtBISTGenEn0", 5, 1 }, { "ExtBISTPat0", 2, 3 }, { "ExtParReset0", 1, 1 }, { "ExtParLPBK0", 0, 1 }, { "XGM_SERDES_STAT0", 0x8f0, 0 }, { "ExtBISTChkErrCnt0", 4, 24 }, { "ExtBISTChkFmd0", 3, 1 }, { "LowSigForceEn0", 2, 1 }, { "LowSigForceValue0", 1, 1 }, { "LowSig0", 0, 1 }, { "XGM_SERDES_STAT1", 0x8f4, 0 }, { "ExtBISTChkErrCnt1", 4, 24 }, { "ExtBISTChkFmd1", 3, 1 }, { "LowSigForceEn1", 2, 1 }, { "LowSigForceValue1", 1, 1 }, { "LowSig1", 0, 1 }, { "XGM_SERDES_STAT2", 0x8f8, 0 }, { "ExtBISTChkErrCnt2", 4, 24 }, { "ExtBISTChkFmd2", 3, 1 }, { "LowSigForceEn2", 2, 1 }, { "LowSigForceValue2", 1, 1 }, { "LowSig2", 0, 1 }, { "XGM_SERDES_STAT3", 0x8fc, 0 }, { "ExtBISTChkErrCnt3", 4, 24 }, { "ExtBISTChkFmd3", 3, 1 }, { "LowSigForceEn3", 2, 1 }, { "LowSigForceValue3", 1, 1 }, { "LowSig3", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0x900, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0x904, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0x908, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0x90c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0x910, 0 }, { "XGM_STAT_TX_MCAST", 0x914, 0 }, { "XGM_STAT_TX_PAUSE", 0x918, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0x91c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0x920, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0x924, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0x928, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0x92c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0x930, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0x934, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0x938, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0x93c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0x940, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0x944, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0x948, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0x94c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0x950, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0x954, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0x958, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0x95c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0x960, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0x964, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0x968, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0x96c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0x970, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0x974, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0x978, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0x97c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0x980, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0x984, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0x988, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_XAUI_PCS_ERR", 0x998, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0x99c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0x9a0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0x9a4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0x9a8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0x9ac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; struct reg_info t3c_xgmac0_1_regs[] = { { "XGM_TX_CTRL", 0xa00, 0 }, { "SendPause", 2, 1 }, { "SendZeroPause", 1, 1 }, { "TxEn", 0, 1 }, { "XGM_TX_CFG", 0xa04, 0 }, { "CfgClkSpeed", 2, 3 }, { "StretchMode", 1, 1 }, { "TxPauseEn", 0, 1 }, { "XGM_TX_PAUSE_QUANTA", 0xa08, 0 }, { "TxPauseQuanta", 0, 16 }, { "XGM_RX_CTRL", 0xa0c, 0 }, { "RxEn", 0, 1 }, { "XGM_RX_CFG", 0xa10, 0 }, { "Con802_3Preamble", 12, 1 }, { "EnNon802_3Preamble", 11, 1 }, { "CopyPreamble", 10, 1 }, { "DisPauseFrames", 9, 1 }, { "En1536BFrames", 8, 1 }, { "EnJumbo", 7, 1 }, { "RmFCS", 6, 1 }, { "DisNonVlan", 5, 1 }, { "EnExtMatch", 4, 1 }, { "EnHashUcast", 3, 1 }, { "EnHashMcast", 2, 1 }, { "DisBCast", 1, 1 }, { "CopyAllFrames", 0, 1 }, { "XGM_RX_HASH_LOW", 0xa14, 0 }, { "XGM_RX_HASH_HIGH", 0xa18, 0 }, { "XGM_RX_EXACT_MATCH_LOW_1", 0xa1c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_1", 0xa20, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_2", 0xa24, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_2", 0xa28, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_3", 0xa2c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_3", 0xa30, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_4", 0xa34, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_4", 0xa38, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_5", 0xa3c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_5", 0xa40, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_6", 0xa44, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_6", 0xa48, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_7", 0xa4c, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_7", 0xa50, 0 }, { "address_high", 0, 16 }, { "XGM_RX_EXACT_MATCH_LOW_8", 0xa54, 0 }, { "XGM_RX_EXACT_MATCH_HIGH_8", 0xa58, 0 }, { "address_high", 0, 16 }, { "XGM_RX_TYPE_MATCH_1", 0xa5c, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_2", 0xa60, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_3", 0xa64, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_RX_TYPE_MATCH_4", 0xa68, 0 }, { "EnTypeMatch", 31, 1 }, { "type", 0, 16 }, { "XGM_INT_STATUS", 0xa6c, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_MASK", 0xa70, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_ENABLE", 0xa74, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_XGM_INT_DISABLE", 0xa78, 0 }, { "XGMIIExtInt", 10, 1 }, { "LinkFaultChange", 9, 1 }, { "PhyFrameComplete", 8, 1 }, { "PauseFrameTxmt", 7, 1 }, { "PauseCntrTimeOut", 6, 1 }, { "Non0PauseRcvd", 5, 1 }, { "StatOFlow", 4, 1 }, { "TxErrFIFO", 3, 1 }, { "TxUFlow", 2, 1 }, { "FrameTxmt", 1, 1 }, { "FrameRcvd", 0, 1 }, { "XGM_TX_PAUSE_TIMER", 0xa7c, 0 }, { "CurPauseTimer", 0, 16 }, { "XGM_STAT_CTRL", 0xa80, 0 }, { "ReadSnpShot", 4, 1 }, { "TakeSnpShot", 3, 1 }, { "ClrStats", 2, 1 }, { "IncrStats", 1, 1 }, { "EnTestModeWr", 0, 1 }, { "XGM_RXFIFO_CFG", 0xa84, 0 }, { "RxFIFO_empty", 31, 1 }, { "RxFIFO_full", 30, 1 }, { "RxFIFOPauseHWM", 17, 12 }, { "RxFIFOPauseLWM", 5, 12 }, { "ForcedPause", 4, 1 }, { "ExternLoopback", 3, 1 }, { "RxByteSwap", 2, 1 }, { "RxStrFrwrd", 1, 1 }, { "DisErrFrames", 0, 1 }, { "XGM_TXFIFO_CFG", 0xa88, 0 }, { "TxFIFO_empty", 31, 1 }, { "TxFIFO_full", 30, 1 }, { "UnderunFix", 22, 1 }, { "EnDropPkt", 21, 1 }, { "TxIPG", 13, 8 }, { "TxFIFOThresh", 4, 9 }, { "InternLoopback", 3, 1 }, { "TxByteSwap", 2, 1 }, { "DisCRC", 1, 1 }, { "DisPreAmble", 0, 1 }, { "XGM_SLOW_TIMER", 0xa8c, 0 }, { "PauseSlowTimerEn", 31, 1 }, { "PauseSlowTimer", 0, 20 }, { "XGM_PAUSE_TIMER", 0xa90, 0 }, { "PauseTimer", 0, 20 }, { "XGM_XAUI_PCS_TEST", 0xa94, 0 }, { "TestPattern", 1, 2 }, { "EnTest", 0, 1 }, { "XGM_RGMII_CTRL", 0xa98, 0 }, { "PhAlignFIFOThresh", 1, 2 }, { "TxClk90Shift", 0, 1 }, { "XGM_RGMII_IMP", 0xa9c, 0 }, { "CalReset", 8, 1 }, { "CalUpdate", 7, 1 }, { "ImpSetUpdate", 6, 1 }, { "RGMIIImpPD", 3, 3 }, { "RGMIIImpPU", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE", 0xaa8, 0 }, { "RxMaxFramerSize", 17, 14 }, { "RxEnErrorGather", 16, 1 }, { "RxEnSingleFlit", 15, 1 }, { "RxEnFramer", 14, 1 }, { "RxMaxPktSize", 0, 14 }, { "XGM_RESET_CTRL", 0xaac, 0 }, { "XGMAC_STOP_EN", 4, 1 }, { "XG2G_Reset_", 3, 1 }, { "RGMII_Reset_", 2, 1 }, { "PCS_Reset_", 1, 1 }, { "MAC_Reset_", 0, 1 }, { "XGM_XAUI1G_CTRL", 0xab0, 0 }, { "XAUI1GLinkId", 0, 2 }, { "XGM_SERDES_LANE_CTRL", 0xab4, 0 }, { "LaneReversal", 8, 1 }, { "TxPolarity", 4, 4 }, { "RxPolarity", 0, 4 }, { "XGM_PORT_CFG", 0xab8, 0 }, { "SafeSpeedChange", 4, 1 }, { "ClkDivReset_", 3, 1 }, { "PortSpeed", 1, 2 }, { "EnRGMII", 0, 1 }, { "XGM_EPIO_DATA0", 0xac0, 0 }, { "XGM_EPIO_DATA1", 0xac4, 0 }, { "XGM_EPIO_DATA2", 0xac8, 0 }, { "XGM_EPIO_DATA3", 0xacc, 0 }, { "XGM_EPIO_OP", 0xad0, 0 }, { "PIO_Ready", 31, 1 }, { "PIO_WrRd", 24, 1 }, { "PIO_Address", 0, 8 }, { "XGM_INT_ENABLE", 0xad4, 0 }, { "XAUIPCSDECErr", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_INT_CAUSE", 0xad8, 0 }, { "XAUIPCSDECErr", 24, 1 }, { "RGMIIRxFIFOOverflow", 23, 1 }, { "RGMIIRxFIFOUnderflow", 22, 1 }, { "RxPktSizeError", 21, 1 }, { "WOLPatDetected", 20, 1 }, { "TXFIFO_prty_err", 17, 3 }, { "RXFIFO_prty_err", 14, 3 }, { "TXFIFO_underrun", 13, 1 }, { "RXFIFO_overflow", 12, 1 }, { "SERDESBISTErr", 8, 4 }, { "SERDESLowSigChange", 4, 4 }, { "XAUIPCSCTCErr", 3, 1 }, { "XAUIPCSAlignChange", 2, 1 }, { "RGMIILinkStsChange", 1, 1 }, { "xgm_int", 0, 1 }, { "XGM_XAUI_ACT_CTRL", 0xadc, 0 }, { "TxEn", 1, 1 }, { "RxEn", 0, 1 }, { "XGM_SERDES_CTRL0", 0xae0, 0 }, { "IntSerLPBK3", 27, 1 }, { "IntSerLPBK2", 26, 1 }, { "IntSerLPBK1", 25, 1 }, { "IntSerLPBK0", 24, 1 }, { "Reset3", 23, 1 }, { "Reset2", 22, 1 }, { "Reset1", 21, 1 }, { "Reset0", 20, 1 }, { "Pwrdn3", 19, 1 }, { "Pwrdn2", 18, 1 }, { "Pwrdn1", 17, 1 }, { "Pwrdn0", 16, 1 }, { "ResetPLL23", 15, 1 }, { "ResetPLL01", 14, 1 }, { "PW23", 12, 2 }, { "PW01", 10, 2 }, { "Deq", 6, 4 }, { "Dtx", 2, 4 }, { "LoDrv", 1, 1 }, { "HiDrv", 0, 1 }, { "XGM_SERDES_CTRL1", 0xae4, 0 }, { "FmOffset3", 19, 5 }, { "FmOffsetEn3", 18, 1 }, { "FmOffset2", 13, 5 }, { "FmOffsetEn2", 12, 1 }, { "FmOffset1", 7, 5 }, { "FmOffsetEn1", 6, 1 }, { "FmOffset0", 1, 5 }, { "FmOffsetEn0", 0, 1 }, { "XGM_SERDES_CTRL2", 0xae8, 0 }, { "DnIn3", 11, 1 }, { "UpIn3", 10, 1 }, { "RxSlave3", 9, 1 }, { "DnIn2", 8, 1 }, { "UpIn2", 7, 1 }, { "RxSlave2", 6, 1 }, { "DnIn1", 5, 1 }, { "UpIn1", 4, 1 }, { "RxSlave1", 3, 1 }, { "DnIn0", 2, 1 }, { "UpIn0", 1, 1 }, { "RxSlave0", 0, 1 }, { "XGM_SERDES_CTRL3", 0xaec, 0 }, { "ExtBISTChkErrClr3", 31, 1 }, { "ExtBISTChkEn3", 30, 1 }, { "ExtBISTGenEn3", 29, 1 }, { "ExtBISTPat3", 26, 3 }, { "ExtParReset3", 25, 1 }, { "ExtParLPBK3", 24, 1 }, { "ExtBISTChkErrClr2", 23, 1 }, { "ExtBISTChkEn2", 22, 1 }, { "ExtBISTGenEn2", 21, 1 }, { "ExtBISTPat2", 18, 3 }, { "ExtParReset2", 17, 1 }, { "ExtParLPBK2", 16, 1 }, { "ExtBISTChkErrClr1", 15, 1 }, { "ExtBISTChkEn1", 14, 1 }, { "ExtBISTGenEn1", 13, 1 }, { "ExtBISTPat1", 10, 3 }, { "ExtParReset1", 9, 1 }, { "ExtParLPBK1", 8, 1 }, { "ExtBISTChkErrClr0", 7, 1 }, { "ExtBISTChkEn0", 6, 1 }, { "ExtBISTGenEn0", 5, 1 }, { "ExtBISTPat0", 2, 3 }, { "ExtParReset0", 1, 1 }, { "ExtParLPBK0", 0, 1 }, { "XGM_SERDES_STAT0", 0xaf0, 0 }, { "ExtBISTChkErrCnt0", 4, 24 }, { "ExtBISTChkFmd0", 3, 1 }, { "LowSigForceEn0", 2, 1 }, { "LowSigForceValue0", 1, 1 }, { "LowSig0", 0, 1 }, { "XGM_SERDES_STAT1", 0xaf4, 0 }, { "ExtBISTChkErrCnt1", 4, 24 }, { "ExtBISTChkFmd1", 3, 1 }, { "LowSigForceEn1", 2, 1 }, { "LowSigForceValue1", 1, 1 }, { "LowSig1", 0, 1 }, { "XGM_SERDES_STAT2", 0xaf8, 0 }, { "ExtBISTChkErrCnt2", 4, 24 }, { "ExtBISTChkFmd2", 3, 1 }, { "LowSigForceEn2", 2, 1 }, { "LowSigForceValue2", 1, 1 }, { "LowSig2", 0, 1 }, { "XGM_SERDES_STAT3", 0xafc, 0 }, { "ExtBISTChkErrCnt3", 4, 24 }, { "ExtBISTChkFmd3", 3, 1 }, { "LowSigForceEn3", 2, 1 }, { "LowSigForceValue3", 1, 1 }, { "LowSig3", 0, 1 }, { "XGM_STAT_TX_BYTE_LOW", 0xb00, 0 }, { "XGM_STAT_TX_BYTE_HIGH", 0xb04, 0 }, { "TxBytes_high", 0, 13 }, { "XGM_STAT_TX_FRAME_LOW", 0xb08, 0 }, { "XGM_STAT_TX_FRAME_HIGH", 0xb0c, 0 }, { "TxFrames_high", 0, 4 }, { "XGM_STAT_TX_BCAST", 0xb10, 0 }, { "XGM_STAT_TX_MCAST", 0xb14, 0 }, { "XGM_STAT_TX_PAUSE", 0xb18, 0 }, { "XGM_STAT_TX_64B_FRAMES", 0xb1c, 0 }, { "XGM_STAT_TX_65_127B_FRAMES", 0xb20, 0 }, { "XGM_STAT_TX_128_255B_FRAMES", 0xb24, 0 }, { "XGM_STAT_TX_256_511B_FRAMES", 0xb28, 0 }, { "XGM_STAT_TX_512_1023B_FRAMES", 0xb2c, 0 }, { "XGM_STAT_TX_1024_1518B_FRAMES", 0xb30, 0 }, { "XGM_STAT_TX_1519_MAXB_FRAMES", 0xb34, 0 }, { "XGM_STAT_TX_ERR_FRAMES", 0xb38, 0 }, { "XGM_STAT_RX_BYTES_LOW", 0xb3c, 0 }, { "XGM_STAT_RX_BYTES_HIGH", 0xb40, 0 }, { "RxBytes_high", 0, 13 }, { "XGM_STAT_RX_FRAMES_LOW", 0xb44, 0 }, { "XGM_STAT_RX_FRAMES_HIGH", 0xb48, 0 }, { "RxFrames_high", 0, 4 }, { "XGM_STAT_RX_BCAST_FRAMES", 0xb4c, 0 }, { "XGM_STAT_RX_MCAST_FRAMES", 0xb50, 0 }, { "XGM_STAT_RX_PAUSE_FRAMES", 0xb54, 0 }, { "RxPauseFrames", 0, 16 }, { "XGM_STAT_RX_64B_FRAMES", 0xb58, 0 }, { "XGM_STAT_RX_65_127B_FRAMES", 0xb5c, 0 }, { "XGM_STAT_RX_128_255B_FRAMES", 0xb60, 0 }, { "XGM_STAT_RX_256_511B_FRAMES", 0xb64, 0 }, { "XGM_STAT_RX_512_1023B_FRAMES", 0xb68, 0 }, { "XGM_STAT_RX_1024_1518B_FRAMES", 0xb6c, 0 }, { "XGM_STAT_RX_1519_MAXB_FRAMES", 0xb70, 0 }, { "XGM_STAT_RX_SHORT_FRAMES", 0xb74, 0 }, { "RxShortFrames", 0, 16 }, { "XGM_STAT_RX_OVERSIZE_FRAMES", 0xb78, 0 }, { "RxOversizeFrames", 0, 16 }, { "XGM_STAT_RX_JABBER_FRAMES", 0xb7c, 0 }, { "RxJabberFrames", 0, 16 }, { "XGM_STAT_RX_CRC_ERR_FRAMES", 0xb80, 0 }, { "RxCRCErrFrames", 0, 16 }, { "XGM_STAT_RX_LENGTH_ERR_FRAMES", 0xb84, 0 }, { "RxLengthErrFrames", 0, 16 }, { "XGM_STAT_RX_SYM_CODE_ERR_FRAMES", 0xb88, 0 }, { "RxSymCodeErrFrames", 0, 16 }, { "XGM_XAUI_PCS_ERR", 0xb98, 0 }, { "PCS_SyncStatus", 5, 4 }, { "PCS_CTCFIFOErr", 1, 4 }, { "PCS_NotAligned", 0, 1 }, { "XGM_RGMII_STATUS", 0xb9c, 0 }, { "GMIIDuplex", 3, 1 }, { "GMIISpeed", 1, 2 }, { "GMIILinkStatus", 0, 1 }, { "XGM_WOL_STATUS", 0xba0, 0 }, { "PatDetected", 31, 1 }, { "MatchedFilter", 0, 3 }, { "XGM_RX_MAX_PKT_SIZE_ERR_CNT", 0xba4, 0 }, { "XGM_TX_SPI4_SOP_EOP_CNT", 0xba8, 0 }, { "TxSPI4SopCnt", 16, 16 }, { "TxSPI4EopCnt", 0, 16 }, { "XGM_RX_SPI4_SOP_EOP_CNT", 0xbac, 0 }, { "RxSPI4SopCnt", 16, 16 }, { "RxSPI4EopCnt", 0, 16 }, { NULL, 0, 0 } }; diff --git a/tools/tools/cxgbtool/version.h b/tools/tools/cxgbtool/version.h index 403a8beeafc2..183684bdb188 100644 --- a/tools/tools/cxgbtool/version.h +++ b/tools/tools/cxgbtool/version.h @@ -1,32 +1,31 @@ /***************************************************************************** * * * File: * * version.h * * * * Description: * * cxgbtool userspace utility version defines. * * * * http://www.chelsio.com * * * * Copyright (c) 2003 - 2008 Chelsio Communications, Inc. * * All rights reserved. * * * * Maintainers: maintainers@chelsio.com * * * * History: * * * ****************************************************************************/ /* $Date: 2007/02/05 18:46:24 $ $RCSfile: version.h,v $ $Revision: 1.9 $ */ /* - * $FreeBSD$ */ #ifndef __CXGBTOOL_VERSION_H #define __CXGBTOOL_VERSION_H #define PROGNAME "cxgbtool" #define VERSION "1.16f" #define COPYRIGHT "Copyright (c) 2004-2009 Chelsio Communications" #endif //__CXGBTOOL_VERSION_H diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index 621e3e215118..c17579a142b9 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -1,3396 +1,3395 @@ /* * Copyright (C) 2011-2014 Matteo Landi, Luigi Rizzo. All rights reserved. * Copyright (C) 2013-2015 Universita` di Pisa. 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* - * $FreeBSD$ * $Id: pkt-gen.c 12346 2013-06-12 17:36:25Z luigi $ * * Example program to show how to build a multithreaded packet * source/sink using the netmap device. * * In this example we create a programmable number of threads * to take care of all the queues of the interface used to * send or receive traffic. * */ #define _GNU_SOURCE /* for CPU_SET() */ #include /* ntohs */ #include #include // isprint() #include #include #include /* getifaddrs */ #include #include #include #include #include #include #include #ifndef NO_PCAP #include #endif #include #include #include #include #include #include #include #include #if !defined(_WIN32) && !defined(linux) #include /* sysctl */ #endif #include #include // sysconf() #ifdef linux #define IPV6_VERSION 0x60 #define IPV6_DEFHLIM 64 #endif #include "ctrs.h" static void usage(int); #ifdef _WIN32 #define cpuset_t DWORD_PTR //uint64_t static inline void CPU_ZERO(cpuset_t *p) { *p = 0; } static inline void CPU_SET(uint32_t i, cpuset_t *p) { *p |= 1<< (i & 0x3f); } #define pthread_setaffinity_np(a, b, c) !SetThreadAffinityMask(a, *c) //((void)a, 0) #define TAP_CLONEDEV "/dev/tap" #define AF_LINK 18 //defined in winsocks.h #define CLOCK_REALTIME_PRECISE CLOCK_REALTIME #include /* * Convert an ASCII representation of an ethernet address to * binary form. */ struct ether_addr * ether_aton(const char *a) { int i; static struct ether_addr o; unsigned int o0, o1, o2, o3, o4, o5; i = sscanf(a, "%x:%x:%x:%x:%x:%x", &o0, &o1, &o2, &o3, &o4, &o5); if (i != 6) return (NULL); o.octet[0]=o0; o.octet[1]=o1; o.octet[2]=o2; o.octet[3]=o3; o.octet[4]=o4; o.octet[5]=o5; return ((struct ether_addr *)&o); } /* * Convert a binary representation of an ethernet address to * an ASCII string. */ char * ether_ntoa(const struct ether_addr *n) { int i; static char a[18]; i = sprintf(a, "%02x:%02x:%02x:%02x:%02x:%02x", n->octet[0], n->octet[1], n->octet[2], n->octet[3], n->octet[4], n->octet[5]); return (i < 17 ? NULL : (char *)&a); } #endif /* _WIN32 */ #ifdef linux #define cpuset_t cpu_set_t #define ifr_flagshigh ifr_flags /* only the low 16 bits here */ #define IFF_PPROMISC IFF_PROMISC /* IFF_PPROMISC does not exist */ #include #include #define CLOCK_REALTIME_PRECISE CLOCK_REALTIME #include /* ether_aton */ #include /* sockaddr_ll */ #endif /* linux */ #ifdef __FreeBSD__ #include /* le64toh */ #include #include /* pthread w/ affinity */ #include /* cpu_set */ #include /* LLADDR */ #endif /* __FreeBSD__ */ #ifdef __APPLE__ #define cpuset_t uint64_t // XXX static inline void CPU_ZERO(cpuset_t *p) { *p = 0; } static inline void CPU_SET(uint32_t i, cpuset_t *p) { *p |= 1<< (i & 0x3f); } #define pthread_setaffinity_np(a, b, c) ((void)a, 0) #define ifr_flagshigh ifr_flags // XXX #define IFF_PPROMISC IFF_PROMISC #include /* LLADDR */ #define clock_gettime(a,b) \ do {struct timespec t0 = {0,0}; *(b) = t0; } while (0) #endif /* __APPLE__ */ static const char *default_payload = "netmap pkt-gen DIRECT payload\n" "http://info.iet.unipi.it/~luigi/netmap/ "; static const char *indirect_payload = "netmap pkt-gen indirect payload\n" "http://info.iet.unipi.it/~luigi/netmap/ "; static int verbose = 0; static int normalize = 1; #define VIRT_HDR_1 10 /* length of a base vnet-hdr */ #define VIRT_HDR_2 12 /* length of the extenede vnet-hdr */ #define VIRT_HDR_MAX VIRT_HDR_2 struct virt_header { uint8_t fields[VIRT_HDR_MAX]; }; #define MAX_BODYSIZE 65536 struct pkt { struct virt_header vh; struct ether_header eh; union { struct { struct ip ip; struct udphdr udp; uint8_t body[MAX_BODYSIZE]; /* hardwired */ } ipv4; struct { struct ip6_hdr ip; struct udphdr udp; uint8_t body[MAX_BODYSIZE]; /* hardwired */ } ipv6; }; } __attribute__((__packed__)); #define PKT(p, f, af) \ ((af) == AF_INET ? (p)->ipv4.f: (p)->ipv6.f) struct ip_range { const char *name; union { struct { uint32_t start, end; /* same as struct in_addr */ } ipv4; struct { struct in6_addr start, end; uint8_t sgroup, egroup; } ipv6; }; uint16_t port0, port1; }; struct mac_range { const char *name; struct ether_addr start, end; }; /* ifname can be netmap:foo-xxxx */ #define MAX_IFNAMELEN 512 /* our buffer for ifname */ //#define MAX_PKTSIZE 1536 #define MAX_PKTSIZE MAX_BODYSIZE /* XXX: + IP_HDR + ETH_HDR */ /* compact timestamp to fit into 60 byte packet. (enough to obtain RTT) */ struct tstamp { uint32_t sec; uint32_t nsec; }; /* * global arguments for all threads */ struct glob_arg { int af; /* address family AF_INET/AF_INET6 */ struct ip_range src_ip; struct ip_range dst_ip; struct mac_range dst_mac; struct mac_range src_mac; int pkt_size; int pkt_min_size; int burst; int forever; uint64_t npackets; /* total packets to send */ int frags; /* fragments per packet */ u_int frag_size; /* size of each fragment */ int nthreads; int cpus; /* cpus used for running */ int system_cpus; /* cpus on the system */ int options; /* testing */ #define OPT_PREFETCH 1 #define OPT_ACCESS 2 #define OPT_COPY 4 #define OPT_MEMCPY 8 #define OPT_TS 16 /* add a timestamp */ #define OPT_INDIRECT 32 /* use indirect buffers, tx only */ #define OPT_DUMP 64 /* dump rx/tx traffic */ #define OPT_RUBBISH 256 /* send whatever the buffers contain */ #define OPT_RANDOM_SRC 512 #define OPT_RANDOM_DST 1024 #define OPT_PPS_STATS 2048 #define OPT_UPDATE_CSUM 4096 int dev_type; #ifndef NO_PCAP pcap_t *p; #endif int tx_rate; struct timespec tx_period; int affinity; int main_fd; struct nmport_d *nmd; uint32_t orig_mode; int report_interval; /* milliseconds between prints */ void *(*td_body)(void *); int td_type; void *mmap_addr; char ifname[MAX_IFNAMELEN]; const char *nmr_config; int dummy_send; int virt_header; /* send also the virt_header */ char *packet_file; /* -P option */ #define STATS_WIN 15 int win_idx; int64_t win[STATS_WIN]; int wait_link; int framing; /* #bits of framing (for bw output) */ }; enum dev_type { DEV_NONE, DEV_NETMAP, DEV_PCAP, DEV_TAP }; enum { TD_TYPE_SENDER = 1, TD_TYPE_RECEIVER, TD_TYPE_OTHER, }; /* * Arguments for a new thread. The same structure is used by * the source and the sink */ struct targ { struct glob_arg *g; int used; int completed; int cancel; int fd; struct nmport_d *nmd; /* these ought to be volatile, but they are * only sampled and errors should not accumulate */ struct my_ctrs ctr; struct timespec tic, toc; int me; pthread_t thread; int affinity; struct pkt pkt; void *frame; uint16_t seed[3]; u_int frags; u_int frag_size; }; static __inline uint16_t cksum_add(uint16_t sum, uint16_t a) { uint16_t res; res = sum + a; return (res + (res < a)); } static void extract_ipv4_addr(char *name, uint32_t *addr, uint16_t *port) { struct in_addr a; char *pp; pp = strchr(name, ':'); if (pp != NULL) { /* do we have ports ? */ *pp++ = '\0'; *port = (uint16_t)strtol(pp, NULL, 0); } inet_pton(AF_INET, name, &a); *addr = ntohl(a.s_addr); } static void extract_ipv6_addr(char *name, struct in6_addr *addr, uint16_t *port, uint8_t *group) { char *pp; /* * We accept IPv6 address in the following form: * group@[2001:DB8::1001]:port (w/ brackets and port) * group@[2001:DB8::1] (w/ brackets and w/o port) * group@2001:DB8::1234 (w/o brackets and w/o port) */ pp = strchr(name, '@'); if (pp != NULL) { *pp++ = '\0'; *group = (uint8_t)strtol(name, NULL, 0); if (*group > 7) *group = 7; name = pp; } if (name[0] == '[') name++; pp = strchr(name, ']'); if (pp != NULL) *pp++ = '\0'; if (pp != NULL && *pp != ':') pp = NULL; if (pp != NULL) { /* do we have ports ? */ *pp++ = '\0'; *port = (uint16_t)strtol(pp, NULL, 0); } inet_pton(AF_INET6, name, addr); } /* * extract the extremes from a range of ipv4 addresses. * addr_lo[-addr_hi][:port_lo[-port_hi]] */ static int extract_ip_range(struct ip_range *r, int af) { char *name, *ap, start[INET6_ADDRSTRLEN]; char end[INET6_ADDRSTRLEN]; struct in_addr a; uint32_t tmp; if (verbose) D("extract IP range from %s", r->name); name = strdup(r->name); if (name == NULL) { D("strdup failed"); usage(-1); } /* the first - splits start/end of range */ ap = strchr(name, '-'); if (ap != NULL) *ap++ = '\0'; r->port0 = 1234; /* default port */ if (af == AF_INET6) { r->ipv6.sgroup = 7; /* default group */ extract_ipv6_addr(name, &r->ipv6.start, &r->port0, &r->ipv6.sgroup); } else extract_ipv4_addr(name, &r->ipv4.start, &r->port0); r->port1 = r->port0; if (af == AF_INET6) { if (ap != NULL) { r->ipv6.egroup = r->ipv6.sgroup; extract_ipv6_addr(ap, &r->ipv6.end, &r->port1, &r->ipv6.egroup); } else { r->ipv6.end = r->ipv6.start; r->ipv6.egroup = r->ipv6.sgroup; } } else { if (ap != NULL) { extract_ipv4_addr(ap, &r->ipv4.end, &r->port1); if (r->ipv4.start > r->ipv4.end) { tmp = r->ipv4.end; r->ipv4.end = r->ipv4.start; r->ipv4.start = tmp; } } else r->ipv4.end = r->ipv4.start; } if (r->port0 > r->port1) { tmp = r->port0; r->port0 = r->port1; r->port1 = tmp; } if (af == AF_INET) { a.s_addr = htonl(r->ipv4.start); inet_ntop(af, &a, start, sizeof(start)); a.s_addr = htonl(r->ipv4.end); inet_ntop(af, &a, end, sizeof(end)); } else { inet_ntop(af, &r->ipv6.start, start, sizeof(start)); inet_ntop(af, &r->ipv6.end, end, sizeof(end)); } if (af == AF_INET) D("range is %s:%d to %s:%d", start, r->port0, end, r->port1); else D("range is %d@[%s]:%d to %d@[%s]:%d", r->ipv6.sgroup, start, r->port0, r->ipv6.egroup, end, r->port1); free(name); if (r->port0 != r->port1 || (af == AF_INET && r->ipv4.start != r->ipv4.end) || (af == AF_INET6 && !IN6_ARE_ADDR_EQUAL(&r->ipv6.start, &r->ipv6.end))) return (OPT_COPY); return (0); } static int extract_mac_range(struct mac_range *r) { struct ether_addr *e; if (verbose) D("extract MAC range from %s", r->name); e = ether_aton(r->name); if (e == NULL) { D("invalid MAC address '%s'", r->name); return 1; } bcopy(e, &r->start, 6); bcopy(e, &r->end, 6); #if 0 bcopy(targ->src_mac, eh->ether_shost, 6); p = index(targ->g->src_mac, '-'); if (p) targ->src_mac_range = atoi(p+1); bcopy(ether_aton(targ->g->dst_mac), targ->dst_mac, 6); bcopy(targ->dst_mac, eh->ether_dhost, 6); p = index(targ->g->dst_mac, '-'); if (p) targ->dst_mac_range = atoi(p+1); #endif if (verbose) D("%s starts at %s", r->name, ether_ntoa(&r->start)); return 0; } static int get_if_mtu(const struct glob_arg *g) { struct ifreq ifreq; int s, ret; const char *ifname = g->nmd->hdr.nr_name; size_t len; if (!strncmp(g->ifname, "netmap:", 7) && !strchr(ifname, '{') && !strchr(ifname, '}')) { len = strlen(ifname); if (len > IFNAMSIZ) { D("'%s' too long, cannot ask for MTU", ifname); return -1; } s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { D("socket() failed: %s", strerror(errno)); return s; } memset(&ifreq, 0, sizeof(ifreq)); memcpy(ifreq.ifr_name, ifname, len); ret = ioctl(s, SIOCGIFMTU, &ifreq); if (ret) { D("ioctl(SIOCGIFMTU) failed: %s", strerror(errno)); } close(s); return ifreq.ifr_mtu; } /* This is a pipe or a VALE port, where the MTU is very large, * so we use some practical limit. */ return 65536; } static struct targ *targs; static int global_nthreads; /* control-C handler */ static void sigint_h(int sig) { int i; (void)sig; /* UNUSED */ D("received control-C on thread %p", (void *)pthread_self()); for (i = 0; i < global_nthreads; i++) { targs[i].cancel = 1; } } /* sysctl wrapper to return the number of active CPUs */ static int system_ncpus(void) { int ncpus; #if defined (__FreeBSD__) int mib[2] = { CTL_HW, HW_NCPU }; size_t len = sizeof(mib); sysctl(mib, 2, &ncpus, &len, NULL, 0); #elif defined(linux) ncpus = sysconf(_SC_NPROCESSORS_ONLN); #elif defined(_WIN32) { SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); ncpus = sysinfo.dwNumberOfProcessors; } #else /* others */ ncpus = 1; #endif /* others */ return (ncpus); } #ifdef __linux__ #define sockaddr_dl sockaddr_ll #define sdl_family sll_family #define AF_LINK AF_PACKET #define LLADDR(s) s->sll_addr; #include #define TAP_CLONEDEV "/dev/net/tun" #endif /* __linux__ */ #ifdef __FreeBSD__ #include #define TAP_CLONEDEV "/dev/tap" #endif /* __FreeBSD */ #ifdef __APPLE__ // #warning TAP not supported on apple ? #include #define TAP_CLONEDEV "/dev/tap" #endif /* __APPLE__ */ /* * parse the vale configuration in conf and put it in nmr. * Return the flag set if necessary. * The configuration may consist of 1 to 4 numbers separated * by commas: #tx-slots,#rx-slots,#tx-rings,#rx-rings. * Missing numbers or zeroes stand for default values. * As an additional convenience, if exactly one number * is specified, then this is assigned to both #tx-slots and #rx-slots. * If there is no 4th number, then the 3rd is assigned to both #tx-rings * and #rx-rings. */ static int parse_nmr_config(const char* conf, struct nmreq_register *nmr) { char *w, *tok; int i, v; if (conf == NULL || ! *conf) return 0; nmr->nr_tx_rings = nmr->nr_rx_rings = 0; nmr->nr_tx_slots = nmr->nr_rx_slots = 0; w = strdup(conf); for (i = 0, tok = strtok(w, ","); tok; i++, tok = strtok(NULL, ",")) { v = atoi(tok); switch (i) { case 0: nmr->nr_tx_slots = nmr->nr_rx_slots = v; break; case 1: nmr->nr_rx_slots = v; break; case 2: nmr->nr_tx_rings = nmr->nr_rx_rings = v; break; case 3: nmr->nr_rx_rings = v; break; default: D("ignored config: %s", tok); break; } } D("txr %d txd %d rxr %d rxd %d", nmr->nr_tx_rings, nmr->nr_tx_slots, nmr->nr_rx_rings, nmr->nr_rx_slots); free(w); return 0; } /* * locate the src mac address for our interface, put it * into the user-supplied buffer. return 0 if ok, -1 on error. */ static int source_hwaddr(const char *ifname, char *buf) { struct ifaddrs *ifaphead, *ifap; if (getifaddrs(&ifaphead) != 0) { D("getifaddrs %s failed", ifname); return (-1); } /* remove 'netmap:' prefix before comparing interfaces */ if (!strncmp(ifname, "netmap:", 7)) ifname = &ifname[7]; for (ifap = ifaphead; ifap; ifap = ifap->ifa_next) { struct sockaddr_dl *sdl = (struct sockaddr_dl *)ifap->ifa_addr; uint8_t *mac; if (!sdl || sdl->sdl_family != AF_LINK) continue; if (strncmp(ifap->ifa_name, ifname, IFNAMSIZ) != 0) continue; mac = (uint8_t *)LLADDR(sdl); sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); if (verbose) D("source hwaddr %s", buf); break; } freeifaddrs(ifaphead); return ifap ? 0 : 1; } /* set the thread affinity. */ static int setaffinity(pthread_t me, int i) { cpuset_t cpumask; if (i == -1) return 0; /* Set thread affinity affinity.*/ CPU_ZERO(&cpumask); CPU_SET(i, &cpumask); if (pthread_setaffinity_np(me, sizeof(cpuset_t), &cpumask) != 0) { D("Unable to set affinity: %s", strerror(errno)); return 1; } return 0; } /* Compute the checksum of the given ip header. */ static uint32_t checksum(const void *data, uint16_t len, uint32_t sum) { const uint8_t *addr = data; uint32_t i; /* Checksum all the pairs of bytes first... */ for (i = 0; i < (len & ~1U); i += 2) { sum += (uint16_t)ntohs(*((const uint16_t *)(addr + i))); if (sum > 0xFFFF) sum -= 0xFFFF; } /* * If there's a single byte left over, checksum it, too. * Network byte order is big-endian, so the remaining byte is * the high byte. */ if (i < len) { sum += addr[i] << 8; if (sum > 0xFFFF) sum -= 0xFFFF; } return sum; } static uint16_t wrapsum(uint32_t sum) { sum = ~sum & 0xFFFF; return (htons(sum)); } /* Check the payload of the packet for errors (use it for debug). * Look for consecutive ascii representations of the size of the packet. */ static void dump_payload(const char *_p, int len, struct netmap_ring *ring, int cur) { char buf[128]; int i, j, i0; const unsigned char *p = (const unsigned char *)_p; /* get the length in ASCII of the length of the packet. */ printf("ring %p cur %5d [buf %6d flags 0x%04x len %5d]\n", ring, cur, ring->slot[cur].buf_idx, ring->slot[cur].flags, len); /* hexdump routine */ for (i = 0; i < len; ) { memset(buf, ' ', sizeof(buf)); sprintf(buf, "%5d: ", i); i0 = i; for (j=0; j < 16 && i < len; i++, j++) sprintf(buf+7+j*3, "%02x ", (uint8_t)(p[i])); i = i0; for (j=0; j < 16 && i < len; i++, j++) sprintf(buf+7+j + 48, "%c", isprint(p[i]) ? p[i] : '.'); printf("%s\n", buf); } } /* * Fill a packet with some payload. * We create a UDP packet so the payload starts at * 14+20+8 = 42 bytes. */ #ifdef __linux__ #define uh_sport source #define uh_dport dest #define uh_ulen len #define uh_sum check #endif /* linux */ static uint16_t new_ip_sum(uint16_t ip_sum, uint32_t oaddr, uint32_t naddr) { ip_sum = cksum_add(ip_sum, ~oaddr >> 16); ip_sum = cksum_add(ip_sum, ~oaddr & 0xffff); ip_sum = cksum_add(ip_sum, naddr >> 16); ip_sum = cksum_add(ip_sum, naddr & 0xffff); return ip_sum; } static uint16_t new_udp_sum(uint16_t udp_sum, uint16_t oport, uint16_t nport) { udp_sum = cksum_add(udp_sum, ~oport); udp_sum = cksum_add(udp_sum, nport); return udp_sum; } static void update_ip(struct pkt *pkt, struct targ *t) { struct glob_arg *g = t->g; struct ip ip; struct udphdr udp; uint32_t oaddr, naddr; uint16_t oport, nport; uint16_t ip_sum = 0, udp_sum = 0; memcpy(&ip, &pkt->ipv4.ip, sizeof(ip)); memcpy(&udp, &pkt->ipv4.udp, sizeof(udp)); do { ip_sum = udp_sum = 0; naddr = oaddr = ntohl(ip.ip_src.s_addr); nport = oport = ntohs(udp.uh_sport); if (g->options & OPT_RANDOM_SRC) { ip.ip_src.s_addr = nrand48(t->seed); udp.uh_sport = nrand48(t->seed); naddr = ntohl(ip.ip_src.s_addr); nport = ntohs(udp.uh_sport); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); udp_sum = new_udp_sum(udp_sum, oport, nport); } else { if (oport < g->src_ip.port1) { nport = oport + 1; udp.uh_sport = htons(nport); udp_sum = new_udp_sum(udp_sum, oport, nport); break; } nport = g->src_ip.port0; udp.uh_sport = htons(nport); if (oaddr < g->src_ip.ipv4.end) { naddr = oaddr + 1; ip.ip_src.s_addr = htonl(naddr); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); break; } naddr = g->src_ip.ipv4.start; ip.ip_src.s_addr = htonl(naddr); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } naddr = oaddr = ntohl(ip.ip_dst.s_addr); nport = oport = ntohs(udp.uh_dport); if (g->options & OPT_RANDOM_DST) { ip.ip_dst.s_addr = nrand48(t->seed); udp.uh_dport = nrand48(t->seed); naddr = ntohl(ip.ip_dst.s_addr); nport = ntohs(udp.uh_dport); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); udp_sum = new_udp_sum(udp_sum, oport, nport); } else { if (oport < g->dst_ip.port1) { nport = oport + 1; udp.uh_dport = htons(nport); udp_sum = new_udp_sum(udp_sum, oport, nport); break; } nport = g->dst_ip.port0; udp.uh_dport = htons(nport); if (oaddr < g->dst_ip.ipv4.end) { naddr = oaddr + 1; ip.ip_dst.s_addr = htonl(naddr); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); break; } naddr = g->dst_ip.ipv4.start; ip.ip_dst.s_addr = htonl(naddr); ip_sum = new_ip_sum(ip_sum, oaddr, naddr); } } while (0); /* update checksums */ if (udp_sum != 0) udp.uh_sum = ~cksum_add(~udp.uh_sum, htons(udp_sum)); if (ip_sum != 0) { ip.ip_sum = ~cksum_add(~ip.ip_sum, htons(ip_sum)); udp.uh_sum = ~cksum_add(~udp.uh_sum, htons(ip_sum)); } memcpy(&pkt->ipv4.ip, &ip, sizeof(ip)); memcpy(&pkt->ipv4.udp, &udp, sizeof(udp)); } #ifndef s6_addr16 #define s6_addr16 __u6_addr.__u6_addr16 #endif static void update_ip6(struct pkt *pkt, struct targ *t) { struct glob_arg *g = t->g; struct ip6_hdr ip6; struct udphdr udp; uint16_t udp_sum; uint16_t oaddr, naddr; uint16_t oport, nport; uint8_t group; memcpy(&ip6, &pkt->ipv6.ip, sizeof(ip6)); memcpy(&udp, &pkt->ipv6.udp, sizeof(udp)); do { udp_sum = 0; group = g->src_ip.ipv6.sgroup; naddr = oaddr = ntohs(ip6.ip6_src.s6_addr16[group]); nport = oport = ntohs(udp.uh_sport); if (g->options & OPT_RANDOM_SRC) { ip6.ip6_src.s6_addr16[group] = nrand48(t->seed); udp.uh_sport = nrand48(t->seed); naddr = ntohs(ip6.ip6_src.s6_addr16[group]); nport = ntohs(udp.uh_sport); break; } if (oport < g->src_ip.port1) { nport = oport + 1; udp.uh_sport = htons(nport); break; } nport = g->src_ip.port0; udp.uh_sport = htons(nport); if (oaddr < ntohs(g->src_ip.ipv6.end.s6_addr16[group])) { naddr = oaddr + 1; ip6.ip6_src.s6_addr16[group] = htons(naddr); break; } naddr = ntohs(g->src_ip.ipv6.start.s6_addr16[group]); ip6.ip6_src.s6_addr16[group] = htons(naddr); /* update checksums if needed */ if (oaddr != naddr) udp_sum = cksum_add(~oaddr, naddr); if (oport != nport) udp_sum = cksum_add(udp_sum, cksum_add(~oport, nport)); group = g->dst_ip.ipv6.egroup; naddr = oaddr = ntohs(ip6.ip6_dst.s6_addr16[group]); nport = oport = ntohs(udp.uh_dport); if (g->options & OPT_RANDOM_DST) { ip6.ip6_dst.s6_addr16[group] = nrand48(t->seed); udp.uh_dport = nrand48(t->seed); naddr = ntohs(ip6.ip6_dst.s6_addr16[group]); nport = ntohs(udp.uh_dport); break; } if (oport < g->dst_ip.port1) { nport = oport + 1; udp.uh_dport = htons(nport); break; } nport = g->dst_ip.port0; udp.uh_dport = htons(nport); if (oaddr < ntohs(g->dst_ip.ipv6.end.s6_addr16[group])) { naddr = oaddr + 1; ip6.ip6_dst.s6_addr16[group] = htons(naddr); break; } naddr = ntohs(g->dst_ip.ipv6.start.s6_addr16[group]); ip6.ip6_dst.s6_addr16[group] = htons(naddr); } while (0); /* update checksums */ if (oaddr != naddr) udp_sum = cksum_add(udp_sum, cksum_add(~oaddr, naddr)); if (oport != nport) udp_sum = cksum_add(udp_sum, cksum_add(~oport, nport)); if (udp_sum != 0) udp.uh_sum = ~cksum_add(~udp.uh_sum, udp_sum); memcpy(&pkt->ipv6.ip, &ip6, sizeof(ip6)); memcpy(&pkt->ipv6.udp, &udp, sizeof(udp)); } static void update_addresses(struct pkt *pkt, struct targ *t) { if (t->g->af == AF_INET) update_ip(pkt, t); else update_ip6(pkt, t); } static void update_ip_size(struct pkt *pkt, int size) { struct ip ip; struct udphdr udp; uint16_t oiplen, niplen; uint16_t nudplen; uint16_t ip_sum = 0; memcpy(&ip, &pkt->ipv4.ip, sizeof(ip)); memcpy(&udp, &pkt->ipv4.udp, sizeof(udp)); oiplen = ntohs(ip.ip_len); niplen = size - sizeof(struct ether_header); ip.ip_len = htons(niplen); nudplen = niplen - sizeof(struct ip); udp.uh_ulen = htons(nudplen); ip_sum = new_udp_sum(ip_sum, oiplen, niplen); /* update checksums */ if (ip_sum != 0) ip.ip_sum = ~cksum_add(~ip.ip_sum, htons(ip_sum)); udp.uh_sum = 0; /* Magic: taken from sbin/dhclient/packet.c */ udp.uh_sum = wrapsum( checksum(&udp, sizeof(udp), /* udp header */ checksum(pkt->ipv4.body, /* udp payload */ nudplen - sizeof(udp), checksum(&ip.ip_src, /* pseudo header */ 2 * sizeof(ip.ip_src), IPPROTO_UDP + (u_int32_t)ntohs(udp.uh_ulen))))); memcpy(&pkt->ipv4.ip, &ip, sizeof(ip)); memcpy(&pkt->ipv4.udp, &udp, sizeof(udp)); } static void update_ip6_size(struct pkt *pkt, int size) { struct ip6_hdr ip6; struct udphdr udp; uint16_t niplen, nudplen; uint32_t csum; memcpy(&ip6, &pkt->ipv6.ip, sizeof(ip6)); memcpy(&udp, &pkt->ipv6.udp, sizeof(udp)); nudplen = niplen = size - sizeof(struct ether_header) - sizeof(ip6); ip6.ip6_plen = htons(niplen); udp.uh_ulen = htons(nudplen); /* Save part of pseudo header checksum into csum */ udp.uh_sum = 0; csum = IPPROTO_UDP << 24; csum = checksum(&csum, sizeof(csum), nudplen); udp.uh_sum = wrapsum( checksum(&udp, sizeof(udp), /* udp header */ checksum(pkt->ipv6.body, /* udp payload */ nudplen - sizeof(udp), checksum(&pkt->ipv6.ip.ip6_src, /* pseudo header */ 2 * sizeof(pkt->ipv6.ip.ip6_src), csum)))); memcpy(&pkt->ipv6.ip, &ip6, sizeof(ip6)); memcpy(&pkt->ipv6.udp, &udp, sizeof(udp)); } static void update_size(struct pkt *pkt, struct targ *t, int size) { if (t->g->options & OPT_UPDATE_CSUM) { if (t->g->af == AF_INET) update_ip_size(pkt, size); else update_ip6_size(pkt, size); } } /* * initialize one packet and prepare for the next one. * The copy could be done better instead of repeating it each time. */ static void initialize_packet(struct targ *targ) { struct pkt *pkt = &targ->pkt; struct ether_header *eh; struct ip6_hdr ip6; struct ip ip; struct udphdr udp; void *udp_ptr; uint16_t paylen; uint32_t csum = 0; const char *payload = targ->g->options & OPT_INDIRECT ? indirect_payload : default_payload; int i, l0 = strlen(payload); #ifndef NO_PCAP char errbuf[PCAP_ERRBUF_SIZE]; pcap_t *file; struct pcap_pkthdr *header; const unsigned char *packet; /* Read a packet from a PCAP file if asked. */ if (targ->g->packet_file != NULL) { if ((file = pcap_open_offline(targ->g->packet_file, errbuf)) == NULL) D("failed to open pcap file %s", targ->g->packet_file); if (pcap_next_ex(file, &header, &packet) < 0) D("failed to read packet from %s", targ->g->packet_file); if ((targ->frame = malloc(header->caplen)) == NULL) D("out of memory"); bcopy(packet, (unsigned char *)targ->frame, header->caplen); targ->g->pkt_size = header->caplen; pcap_close(file); return; } #endif paylen = targ->g->pkt_size - sizeof(*eh) - (targ->g->af == AF_INET ? sizeof(ip): sizeof(ip6)); /* create a nice NUL-terminated string */ for (i = 0; i < paylen; i += l0) { if (l0 > paylen - i) l0 = paylen - i; // last round bcopy(payload, PKT(pkt, body, targ->g->af) + i, l0); } PKT(pkt, body, targ->g->af)[i - 1] = '\0'; /* prepare the headers */ eh = &pkt->eh; bcopy(&targ->g->src_mac.start, eh->ether_shost, 6); bcopy(&targ->g->dst_mac.start, eh->ether_dhost, 6); if (targ->g->af == AF_INET) { eh->ether_type = htons(ETHERTYPE_IP); memcpy(&ip, &pkt->ipv4.ip, sizeof(ip)); udp_ptr = &pkt->ipv4.udp; ip.ip_v = IPVERSION; ip.ip_hl = sizeof(ip) >> 2; ip.ip_id = 0; ip.ip_tos = IPTOS_LOWDELAY; ip.ip_len = htons(targ->g->pkt_size - sizeof(*eh)); ip.ip_id = 0; ip.ip_off = htons(IP_DF); /* Don't fragment */ ip.ip_ttl = IPDEFTTL; ip.ip_p = IPPROTO_UDP; ip.ip_dst.s_addr = htonl(targ->g->dst_ip.ipv4.start); ip.ip_src.s_addr = htonl(targ->g->src_ip.ipv4.start); ip.ip_sum = wrapsum(checksum(&ip, sizeof(ip), 0)); memcpy(&pkt->ipv4.ip, &ip, sizeof(ip)); } else { eh->ether_type = htons(ETHERTYPE_IPV6); memcpy(&ip6, &pkt->ipv4.ip, sizeof(ip6)); udp_ptr = &pkt->ipv6.udp; ip6.ip6_flow = 0; ip6.ip6_plen = htons(paylen); ip6.ip6_vfc = IPV6_VERSION; ip6.ip6_nxt = IPPROTO_UDP; ip6.ip6_hlim = IPV6_DEFHLIM; ip6.ip6_src = targ->g->src_ip.ipv6.start; ip6.ip6_dst = targ->g->dst_ip.ipv6.start; } memcpy(&udp, udp_ptr, sizeof(udp)); udp.uh_sport = htons(targ->g->src_ip.port0); udp.uh_dport = htons(targ->g->dst_ip.port0); udp.uh_ulen = htons(paylen); if (targ->g->af == AF_INET) { /* Magic: taken from sbin/dhclient/packet.c */ udp.uh_sum = wrapsum( checksum(&udp, sizeof(udp), /* udp header */ checksum(pkt->ipv4.body, /* udp payload */ paylen - sizeof(udp), checksum(&pkt->ipv4.ip.ip_src, /* pseudo header */ 2 * sizeof(pkt->ipv4.ip.ip_src), IPPROTO_UDP + (u_int32_t)ntohs(udp.uh_ulen))))); memcpy(&pkt->ipv4.ip, &ip, sizeof(ip)); } else { /* Save part of pseudo header checksum into csum */ csum = IPPROTO_UDP << 24; csum = checksum(&csum, sizeof(csum), paylen); udp.uh_sum = wrapsum( checksum(udp_ptr, sizeof(udp), /* udp header */ checksum(pkt->ipv6.body, /* udp payload */ paylen - sizeof(udp), checksum(&pkt->ipv6.ip.ip6_src, /* pseudo header */ 2 * sizeof(pkt->ipv6.ip.ip6_src), csum)))); memcpy(&pkt->ipv6.ip, &ip6, sizeof(ip6)); } memcpy(udp_ptr, &udp, sizeof(udp)); bzero(&pkt->vh, sizeof(pkt->vh)); // dump_payload((void *)pkt, targ->g->pkt_size, NULL, 0); } static void get_vnet_hdr_len(struct glob_arg *g) { struct nmreq_header hdr; struct nmreq_port_hdr ph; int err; hdr = g->nmd->hdr; /* copy name and version */ hdr.nr_reqtype = NETMAP_REQ_PORT_HDR_GET; hdr.nr_options = 0; memset(&ph, 0, sizeof(ph)); hdr.nr_body = (uintptr_t)&ph; err = ioctl(g->main_fd, NIOCCTRL, &hdr); if (err) { D("Unable to get virtio-net header length"); return; } g->virt_header = ph.nr_hdr_len; if (g->virt_header) { D("Port requires virtio-net header, length = %d", g->virt_header); } } static void set_vnet_hdr_len(struct glob_arg *g) { int err, l = g->virt_header; struct nmreq_header hdr; struct nmreq_port_hdr ph; if (l == 0) return; hdr = g->nmd->hdr; /* copy name and version */ hdr.nr_reqtype = NETMAP_REQ_PORT_HDR_SET; hdr.nr_options = 0; memset(&ph, 0, sizeof(ph)); hdr.nr_body = (uintptr_t)&ph; err = ioctl(g->main_fd, NIOCCTRL, &hdr); if (err) { D("Unable to set virtio-net header length %d", l); } } /* * create and enqueue a batch of packets on a ring. * On the last one set NS_REPORT to tell the driver to generate * an interrupt when done. */ static int send_packets(struct netmap_ring *ring, struct pkt *pkt, void *frame, int size, struct targ *t, u_int count, int options) { u_int n, sent, head = ring->head; u_int frags = t->frags; u_int frag_size = t->frag_size; struct netmap_slot *slot = &ring->slot[head]; n = nm_ring_space(ring); #if 0 if (options & (OPT_COPY | OPT_PREFETCH) ) { for (sent = 0; sent < count; sent++) { struct netmap_slot *slot = &ring->slot[head]; char *p = NETMAP_BUF(ring, slot->buf_idx); __builtin_prefetch(p); head = nm_ring_next(ring, head); } head = ring->head; } #endif for (sent = 0; sent < count && n >= frags; sent++, n--) { char *p; int buf_changed; u_int tosend = size; slot = &ring->slot[head]; p = NETMAP_BUF(ring, slot->buf_idx); buf_changed = slot->flags & NS_BUF_CHANGED; slot->flags = 0; if (options & OPT_RUBBISH) { /* do nothing */ } else if (options & OPT_INDIRECT) { slot->flags |= NS_INDIRECT; slot->ptr = (uint64_t)((uintptr_t)frame); } else if (frags > 1) { u_int i; const char *f = frame; char *fp = p; for (i = 0; i < frags - 1; i++) { memcpy(fp, f, frag_size); slot->len = frag_size; slot->flags = NS_MOREFRAG; if (options & OPT_DUMP) dump_payload(fp, frag_size, ring, head); tosend -= frag_size; f += frag_size; head = nm_ring_next(ring, head); slot = &ring->slot[head]; fp = NETMAP_BUF(ring, slot->buf_idx); } n -= (frags - 1); p = fp; slot->flags = 0; memcpy(p, f, tosend); update_addresses(pkt, t); } else if ((options & (OPT_COPY | OPT_MEMCPY)) || buf_changed) { if (options & OPT_COPY) nm_pkt_copy(frame, p, size); else memcpy(p, frame, size); update_addresses(pkt, t); } else if (options & OPT_PREFETCH) { __builtin_prefetch(p); } slot->len = tosend; if (options & OPT_DUMP) dump_payload(p, tosend, ring, head); head = nm_ring_next(ring, head); } if (sent) { slot->flags |= NS_REPORT; ring->head = ring->cur = head; } if (sent < count) { /* tell netmap that we need more slots */ ring->cur = ring->tail; } return (sent); } /* * Index of the highest bit set */ static uint32_t msb64(uint64_t x) { uint64_t m = 1ULL << 63; int i; for (i = 63; i >= 0; i--, m >>=1) if (m & x) return i; return 0; } /* * wait until ts, either busy or sleeping if more than 1ms. * Return wakeup time. */ static struct timespec wait_time(struct timespec ts) { for (;;) { struct timespec w, cur; clock_gettime(CLOCK_REALTIME_PRECISE, &cur); w = timespec_sub(ts, cur); if (w.tv_sec < 0) return cur; else if (w.tv_sec > 0 || w.tv_nsec > 1000000) poll(NULL, 0, 1); } } /* * Send a packet, and wait for a response. * The payload (after UDP header, ofs 42) has a 4-byte sequence * followed by a struct timeval (or bintime?) */ static void * ping_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLIN }; struct netmap_if *nifp = targ->nmd->nifp; int i, m; void *frame; int size; struct timespec ts, now, last_print; struct timespec nexttime = {0, 0}; /* silence compiler */ uint64_t sent = 0, n = targ->g->npackets; uint64_t count = 0, t_cur, t_min = ~0, av = 0; uint64_t g_min = ~0, g_av = 0; uint64_t buckets[64]; /* bins for delays, ns */ int rate_limit = targ->g->tx_rate, tosend = 0; frame = (char*)&targ->pkt + sizeof(targ->pkt.vh) - targ->g->virt_header; size = targ->g->pkt_size + targ->g->virt_header; if (targ->g->nthreads > 1) { D("can only ping with 1 thread"); return NULL; } if (targ->g->af == AF_INET6) { D("Warning: ping-pong with IPv6 not supported"); } bzero(&buckets, sizeof(buckets)); clock_gettime(CLOCK_REALTIME_PRECISE, &last_print); now = last_print; if (rate_limit) { targ->tic = timespec_add(now, (struct timespec){2,0}); targ->tic.tv_nsec = 0; wait_time(targ->tic); nexttime = targ->tic; } while (!targ->cancel && (n == 0 || sent < n)) { struct netmap_ring *ring = NETMAP_TXRING(nifp, targ->nmd->first_tx_ring); struct netmap_slot *slot; char *p; int rv; uint64_t limit, event = 0; if (rate_limit && tosend <= 0) { tosend = targ->g->burst; nexttime = timespec_add(nexttime, targ->g->tx_period); wait_time(nexttime); } limit = rate_limit ? tosend : targ->g->burst; if (n > 0 && n - sent < limit) limit = n - sent; for (m = 0; (unsigned)m < limit; m++) { slot = &ring->slot[ring->head]; slot->len = size; p = NETMAP_BUF(ring, slot->buf_idx); if (nm_ring_empty(ring)) { D("-- ouch, cannot send"); break; } else { struct tstamp *tp; nm_pkt_copy(frame, p, size); clock_gettime(CLOCK_REALTIME_PRECISE, &ts); bcopy(&sent, p+42, sizeof(sent)); tp = (struct tstamp *)(p+46); tp->sec = (uint32_t)ts.tv_sec; tp->nsec = (uint32_t)ts.tv_nsec; sent++; ring->head = ring->cur = nm_ring_next(ring, ring->head); } } if (m > 0) event++; targ->ctr.pkts = sent; targ->ctr.bytes = sent*size; targ->ctr.events = event; if (rate_limit) tosend -= m; #ifdef BUSYWAIT rv = ioctl(pfd.fd, NIOCTXSYNC, NULL); if (rv < 0) { D("TXSYNC error on queue %d: %s", targ->me, strerror(errno)); } again: ioctl(pfd.fd, NIOCRXSYNC, NULL); #else /* should use a parameter to decide how often to send */ if ( (rv = poll(&pfd, 1, 3000)) <= 0) { D("poll error on queue %d: %s", targ->me, (rv ? strerror(errno) : "timeout")); continue; } #endif /* BUSYWAIT */ /* see what we got back */ #ifdef BUSYWAIT int rx = 0; #endif for (i = targ->nmd->first_rx_ring; i <= targ->nmd->last_rx_ring; i++) { ring = NETMAP_RXRING(nifp, i); while (!nm_ring_empty(ring)) { uint32_t seq; struct tstamp *tp; int pos; slot = &ring->slot[ring->head]; p = NETMAP_BUF(ring, slot->buf_idx); clock_gettime(CLOCK_REALTIME_PRECISE, &now); bcopy(p+42, &seq, sizeof(seq)); tp = (struct tstamp *)(p+46); ts.tv_sec = (time_t)tp->sec; ts.tv_nsec = (long)tp->nsec; ts.tv_sec = now.tv_sec - ts.tv_sec; ts.tv_nsec = now.tv_nsec - ts.tv_nsec; if (ts.tv_nsec < 0) { ts.tv_nsec += 1000000000; ts.tv_sec--; } if (0) D("seq %d/%llu delta %d.%09d", seq, (unsigned long long)sent, (int)ts.tv_sec, (int)ts.tv_nsec); t_cur = ts.tv_sec * 1000000000UL + ts.tv_nsec; if (t_cur < t_min) t_min = t_cur; count ++; av += t_cur; pos = msb64(t_cur); buckets[pos]++; /* now store it in a bucket */ ring->head = ring->cur = nm_ring_next(ring, ring->head); #ifdef BUSYWAIT rx++; #endif } } //D("tx %d rx %d", sent, rx); //usleep(100000); ts.tv_sec = now.tv_sec - last_print.tv_sec; ts.tv_nsec = now.tv_nsec - last_print.tv_nsec; if (ts.tv_nsec < 0) { ts.tv_nsec += 1000000000; ts.tv_sec--; } if (ts.tv_sec >= 1) { D("count %d RTT: min %d av %d ns", (int)count, (int)t_min, (int)(av/count)); int k, j, kmin, off; char buf[512]; for (kmin = 0; kmin < 64; kmin ++) if (buckets[kmin]) break; for (k = 63; k >= kmin; k--) if (buckets[k]) break; buf[0] = '\0'; off = 0; for (j = kmin; j <= k; j++) { off += sprintf(buf + off, " %5d", (int)buckets[j]); } D("k: %d .. %d\n\t%s", 1<cancel) goto again; #endif /* BUSYWAIT */ } if (sent > 0) { D("RTT over %llu packets: min %d av %d ns", (long long unsigned)sent, (int)g_min, (int)((double)g_av/sent)); } targ->completed = 1; /* reset the ``used`` flag. */ targ->used = 0; return NULL; } /* * reply to ping requests */ static void * pong_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLIN }; struct netmap_if *nifp = targ->nmd->nifp; struct netmap_ring *txring, *rxring; int i; uint64_t sent = 0, n = targ->g->npackets; if (targ->g->nthreads > 1) { D("can only reply ping with 1 thread"); return NULL; } if (n > 0) D("understood ponger %llu but don't know how to do it", (unsigned long long)n); if (targ->g->af == AF_INET6) { D("Warning: ping-pong with IPv6 not supported"); } while (!targ->cancel && (n == 0 || sent < n)) { uint32_t txhead, txavail; //#define BUSYWAIT #ifdef BUSYWAIT ioctl(pfd.fd, NIOCRXSYNC, NULL); #else int rv; if ( (rv = poll(&pfd, 1, 1000)) <= 0) { D("poll error on queue %d: %s", targ->me, rv ? strerror(errno) : "timeout"); continue; } #endif txring = NETMAP_TXRING(nifp, targ->nmd->first_tx_ring); txhead = txring->head; txavail = nm_ring_space(txring); /* see what we got back */ for (i = targ->nmd->first_rx_ring; i <= targ->nmd->last_rx_ring; i++) { rxring = NETMAP_RXRING(nifp, i); while (!nm_ring_empty(rxring)) { uint16_t *spkt, *dpkt; uint32_t head = rxring->head; struct netmap_slot *slot = &rxring->slot[head]; char *src, *dst; src = NETMAP_BUF(rxring, slot->buf_idx); //D("got pkt %p of size %d", src, slot->len); rxring->head = rxring->cur = nm_ring_next(rxring, head); if (txavail == 0) continue; dst = NETMAP_BUF(txring, txring->slot[txhead].buf_idx); /* copy... */ dpkt = (uint16_t *)dst; spkt = (uint16_t *)src; nm_pkt_copy(src, dst, slot->len); /* swap source and destination MAC */ dpkt[0] = spkt[3]; dpkt[1] = spkt[4]; dpkt[2] = spkt[5]; dpkt[3] = spkt[0]; dpkt[4] = spkt[1]; dpkt[5] = spkt[2]; /* swap source and destination IPv4 */ if (spkt[6] == htons(ETHERTYPE_IP)) { dpkt[13] = spkt[15]; dpkt[14] = spkt[16]; dpkt[15] = spkt[13]; dpkt[16] = spkt[14]; } txring->slot[txhead].len = slot->len; //dump_payload(dst, slot->len, txring, txhead); txhead = nm_ring_next(txring, txhead); txavail--; sent++; } } txring->head = txring->cur = txhead; targ->ctr.pkts = sent; #ifdef BUSYWAIT ioctl(pfd.fd, NIOCTXSYNC, NULL); #endif } targ->completed = 1; /* reset the ``used`` flag. */ targ->used = 0; return NULL; } static void * sender_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLOUT }; struct netmap_if *nifp; struct netmap_ring *txring = NULL; int i; uint64_t n = targ->g->npackets / targ->g->nthreads; uint64_t sent = 0; uint64_t event = 0; int options = targ->g->options; struct timespec nexttime = { 0, 0}; // XXX silence compiler int rate_limit = targ->g->tx_rate; struct pkt *pkt = &targ->pkt; void *frame; int size; if (targ->frame == NULL) { frame = (char *)pkt + sizeof(pkt->vh) - targ->g->virt_header; size = targ->g->pkt_size + targ->g->virt_header; } else { frame = targ->frame; size = targ->g->pkt_size; } D("start, fd %d main_fd %d", targ->fd, targ->g->main_fd); if (setaffinity(targ->thread, targ->affinity)) goto quit; /* main loop.*/ clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); if (rate_limit) { targ->tic = timespec_add(targ->tic, (struct timespec){2,0}); targ->tic.tv_nsec = 0; wait_time(targ->tic); nexttime = targ->tic; } if (targ->g->dev_type == DEV_TAP) { D("writing to file desc %d", targ->g->main_fd); for (i = 0; !targ->cancel && (n == 0 || sent < n); i++) { if (write(targ->g->main_fd, frame, size) != -1) sent++; update_addresses(pkt, targ); if (i > 10000) { targ->ctr.pkts = sent; targ->ctr.bytes = sent*size; targ->ctr.events = sent; i = 0; } } #ifndef NO_PCAP } else if (targ->g->dev_type == DEV_PCAP) { pcap_t *p = targ->g->p; for (i = 0; !targ->cancel && (n == 0 || sent < n); i++) { if (pcap_inject(p, frame, size) != -1) sent++; update_addresses(pkt, targ); if (i > 10000) { targ->ctr.pkts = sent; targ->ctr.bytes = sent*size; targ->ctr.events = sent; i = 0; } } #endif /* NO_PCAP */ } else { int tosend = 0; u_int bufsz, frag_size = targ->g->frag_size; nifp = targ->nmd->nifp; txring = NETMAP_TXRING(nifp, targ->nmd->first_tx_ring); bufsz = txring->nr_buf_size; if (bufsz < frag_size) frag_size = bufsz; targ->frag_size = targ->g->pkt_size / targ->frags; if (targ->frag_size > frag_size) { targ->frags = targ->g->pkt_size / frag_size; targ->frag_size = frag_size; if (targ->g->pkt_size % frag_size != 0) targ->frags++; } D("frags %u frag_size %u", targ->frags, targ->frag_size); /* mark all slots of all rings as changed so initial copy will be done */ for (i = targ->nmd->first_tx_ring; i <= targ->nmd->last_tx_ring; i++) { uint32_t j; struct netmap_slot *slot; txring = NETMAP_TXRING(nifp, i); for (j = 0; j < txring->num_slots; j++) { slot = &txring->slot[j]; slot->flags = NS_BUF_CHANGED; } } while (!targ->cancel && (n == 0 || sent < n)) { int rv; if (rate_limit && tosend <= 0) { tosend = targ->g->burst; nexttime = timespec_add(nexttime, targ->g->tx_period); wait_time(nexttime); } /* * wait for available room in the send queue(s) */ #ifdef BUSYWAIT (void)rv; if (ioctl(pfd.fd, NIOCTXSYNC, NULL) < 0) { D("ioctl error on queue %d: %s", targ->me, strerror(errno)); goto quit; } #else /* !BUSYWAIT */ if ( (rv = poll(&pfd, 1, 2000)) <= 0) { if (targ->cancel) break; D("poll error on queue %d: %s", targ->me, rv ? strerror(errno) : "timeout"); // goto quit; } if (pfd.revents & POLLERR) { D("poll error on %d ring %d-%d", pfd.fd, targ->nmd->first_tx_ring, targ->nmd->last_tx_ring); goto quit; } #endif /* !BUSYWAIT */ /* * scan our queues and send on those with room */ for (i = targ->nmd->first_tx_ring; i <= targ->nmd->last_tx_ring; i++) { int m; uint64_t limit = rate_limit ? tosend : targ->g->burst; if (n > 0 && n == sent) break; if (n > 0 && n - sent < limit) limit = n - sent; txring = NETMAP_TXRING(nifp, i); if (nm_ring_empty(txring)) continue; if (targ->g->pkt_min_size > 0) { size = nrand48(targ->seed) % (targ->g->pkt_size - targ->g->pkt_min_size) + targ->g->pkt_min_size; update_size(pkt, targ, size); } m = send_packets(txring, pkt, frame, size, targ, limit, options); ND("limit %lu tail %d m %d", limit, txring->tail, m); sent += m; if (m > 0) //XXX-ste: can m be 0? event++; targ->ctr.pkts = sent; targ->ctr.bytes += m*size; targ->ctr.events = event; if (rate_limit) { tosend -= m; if (tosend <= 0) break; } } } /* flush any remaining packets */ if (txring != NULL) { D("flush tail %d head %d on thread %p", txring->tail, txring->head, (void *)pthread_self()); ioctl(pfd.fd, NIOCTXSYNC, NULL); } /* final part: wait all the TX queues to be empty. */ for (i = targ->nmd->first_tx_ring; i <= targ->nmd->last_tx_ring; i++) { txring = NETMAP_TXRING(nifp, i); while (!targ->cancel && nm_tx_pending(txring)) { RD(5, "pending tx tail %d head %d on ring %d", txring->tail, txring->head, i); ioctl(pfd.fd, NIOCTXSYNC, NULL); usleep(1); /* wait 1 tick */ } } } /* end DEV_NETMAP */ clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); targ->completed = 1; targ->ctr.pkts = sent; targ->ctr.bytes = sent*size; targ->ctr.events = event; quit: /* reset the ``used`` flag. */ targ->used = 0; return (NULL); } #ifndef NO_PCAP static void receive_pcap(u_char *user, const struct pcap_pkthdr * h, const u_char * bytes) { struct my_ctrs *ctr = (struct my_ctrs *)user; (void)bytes; /* UNUSED */ ctr->bytes += h->len; ctr->pkts++; } #endif /* !NO_PCAP */ static int receive_packets(struct netmap_ring *ring, u_int limit, int dump, uint64_t *bytes) { u_int head, rx, n; uint64_t b = 0; u_int complete = 0; if (bytes == NULL) bytes = &b; head = ring->head; n = nm_ring_space(ring); if (n < limit) limit = n; for (rx = 0; rx < limit; rx++) { struct netmap_slot *slot = &ring->slot[head]; char *p = NETMAP_BUF(ring, slot->buf_idx); *bytes += slot->len; if (dump) dump_payload(p, slot->len, ring, head); if (!(slot->flags & NS_MOREFRAG)) complete++; head = nm_ring_next(ring, head); } ring->head = ring->cur = head; return (complete); } static void * receiver_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLIN }; struct netmap_if *nifp; struct netmap_ring *rxring; int i; struct my_ctrs cur; uint64_t n = targ->g->npackets / targ->g->nthreads; memset(&cur, 0, sizeof(cur)); if (setaffinity(targ->thread, targ->affinity)) goto quit; D("reading from %s fd %d main_fd %d", targ->g->ifname, targ->fd, targ->g->main_fd); /* unbounded wait for the first packet. */ for (;!targ->cancel;) { i = poll(&pfd, 1, 1000); if (i > 0 && !(pfd.revents & POLLERR)) break; if (i < 0) { D("poll() error: %s", strerror(errno)); goto quit; } if (pfd.revents & POLLERR) { D("fd error"); goto quit; } RD(1, "waiting for initial packets, poll returns %d %d", i, pfd.revents); } /* main loop, exit after 1s silence */ clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); if (targ->g->dev_type == DEV_TAP) { while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { char buf[MAX_BODYSIZE]; /* XXX should we poll ? */ i = read(targ->g->main_fd, buf, sizeof(buf)); if (i > 0) { targ->ctr.pkts++; targ->ctr.bytes += i; targ->ctr.events++; } } #ifndef NO_PCAP } else if (targ->g->dev_type == DEV_PCAP) { while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* XXX should we poll ? */ pcap_dispatch(targ->g->p, targ->g->burst, receive_pcap, (u_char *)&targ->ctr); targ->ctr.events++; } #endif /* !NO_PCAP */ } else { int dump = targ->g->options & OPT_DUMP; nifp = targ->nmd->nifp; while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* Once we started to receive packets, wait at most 1 seconds before quitting. */ #ifdef BUSYWAIT if (ioctl(pfd.fd, NIOCRXSYNC, NULL) < 0) { D("ioctl error on queue %d: %s", targ->me, strerror(errno)); goto quit; } #else /* !BUSYWAIT */ if (poll(&pfd, 1, 1 * 1000) <= 0 && !targ->g->forever) { clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); targ->toc.tv_sec -= 1; /* Subtract timeout time. */ goto out; } if (pfd.revents & POLLERR) { D("poll err"); goto quit; } #endif /* !BUSYWAIT */ uint64_t cur_space = 0; for (i = targ->nmd->first_rx_ring; i <= targ->nmd->last_rx_ring; i++) { int m; rxring = NETMAP_RXRING(nifp, i); /* compute free space in the ring */ m = rxring->head + rxring->num_slots - rxring->tail; if (m >= (int) rxring->num_slots) m -= rxring->num_slots; cur_space += m; if (nm_ring_empty(rxring)) continue; m = receive_packets(rxring, targ->g->burst, dump, &cur.bytes); cur.pkts += m; if (m > 0) cur.events++; } cur.min_space = targ->ctr.min_space; if (cur_space < cur.min_space) cur.min_space = cur_space; targ->ctr = cur; } } clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); #if !defined(BUSYWAIT) out: #endif targ->completed = 1; targ->ctr = cur; quit: /* reset the ``used`` flag. */ targ->used = 0; return (NULL); } static void * txseq_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLOUT }; struct netmap_ring *ring; int64_t sent = 0; uint64_t event = 0; int options = targ->g->options | OPT_COPY; struct timespec nexttime = {0, 0}; int rate_limit = targ->g->tx_rate; struct pkt *pkt = &targ->pkt; int frags = targ->g->frags; uint32_t sequence = 0; int budget = 0; void *frame; int size; if (targ->g->nthreads > 1) { D("can only txseq ping with 1 thread"); return NULL; } if (targ->g->npackets > 0) { D("Ignoring -n argument"); } frame = (char *)pkt + sizeof(pkt->vh) - targ->g->virt_header; size = targ->g->pkt_size + targ->g->virt_header; D("start, fd %d main_fd %d", targ->fd, targ->g->main_fd); if (setaffinity(targ->thread, targ->affinity)) goto quit; clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); if (rate_limit) { targ->tic = timespec_add(targ->tic, (struct timespec){2,0}); targ->tic.tv_nsec = 0; wait_time(targ->tic); nexttime = targ->tic; } /* Only use the first queue. */ ring = NETMAP_TXRING(targ->nmd->nifp, targ->nmd->first_tx_ring); while (!targ->cancel) { int64_t limit; unsigned int space; unsigned int head; int fcnt; uint16_t sum = 0; int rv; if (!rate_limit) { budget = targ->g->burst; } else if (budget <= 0) { budget = targ->g->burst; nexttime = timespec_add(nexttime, targ->g->tx_period); wait_time(nexttime); } /* wait for available room in the send queue */ #ifdef BUSYWAIT (void)rv; if (ioctl(pfd.fd, NIOCTXSYNC, NULL) < 0) { D("ioctl error on queue %d: %s", targ->me, strerror(errno)); goto quit; } #else /* !BUSYWAIT */ if ( (rv = poll(&pfd, 1, 2000)) <= 0) { if (targ->cancel) break; D("poll error on queue %d: %s", targ->me, rv ? strerror(errno) : "timeout"); // goto quit; } if (pfd.revents & POLLERR) { D("poll error on %d ring %d-%d", pfd.fd, targ->nmd->first_tx_ring, targ->nmd->last_tx_ring); goto quit; } #endif /* !BUSYWAIT */ /* If no room poll() again. */ space = nm_ring_space(ring); if (!space) { continue; } limit = budget; if (space < limit) { limit = space; } /* Cut off ``limit`` to make sure is multiple of ``frags``. */ if (frags > 1) { limit = (limit / frags) * frags; } limit = sent + limit; /* Convert to absolute. */ for (fcnt = frags, head = ring->head; sent < limit; sent++, sequence++) { struct netmap_slot *slot = &ring->slot[head]; char *p = NETMAP_BUF(ring, slot->buf_idx); uint16_t *w = (uint16_t *)PKT(pkt, body, targ->g->af), t; memcpy(&sum, targ->g->af == AF_INET ? &pkt->ipv4.udp.uh_sum : &pkt->ipv6.udp.uh_sum, sizeof(sum)); slot->flags = 0; t = *w; PKT(pkt, body, targ->g->af)[0] = sequence >> 24; PKT(pkt, body, targ->g->af)[1] = (sequence >> 16) & 0xff; sum = ~cksum_add(~sum, cksum_add(~t, *w)); t = *++w; PKT(pkt, body, targ->g->af)[2] = (sequence >> 8) & 0xff; PKT(pkt, body, targ->g->af)[3] = sequence & 0xff; sum = ~cksum_add(~sum, cksum_add(~t, *w)); memcpy(targ->g->af == AF_INET ? &pkt->ipv4.udp.uh_sum : &pkt->ipv6.udp.uh_sum, &sum, sizeof(sum)); nm_pkt_copy(frame, p, size); if (fcnt == frags) { update_addresses(pkt, targ); } if (options & OPT_DUMP) { dump_payload(p, size, ring, head); } slot->len = size; if (--fcnt > 0) { slot->flags |= NS_MOREFRAG; } else { fcnt = frags; } if (sent == limit - 1) { /* Make sure we don't push an incomplete * packet. */ assert(!(slot->flags & NS_MOREFRAG)); slot->flags |= NS_REPORT; } head = nm_ring_next(ring, head); if (rate_limit) { budget--; } } ring->cur = ring->head = head; event ++; targ->ctr.pkts = sent; targ->ctr.bytes = sent * size; targ->ctr.events = event; } /* flush any remaining packets */ D("flush tail %d head %d on thread %p", ring->tail, ring->head, (void *)pthread_self()); ioctl(pfd.fd, NIOCTXSYNC, NULL); /* final part: wait the TX queues to become empty. */ while (!targ->cancel && nm_tx_pending(ring)) { RD(5, "pending tx tail %d head %d on ring %d", ring->tail, ring->head, targ->nmd->first_tx_ring); ioctl(pfd.fd, NIOCTXSYNC, NULL); usleep(1); /* wait 1 tick */ } clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); targ->completed = 1; targ->ctr.pkts = sent; targ->ctr.bytes = sent * size; targ->ctr.events = event; quit: /* reset the ``used`` flag. */ targ->used = 0; return (NULL); } static char * multi_slot_to_string(struct netmap_ring *ring, unsigned int head, unsigned int nfrags, char *strbuf, size_t strbuflen) { unsigned int f; char *ret = strbuf; for (f = 0; f < nfrags; f++) { struct netmap_slot *slot = &ring->slot[head]; int m = snprintf(strbuf, strbuflen, "|%u,%x|", slot->len, slot->flags); if (m >= (int)strbuflen) { break; } strbuf += m; strbuflen -= m; head = nm_ring_next(ring, head); } return ret; } static void * rxseq_body(void *data) { struct targ *targ = (struct targ *) data; struct pollfd pfd = { .fd = targ->fd, .events = POLLIN }; int dump = targ->g->options & OPT_DUMP; struct netmap_ring *ring; unsigned int frags_exp = 1; struct my_ctrs cur; unsigned int frags = 0; int first_packet = 1; int first_slot = 1; int i, j, af, nrings; uint32_t seq, *seq_exp = NULL; memset(&cur, 0, sizeof(cur)); if (setaffinity(targ->thread, targ->affinity)) goto quit; nrings = targ->nmd->last_rx_ring - targ->nmd->first_rx_ring + 1; seq_exp = calloc(nrings, sizeof(uint32_t)); if (seq_exp == NULL) { D("failed to allocate seq array"); goto quit; } D("reading from %s fd %d main_fd %d", targ->g->ifname, targ->fd, targ->g->main_fd); /* unbounded wait for the first packet. */ for (;!targ->cancel;) { i = poll(&pfd, 1, 1000); if (i > 0 && !(pfd.revents & POLLERR)) break; RD(1, "waiting for initial packets, poll returns %d %d", i, pfd.revents); } clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); while (!targ->cancel) { unsigned int head; int limit; #ifdef BUSYWAIT if (ioctl(pfd.fd, NIOCRXSYNC, NULL) < 0) { D("ioctl error on queue %d: %s", targ->me, strerror(errno)); goto quit; } #else /* !BUSYWAIT */ if (poll(&pfd, 1, 1 * 1000) <= 0 && !targ->g->forever) { clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); targ->toc.tv_sec -= 1; /* Subtract timeout time. */ goto out; } if (pfd.revents & POLLERR) { D("poll err"); goto quit; } #endif /* !BUSYWAIT */ for (j = targ->nmd->first_rx_ring; j <= targ->nmd->last_rx_ring; j++) { ring = NETMAP_RXRING(targ->nmd->nifp, j); if (nm_ring_empty(ring)) continue; limit = nm_ring_space(ring); if (limit > targ->g->burst) limit = targ->g->burst; #if 0 /* Enable this if * 1) we remove the early-return optimization from * the netmap poll implementation, or * 2) pipes get NS_MOREFRAG support. * With the current netmap implementation, an experiment like * pkt-gen -i vale:1{1 -f txseq -F 9 * pkt-gen -i vale:1}1 -f rxseq * would get stuck as soon as we find nm_ring_space(ring) < 9, * since here limit is rounded to 0 and * pipe rxsync is not called anymore by the poll() of this loop. */ if (frags_exp > 1) { int o = limit; /* Cut off to the closest smaller multiple. */ limit = (limit / frags_exp) * frags_exp; RD(2, "LIMIT %d --> %d", o, limit); } #endif for (head = ring->head, i = 0; i < limit; i++) { struct netmap_slot *slot = &ring->slot[head]; char *p = NETMAP_BUF(ring, slot->buf_idx); int len = slot->len; struct pkt *pkt; if (dump) { dump_payload(p, slot->len, ring, head); } frags++; if (!(slot->flags & NS_MOREFRAG)) { if (first_packet) { first_packet = 0; } else if (frags != frags_exp) { char prbuf[512]; RD(1, "Received packets with %u frags, " "expected %u, '%s'", frags, frags_exp, multi_slot_to_string(ring, head-frags+1, frags, prbuf, sizeof(prbuf))); } first_packet = 0; frags_exp = frags; frags = 0; } p -= sizeof(pkt->vh) - targ->g->virt_header; len += sizeof(pkt->vh) - targ->g->virt_header; pkt = (struct pkt *)p; if (ntohs(pkt->eh.ether_type) == ETHERTYPE_IP) af = AF_INET; else af = AF_INET6; if ((char *)pkt + len < ((char *)PKT(pkt, body, af)) + sizeof(seq)) { RD(1, "%s: packet too small (len=%u)", __func__, slot->len); } else { seq = (PKT(pkt, body, af)[0] << 24) | (PKT(pkt, body, af)[1] << 16) | (PKT(pkt, body, af)[2] << 8) | PKT(pkt, body, af)[3]; if (first_slot) { /* Grab the first one, whatever it is. */ seq_exp[j] = seq; first_slot = 0; } else if (seq != seq_exp[j]) { uint32_t delta = seq - seq_exp[j]; if (delta < (0xFFFFFFFF >> 1)) { RD(2, "Sequence GAP: exp %u found %u", seq_exp[j], seq); } else { RD(2, "Sequence OUT OF ORDER: " "exp %u found %u", seq_exp[j], seq); } seq_exp[j] = seq; } seq_exp[j]++; } cur.bytes += slot->len; head = nm_ring_next(ring, head); cur.pkts++; } ring->cur = ring->head = head; cur.events++; targ->ctr = cur; } } clock_gettime(CLOCK_REALTIME_PRECISE, &targ->toc); #ifndef BUSYWAIT out: #endif /* !BUSYWAIT */ targ->completed = 1; targ->ctr = cur; quit: if (seq_exp != NULL) free(seq_exp); /* reset the ``used`` flag. */ targ->used = 0; return (NULL); } static void tx_output(struct glob_arg *g, struct my_ctrs *cur, double delta, const char *msg) { double bw, raw_bw, pps, abs; char b1[40], b2[80], b3[80]; int size; if (cur->pkts == 0) { printf("%s nothing.\n", msg); return; } size = (int)(cur->bytes / cur->pkts); printf("%s %llu packets %llu bytes %llu events %d bytes each in %.2f seconds.\n", msg, (unsigned long long)cur->pkts, (unsigned long long)cur->bytes, (unsigned long long)cur->events, size, delta); if (delta == 0) delta = 1e-6; if (size < 60) /* correct for min packet size */ size = 60; pps = cur->pkts / delta; bw = (8.0 * cur->bytes) / delta; raw_bw = (8.0 * cur->bytes + cur->pkts * g->framing) / delta; abs = cur->pkts / (double)(cur->events); printf("Speed: %spps Bandwidth: %sbps (raw %sbps). Average batch: %.2f pkts\n", norm(b1, pps, normalize), norm(b2, bw, normalize), norm(b3, raw_bw, normalize), abs); } static void usage(int errcode) { /* This usage is generated from the pkt-gen man page: * $ man pkt-gen > x * and pasted here adding the string terminators and endlines with simple * regular expressions. */ const char *cmd = "pkt-gen"; fprintf(stderr, "Usage:\n" "%s arguments\n" " -h Show program usage and exit.\n" "\n" " -i interface\n" " Name of the network interface that pkt-gen operates on. It can be a system network interface\n" " (e.g., em0), the name of a vale(4) port (e.g., valeSSS:PPP), the name of a netmap pipe or\n" " monitor, or any valid netmap port name accepted by the nm_open library function, as docu-\n" " mented in netmap(4) (NIOCREGIF section).\n" "\n" " -f function\n" " The function to be executed by pkt-gen. Specify tx for transmission, rx for reception, ping\n" " for client-side ping-pong operation, and pong for server-side ping-pong operation.\n" "\n" " -n count\n" " Number of iterations of the pkt-gen function (with 0 meaning infinite). In case of tx or rx,\n" " count is the number of packets to receive or transmit. In case of ping or pong, count is the\n" " number of ping-pong transactions.\n" "\n" " -l pkt_size\n" " Packet size in bytes excluding CRC. If passed a second time, use random sizes larger or\n" " equal than the second one and lower than the first one.\n" "\n" " -b burst_size\n" " Transmit or receive up to burst_size packets at a time.\n" "\n" " -4 Use IPv4 addresses.\n" "\n" " -6 Use IPv6 addresses.\n" "\n" " -d dst_ip[:port[-dst_ip:port]]\n" " Destination IPv4/IPv6 address and port, single or range.\n" "\n" " -s src_ip[:port[-src_ip:port]]\n" " Source IPv4/IPv6 address and port, single or range.\n" "\n" " -D dst_mac\n" " Destination MAC address in colon notation (e.g., aa:bb:cc:dd:ee:00).\n" "\n" " -S src_mac\n" " Source MAC address in colon notation.\n" "\n" " -a cpu_id\n" " Pin the first thread of pkt-gen to a particular CPU using pthread_setaffinity_np(3). If more\n" " threads are used, they are pinned to the subsequent CPUs, one per thread.\n" "\n" " -c cpus\n" " Maximum number of CPUs to use (0 means to use all the available ones).\n" "\n" " -p threads\n" " Number of threads to use. By default, only a single thread is used to handle all the netmap\n" " rings. If threads is larger than one, each thread handles a single TX ring (in tx mode), a\n" " single RX ring (in rx mode), or a TX/RX ring pair. The number of threads must be less than or\n" " equal to the number of TX (or RX) rings available in the device specified by interface.\n" "\n" " -T report_ms\n" " Number of milliseconds between reports.\n" "\n" " -w wait_for_link_time\n" " Number of seconds to wait before starting the pkt-gen function, useful to make sure that the\n" " network link is up. A network device driver may take some time to enter netmap mode, or to\n" " create a new transmit/receive ring pair when netmap(4) requests one.\n" "\n" " -R rate\n" " Packet transmission rate. Not setting the packet transmission rate tells pkt-gen to transmit\n" " packets as quickly as possible. On servers from 2010 onward netmap(4) is able to com-\n" " pletely use all of the bandwidth of a 10 or 40Gbps link, so this option should be used unless\n" " your intention is to saturate the link.\n" "\n" " -X Dump payload of each packet transmitted or received.\n" "\n" " -H len Add empty virtio-net-header with size 'len'. Valid sizes are 0, 10 and 12. This option is\n" " only used with Virtual Machine technologies that use virtio as a network interface.\n" "\n" " -P file\n" " Load the packet to be transmitted from a pcap file rather than constructing it within\n" " pkt-gen.\n" "\n" " -z Use random IPv4/IPv6 src address/port.\n" "\n" " -Z Use random IPv4/IPv6 dst address/port.\n" "\n" " -N Do not normalize units (i.e., use bps, pps instead of Mbps, Kpps, etc.).\n" "\n" " -F num_frags\n" " Send multi-slot packets, each one with num_frags fragments. A multi-slot packet is repre-\n" " sented by two or more consecutive netmap slots with the NS_MOREFRAG flag set (except for the\n" " last slot). This is useful to transmit or receive packets larger than the netmap buffer\n" " size.\n" "\n" " -M frag_size\n" " In multi-slot mode, frag_size specifies the size of each fragment, if smaller than the packet\n" " length divided by num_frags.\n" "\n" " -I Use indirect buffers. It is only valid for transmitting on VALE ports, and it is implemented\n" " by setting the NS_INDIRECT flag in the netmap slots.\n" "\n" " -W Exit immediately if all the RX rings are empty the first time they are examined.\n" "\n" " -v Increase the verbosity level.\n" "\n" " -r In tx mode, do not initialize packets, but send whatever the content of the uninitialized\n" " netmap buffers is (rubbish mode).\n" "\n" " -A Compute mean and standard deviation (over a sliding window) for the transmit or receive rate.\n" "\n" " -B Take Ethernet framing and CRC into account when computing the average bps. This adds 4 bytes\n" " of CRC and 20 bytes of framing to each packet.\n" "\n" " -C tx_slots[,rx_slots[,tx_rings[,rx_rings]]]\n" " Configuration in terms of number of rings and slots to be used when opening the netmap port.\n" " Such configuration has an effect on software ports created on the fly, such as VALE ports and\n" " netmap pipes. The configuration may consist of 1 to 4 numbers separated by commas: tx_slots,\n" " rx_slots, tx_rings, rx_rings. Missing numbers or zeroes stand for default values. As an\n" " additional convenience, if exactly one number is specified, then this is assigned to both\n" " tx_slots and rx_slots. If there is no fourth number, then the third one is assigned to both\n" " tx_rings and rx_rings.\n" "\n" " -o options data generation options (parsed using atoi)\n" " OPT_PREFETCH 1\n" " OPT_ACCESS 2\n" " OPT_COPY 4\n" " OPT_MEMCPY 8\n" " OPT_TS 16 (add a timestamp)\n" " OPT_INDIRECT 32 (use indirect buffers)\n" " OPT_DUMP 64 (dump rx/tx traffic)\n" " OPT_RUBBISH 256\n" " (send whatever the buffers contain)\n" " OPT_RANDOM_SRC 512\n" " OPT_RANDOM_DST 1024\n" " OPT_PPS_STATS 2048\n" " OPT_UPDATE_CSUM 4096\n" "", cmd); exit(errcode); } static int start_threads(struct glob_arg *g) { int i; targs = calloc(g->nthreads, sizeof(*targs)); struct targ *t; /* * Now create the desired number of threads, each one * using a single descriptor. */ for (i = 0; i < g->nthreads; i++) { uint64_t seed = (uint64_t)time(0) | ((uint64_t)time(0) << 32); t = &targs[i]; bzero(t, sizeof(*t)); t->fd = -1; /* default, with pcap */ t->g = g; memcpy(t->seed, &seed, sizeof(t->seed)); if (g->dev_type == DEV_NETMAP) { int m = -1; /* * if the user wants both HW and SW rings, we need to * know when to switch from NR_REG_ONE_NIC to NR_REG_ONE_SW */ if (g->orig_mode == NR_REG_NIC_SW) { m = (g->td_type == TD_TYPE_RECEIVER ? g->nmd->reg.nr_rx_rings : g->nmd->reg.nr_tx_rings); } if (i > 0) { int j; /* the first thread uses the fd opened by the main * thread, the other threads re-open /dev/netmap */ t->nmd = nmport_clone(g->nmd); if (t->nmd == NULL) return -1; j = i; if (m > 0 && j >= m) { /* switch to the software rings */ t->nmd->reg.nr_mode = NR_REG_ONE_SW; j -= m; } t->nmd->reg.nr_ringid = j & NETMAP_RING_MASK; /* Only touch one of the rings (rx is already ok) */ if (g->td_type == TD_TYPE_RECEIVER) t->nmd->reg.nr_flags |= NETMAP_NO_TX_POLL; /* register interface. Override ifname and ringid etc. */ if (nmport_open_desc(t->nmd) < 0) { nmport_undo_prepare(t->nmd); t->nmd = NULL; return -1; } } else { t->nmd = g->nmd; } t->fd = t->nmd->fd; t->frags = g->frags; } else { targs[i].fd = g->main_fd; } t->used = 1; t->me = i; if (g->affinity >= 0) { t->affinity = (g->affinity + i) % g->cpus; } else { t->affinity = -1; } /* default, init packets */ initialize_packet(t); } /* Wait for PHY reset. */ D("Wait %d secs for phy reset", g->wait_link); sleep(g->wait_link); D("Ready..."); for (i = 0; i < g->nthreads; i++) { t = &targs[i]; if (pthread_create(&t->thread, NULL, g->td_body, t) == -1) { D("Unable to create thread %d: %s", i, strerror(errno)); t->used = 0; } } return 0; } static void main_thread(struct glob_arg *g) { int i; struct my_ctrs prev, cur; double delta_t; struct timeval tic, toc; prev.pkts = prev.bytes = prev.events = 0; gettimeofday(&prev.t, NULL); for (;;) { char b1[40], b2[40], b3[40], b4[100]; uint64_t pps, usec; struct my_ctrs x; double abs; int done = 0; usec = wait_for_next_report(&prev.t, &cur.t, g->report_interval); cur.pkts = cur.bytes = cur.events = 0; cur.min_space = 0; if (usec < 10000) /* too short to be meaningful */ continue; /* accumulate counts for all threads */ for (i = 0; i < g->nthreads; i++) { cur.pkts += targs[i].ctr.pkts; cur.bytes += targs[i].ctr.bytes; cur.events += targs[i].ctr.events; cur.min_space += targs[i].ctr.min_space; targs[i].ctr.min_space = 99999; if (targs[i].used == 0) done++; } x.pkts = cur.pkts - prev.pkts; x.bytes = cur.bytes - prev.bytes; x.events = cur.events - prev.events; pps = (x.pkts*1000000 + usec/2) / usec; abs = (x.events > 0) ? (x.pkts / (double) x.events) : 0; if (!(g->options & OPT_PPS_STATS)) { strcpy(b4, ""); } else { /* Compute some pps stats using a sliding window. */ double ppsavg = 0.0, ppsdev = 0.0; int nsamples = 0; g->win[g->win_idx] = pps; g->win_idx = (g->win_idx + 1) % STATS_WIN; for (i = 0; i < STATS_WIN; i++) { ppsavg += g->win[i]; if (g->win[i]) { nsamples ++; } } ppsavg /= nsamples; for (i = 0; i < STATS_WIN; i++) { if (g->win[i] == 0) { continue; } ppsdev += (g->win[i] - ppsavg) * (g->win[i] - ppsavg); } ppsdev /= nsamples; ppsdev = sqrt(ppsdev); snprintf(b4, sizeof(b4), "[avg/std %s/%s pps]", norm(b1, ppsavg, normalize), norm(b2, ppsdev, normalize)); } D("%spps %s(%spkts %sbps in %llu usec) %.2f avg_batch %d min_space", norm(b1, pps, normalize), b4, norm(b2, (double)x.pkts, normalize), norm(b3, 1000000*((double)x.bytes*8+(double)x.pkts*g->framing)/usec, normalize), (unsigned long long)usec, abs, (int)cur.min_space); prev = cur; if (done == g->nthreads) break; } timerclear(&tic); timerclear(&toc); cur.pkts = cur.bytes = cur.events = 0; /* final round */ for (i = 0; i < g->nthreads; i++) { struct timespec t_tic, t_toc; /* * Join active threads, unregister interfaces and close * file descriptors. */ if (targs[i].used) pthread_join(targs[i].thread, NULL); /* blocking */ if (g->dev_type == DEV_NETMAP) { nmport_close(targs[i].nmd); targs[i].nmd = NULL; } else { close(targs[i].fd); } if (targs[i].completed == 0) D("ouch, thread %d exited with error", i); /* * Collect threads output and extract information about * how long it took to send all the packets. */ cur.pkts += targs[i].ctr.pkts; cur.bytes += targs[i].ctr.bytes; cur.events += targs[i].ctr.events; /* collect the largest start (tic) and end (toc) times, * XXX maybe we should do the earliest tic, or do a weighted * average ? */ t_tic = timeval2spec(&tic); t_toc = timeval2spec(&toc); if (!timerisset(&tic) || timespec_ge(&targs[i].tic, &t_tic)) tic = timespec2val(&targs[i].tic); if (!timerisset(&toc) || timespec_ge(&targs[i].toc, &t_toc)) toc = timespec2val(&targs[i].toc); } /* print output. */ timersub(&toc, &tic, &toc); delta_t = toc.tv_sec + 1e-6* toc.tv_usec; if (g->td_type == TD_TYPE_SENDER) tx_output(g, &cur, delta_t, "Sent"); else if (g->td_type == TD_TYPE_RECEIVER) tx_output(g, &cur, delta_t, "Received"); } struct td_desc { int ty; const char *key; void *f; int default_burst; }; static struct td_desc func[] = { { TD_TYPE_RECEIVER, "rx", receiver_body, 512}, /* default */ { TD_TYPE_SENDER, "tx", sender_body, 512 }, { TD_TYPE_OTHER, "ping", ping_body, 1 }, { TD_TYPE_OTHER, "pong", pong_body, 1 }, { TD_TYPE_SENDER, "txseq", txseq_body, 512 }, { TD_TYPE_RECEIVER, "rxseq", rxseq_body, 512 }, { 0, NULL, NULL, 0 } }; static int tap_alloc(char *dev) { struct ifreq ifr; int fd, err; const char *clonedev = TAP_CLONEDEV; (void)err; (void)dev; /* Arguments taken by the function: * * char *dev: the name of an interface (or '\0'). MUST have enough * space to hold the interface name if '\0' is passed * int flags: interface flags (eg, IFF_TUN etc.) */ #ifdef __FreeBSD__ if (dev[3]) { /* tapSomething */ static char buf[128]; snprintf(buf, sizeof(buf), "/dev/%s", dev); clonedev = buf; } #endif /* open the device */ if( (fd = open(clonedev, O_RDWR)) < 0 ) { return fd; } D("%s open successful", clonedev); /* preparation of the struct ifr, of type "struct ifreq" */ memset(&ifr, 0, sizeof(ifr)); #ifdef linux ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (*dev) { /* if a device name was specified, put it in the structure; otherwise, * the kernel will try to allocate the "next" device of the * specified type */ size_t len = strlen(dev); if (len > IFNAMSIZ) { D("%s too long", dev); return -1; } memcpy(ifr.ifr_name, dev, len); } /* try to create the device */ if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) { D("failed to do a TUNSETIFF: %s", strerror(errno)); close(fd); return err; } /* if the operation was successful, write back the name of the * interface to the variable "dev", so the caller can know * it. Note that the caller MUST reserve space in *dev (see calling * code below) */ strcpy(dev, ifr.ifr_name); D("new name is %s", dev); #endif /* linux */ /* this is the special file descriptor that the caller will use to talk * with the virtual interface */ return fd; } int main(int arc, char **argv) { int i; struct sigaction sa; sigset_t ss; struct glob_arg g; int ch; int devqueues = 1; /* how many device queues */ int wait_link_arg = 0; int pkt_size_done = 0; struct td_desc *fn = func; bzero(&g, sizeof(g)); g.main_fd = -1; g.td_body = fn->f; g.td_type = fn->ty; g.report_interval = 1000; /* report interval */ g.affinity = -1; /* ip addresses can also be a range x.x.x.x-x.x.x.y */ g.af = AF_INET; /* default */ g.src_ip.name = "10.0.0.1"; g.dst_ip.name = "10.1.0.1"; g.dst_mac.name = "ff:ff:ff:ff:ff:ff"; g.src_mac.name = NULL; g.pkt_size = 60; g.pkt_min_size = 0; g.nthreads = 1; g.cpus = 1; /* default */ g.forever = 1; g.tx_rate = 0; g.frags = 1; g.frag_size = (u_int)-1; /* use the netmap buffer size by default */ g.nmr_config = ""; g.virt_header = 0; g.wait_link = 2; /* wait 2 seconds for physical ports */ while ((ch = getopt(arc, argv, "46a:f:F:Nn:i:Il:d:s:D:S:b:c:o:p:" "T:w:WvR:XC:H:rP:zZAhBM:")) != -1) { switch(ch) { default: D("bad option %c %s", ch, optarg); usage(-1); break; case 'h': usage(0); break; case '4': g.af = AF_INET; break; case '6': g.af = AF_INET6; break; case 'N': normalize = 0; break; case 'n': g.npackets = strtoull(optarg, NULL, 10); break; case 'F': i = atoi(optarg); if (i < 1 || i > 63) { D("invalid frags %d [1..63], ignore", i); break; } g.frags = i; break; case 'M': g.frag_size = atoi(optarg); break; case 'f': for (fn = func; fn->key; fn++) { if (!strcmp(fn->key, optarg)) break; } if (fn->key) { g.td_body = fn->f; g.td_type = fn->ty; } else { D("unrecognised function %s", optarg); } break; case 'o': /* data generation options */ g.options |= atoi(optarg); break; case 'a': /* force affinity */ g.affinity = atoi(optarg); break; case 'i': /* interface */ /* a prefix of tap: netmap: or pcap: forces the mode. * otherwise we guess */ D("interface is %s", optarg); if (strlen(optarg) > MAX_IFNAMELEN - 8) { D("ifname too long %s", optarg); break; } strcpy(g.ifname, optarg); if (!strcmp(optarg, "null")) { g.dev_type = DEV_NETMAP; g.dummy_send = 1; } else if (!strncmp(optarg, "tap:", 4)) { g.dev_type = DEV_TAP; strcpy(g.ifname, optarg + 4); } else if (!strncmp(optarg, "pcap:", 5)) { g.dev_type = DEV_PCAP; strcpy(g.ifname, optarg + 5); } else if (!strncmp(optarg, "netmap:", 7) || !strncmp(optarg, "vale", 4)) { g.dev_type = DEV_NETMAP; } else if (!strncmp(optarg, "tap", 3)) { g.dev_type = DEV_TAP; } else { /* prepend netmap: */ g.dev_type = DEV_NETMAP; sprintf(g.ifname, "netmap:%s", optarg); } break; case 'I': g.options |= OPT_INDIRECT; /* use indirect buffers */ break; case 'l': /* pkt_size */ if (pkt_size_done) { g.pkt_min_size = atoi(optarg); } else { g.pkt_size = atoi(optarg); pkt_size_done = 1; } break; case 'd': g.dst_ip.name = optarg; break; case 's': g.src_ip.name = optarg; break; case 'T': /* report interval */ g.report_interval = atoi(optarg); break; case 'w': g.wait_link = atoi(optarg); wait_link_arg = 1; break; case 'W': g.forever = 0; /* exit RX with no traffic */ break; case 'b': /* burst */ g.burst = atoi(optarg); break; case 'c': g.cpus = atoi(optarg); break; case 'p': g.nthreads = atoi(optarg); break; case 'D': /* destination mac */ g.dst_mac.name = optarg; break; case 'S': /* source mac */ g.src_mac.name = optarg; break; case 'v': verbose++; break; case 'R': g.tx_rate = atoi(optarg); break; case 'X': g.options |= OPT_DUMP; break; case 'C': D("WARNING: the 'C' option is deprecated, use the '+conf:' libnetmap option instead"); g.nmr_config = strdup(optarg); break; case 'H': g.virt_header = atoi(optarg); break; case 'P': g.packet_file = strdup(optarg); break; case 'r': g.options |= OPT_RUBBISH; break; case 'z': g.options |= OPT_RANDOM_SRC; break; case 'Z': g.options |= OPT_RANDOM_DST; break; case 'A': g.options |= OPT_PPS_STATS; break; case 'B': /* raw packets have4 bytes crc + 20 bytes framing */ // XXX maybe add an option to pass the IFG g.framing = 24 * 8; break; } } if (strlen(g.ifname) <=0 ) { D("missing ifname"); usage(-1); } if (g.burst == 0) { g.burst = fn->default_burst; D("using default burst size: %d", g.burst); } g.system_cpus = i = system_ncpus(); if (g.cpus < 0 || g.cpus > i) { D("%d cpus is too high, have only %d cpus", g.cpus, i); usage(-1); } D("running on %d cpus (have %d)", g.cpus, i); if (g.cpus == 0) g.cpus = i; if (!wait_link_arg && !strncmp(g.ifname, "vale", 4)) { g.wait_link = 0; } if (g.pkt_size < 16 || g.pkt_size > MAX_PKTSIZE) { D("bad pktsize %d [16..%d]\n", g.pkt_size, MAX_PKTSIZE); usage(-1); } if (g.pkt_min_size > 0 && (g.pkt_min_size < 16 || g.pkt_min_size > g.pkt_size)) { D("bad pktminsize %d [16..%d]\n", g.pkt_min_size, g.pkt_size); usage(-1); } if (g.src_mac.name == NULL) { static char mybuf[20] = "00:00:00:00:00:00"; /* retrieve source mac address. */ if (source_hwaddr(g.ifname, mybuf) == -1) { D("Unable to retrieve source mac"); // continue, fail later } g.src_mac.name = mybuf; } /* extract address ranges */ if (extract_mac_range(&g.src_mac) || extract_mac_range(&g.dst_mac)) usage(-1); g.options |= extract_ip_range(&g.src_ip, g.af); g.options |= extract_ip_range(&g.dst_ip, g.af); if (g.virt_header != 0 && g.virt_header != VIRT_HDR_1 && g.virt_header != VIRT_HDR_2) { D("bad virtio-net-header length"); usage(-1); } if (g.dev_type == DEV_TAP) { D("want to use tap %s", g.ifname); g.main_fd = tap_alloc(g.ifname); if (g.main_fd < 0) { D("cannot open tap %s", g.ifname); usage(-1); } #ifndef NO_PCAP } else if (g.dev_type == DEV_PCAP) { char pcap_errbuf[PCAP_ERRBUF_SIZE]; pcap_errbuf[0] = '\0'; // init the buffer g.p = pcap_open_live(g.ifname, 256 /* XXX */, 1, 100, pcap_errbuf); if (g.p == NULL) { D("cannot open pcap on %s", g.ifname); usage(-1); } g.main_fd = pcap_fileno(g.p); D("using pcap on %s fileno %d", g.ifname, g.main_fd); #endif /* !NO_PCAP */ } else if (g.dummy_send) { /* but DEV_NETMAP */ D("using a dummy send routine"); } else { g.nmd = nmport_prepare(g.ifname); if (g.nmd == NULL) goto out; parse_nmr_config(g.nmr_config, &g.nmd->reg); g.nmd->reg.nr_flags |= NR_ACCEPT_VNET_HDR; /* * Open the netmap device using nm_open(). * * protocol stack and may cause a reset of the card, * which in turn may take some time for the PHY to * reconfigure. We do the open here to have time to reset. */ g.orig_mode = g.nmd->reg.nr_mode; if (g.nthreads > 1) { switch (g.orig_mode) { case NR_REG_ALL_NIC: case NR_REG_NIC_SW: g.nmd->reg.nr_mode = NR_REG_ONE_NIC; break; case NR_REG_SW: g.nmd->reg.nr_mode = NR_REG_ONE_SW; break; default: break; } g.nmd->reg.nr_ringid = 0; } if (nmport_open_desc(g.nmd) < 0) goto out; g.main_fd = g.nmd->fd; ND("mapped %luKB at %p", (unsigned long)(g.nmd->req.nr_memsize>>10), g.nmd->mem); if (g.virt_header) { /* Set the virtio-net header length, since the user asked * for it explicitly. */ set_vnet_hdr_len(&g); } else { /* Check whether the netmap port we opened requires us to send * and receive frames with virtio-net header. */ get_vnet_hdr_len(&g); } /* get num of queues in tx or rx */ if (g.td_type == TD_TYPE_SENDER) devqueues = g.nmd->reg.nr_tx_rings + g.nmd->reg.nr_host_tx_rings; else devqueues = g.nmd->reg.nr_rx_rings + g.nmd->reg.nr_host_rx_rings; /* validate provided nthreads. */ if (g.nthreads < 1 || g.nthreads > devqueues) { D("bad nthreads %d, have %d queues", g.nthreads, devqueues); // continue, fail later } if (g.td_type == TD_TYPE_SENDER) { int mtu = get_if_mtu(&g); if (mtu > 0 && g.pkt_size > mtu) { D("pkt_size (%d) must be <= mtu (%d)", g.pkt_size, mtu); return -1; } } if (verbose) { struct netmap_if *nifp = g.nmd->nifp; struct nmreq_register *req = &g.nmd->reg; D("nifp at offset %"PRIu64" ntxqs %d nrxqs %d memid %d", req->nr_offset, req->nr_tx_rings, req->nr_rx_rings, req->nr_mem_id); for (i = 0; i < req->nr_tx_rings + req->nr_host_tx_rings; i++) { struct netmap_ring *ring = NETMAP_TXRING(nifp, i); D(" TX%d at offset %p slots %d", i, (void *)((char *)ring - (char *)nifp), ring->num_slots); } for (i = 0; i < req->nr_rx_rings + req->nr_host_rx_rings; i++) { struct netmap_ring *ring = NETMAP_RXRING(nifp, i); D(" RX%d at offset %p slots %d", i, (void *)((char *)ring - (char *)nifp), ring->num_slots); } } /* Print some debug information. */ fprintf(stdout, "%s %s: %d queues, %d threads and %d cpus.\n", (g.td_type == TD_TYPE_SENDER) ? "Sending on" : ((g.td_type == TD_TYPE_RECEIVER) ? "Receiving from" : "Working on"), g.ifname, devqueues, g.nthreads, g.cpus); if (g.td_type == TD_TYPE_SENDER) { fprintf(stdout, "%s -> %s (%s -> %s)\n", g.src_ip.name, g.dst_ip.name, g.src_mac.name, g.dst_mac.name); } out: /* Exit if something went wrong. */ if (g.main_fd < 0) { D("aborting"); usage(-1); } } if (g.options) { D("--- SPECIAL OPTIONS:%s%s%s%s%s%s\n", g.options & OPT_PREFETCH ? " prefetch" : "", g.options & OPT_ACCESS ? " access" : "", g.options & OPT_MEMCPY ? " memcpy" : "", g.options & OPT_INDIRECT ? " indirect" : "", g.options & OPT_COPY ? " copy" : "", g.options & OPT_RUBBISH ? " rubbish " : ""); } g.tx_period.tv_sec = g.tx_period.tv_nsec = 0; if (g.tx_rate > 0) { /* try to have at least something every second, * reducing the burst size to some 0.01s worth of data * (but no less than one full set of fragments) */ uint64_t x; int lim = (g.tx_rate)/300; if (g.burst > lim) g.burst = lim; if (g.burst == 0) g.burst = 1; x = ((uint64_t)1000000000 * (uint64_t)g.burst) / (uint64_t) g.tx_rate; g.tx_period.tv_nsec = x; g.tx_period.tv_sec = g.tx_period.tv_nsec / 1000000000; g.tx_period.tv_nsec = g.tx_period.tv_nsec % 1000000000; } if (g.td_type == TD_TYPE_SENDER) D("Sending %d packets every %jd.%09ld s", g.burst, (intmax_t)g.tx_period.tv_sec, g.tx_period.tv_nsec); /* Install ^C handler. */ global_nthreads = g.nthreads; sigemptyset(&ss); sigaddset(&ss, SIGINT); /* block SIGINT now, so that all created threads will inherit the mask */ if (pthread_sigmask(SIG_BLOCK, &ss, NULL) < 0) { D("failed to block SIGINT: %s", strerror(errno)); } if (start_threads(&g) < 0) return 1; /* Install the handler and re-enable SIGINT for the main thread */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sigint_h; if (sigaction(SIGINT, &sa, NULL) < 0) { D("failed to install ^C handler: %s", strerror(errno)); } if (pthread_sigmask(SIG_UNBLOCK, &ss, NULL) < 0) { D("failed to re-enable SIGINT: %s", strerror(errno)); } main_thread(&g); free(targs); return 0; } /* end of file */ diff --git a/tools/tools/shlib-compat/test/libtest1/Symbol.map b/tools/tools/shlib-compat/test/libtest1/Symbol.map index 67649ae01868..5b5bcec8853f 100644 --- a/tools/tools/shlib-compat/test/libtest1/Symbol.map +++ b/tools/tools/shlib-compat/test/libtest1/Symbol.map @@ -1,12 +1,11 @@ /* - * $FreeBSD$ */ TEST_1.0 { func1; func2; func3; func4; func5; func6; }; diff --git a/tools/tools/shlib-compat/test/libtest1/test.c b/tools/tools/shlib-compat/test/libtest1/test.c index dc3a561d6782..73789bdb67ba 100644 --- a/tools/tools/shlib-compat/test/libtest1/test.c +++ b/tools/tools/shlib-compat/test/libtest1/test.c @@ -1,66 +1,65 @@ /* - * $FreeBSD$ */ #include #include struct s1 { int32_t f1_int; char *f2_str; short f3_short; uint64_t f4_uint64; intmax_t f5_intmax; void* f6_ptr; }; struct s2 { char f1_buf[30]; struct s1 *f2_s1; }; struct s3 { struct s1 f1_s1; uint32_t f2_int32; }; int func1(int a, int b); int func2(int64_t a, uint64_t b); void func3(struct s1 *s); void func4(struct s1 s); int func5(int a, void *b, struct s2 *s); int func6(char a, struct s3 *s); int func1(int a, int b) { return (a - b); } int func2(int64_t a, uint64_t b) { return (a - b); } void func3(struct s1 *s) { } void func4(struct s1 s) { } int func5(int a, void *b, struct s2 *s) { return (0); } int func6(char a, struct s3 *s) { return (0); } diff --git a/tools/tools/shlib-compat/test/libtest2/Symbol.map b/tools/tools/shlib-compat/test/libtest2/Symbol.map index d4b7826913d0..11ffa7b08be4 100644 --- a/tools/tools/shlib-compat/test/libtest2/Symbol.map +++ b/tools/tools/shlib-compat/test/libtest2/Symbol.map @@ -1,15 +1,14 @@ /* - * $FreeBSD$ */ TEST_1.0 { func2; func3; func4; func5; func6; }; TEST_1.1 { func1; }; diff --git a/tools/tools/shlib-compat/test/libtest2/test.c b/tools/tools/shlib-compat/test/libtest2/test.c index c26935cec33e..2731a60836f2 100644 --- a/tools/tools/shlib-compat/test/libtest2/test.c +++ b/tools/tools/shlib-compat/test/libtest2/test.c @@ -1,74 +1,73 @@ /* - * $FreeBSD$ */ #include #include struct s1 { int32_t f1_int; char *f2_str; short f3_short; uint64_t f4_uint64; intmax_t f5_intmax; void* f6_ptr; }; struct s2 { char f1_buf[30]; struct s1 *f2_s1; }; struct s3 { struct s1 f1_s1; uint32_t f2_int32; }; int func1(uint64_t a, uint64_t b); int compat_func1(int a, int b); int func2(int64_t a, uint64_t b); void func3(struct s1 *s); void func4(struct s1 s); int func5(int a, void *b, struct s2 *s); int func6(char a, struct s3 *s); int func1(uint64_t a, uint64_t b) { return (a - b); } int compat_func1(int a, int b) { return func1(a, b); } __sym_compat(func1, compat_func1, TEST_1.0); int func2(int64_t a, uint64_t b) { return (a - b); } void func3(struct s1 *s) { } void func4(struct s1 s) { } int func5(int a, void *b, struct s2 *s) { return (0); } int func6(char a, struct s3 *s) { return (0); } diff --git a/tools/tools/shlib-compat/test/libtest3/Symbol.map b/tools/tools/shlib-compat/test/libtest3/Symbol.map index 67649ae01868..5b5bcec8853f 100644 --- a/tools/tools/shlib-compat/test/libtest3/Symbol.map +++ b/tools/tools/shlib-compat/test/libtest3/Symbol.map @@ -1,12 +1,11 @@ /* - * $FreeBSD$ */ TEST_1.0 { func1; func2; func3; func4; func5; func6; }; diff --git a/tools/tools/shlib-compat/test/libtest3/test.c b/tools/tools/shlib-compat/test/libtest3/test.c index 95a169c68236..27d3fd989197 100644 --- a/tools/tools/shlib-compat/test/libtest3/test.c +++ b/tools/tools/shlib-compat/test/libtest3/test.c @@ -1,87 +1,86 @@ /* - * $FreeBSD$ */ #include #include struct s1 { int f1_int; char *f2_str; short f3_short; uint64_t f4_uint64; intmax_t f5_intmax; void* f6_ptr; }; struct s2 { char f1_buf[20]; struct s1 *f2_s1; }; struct s3 { struct s1 f1_s1; uint32_t f2_int32; }; enum f3_t { f3_val0, f3_val1 }; struct s4 { struct s1 f1_s1; uint32_t f2_int32; enum f3_t f3_enum; }; typedef int i32; int func1(int a, int b); int func2(int64_t a, uint64_t b); void func3(struct s1 *s); void func4(struct s1 s); int32_t func5(i32 a, void *b, struct s2 *s); int func6__compat(char a, struct s3 *s); int func6(char a, struct s4 *s); int func1(int a, int b) { return (a - b); } int func2(int64_t a, uint64_t b) { return (a - b); } void func3(struct s1 *s) { } void func4(struct s1 s) { } int func5(int a, void *b, struct s2 *s) { return (0); } int func6(char a, struct s4 *s) { return (0); } int func6__compat(char a, struct s3 *s) { return (0); } __sym_compat(func6, func6__compat, TEST_1.0); diff --git a/tools/tools/shlib-compat/test/libtestsys/Symbol.map b/tools/tools/shlib-compat/test/libtestsys/Symbol.map index d596923bf077..5f4c2477b037 100644 --- a/tools/tools/shlib-compat/test/libtestsys/Symbol.map +++ b/tools/tools/shlib-compat/test/libtestsys/Symbol.map @@ -1,9 +1,8 @@ /* - * $FreeBSD$ */ TEST_1.0 { mknod; chmod; stat; }; diff --git a/usr.bin/bluetooth/bthost/bthost.c b/usr.bin/bluetooth/bthost/bthost.c index 95d672317e6d..23c81f985c53 100644 --- a/usr.bin/bluetooth/bthost/bthost.c +++ b/usr.bin/bluetooth/bthost/bthost.c @@ -1,145 +1,144 @@ /*- * bthost.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthost.c,v 1.5 2003/05/21 20:30:01 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include static int hostmode (char const *arg, int brief); static int protomode (char const *arg, int brief); static void usage (void); int main(int argc, char **argv) { int opt, brief = 0, proto = 0; while ((opt = getopt(argc, argv, "bhp")) != -1) { switch (opt) { case 'b': brief = 1; break; case 'p': proto = 1; break; case 'h': default: usage(); /* NOT REACHED */ } } argc -= optind; argv += optind; if (argc < 1) usage(); exit(proto? protomode(*argv, brief) : hostmode(*argv, brief)); } static int hostmode(char const *arg, int brief) { struct hostent *he = NULL; bdaddr_t ba; char bastr[32]; int reverse; if (bt_aton(arg, &ba) == 1) { reverse = 1; he = bt_gethostbyaddr((char const *) &ba, sizeof(ba), AF_BLUETOOTH); } else { reverse = 0; he = bt_gethostbyname(arg); } if (he == NULL) { herror(reverse? bt_ntoa(&ba, bastr) : arg); return (1); } if (brief) printf("%s", reverse? he->h_name : bt_ntoa((bdaddr_t *)(he->h_addr), bastr)); else printf("Host %s has %s %s\n", reverse? bt_ntoa(&ba, bastr) : arg, reverse? "name" : "address", reverse? he->h_name : bt_ntoa((bdaddr_t *)(he->h_addr), bastr)); return (0); } static int protomode(char const *arg, int brief) { struct protoent *pe = NULL; int proto; if ((proto = atoi(arg)) != 0) pe = bt_getprotobynumber(proto); else pe = bt_getprotobyname(arg); if (pe == NULL) { fprintf(stderr, "%s: Unknown Protocol/Service Multiplexor\n", arg); return (1); } if (brief) { if (proto) printf("%s", pe->p_name); else printf("%d", pe->p_proto); } else { printf("Protocol/Service Multiplexor %s has number %d\n", pe->p_name, pe->p_proto); } return (0); } static void usage(void) { fprintf(stdout, "Usage: bthost [-b -h -p] host_or_protocol\n"); exit(255); } diff --git a/usr.bin/bluetooth/btsockstat/btsockstat.c b/usr.bin/bluetooth/btsockstat/btsockstat.c index 46ee0e101359..99e972f515c7 100644 --- a/usr.bin/bluetooth/btsockstat/btsockstat.c +++ b/usr.bin/bluetooth/btsockstat/btsockstat.c @@ -1,642 +1,641 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * btsockstat.c * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: btsockstat.c,v 1.8 2003/05/21 22:40:25 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #define _WANT_SOCKET #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void hcirawpr (kvm_t *kvmd, u_long addr); static void l2caprawpr (kvm_t *kvmd, u_long addr); static void l2cappr (kvm_t *kvmd, u_long addr); static void l2caprtpr (kvm_t *kvmd, u_long addr); static void rfcommpr (kvm_t *kvmd, u_long addr); static void rfcommpr_s (kvm_t *kvmd, u_long addr); static char * bdaddrpr (bdaddr_p const ba, char *str, int len); static kvm_t * kopen (char const *memf); static int kread (kvm_t *kvmd, u_long addr, char *buffer, int size); static void usage (void); /* * List of symbols */ static struct nlist nl[] = { #define N_HCI_RAW 0 { "_ng_btsocket_hci_raw_sockets" }, #define N_L2CAP_RAW 1 { "_ng_btsocket_l2cap_raw_sockets" }, #define N_L2CAP 2 { "_ng_btsocket_l2cap_sockets" }, #define N_L2CAP_RAW_RT 3 { "_ng_btsocket_l2cap_raw_rt" }, #define N_L2CAP_RT 4 { "_ng_btsocket_l2cap_rt" }, #define N_RFCOMM 5 { "_ng_btsocket_rfcomm_sockets" }, #define N_RFCOMM_S 6 { "_ng_btsocket_rfcomm_sessions" }, { "" }, }; #define state2str(x) \ (((x) >= sizeof(states)/sizeof(states[0]))? "UNKNOWN" : states[(x)]) /* * Main */ static int numeric_bdaddr = 0; int main(int argc, char *argv[]) { int opt, proto = -1, route = 0; kvm_t *kvmd = NULL; char *memf = NULL; while ((opt = getopt(argc, argv, "hnM:p:r")) != -1) { switch (opt) { case 'n': numeric_bdaddr = 1; break; case 'M': memf = optarg; break; case 'p': if (strcasecmp(optarg, "hci_raw") == 0) proto = N_HCI_RAW; else if (strcasecmp(optarg, "l2cap_raw") == 0) proto = N_L2CAP_RAW; else if (strcasecmp(optarg, "l2cap") == 0) proto = N_L2CAP; else if (strcasecmp(optarg, "rfcomm") == 0) proto = N_RFCOMM; else if (strcasecmp(optarg, "rfcomm_s") == 0) proto = N_RFCOMM_S; else usage(); /* NOT REACHED */ break; case 'r': route = 1; break; case 'h': default: usage(); /* NOT REACHED */ } } if ((proto == N_HCI_RAW || proto == N_RFCOMM || proto == N_RFCOMM_S) && route) usage(); /* NOT REACHED */ /* * Discard setgid privileges if not the running kernel so that * bad guys can't print interesting stuff from kernel memory. */ if (memf != NULL) if (setgid(getgid()) != 0) err(1, "setgid"); kvmd = kopen(memf); if (kvmd == NULL) return (1); switch (proto) { case N_HCI_RAW: hcirawpr(kvmd, nl[N_HCI_RAW].n_value); break; case N_L2CAP_RAW: if (route) l2caprtpr(kvmd, nl[N_L2CAP_RAW_RT].n_value); else l2caprawpr(kvmd, nl[N_L2CAP_RAW].n_value); break; case N_L2CAP: if (route) l2caprtpr(kvmd, nl[N_L2CAP_RT].n_value); else l2cappr(kvmd, nl[N_L2CAP].n_value); break; case N_RFCOMM: rfcommpr(kvmd, nl[N_RFCOMM].n_value); break; case N_RFCOMM_S: rfcommpr_s(kvmd, nl[N_RFCOMM_S].n_value); break; default: if (route) { l2caprtpr(kvmd, nl[N_L2CAP_RAW_RT].n_value); l2caprtpr(kvmd, nl[N_L2CAP_RT].n_value); } else { hcirawpr(kvmd, nl[N_HCI_RAW].n_value); l2caprawpr(kvmd, nl[N_L2CAP_RAW].n_value); l2cappr(kvmd, nl[N_L2CAP].n_value); rfcommpr_s(kvmd, nl[N_RFCOMM_S].n_value); rfcommpr(kvmd, nl[N_RFCOMM].n_value); } break; } return (kvm_close(kvmd)); } /* main */ /* * Print raw HCI sockets */ static void hcirawpr(kvm_t *kvmd, u_long addr) { ng_btsocket_hci_raw_pcb_p this = NULL, next = NULL; ng_btsocket_hci_raw_pcb_t pcb; struct socket so; int first = 1; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &pcb, sizeof(pcb)) < 0) return; if (kread(kvmd, (u_long) pcb.so, (char *) &so, sizeof(so)) < 0) return; next = LIST_NEXT(&pcb, next); if (first) { first = 0; fprintf(stdout, "Active raw HCI sockets\n" \ "%-8.8s %-8.8s %-6.6s %-6.6s %-6.6s %-16.16s\n", "Socket", "PCB", "Flags", "Recv-Q", "Send-Q", "Local address"); } if (pcb.addr.hci_node[0] == 0) { pcb.addr.hci_node[0] = '*'; pcb.addr.hci_node[1] = 0; } fprintf(stdout, "%-8lx %-8lx %-6.6x %6d %6d %-16.16s\n", (unsigned long) pcb.so, (unsigned long) this, pcb.flags, so.so_rcv.sb_ccc, so.so_snd.sb_ccc, pcb.addr.hci_node); } } /* hcirawpr */ /* * Print raw L2CAP sockets */ static void l2caprawpr(kvm_t *kvmd, u_long addr) { ng_btsocket_l2cap_raw_pcb_p this = NULL, next = NULL; ng_btsocket_l2cap_raw_pcb_t pcb; struct socket so; int first = 1; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &pcb, sizeof(pcb)) < 0) return; if (kread(kvmd, (u_long) pcb.so, (char *) &so, sizeof(so)) < 0) return; next = LIST_NEXT(&pcb, next); if (first) { first = 0; fprintf(stdout, "Active raw L2CAP sockets\n" \ "%-8.8s %-8.8s %-6.6s %-6.6s %-17.17s\n", "Socket", "PCB", "Recv-Q", "Send-Q", "Local address"); } fprintf(stdout, "%-8lx %-8lx %6d %6d %-17.17s\n", (unsigned long) pcb.so, (unsigned long) this, so.so_rcv.sb_ccc, so.so_snd.sb_ccc, bdaddrpr(&pcb.src, NULL, 0)); } } /* l2caprawpr */ /* * Print L2CAP sockets */ static void l2cappr(kvm_t *kvmd, u_long addr) { static char const * const states[] = { /* NG_BTSOCKET_L2CAP_CLOSED */ "CLOSED", /* NG_BTSOCKET_L2CAP_CONNECTING */ "CON", /* NG_BTSOCKET_L2CAP_CONFIGURING */ "CONFIG", /* NG_BTSOCKET_L2CAP_OPEN */ "OPEN", /* NG_BTSOCKET_L2CAP_DISCONNECTING */ "DISCON" }; ng_btsocket_l2cap_pcb_p this = NULL, next = NULL; ng_btsocket_l2cap_pcb_t pcb; struct socket so; int first = 1; char local[24], remote[24]; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &pcb, sizeof(pcb)) < 0) return; if (kread(kvmd, (u_long) pcb.so, (char *) &so, sizeof(so)) < 0) return; next = LIST_NEXT(&pcb, next); if (first) { first = 0; fprintf(stdout, "Active L2CAP sockets\n" \ "%-8.8s %-6.6s %-6.6s %-23.23s %-17.17s %-5.5s %s\n", "PCB", "Recv-Q", "Send-Q", "Local address/PSM", "Foreign address", "CID", "State"); } fprintf(stdout, "%-8lx %6d %6d %-17.17s/%-5d %-17.17s %-5d %s\n", (unsigned long) this, so.so_rcv.sb_ccc, so.so_snd.sb_ccc, bdaddrpr(&pcb.src, local, sizeof(local)), pcb.psm, bdaddrpr(&pcb.dst, remote, sizeof(remote)), pcb.cid, (so.so_options & SO_ACCEPTCONN)? "LISTEN" : state2str(pcb.state)); } } /* l2cappr */ /* * Print L2CAP routing table */ static void l2caprtpr(kvm_t *kvmd, u_long addr) { ng_btsocket_l2cap_rtentry_p this = NULL, next = NULL; ng_btsocket_l2cap_rtentry_t rt; int first = 1; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &rt, sizeof(rt)) < 0) return; next = LIST_NEXT(&rt, next); if (first) { first = 0; fprintf(stdout, "Known %sL2CAP routes\n", (addr == nl[N_L2CAP_RAW_RT].n_value)? "raw " : ""); fprintf(stdout, "%-8.8s %-8.8s %-17.17s\n", "RTentry", "Hook", "BD_ADDR"); } fprintf(stdout, "%-8lx %-8lx %-17.17s\n", (unsigned long) this, (unsigned long) rt.hook, bdaddrpr(&rt.src, NULL, 0)); } } /* l2caprtpr */ /* * Print RFCOMM sockets */ static void rfcommpr(kvm_t *kvmd, u_long addr) { static char const * const states[] = { /* NG_BTSOCKET_RFCOMM_DLC_CLOSED */ "CLOSED", /* NG_BTSOCKET_RFCOMM_DLC_W4_CONNECT */ "W4CON", /* NG_BTSOCKET_RFCOMM_DLC_CONFIGURING */ "CONFIG", /* NG_BTSOCKET_RFCOMM_DLC_CONNECTING */ "CONN", /* NG_BTSOCKET_RFCOMM_DLC_CONNECTED */ "OPEN", /* NG_BTSOCKET_RFCOMM_DLC_DISCONNECTING */ "DISCON" }; ng_btsocket_rfcomm_pcb_p this = NULL, next = NULL; ng_btsocket_rfcomm_pcb_t pcb; struct socket so; int first = 1; char local[24], remote[24]; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &pcb, sizeof(pcb)) < 0) return; if (kread(kvmd, (u_long) pcb.so, (char *) &so, sizeof(so)) < 0) return; next = LIST_NEXT(&pcb, next); if (first) { first = 0; fprintf(stdout, "Active RFCOMM sockets\n" \ "%-8.8s %-6.6s %-6.6s %-17.17s %-17.17s %-4.4s %-4.4s %s\n", "PCB", "Recv-Q", "Send-Q", "Local address", "Foreign address", "Chan", "DLCI", "State"); } fprintf(stdout, "%-8lx %6d %6d %-17.17s %-17.17s %-4d %-4d %s\n", (unsigned long) this, so.so_rcv.sb_ccc, so.so_snd.sb_ccc, bdaddrpr(&pcb.src, local, sizeof(local)), bdaddrpr(&pcb.dst, remote, sizeof(remote)), pcb.channel, pcb.dlci, (so.so_options & SO_ACCEPTCONN)? "LISTEN" : state2str(pcb.state)); } } /* rfcommpr */ /* * Print RFCOMM sessions */ static void rfcommpr_s(kvm_t *kvmd, u_long addr) { static char const * const states[] = { /* NG_BTSOCKET_RFCOMM_SESSION_CLOSED */ "CLOSED", /* NG_BTSOCKET_RFCOMM_SESSION_LISTENING */ "LISTEN", /* NG_BTSOCKET_RFCOMM_SESSION_CONNECTING */ "CONNECTING", /* NG_BTSOCKET_RFCOMM_SESSION_CONNECTED */ "CONNECTED", /* NG_BTSOCKET_RFCOMM_SESSION_OPEN */ "OPEN", /* NG_BTSOCKET_RFCOMM_SESSION_DISCONNECTING */ "DISCONNECTING" }; ng_btsocket_rfcomm_session_p this = NULL, next = NULL; ng_btsocket_rfcomm_session_t s; struct socket so; int first = 1; if (addr == 0) return; if (kread(kvmd, addr, (char *) &this, sizeof(this)) < 0) return; for ( ; this != NULL; this = next) { if (kread(kvmd, (u_long) this, (char *) &s, sizeof(s)) < 0) return; if (kread(kvmd, (u_long) s.l2so, (char *) &so, sizeof(so)) < 0) return; next = LIST_NEXT(&s, next); if (first) { first = 0; fprintf(stdout, "Active RFCOMM sessions\n" \ "%-8.8s %-8.8s %-4.4s %-5.5s %-5.5s %-4.4s %s\n", "L2PCB", "PCB", "Flags", "MTU", "Out-Q", "DLCs", "State"); } fprintf(stdout, "%-8lx %-8lx %-4x %-5d %-5d %-4s %s\n", (unsigned long) so.so_pcb, (unsigned long) this, s.flags, s.mtu, s.outq.len, LIST_EMPTY(&s.dlcs)? "No" : "Yes", state2str(s.state)); } } /* rfcommpr_s */ /* * Return BD_ADDR as string */ static char * bdaddrpr(bdaddr_p const ba, char *str, int len) { static char buffer[MAXHOSTNAMELEN]; struct hostent *he = NULL; if (str == NULL) { str = buffer; len = sizeof(buffer); } if (memcmp(ba, NG_HCI_BDADDR_ANY, sizeof(*ba)) == 0) { str[0] = '*'; str[1] = 0; return (str); } if (!numeric_bdaddr && (he = bt_gethostbyaddr((char *)ba, sizeof(*ba), AF_BLUETOOTH)) != NULL) { strlcpy(str, he->h_name, len); return (str); } bt_ntoa(ba, str); return (str); } /* bdaddrpr */ /* * Open kvm */ static kvm_t * kopen(char const *memf) { kvm_t *kvmd = NULL; char errbuf[_POSIX2_LINE_MAX]; kvmd = kvm_openfiles(NULL, memf, NULL, O_RDONLY, errbuf); if (setgid(getgid()) != 0) err(1, "setgid"); if (kvmd == NULL) { warnx("kvm_openfiles: %s", errbuf); return (NULL); } if (kvm_nlist(kvmd, nl) < 0) { warnx("kvm_nlist: %s", kvm_geterr(kvmd)); goto fail; } if (nl[0].n_type == 0) { warnx("kvm_nlist: no namelist"); goto fail; } return (kvmd); fail: kvm_close(kvmd); return (NULL); } /* kopen */ /* * Read kvm */ static int kread(kvm_t *kvmd, u_long addr, char *buffer, int size) { if (kvmd == NULL || buffer == NULL) return (-1); if (kvm_read(kvmd, addr, buffer, size) != size) { warnx("kvm_read: %s", kvm_geterr(kvmd)); return (-1); } return (0); } /* kread */ /* * Print usage and exit */ static void usage(void) { fprintf(stdout, "Usage: btsockstat [-M core ] [-n] [-p proto] [-r]\n"); exit(255); } /* usage */ diff --git a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c index 778169486ed8..1506eeb30584 100644 --- a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c +++ b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sdp.c @@ -1,268 +1,267 @@ /*- * rfcomm_sdp.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: rfcomm_sdp.c,v 1.1 2003/09/07 18:15:55 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #undef PROTOCOL_DESCRIPTOR_LIST_BUFFER_SIZE #define PROTOCOL_DESCRIPTOR_LIST_BUFFER_SIZE 256 #undef PROTOCOL_DESCRIPTOR_LIST_MINIMAL_SIZE #define PROTOCOL_DESCRIPTOR_LIST_MINIMAL_SIZE 12 static int rfcomm_proto_list_parse (uint8_t const *start, uint8_t const *end, int *channel, int *error); /* * Lookup RFCOMM channel number in the Protocol Descriptor List */ #undef rfcomm_channel_lookup_exit #define rfcomm_channel_lookup_exit(e) { \ if (error != NULL) \ *error = (e); \ if (ss != NULL) { \ sdp_close(ss); \ ss = NULL; \ } \ return (((e) == 0)? 0 : -1); \ } int rfcomm_channel_lookup(bdaddr_t const *local, bdaddr_t const *remote, int service, int *channel, int *error) { uint8_t buffer[PROTOCOL_DESCRIPTOR_LIST_BUFFER_SIZE]; void *ss = NULL; uint16_t serv = (uint16_t) service; uint32_t attr = SDP_ATTR_RANGE( SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST); sdp_attr_t proto = { SDP_ATTR_INVALID,0,sizeof(buffer),buffer }; uint32_t type, len; if (local == NULL) local = NG_HCI_BDADDR_ANY; if (remote == NULL || channel == NULL) rfcomm_channel_lookup_exit(EINVAL); if ((ss = sdp_open(local, remote)) == NULL) rfcomm_channel_lookup_exit(ENOMEM); if (sdp_error(ss) != 0) rfcomm_channel_lookup_exit(sdp_error(ss)); if (sdp_search(ss, 1, &serv, 1, &attr, 1, &proto) != 0) rfcomm_channel_lookup_exit(sdp_error(ss)); if (proto.flags != SDP_ATTR_OK) rfcomm_channel_lookup_exit(ENOATTR); sdp_close(ss); ss = NULL; /* * If it is possible for more than one kind of protocol stack to be * used to gain access to the service, the ProtocolDescriptorList * takes the form of a data element alternative. We always use the * first protocol stack. * * A minimal Protocol Descriptor List for RFCOMM based service would * look like * * seq8 len8 - 2 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes L2CAP * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes RFCOMM * uint8 value8 - 2 bytes RFCOMM param #1 * ========= * 14 bytes * * Lets not count first [seq8 len8] wrapper, so the minimal size of * the Protocol Descriptor List (the data we are actually interested * in) for RFCOMM based service would be 12 bytes. */ if (proto.vlen < PROTOCOL_DESCRIPTOR_LIST_MINIMAL_SIZE) rfcomm_channel_lookup_exit(EINVAL); SDP_GET8(type, proto.value); if (type == SDP_DATA_ALT8) { SDP_GET8(len, proto.value); } else if (type == SDP_DATA_ALT16) { SDP_GET16(len, proto.value); } else if (type == SDP_DATA_ALT32) { SDP_GET32(len, proto.value); } else len = 0; if (len > 0) SDP_GET8(type, proto.value); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, proto.value); break; case SDP_DATA_SEQ16: SDP_GET16(len, proto.value); break; case SDP_DATA_SEQ32: SDP_GET32(len, proto.value); break; default: rfcomm_channel_lookup_exit(ENOATTR); /* NOT REACHED */ } if (len < PROTOCOL_DESCRIPTOR_LIST_MINIMAL_SIZE) rfcomm_channel_lookup_exit(EINVAL); return (rfcomm_proto_list_parse(proto.value, buffer + proto.vlen, channel, error)); } /* * Parse protocol descriptor list * * The ProtocolDescriptorList attribute describes one or more protocol * stacks that may be used to gain access to the service described by * the service record. If the ProtocolDescriptorList describes a single * stack, it takes the form of a data element sequence in which each * element of the sequence is a protocol descriptor. */ #undef rfcomm_proto_list_parse_exit #define rfcomm_proto_list_parse_exit(e) { \ if (error != NULL) \ *error = (e); \ return (((e) == 0)? 0 : -1); \ } static int rfcomm_proto_list_parse(uint8_t const *start, uint8_t const *end, int *channel, int *error) { int type, len, value; while (start < end) { /* * Parse protocol descriptor * * A protocol descriptor identifies a communications protocol * and provides protocol specific parameters. A protocol * descriptor is represented as a data element sequence. The * first data element in the sequence must be the UUID that * identifies the protocol. Additional data elements optionally * provide protocol specific information, such as the L2CAP * protocol/service multiplexer (PSM) and the RFCOMM server * channel number (CN). */ /* We must have at least one byte (type) */ if (end - start < 1) rfcomm_proto_list_parse_exit(EINVAL) SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: rfcomm_proto_list_parse_exit(ENOATTR) /* NOT REACHED */ } /* We must have at least 3 bytes (type + UUID16) */ if (end - start < 3) rfcomm_proto_list_parse_exit(EINVAL); /* Get protocol UUID */ SDP_GET8(type, start); len -= sizeof(uint8_t); switch (type) { case SDP_DATA_UUID16: SDP_GET16(value, start); len -= sizeof(uint16_t); if (value != SDP_UUID_PROTOCOL_RFCOMM) goto next_protocol; break; case SDP_DATA_UUID32: /* XXX FIXME can we have 32-bit UUID */ case SDP_DATA_UUID128: /* XXX FIXME can we have 128-bit UUID */ default: rfcomm_proto_list_parse_exit(ENOATTR); /* NOT REACHED */ } /* * First protocol specific parameter for RFCOMM procotol must * be uint8 that represents RFCOMM channel number. So we must * have at least two bytes. */ if (end - start < 2) rfcomm_proto_list_parse_exit(EINVAL); SDP_GET8(type, start); if (type != SDP_DATA_UINT8) rfcomm_proto_list_parse_exit(ENOATTR); SDP_GET8(*channel, start); rfcomm_proto_list_parse_exit(0); /* NOT REACHED */ next_protocol: start += len; } /* * If we got here then it means we could not find RFCOMM protocol * descriptor, but the reply format was actually valid. */ rfcomm_proto_list_parse_exit(ENOATTR); } diff --git a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c index f28c145ce425..15298920d3c7 100644 --- a/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c +++ b/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c @@ -1,462 +1,461 @@ /* * rfcomm_sppd.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: rfcomm_sppd.c,v 1.4 2003/09/07 18:15:55 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define SPPD_IDENT "rfcomm_sppd" #define SPPD_BUFFER_SIZE 1024 #define max(a, b) (((a) > (b))? (a) : (b)) int rfcomm_channel_lookup (bdaddr_t const *local, bdaddr_t const *remote, int service, int *channel, int *error); static int sppd_ttys_open (char **tty, int *amaster, int *aslave); static int sppd_read (int fd, char *buffer, int size); static int sppd_write (int fd, char *buffer, int size); static void sppd_sighandler (int s); static void usage (void); static int done; /* are we done? */ /* Main */ int main(int argc, char *argv[]) { struct sigaction sa; struct sockaddr_rfcomm ra; bdaddr_t addr; int n, background, channel, service, s, amaster, aslave, fd, doserver, dopty; fd_set rfd; char *tty = NULL, *ep = NULL, buf[SPPD_BUFFER_SIZE]; memcpy(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)); background = channel = 0; service = SDP_SERVICE_CLASS_SERIAL_PORT; doserver = 0; dopty = 0; /* Parse command line options */ while ((n = getopt(argc, argv, "a:bc:thS")) != -1) { switch (n) { case 'a': /* BDADDR */ if (!bt_aton(optarg, &addr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&addr, he->h_addr, sizeof(addr)); } break; case 'c': /* RFCOMM channel */ channel = strtoul(optarg, &ep, 10); if (*ep != '\0') { channel = 0; switch (tolower(optarg[0])) { case 'd': /* DialUp Networking */ service = SDP_SERVICE_CLASS_DIALUP_NETWORKING; break; case 'f': /* Fax */ service = SDP_SERVICE_CLASS_FAX; break; case 'l': /* LAN */ service = SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP; break; case 's': /* Serial Port */ service = SDP_SERVICE_CLASS_SERIAL_PORT; break; default: errx(1, "Unknown service name: %s", optarg); /* NOT REACHED */ } } break; case 'b': /* Run in background */ background = 1; break; case 't': /* Open pseudo TTY */ dopty = 1; break; case 'S': doserver = 1; break; case 'h': default: usage(); /* NOT REACHED */ } } /* Check if we have everything we need */ if (!doserver && memcmp(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)) == 0) usage(); /* NOT REACHED */ /* Set signal handlers */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sppd_sighandler; if (sigaction(SIGTERM, &sa, NULL) < 0) err(1, "Could not sigaction(SIGTERM)"); if (sigaction(SIGHUP, &sa, NULL) < 0) err(1, "Could not sigaction(SIGHUP)"); if (sigaction(SIGINT, &sa, NULL) < 0) err(1, "Could not sigaction(SIGINT)"); sa.sa_handler = SIG_IGN; sa.sa_flags = SA_NOCLDWAIT; if (sigaction(SIGCHLD, &sa, NULL) < 0) err(1, "Could not sigaction(SIGCHLD)"); /* Open TTYs */ if (dopty) { if (sppd_ttys_open(&tty, &amaster, &aslave) < 0) exit(1); fd = amaster; } else { if (background) usage(); amaster = STDIN_FILENO; fd = STDOUT_FILENO; } /* Open RFCOMM connection */ if (doserver) { struct sockaddr_rfcomm ma; bdaddr_t bt_addr_any; sdp_sp_profile_t sp; void *ss; uint32_t sdp_handle; int acceptsock, aaddrlen; acceptsock = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM); if (acceptsock < 0) err(1, "Could not create socket"); memcpy(&bt_addr_any, NG_HCI_BDADDR_ANY, sizeof(bt_addr_any)); memset(&ma, 0, sizeof(ma)); ma.rfcomm_len = sizeof(ma); ma.rfcomm_family = AF_BLUETOOTH; memcpy(&ma.rfcomm_bdaddr, &bt_addr_any, sizeof(bt_addr_any)); ma.rfcomm_channel = channel; if (bind(acceptsock, (struct sockaddr *)&ma, sizeof(ma)) < 0) err(1, "Could not bind socket on channel %d", channel); if (listen(acceptsock, 10) != 0) err(1, "Could not listen on socket"); aaddrlen = sizeof(ma); if (getsockname(acceptsock, (struct sockaddr *)&ma, &aaddrlen) < 0) err(1, "Could not get socket name"); channel = ma.rfcomm_channel; ss = sdp_open_local(NULL); if (ss == NULL) errx(1, "Unable to create local SDP session"); if (sdp_error(ss) != 0) errx(1, "Unable to open local SDP session. %s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); memset(&sp, 0, sizeof(sp)); sp.server_channel = channel; if (sdp_register_service(ss, SDP_SERVICE_CLASS_SERIAL_PORT, &bt_addr_any, (void *)&sp, sizeof(sp), &sdp_handle) != 0) { errx(1, "Unable to register LAN service with " "local SDP daemon. %s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); } s = -1; while (s < 0) { aaddrlen = sizeof(ra); s = accept(acceptsock, (struct sockaddr *)&ra, &aaddrlen); if (s < 0) err(1, "Unable to accept()"); if (memcmp(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)) && memcmp(&addr, &ra.rfcomm_bdaddr, sizeof(addr))) { warnx("Connect from wrong client"); close(s); s = -1; } } sdp_unregister_service(ss, sdp_handle); sdp_close(ss); close(acceptsock); } else { /* Check channel, if was not set then obtain it via SDP */ if (channel == 0 && service != 0) if (rfcomm_channel_lookup(NULL, &addr, service, &channel, &n) != 0) errc(1, n, "Could not obtain RFCOMM channel"); if (channel <= 0 || channel > 30) errx(1, "Invalid RFCOMM channel number %d", channel); s = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM); if (s < 0) err(1, "Could not create socket"); memset(&ra, 0, sizeof(ra)); ra.rfcomm_len = sizeof(ra); ra.rfcomm_family = AF_BLUETOOTH; if (bind(s, (struct sockaddr *) &ra, sizeof(ra)) < 0) err(1, "Could not bind socket"); memcpy(&ra.rfcomm_bdaddr, &addr, sizeof(ra.rfcomm_bdaddr)); ra.rfcomm_channel = channel; if (connect(s, (struct sockaddr *) &ra, sizeof(ra)) < 0) err(1, "Could not connect socket"); } /* Became daemon if required */ if (background && daemon(0, 0) < 0) err(1, "Could not daemon()"); openlog(SPPD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "Starting on %s...", (tty != NULL)? tty : "stdin/stdout"); /* Print used tty on stdout for wrappers to pick up */ if (!background) fprintf(stdout, "%s\n", tty); for (done = 0; !done; ) { FD_ZERO(&rfd); FD_SET(amaster, &rfd); FD_SET(s, &rfd); n = select(max(amaster, s) + 1, &rfd, NULL, NULL, NULL); if (n < 0) { if (errno == EINTR) continue; syslog(LOG_ERR, "Could not select(). %s", strerror(errno)); exit(1); } if (n == 0) continue; if (FD_ISSET(amaster, &rfd)) { n = sppd_read(amaster, buf, sizeof(buf)); if (n < 0) { syslog(LOG_ERR, "Could not read master pty, " \ "fd=%d. %s", amaster, strerror(errno)); exit(1); } if (n == 0) break; /* XXX */ if (sppd_write(s, buf, n) < 0) { syslog(LOG_ERR, "Could not write to socket, " \ "fd=%d, size=%d. %s", s, n, strerror(errno)); exit(1); } } if (FD_ISSET(s, &rfd)) { n = sppd_read(s, buf, sizeof(buf)); if (n < 0) { syslog(LOG_ERR, "Could not read socket, " \ "fd=%d. %s", s, strerror(errno)); exit(1); } if (n == 0) break; if (sppd_write(fd, buf, n) < 0) { syslog(LOG_ERR, "Could not write to master " \ "pty, fd=%d, size=%d. %s", fd, n, strerror(errno)); exit(1); } } } syslog(LOG_INFO, "Completed on %s", (tty != NULL)? tty : "stdin/stdout"); closelog(); close(s); if (tty != NULL) { close(aslave); close(amaster); } return (0); } /* Open TTYs */ static int sppd_ttys_open(char **tty, int *amaster, int *aslave) { char pty[PATH_MAX]; struct termios tio; cfmakeraw(&tio); if (openpty(amaster, aslave, pty, &tio, NULL) == -1) { syslog(LOG_ERR, "Could not openpty(). %s", strerror(errno)); return (-1); } if ((*tty = strdup(pty)) == NULL) { syslog(LOG_ERR, "Could not strdup(). %s", strerror(errno)); close(*aslave); close(*amaster); return (-1); } return (0); } /* sppd_ttys_open */ /* Read data */ static int sppd_read(int fd, char *buffer, int size) { int n; again: n = read(fd, buffer, size); if (n < 0) { if (errno == EINTR) goto again; return (-1); } return (n); } /* sppd_read */ /* Write data */ static int sppd_write(int fd, char *buffer, int size) { int n, wrote; for (wrote = 0; size > 0; ) { n = write(fd, buffer, size); switch (n) { case -1: if (errno != EINTR) return (-1); break; case 0: /* XXX can happen? */ break; default: wrote += n; buffer += n; size -= n; break; } } return (wrote); } /* sppd_write */ /* Signal handler */ static void sppd_sighandler(int s) { syslog(LOG_INFO, "Signal %d received. Total %d signals received\n", s, ++ done); } /* sppd_sighandler */ /* Display usage and exit */ static void usage(void) { fprintf(stdout, "Usage: %s options\n" \ "Where options are:\n" \ "\t-a address Peer address (required in client mode)\n" \ "\t-b Run in background\n" \ "\t-c channel RFCOMM channel to connect to or listen on\n" \ "\t-t use slave pseudo tty (required in background mode)\n" \ "\t-S Server mode\n" \ "\t-h Display this message\n", SPPD_IDENT); exit(255); } /* usage */ diff --git a/usr.bin/calendar/pathnames.h b/usr.bin/calendar/pathnames.h index fa46eb0c7e50..a35198a0d819 100644 --- a/usr.bin/calendar/pathnames.h +++ b/usr.bin/calendar/pathnames.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #define _PATH_INCLUDE "/usr/share/calendar" #define _PATH_INCLUDE_LOCAL "%s/share/calendar" diff --git a/usr.bin/chpass/chpass.h b/usr.bin/chpass/chpass.h index b655c5dd0b59..ce8b7c4f1e9f 100644 --- a/usr.bin/chpass/chpass.h +++ b/usr.bin/chpass/chpass.h @@ -1,81 +1,80 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1988, 1993, 1994 * The Regents of the University of California. All rights reserved. * Copyright (c) 2002 Networks Associates Technology, Inc. * All rights reserved. * * Portions of this software were developed for the FreeBSD Project by * ThinkSec AS and NAI Labs, the Security Research Division of Network * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 * ("CBOSS"), as part of the DARPA CHATS research program. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)chpass.h 8.4 (Berkeley) 4/2/94 - * $FreeBSD$ */ struct passwd; typedef struct _entry { const char *prompt; int (*func)(char *, struct passwd *, struct _entry *); int restricted; size_t len; const char *except, *save; } ENTRY; /* Field numbers. */ #define E_BPHONE 8 #define E_HPHONE 9 #define E_LOCATE 10 #define E_NAME 7 #define E_OTHER 11 #define E_SHELL 13 extern ENTRY list[]; extern int master_mode; int atot(char *, time_t *); struct passwd *edit(const char *, struct passwd *); int ok_shell(char *); char *dup_shell(char *); int p_change(char *, struct passwd *, ENTRY *); int p_class(char *, struct passwd *, ENTRY *); int p_expire(char *, struct passwd *, ENTRY *); int p_gecos(char *, struct passwd *, ENTRY *); int p_gid(char *, struct passwd *, ENTRY *); int p_hdir(char *, struct passwd *, ENTRY *); int p_login(char *, struct passwd *, ENTRY *); int p_passwd(char *, struct passwd *, ENTRY *); int p_shell(char *, struct passwd *, ENTRY *); int p_uid(char *, struct passwd *, ENTRY *); char *ttoa(time_t); diff --git a/usr.bin/cksum/extern.h b/usr.bin/cksum/extern.h index ce18531d0f13..a337fefae414 100644 --- a/usr.bin/cksum/extern.h +++ b/usr.bin/cksum/extern.h @@ -1,45 +1,44 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include __BEGIN_DECLS int crc(int, uint32_t *, off_t *); void pcrc(char *, uint32_t, off_t); void psum1(char *, uint32_t, off_t); void psum2(char *, uint32_t, off_t); int csum1(int, uint32_t *, off_t *); int csum2(int, uint32_t *, off_t *); int crc32(int, uint32_t *, off_t *); __END_DECLS diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h index fd649b017211..4ece1979795f 100644 --- a/usr.bin/diff/diff.h +++ b/usr.bin/diff/diff.h @@ -1,117 +1,116 @@ /* $OpenBSD: diff.h,v 1.34 2020/11/01 18:16:08 jcs Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)diff.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include /* * Output format options */ #define D_NORMAL 0 /* Normal output */ #define D_EDIT -1 /* Editor script out */ #define D_REVERSE 1 /* Reverse editor script */ #define D_CONTEXT 2 /* Diff with context */ #define D_UNIFIED 3 /* Unified context diff */ #define D_IFDEF 4 /* Diff with merged #ifdef's */ #define D_NREVERSE 5 /* Reverse ed script with numbered lines and no trailing . */ #define D_BRIEF 6 /* Say if the files differ */ #define D_GFORMAT 7 /* Diff with defined changed group format */ #define D_SIDEBYSIDE 8 /* Side by side */ #define D_UNSET -2 /* * Output flags */ #define D_HEADER 0x001 /* Print a header/footer between files */ #define D_EMPTY1 0x002 /* Treat first file as empty (/dev/null) */ #define D_EMPTY2 0x004 /* Treat second file as empty (/dev/null) */ /* * Command line flags */ #define D_FORCEASCII 0x008 /* Treat file as ascii regardless of content */ #define D_FOLDBLANKS 0x010 /* Treat all white space as equal */ #define D_MINIMAL 0x020 /* Make diff as small as possible */ #define D_IGNORECASE 0x040 /* Case-insensitive matching */ #define D_PROTOTYPE 0x080 /* Display C function prototype */ #define D_EXPANDTABS 0x100 /* Expand tabs to spaces */ #define D_IGNOREBLANKS 0x200 /* Ignore white space changes */ #define D_STRIPCR 0x400 /* Strip trailing cr */ #define D_SKIPBLANKLINES 0x800 /* Skip blank lines */ #define D_MATCHLAST 0x1000 /* Display last line matching provided regex */ /* * Status values for print_status() and diffreg() return values */ #define D_SAME 0 /* Files are the same */ #define D_DIFFER 1 /* Files are different */ #define D_BINARY 2 /* Binary files are different */ #define D_MISMATCH1 3 /* path1 was a dir, path2 a file */ #define D_MISMATCH2 4 /* path1 was a file, path2 a dir */ #define D_SKIPPED1 5 /* path1 was a special file */ #define D_SKIPPED2 6 /* path2 was a special file */ #define D_ERROR 7 /* A file access error occurred */ /* * Color options */ #define COLORFLAG_NEVER 0 #define COLORFLAG_AUTO 1 #define COLORFLAG_ALWAYS 2 struct excludes { char *pattern; struct excludes *next; }; extern bool lflag, Nflag, Pflag, rflag, sflag, Tflag, cflag; extern bool ignore_file_case, suppress_common, color, noderef; extern int diff_format, diff_context, status; extern int tabsize, width; extern char *start, *ifdefname, *diffargs, *label[2]; extern char *ignore_pats, *most_recent_pat; extern char *group_format; extern const char *add_code, *del_code; extern struct stat stb1, stb2; extern struct excludes *excludes_list; extern regex_t ignore_re, most_recent_re; int diffreg(char *, char *, int, int); void diffdir(char *, char *, int); void print_status(int, char *, char *, const char *); diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 9abd97099ce9..8c98a6d86bcd 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,126 +1,125 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.3 (Berkeley) 4/16/94 - * $FreeBSD$ */ #include void brace_subst(char *, char **, char *, size_t); PLAN *find_create(char ***); int find_execute(PLAN *, char **); PLAN *find_formplan(char **); PLAN *not_squish(PLAN *); PLAN *or_squish(PLAN *); PLAN *paren_squish(PLAN *); time_t get_date(char *); struct stat; void printlong(char *, char *, struct stat *); int queryuser(char **); OPTION *lookup_option(const char *); void finish_execplus(void); creat_f c_Xmin; creat_f c_Xtime; creat_f c_acl; creat_f c_and; creat_f c_delete; creat_f c_depth; creat_f c_empty; creat_f c_exec; creat_f c_flags; creat_f c_follow; creat_f c_fstype; creat_f c_group; creat_f c_ignore_readdir_race; creat_f c_inum; creat_f c_links; creat_f c_ls; creat_f c_mXXdepth; creat_f c_name; creat_f c_newer; creat_f c_nogroup; creat_f c_nouser; creat_f c_perm; creat_f c_print; creat_f c_regex; creat_f c_samefile; creat_f c_simple; creat_f c_size; creat_f c_sparse; creat_f c_type; creat_f c_user; creat_f c_xdev; exec_f f_Xmin; exec_f f_Xtime; exec_f f_acl; exec_f f_always_true; exec_f f_closeparen; exec_f f_delete; exec_f f_depth; exec_f f_empty; exec_f f_exec; exec_f f_expr; exec_f f_false; exec_f f_flags; exec_f f_fstype; exec_f f_group; exec_f f_inum; exec_f f_links; exec_f f_ls; exec_f f_name; exec_f f_newer; exec_f f_nogroup; exec_f f_not; exec_f f_nouser; exec_f f_openparen; exec_f f_or; exec_f f_path; exec_f f_perm; exec_f f_print; exec_f f_print0; exec_f f_prune; exec_f f_quit; exec_f f_regex; exec_f f_size; exec_f f_sparse; exec_f f_type; exec_f f_user; extern int ftsoptions, ignore_readdir_race, isdepth, isoutput; extern int issort, isxargs; extern int mindepth, maxdepth; extern int regexp_flags; extern int exitstatus; extern time_t now; extern int dotfd; extern FTS *tree; diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index 703cb6777086..44e1d97c0452 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,174 +1,173 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Cimarron D. Taylor of the University of California, Berkeley. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)find.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include /* * We need to build find during the bootstrap stage when building on a * non-FreeBSD system. Linux does not have the st_flags and st_birthtime * members in struct stat so we need to omit support for tests that depend * on these members. This works fine since none of these flags are used * during the build of world and kernel. */ #ifdef UF_SETTABLE #define HAVE_STRUCT_STAT_ST_FLAGS 1 #else #define HAVE_STRUCT_STAT_ST_FLAGS 0 #endif #if defined(st_birthtime) || defined(st_birthtimespec) #define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 #else #define HAVE_STRUCT_STAT_ST_BIRTHTIME 0 #endif #if defined(MFSNAMELEN) || defined(MFSTYPENAMELEN) #define HAVE_STRUCT_STATFS_F_FSTYPENAME 1 #else #define HAVE_STRUCT_STATFS_F_FSTYPENAME 0 #endif /* forward declarations */ struct _plandata; struct _option; /* execute function */ typedef int exec_f(struct _plandata *, FTSENT *); /* create function */ typedef struct _plandata *creat_f(struct _option *, char ***); /* function modifiers */ #define F_NEEDOK 0x00000001 /* -ok vs. -exec */ #define F_EXECDIR 0x00000002 /* -execdir vs. -exec */ #define F_TIME_A 0x00000004 /* one of -atime, -anewer, -newera* */ #define F_TIME_C 0x00000008 /* one of -ctime, -cnewer, -newerc* */ #define F_TIME2_A 0x00000010 /* one of -newer?a */ #define F_TIME2_C 0x00000020 /* one of -newer?c */ #define F_TIME2_T 0x00000040 /* one of -newer?t */ #define F_MAXDEPTH F_TIME_A /* maxdepth vs. mindepth */ #define F_DEPTH F_TIME_A /* -depth n vs. -d */ /* command line function modifiers */ #define F_EQUAL 0x00000000 /* [acm]min [acm]time inum links size */ #define F_LESSTHAN 0x00000100 #define F_GREATER 0x00000200 #define F_ELG_MASK 0x00000300 #define F_ATLEAST 0x00000400 /* flags perm */ #define F_ANY 0x00000800 /* perm */ #define F_MTMASK 0x00003000 #define F_MTFLAG 0x00000000 /* fstype */ #define F_MTTYPE 0x00001000 #define F_MTUNKNOWN 0x00002000 #define F_IGNCASE 0x00010000 /* iname ipath iregex */ #define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */ #define F_EXECPLUS 0x00020000 /* -exec ... {} + */ #if HAVE_STRUCT_STAT_ST_BIRTHTIME #define F_TIME_B 0x00040000 /* one of -Btime, -Bnewer, -newerB* */ #define F_TIME2_B 0x00080000 /* one of -newer?B */ #endif #define F_LINK 0x00100000 /* lname or ilname */ /* node definition */ typedef struct _plandata { struct _plandata *next; /* next node */ exec_f *execute; /* node evaluation function */ int flags; /* private flags */ union { gid_t _g_data; /* gid */ ino_t _i_data; /* inode */ mode_t _m_data; /* mode mask */ struct { u_long _f_flags; u_long _f_notflags; } fl; nlink_t _l_data; /* link count */ short _d_data; /* level depth (-1 to N) */ off_t _o_data; /* file size */ struct timespec _t_data; /* time value */ uid_t _u_data; /* uid */ short _mt_data; /* mount flags */ struct _plandata *_p_data[2]; /* PLAN trees */ struct _ex { char **_e_argv; /* argv array */ char **_e_orig; /* original strings */ int *_e_len; /* allocated length */ int _e_pbnum; /* base num. of args. used */ int _e_ppos; /* number of arguments used */ int _e_pnummax; /* max. number of arguments */ int _e_psize; /* number of bytes of args. */ int _e_pbsize; /* base num. of bytes of args */ int _e_psizemax; /* max num. of bytes of args */ struct _plandata *_e_next;/* next F_EXECPLUS in tree */ } ex; char *_a_data[2]; /* array of char pointers */ char *_c_data; /* char pointer */ regex_t *_re_data; /* regex */ } p_un; } PLAN; #define a_data p_un._a_data #define c_data p_un._c_data #define d_data p_un._d_data #define fl_flags p_un.fl._f_flags #define fl_notflags p_un.fl._f_notflags #define g_data p_un._g_data #define i_data p_un._i_data #define l_data p_un._l_data #define m_data p_un._m_data #define mt_data p_un._mt_data #define o_data p_un._o_data #define p_data p_un._p_data #define t_data p_un._t_data #define u_data p_un._u_data #define re_data p_un._re_data #define e_argv p_un.ex._e_argv #define e_orig p_un.ex._e_orig #define e_len p_un.ex._e_len #define e_pbnum p_un.ex._e_pbnum #define e_ppos p_un.ex._e_ppos #define e_pnummax p_un.ex._e_pnummax #define e_psize p_un.ex._e_psize #define e_pbsize p_un.ex._e_pbsize #define e_psizemax p_un.ex._e_psizemax #define e_next p_un.ex._e_next typedef struct _option { const char *name; /* option name */ creat_f *create; /* create function */ exec_f *execute; /* execute function */ int flags; } OPTION; #include "extern.h" diff --git a/usr.bin/finger/extern.h b/usr.bin/finger/extern.h index 05918171ae01..74494579004a 100644 --- a/usr.bin/finger/extern.h +++ b/usr.bin/finger/extern.h @@ -1,63 +1,62 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.2 (Berkeley) 4/28/95 - * $FreeBSD$ */ #ifndef _EXTERN_H_ #define _EXTERN_H_ extern char tbuf[1024]; /* Temp buffer for anybody. */ extern int entries; /* Number of people. */ extern DB *db; /* Database. */ extern int d_first; extern sa_family_t family; extern int gflag; extern int lflag; extern time_t now; extern int oflag; extern int pplan; /* don't show .plan/.project */ extern int invoker_root; /* Invoked by root */ void enter_lastlog(PERSON *); PERSON *enter_person(struct passwd *); void enter_where(struct utmpx *, PERSON *); PERSON *find_person(char *); int hide(struct passwd *); void lflag_print(void); int match(struct passwd *, const char *); void netfinger(char *); PERSON *palloc(void); char *prphone(char *); void sflag_print(void); int show_text(const char *, const char *, const char *); #endif /* !_EXTERN_H_ */ diff --git a/usr.bin/finger/finger.h b/usr.bin/finger/finger.h index f750d256cf1f..2675240c43f6 100644 --- a/usr.bin/finger/finger.h +++ b/usr.bin/finger/finger.h @@ -1,74 +1,73 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)finger.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #ifndef _FINGER_H_ #define _FINGER_H_ typedef struct person { uid_t uid; /* user id */ char *dir; /* user's home directory */ char *homephone; /* pointer to home phone no. */ char *name; /* login name */ char *office; /* pointer to office name */ char *officephone; /* pointer to office phone no. */ char *realname; /* pointer to full name */ char *shell; /* user's shell */ time_t mailread; /* last time mail was read */ time_t mailrecv; /* last time mail was received */ struct where *whead, *wtail; /* list of where user is or has been */ } PERSON; enum status { LASTLOG, LOGGEDIN }; typedef struct where { struct where *next; /* next place user is or has been */ enum status info; /* type/status of request */ short writable; /* tty is writable */ time_t loginat; /* time of (last) login */ time_t idletime; /* how long idle (if logged in) */ char tty[sizeof ((struct utmpx *)0)->ut_line]; /* tty line */ char host[sizeof ((struct utmpx *)0)->ut_host]; /* host name */ } WHERE; #define UNPRIV_NAME "nobody" /* Preferred privilege level */ #define UNPRIV_UGID 32767 /* Default uid and gid */ #define OUTPUT_MAX 100000 /* Do not keep listinging forever */ #define TIME_LIMIT 360 /* Do not keep listinging forever */ #include "extern.h" #endif /* !_FINGER_H_ */ diff --git a/usr.bin/fortune/fortune/pathnames.h b/usr.bin/fortune/fortune/pathnames.h index b6c9985ea885..bb14e9957e61 100644 --- a/usr.bin/fortune/fortune/pathnames.h +++ b/usr.bin/fortune/fortune/pathnames.h @@ -1,36 +1,35 @@ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 5/31/93 - * $FreeBSD$ */ #include #define FORTDIR "/usr/share/games/fortune:" \ _PATH_LOCALBASE "/share/games/fortune" diff --git a/usr.bin/gcore/extern.h b/usr.bin/gcore/extern.h index cf37d6f3c376..3820327f258a 100644 --- a/usr.bin/gcore/extern.h +++ b/usr.bin/gcore/extern.h @@ -1,41 +1,40 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define PFLAGS_FULL 0x01 struct dumpers { int (*ident)(int efd, pid_t pid, char *binfile); void (*dump)(int efd, int fd, pid_t pid); }; extern int pflags; diff --git a/usr.bin/gprof/gprof.h b/usr.bin/gprof/gprof.h index d13d4eb04455..6b92e2b6e70d 100644 --- a/usr.bin/gprof/gprof.h +++ b/usr.bin/gprof/gprof.h @@ -1,327 +1,326 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)gprof.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include #include #include /* * offset (in bytes) of the code from the entry address of a routine. * (see asgnsamples for use and explanation.) */ #define OFFSET_OF_CODE 0 enum opermodes { dummy }; typedef enum opermodes operandenum; /* * booleans */ typedef int bool; #define FALSE 0 #define TRUE 1 /* * Historical scale factor in profil(2)'s algorithm for converting * pc addresses to bucket numbers. This now just complicates the * scaling and makes bucket:pc densities of more than 1/2 useless. */ #define HISTORICAL_SCALE_2 2 #ifndef EXTERN #define EXTERN extern #endif /* * ticks per second */ EXTERN long hz; EXTERN size_t histcounter_size; EXTERN int histcounter_type; EXTERN char *a_outname; #define A_OUTNAME "a.out" EXTERN char *gmonname; #define GMONSUM "gmon.sum" /* * a constructed arc, * with pointers to the namelist entry of the parent and the child, * a count of how many times this arc was traversed, * and pointers to the next parent of this child and * the next child of this parent. */ struct arcstruct { struct nl *arc_parentp; /* pointer to parent's nl entry */ struct nl *arc_childp; /* pointer to child's nl entry */ long arc_count; /* num calls from parent to child */ double arc_time; /* time inherited along arc */ double arc_childtime; /* childtime inherited along arc */ struct arcstruct *arc_parentlist; /* parents-of-this-child list */ struct arcstruct *arc_childlist; /* children-of-this-parent list */ struct arcstruct *arc_next; /* list of arcs on cycle */ unsigned short arc_cyclecnt; /* num cycles involved in */ unsigned short arc_flags; /* see below */ }; typedef struct arcstruct arctype; /* * arc flags */ #define DEADARC 0x01 /* time should not propagate across the arc */ #define ONLIST 0x02 /* arc is on list of arcs in cycles */ /* * The symbol table; * for each external in the specified file we gather * its address, the number of calls and compute its share of CPU time. */ struct nl { const char *name; /* the name */ unsigned long value; /* the pc entry point */ unsigned long svalue; /* entry point aligned to histograms */ double time; /* ticks in this routine */ double childtime; /* cumulative ticks in children */ long ncall; /* how many times called */ long npropcall; /* times called by live arcs */ long selfcalls; /* how many calls to self */ double propfraction; /* what % of time propagates */ double propself; /* how much self time propagates */ double propchild; /* how much child time propagates */ short printflag; /* should this be printed? */ short flags; /* see below */ int index; /* index in the graph list */ int toporder; /* graph call chain top-sort order */ int cycleno; /* internal number of cycle on */ int parentcnt; /* number of live parent arcs */ struct nl *cyclehead; /* pointer to head of cycle */ struct nl *cnext; /* pointer to next member of cycle */ arctype *parents; /* list of caller arcs */ arctype *children; /* list of callee arcs */ }; typedef struct nl nltype; EXTERN nltype *nl; /* the whole namelist */ EXTERN nltype *npe; /* the virtual end of the namelist */ EXTERN int nname; /* the number of function names */ #define HASCYCLEXIT 0x08 /* node has arc exiting from cycle */ #define CYCLEHEAD 0x10 /* node marked as head of a cycle */ #define VISITED 0x20 /* node visited during a cycle */ /* * The cycle list. * for each subcycle within an identified cycle, we gather * its size and the list of included arcs. */ struct cl { int size; /* length of cycle */ struct cl *next; /* next member of list */ arctype *list[1]; /* list of arcs in cycle */ /* actually longer */ }; typedef struct cl cltype; EXTERN arctype *archead; /* the head of arcs in current cycle list */ EXTERN cltype *cyclehead; /* the head of the list */ EXTERN int cyclecnt; /* the number of cycles found */ #define CYCLEMAX 100 /* maximum cycles before cutting one of them */ /* * flag which marks a nl entry as topologically ``busy'' * flag which marks a nl entry as topologically ``not_numbered'' */ #define DFN_BUSY -1 #define DFN_NAN 0 /* * namelist entries for cycle headers. * the number of discovered cycles. */ EXTERN nltype *cyclenl; /* cycle header namelist */ EXTERN int ncycle; /* number of cycles discovered */ /* * The header on the gmon.out file. * gmon.out consists of a struct phdr (defined in gmon.h) * and then an array of ncnt samples representing the * discretized program counter values. * * Backward compatible old style header */ struct ophdr { u_short *lpc; u_short *hpc; int ncnt; }; EXTERN int debug; /* * Each discretized pc sample has * a count of the number of samples in its range */ EXTERN double *samples; EXTERN unsigned long s_lowpc; /* lowpc from the profile file */ EXTERN unsigned long s_highpc; /* highpc from the profile file */ /* range profiled, in historical units */ EXTERN unsigned long lowpc, highpc; EXTERN unsigned sampbytes; /* number of bytes of samples */ EXTERN int nsamples; /* number of samples */ /* accumulated time thus far for putprofline */ EXTERN double actime; EXTERN double totime; /* total time for all routines */ EXTERN double printtime; /* total of time being printed */ EXTERN double scale; /* scale factor converting samples to pc values: each sample covers scale bytes */ EXTERN unsigned char *textspace; /* text space of a.out in core */ /* with -C, minimum cycle size to ignore */ EXTERN int cyclethreshold; /* * option flags, from a to z. */ EXTERN bool aflag; /* suppress static functions */ EXTERN bool bflag; /* blurbs, too */ EXTERN bool Cflag; /* find cut-set to eliminate cycles */ EXTERN bool dflag; /* debugging options */ EXTERN bool eflag; /* specific functions excluded */ EXTERN bool Eflag; /* functions excluded with time */ EXTERN bool fflag; /* specific functions requested */ EXTERN bool Fflag; /* functions requested with time */ EXTERN bool kflag; /* arcs to be deleted */ EXTERN bool Kflag; /* use the running kernel for symbols */ EXTERN bool sflag; /* sum multiple gmon.out files */ EXTERN bool uflag; /* suppress symbols hidden from C */ EXTERN bool zflag; /* zero time/called functions, too */ /* * structure for various string lists */ struct stringlist { struct stringlist *next; char *string; }; extern struct stringlist *elist; extern struct stringlist *Elist; extern struct stringlist *flist; extern struct stringlist *Flist; extern struct stringlist *kfromlist; extern struct stringlist *ktolist; /* * function declarations */ void addarc(nltype *, nltype *, long); bool addcycle(arctype **, arctype **); void addlist(struct stringlist *, char *); void alignentries(void); int arccmp(arctype *, arctype *); arctype *arclookup(nltype *, nltype *); void asgnsamples(void); void compresslist(void); bool cycleanalyze(void); void cyclelink(void); void cycletime(void); bool descend(nltype *, arctype **, arctype **); void dfn(nltype *); bool dfn_busy(nltype *); void dfn_findcycle(nltype *); void dfn_init(void); bool dfn_numbered(nltype *); void dfn_post_visit(nltype *); void dfn_pre_visit(nltype *); void dfn_self_cycle(nltype *); nltype **doarcs(void); void doflags(void); void dotime(void); void dumpsum(const char *); int elf_getnfile(const char *, char ***); void flatprofheader(void); void flatprofline(nltype *); void getpfile(char *); void gprofheader(void); void gprofline(register nltype *); int hertz(void); void inheritflags(nltype *); int kernel_getnfile(const char *, char ***); /* main(); */ unsigned long max(unsigned long, unsigned long); int membercmp(nltype *, nltype *); unsigned long min(unsigned long, unsigned long); nltype *nllookup(unsigned long); bool onlist(struct stringlist *, const char *); FILE *openpfile(char *); void printblurb(const char *); void printchildren(nltype *); void printcycle(nltype *); void printgprof(nltype **); void printindex(void); void printmembers(nltype *); void printname(nltype *); void printparents(nltype *); void printprof(void); void printsubcycle(cltype *); void readsamples(FILE *); void sortchildren(nltype *); void sortmembers(nltype *); void sortparents(nltype *); void tally(struct rawarc *); void timepropagate(nltype *); int totalcmp(const void *, const void *); #define LESSTHAN -1 #define EQUALTO 0 #define GREATERTHAN 1 #define DFNDEBUG 1 #define CYCLEDEBUG 2 #define ARCDEBUG 4 #define TALLYDEBUG 8 #define TIMEDEBUG 16 #define SAMPLEDEBUG 32 #define CALLDEBUG 128 #define LOOKUPDEBUG 256 #define PROPDEBUG 512 #define BREAKCYCLE 1024 #define SUBCYCLELIST 2048 #define ANYDEBUG 4096 diff --git a/usr.bin/gprof/pathnames.h b/usr.bin/gprof/pathnames.h index fd152db3f600..8b97811e2ece 100644 --- a/usr.bin/gprof/pathnames.h +++ b/usr.bin/gprof/pathnames.h @@ -1,37 +1,36 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define _PATH_FLAT_BLURB "/usr/share/misc/gprof.flat" #define _PATH_CALLG_BLURB "/usr/share/misc/gprof.callg" diff --git a/usr.bin/gzip/zuncompress.c b/usr.bin/gzip/zuncompress.c index b2f3e8d51bd3..79f3983037f7 100644 --- a/usr.bin/gzip/zuncompress.c +++ b/usr.bin/gzip/zuncompress.c @@ -1,398 +1,397 @@ /* $NetBSD: zuncompress.c,v 1.11 2011/08/16 13:55:02 joerg Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1985, 1986, 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Diomidis Spinellis and James A. Woods, derived from original * work by Spencer Thomas and Joseph Orost. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * from: NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp - * $FreeBSD$ */ /* This file is #included by gzip.c */ static int zread(void *, char *, int); #define tab_prefixof(i) (zs->zs_codetab[i]) #define tab_suffixof(i) ((char_type *)(zs->zs_htab))[i] #define de_stack ((char_type *)&tab_suffixof(1 << BITS)) #define BITS 16 /* Default bits. */ #define HSIZE 69001 /* 95% occupancy */ /* XXX may not need HSIZE */ #define BIT_MASK 0x1f /* Defines for third byte of header. */ #define BLOCK_MASK 0x80 #define CHECK_GAP 10000 /* Ratio check interval. */ #define BUFSIZE (64 * 1024) /* * Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is * a fourth header byte (for expansion). */ #define INIT_BITS 9 /* Initial number of bits/code. */ /* * the next two codes should not be changed lightly, as they must not * lie within the contiguous general code space. */ #define FIRST 257 /* First free entry. */ #define CLEAR 256 /* Table clear output code. */ #define MAXCODE(n_bits) ((1 << (n_bits)) - 1) typedef long code_int; typedef long count_int; typedef u_char char_type; static char_type magic_header[] = {'\037', '\235'}; /* 1F 9D */ static char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; static off_t total_compressed_bytes; static size_t compressed_prelen; static char *compressed_pre; struct s_zstate { FILE *zs_fp; /* File stream for I/O */ char zs_mode; /* r or w */ enum { S_START, S_MIDDLE, S_EOF } zs_state; /* State of computation */ int zs_n_bits; /* Number of bits/code. */ int zs_maxbits; /* User settable max # bits/code. */ code_int zs_maxcode; /* Maximum code, given n_bits. */ code_int zs_maxmaxcode; /* Should NEVER generate this code. */ count_int zs_htab [HSIZE]; u_short zs_codetab [HSIZE]; code_int zs_hsize; /* For dynamic table sizing. */ code_int zs_free_ent; /* First unused entry. */ /* * Block compression parameters -- after all codes are used up, * and compression rate changes, start over. */ int zs_block_compress; int zs_clear_flg; long zs_ratio; count_int zs_checkpoint; int zs_offset; long zs_in_count; /* Length of input. */ long zs_bytes_out; /* Length of compressed output. */ long zs_out_count; /* # of codes output (for debugging). */ char_type zs_buf[BITS]; union { struct { long zs_fcode; code_int zs_ent; code_int zs_hsize_reg; int zs_hshift; } w; /* Write parameters */ struct { char_type *zs_stackp; int zs_finchar; code_int zs_code, zs_oldcode, zs_incode; int zs_roffset, zs_size; char_type zs_gbuf[BITS]; } r; /* Read parameters */ } u; }; static code_int getcode(struct s_zstate *zs); static off_t zuncompress(FILE *in, FILE *out, char *pre, size_t prelen, off_t *compressed_bytes) { off_t bin, bout = 0; char *buf; buf = malloc(BUFSIZE); if (buf == NULL) return -1; /* XXX */ compressed_prelen = prelen; if (prelen != 0) compressed_pre = pre; else compressed_pre = NULL; while ((bin = fread(buf, 1, BUFSIZE, in)) != 0) { if (tflag == 0 && (off_t)fwrite(buf, 1, bin, out) != bin) { free(buf); return -1; } bout += bin; } if (compressed_bytes) *compressed_bytes = total_compressed_bytes; free(buf); return bout; } static int zclose(void *zs) { free(zs); /* We leave the caller to close the fd passed to zdopen() */ return 0; } FILE * zdopen(int fd) { struct s_zstate *zs; if ((zs = calloc(1, sizeof(struct s_zstate))) == NULL) return (NULL); zs->zs_state = S_START; /* XXX we can get rid of some of these */ zs->zs_hsize = HSIZE; /* For dynamic table sizing. */ zs->zs_free_ent = 0; /* First unused entry. */ zs->zs_block_compress = BLOCK_MASK; zs->zs_clear_flg = 0; /* XXX we calloc()'d this structure why = 0? */ zs->zs_ratio = 0; zs->zs_checkpoint = CHECK_GAP; zs->zs_in_count = 1; /* Length of input. */ zs->zs_out_count = 0; /* # of codes output (for debugging). */ zs->u.r.zs_roffset = 0; zs->u.r.zs_size = 0; /* * Layering compress on top of stdio in order to provide buffering, * and ensure that reads and write work with the data specified. */ if ((zs->zs_fp = fdopen(fd, "r")) == NULL) { free(zs); return NULL; } return funopen(zs, zread, NULL, NULL, zclose); } /* * Decompress read. This routine adapts to the codes in the file building * the "string" table on-the-fly; requiring no table to be stored in the * compressed file. The tables used herein are shared with those of the * compress() routine. See the definitions above. */ static int zread(void *cookie, char *rbp, int num) { u_int count, i; struct s_zstate *zs; u_char *bp, header[3]; if (num == 0) return (0); zs = cookie; count = num; bp = (u_char *)rbp; switch (zs->zs_state) { case S_START: zs->zs_state = S_MIDDLE; break; case S_MIDDLE: goto middle; case S_EOF: goto eof; } /* Check the magic number */ for (i = 0; i < 3 && compressed_prelen; i++, compressed_prelen--) header[i] = *compressed_pre++; if (fread(header + i, 1, sizeof(header) - i, zs->zs_fp) != sizeof(header) - i || memcmp(header, magic_header, sizeof(magic_header)) != 0) { errno = EFTYPE; return (-1); } total_compressed_bytes = 0; zs->zs_maxbits = header[2]; /* Set -b from file. */ zs->zs_block_compress = zs->zs_maxbits & BLOCK_MASK; zs->zs_maxbits &= BIT_MASK; zs->zs_maxmaxcode = 1L << zs->zs_maxbits; if (zs->zs_maxbits > BITS || zs->zs_maxbits < 12) { errno = EFTYPE; return (-1); } /* As above, initialize the first 256 entries in the table. */ zs->zs_maxcode = MAXCODE(zs->zs_n_bits = INIT_BITS); for (zs->u.r.zs_code = 255; zs->u.r.zs_code >= 0; zs->u.r.zs_code--) { tab_prefixof(zs->u.r.zs_code) = 0; tab_suffixof(zs->u.r.zs_code) = (char_type) zs->u.r.zs_code; } zs->zs_free_ent = zs->zs_block_compress ? FIRST : 256; zs->u.r.zs_oldcode = -1; zs->u.r.zs_stackp = de_stack; while ((zs->u.r.zs_code = getcode(zs)) > -1) { if ((zs->u.r.zs_code == CLEAR) && zs->zs_block_compress) { for (zs->u.r.zs_code = 255; zs->u.r.zs_code >= 0; zs->u.r.zs_code--) tab_prefixof(zs->u.r.zs_code) = 0; zs->zs_clear_flg = 1; zs->zs_free_ent = FIRST; zs->u.r.zs_oldcode = -1; continue; } zs->u.r.zs_incode = zs->u.r.zs_code; /* Special case for KwKwK string. */ if (zs->u.r.zs_code >= zs->zs_free_ent) { if (zs->u.r.zs_code > zs->zs_free_ent || zs->u.r.zs_oldcode == -1) { /* Bad stream. */ errno = EFTYPE; return (-1); } *zs->u.r.zs_stackp++ = zs->u.r.zs_finchar; zs->u.r.zs_code = zs->u.r.zs_oldcode; } /* * The above condition ensures that code < free_ent. * The construction of tab_prefixof in turn guarantees that * each iteration decreases code and therefore stack usage is * bound by 1 << BITS - 256. */ /* Generate output characters in reverse order. */ while (zs->u.r.zs_code >= 256) { *zs->u.r.zs_stackp++ = tab_suffixof(zs->u.r.zs_code); zs->u.r.zs_code = tab_prefixof(zs->u.r.zs_code); } *zs->u.r.zs_stackp++ = zs->u.r.zs_finchar = tab_suffixof(zs->u.r.zs_code); /* And put them out in forward order. */ middle: do { if (count-- == 0) return (num); *bp++ = *--zs->u.r.zs_stackp; } while (zs->u.r.zs_stackp > de_stack); /* Generate the new entry. */ if ((zs->u.r.zs_code = zs->zs_free_ent) < zs->zs_maxmaxcode && zs->u.r.zs_oldcode != -1) { tab_prefixof(zs->u.r.zs_code) = (u_short) zs->u.r.zs_oldcode; tab_suffixof(zs->u.r.zs_code) = zs->u.r.zs_finchar; zs->zs_free_ent = zs->u.r.zs_code + 1; } /* Remember previous code. */ zs->u.r.zs_oldcode = zs->u.r.zs_incode; } zs->zs_state = S_EOF; eof: return (num - count); } /*- * Read one code from the standard input. If EOF, return -1. * Inputs: * stdin * Outputs: * code or -1 is returned. */ static code_int getcode(struct s_zstate *zs) { code_int gcode; int r_off, bits, i; char_type *bp; bp = zs->u.r.zs_gbuf; if (zs->zs_clear_flg > 0 || zs->u.r.zs_roffset >= zs->u.r.zs_size || zs->zs_free_ent > zs->zs_maxcode) { /* * If the next entry will be too big for the current gcode * size, then we must increase the size. This implies reading * a new buffer full, too. */ if (zs->zs_free_ent > zs->zs_maxcode) { zs->zs_n_bits++; if (zs->zs_n_bits == zs->zs_maxbits) /* Won't get any bigger now. */ zs->zs_maxcode = zs->zs_maxmaxcode; else zs->zs_maxcode = MAXCODE(zs->zs_n_bits); } if (zs->zs_clear_flg > 0) { zs->zs_maxcode = MAXCODE(zs->zs_n_bits = INIT_BITS); zs->zs_clear_flg = 0; } /* XXX */ for (i = 0; i < zs->zs_n_bits && compressed_prelen; i++, compressed_prelen--) zs->u.r.zs_gbuf[i] = *compressed_pre++; zs->u.r.zs_size = fread(zs->u.r.zs_gbuf + i, 1, zs->zs_n_bits - i, zs->zs_fp); zs->u.r.zs_size += i; if (zs->u.r.zs_size <= 0) /* End of file. */ return (-1); zs->u.r.zs_roffset = 0; total_compressed_bytes += zs->u.r.zs_size; /* Round size down to integral number of codes. */ zs->u.r.zs_size = (zs->u.r.zs_size << 3) - (zs->zs_n_bits - 1); } r_off = zs->u.r.zs_roffset; bits = zs->zs_n_bits; /* Get to the first byte. */ bp += (r_off >> 3); r_off &= 7; /* Get first part (low order bits). */ gcode = (*bp++ >> r_off); bits -= (8 - r_off); r_off = 8 - r_off; /* Now, roffset into gcode word. */ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */ if (bits >= 8) { gcode |= *bp++ << r_off; r_off += 8; bits -= 8; } /* High order bits. */ gcode |= (*bp & rmask[bits]) << r_off; zs->u.r.zs_roffset += zs->zs_n_bits; return (gcode); } diff --git a/usr.bin/hexdump/hexdump.h b/usr.bin/hexdump/hexdump.h index f21e2f240b1e..b58d826c172f 100644 --- a/usr.bin/hexdump/hexdump.h +++ b/usr.bin/hexdump/hexdump.h @@ -1,107 +1,106 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)hexdump.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include typedef struct _pr { struct _pr *nextpr; /* next print unit */ #define F_ADDRESS 0x001 /* print offset */ #define F_BPAD 0x002 /* blank pad */ #define F_C 0x004 /* %_c */ #define F_CHAR 0x008 /* %c */ #define F_DBL 0x010 /* %[EefGf] */ #define F_INT 0x020 /* %[di] */ #define F_P 0x040 /* %_p */ #define F_STR 0x080 /* %s */ #define F_U 0x100 /* %_u */ #define F_UINT 0x200 /* %[ouXx] */ #define F_TEXT 0x400 /* no conversions */ u_int flags; /* flag values */ int bcnt; /* byte count */ char *cchar; /* conversion character */ char *fmt; /* printf format */ char *nospace; /* no whitespace version */ int mbleft; /* bytes left of multibyte char. */ mbstate_t mbstate; /* conversion state */ } PR; typedef struct _fu { struct _fu *nextfu; /* next format unit */ struct _pr *nextpr; /* next print unit */ #define F_IGNORE 0x01 /* %_A */ #define F_SETREP 0x02 /* rep count set, not default */ u_int flags; /* flag values */ int reps; /* repetition count */ int bcnt; /* byte count */ char *fmt; /* format string */ } FU; typedef struct _fs { /* format strings */ struct _fs *nextfs; /* linked list of format strings */ struct _fu *nextfu; /* linked list of format units */ int bcnt; } FS; extern FS *fshead; /* head of format strings list */ extern FU *endfu; /* format at end-of-data */ extern int blocksize; /* data block size */ extern int exitval; /* final exit value */ extern int odmode; /* are we acting as od(1)? */ extern int length; /* amount of data to read */ extern off_t skip; /* amount of data to skip at start */ enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */ extern enum _vflag vflag; void add(const char *); void addfile(const char *); void badcnt(const char *); void badconv(const char *); void badfmt(const char *); void badnoconv(void); void badsfmt(void); void bpad(PR *); void conv_c(PR *, u_char *, size_t); void conv_u(PR *, u_char *); void display(void); void doskip(const char *, int); void escape(char *); u_char *get(void); void newsyntax(int, char ***); int next(char **); void nomem(void); void oldsyntax(int, char ***); size_t peek(u_char *, size_t); void rewrite(FS *); int size(FS *); void usage(void); diff --git a/usr.bin/indent/indent_codes.h b/usr.bin/indent/indent_codes.h index 0d043279c4e1..8eb80f166efb 100644 --- a/usr.bin/indent/indent_codes.h +++ b/usr.bin/indent/indent_codes.h @@ -1,77 +1,76 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1985 Sun Microsystems, Inc. * Copyright (c) 1980, 1993 * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)indent_codes.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define newline 1 #define lparen 2 #define rparen 3 #define unary_op 4 #define binary_op 5 #define postop 6 #define question 7 #define casestmt 8 #define colon 9 #define semicolon 10 #define lbrace 11 #define rbrace 12 #define ident 13 #define comma 14 #define comment 15 #define swstmt 16 #define preesc 17 #define form_feed 18 #define decl 19 #define sp_paren 20 #define sp_nparen 21 #define ifstmt 22 #define whilestmt 23 #define forstmt 24 #define stmt 25 #define stmtl 26 #define elselit 27 #define dolit 28 #define dohead 29 #define ifhead 30 #define elsehead 31 #define period 32 #define strpfx 33 #define storage 34 #define funcname 35 #define type_def 36 #define structure 37 diff --git a/usr.bin/indent/indent_globs.h b/usr.bin/indent/indent_globs.h index cadf442a2c98..640ba1bf48ec 100644 --- a/usr.bin/indent/indent_globs.h +++ b/usr.bin/indent/indent_globs.h @@ -1,326 +1,325 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1985 Sun Microsystems, Inc. * Copyright (c) 1980, 1993 * The Regents of the University of California. 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. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)indent_globs.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define BACKSLASH '\\' #define bufsize 200 /* size of internal buffers */ #define sc_size 5000 /* size of save_com buffer */ #define label_offset 2 /* number of levels a label is placed to left * of code */ #define false 0 #define true 1 extern FILE *input; /* the fid for the input file */ extern FILE *output; /* the output file */ #define CHECK_SIZE_CODE(desired_size) \ if (e_code + (desired_size) >= l_code) { \ int nsize = l_code-s_code + 400 + desired_size; \ int code_len = e_code-s_code; \ codebuf = (char *) realloc(codebuf, nsize); \ if (codebuf == NULL) \ err(1, NULL); \ e_code = codebuf + code_len + 1; \ l_code = codebuf + nsize - 5; \ s_code = codebuf + 1; \ } #define CHECK_SIZE_COM(desired_size) \ if (e_com + (desired_size) >= l_com) { \ int nsize = l_com-s_com + 400 + desired_size; \ int com_len = e_com - s_com; \ int blank_pos; \ if (last_bl != NULL) \ blank_pos = last_bl - combuf; \ else \ blank_pos = -1; \ combuf = (char *) realloc(combuf, nsize); \ if (combuf == NULL) \ err(1, NULL); \ e_com = combuf + com_len + 1; \ if (blank_pos > 0) \ last_bl = combuf + blank_pos; \ l_com = combuf + nsize - 5; \ s_com = combuf + 1; \ } #define CHECK_SIZE_LAB(desired_size) \ if (e_lab + (desired_size) >= l_lab) { \ int nsize = l_lab-s_lab + 400 + desired_size; \ int label_len = e_lab - s_lab; \ labbuf = (char *) realloc(labbuf, nsize); \ if (labbuf == NULL) \ err(1, NULL); \ e_lab = labbuf + label_len + 1; \ l_lab = labbuf + nsize - 5; \ s_lab = labbuf + 1; \ } #define CHECK_SIZE_TOKEN(desired_size) \ if (e_token + (desired_size) >= l_token) { \ int nsize = l_token-s_token + 400 + desired_size; \ int token_len = e_token - s_token; \ tokenbuf = (char *) realloc(tokenbuf, nsize); \ if (tokenbuf == NULL) \ err(1, NULL); \ e_token = tokenbuf + token_len + 1; \ l_token = tokenbuf + nsize - 5; \ s_token = tokenbuf + 1; \ } extern char *labbuf; /* buffer for label */ extern char *s_lab; /* start ... */ extern char *e_lab; /* .. and end of stored label */ extern char *l_lab; /* limit of label buffer */ extern char *codebuf; /* buffer for code section */ extern char *s_code; /* start ... */ extern char *e_code; /* .. and end of stored code */ extern char *l_code; /* limit of code section */ extern char *combuf; /* buffer for comments */ extern char *s_com; /* start ... */ extern char *e_com; /* ... and end of stored comments */ extern char *l_com; /* limit of comment buffer */ #define token s_token extern char *tokenbuf; /* the last token scanned */ extern char *s_token; extern char *e_token; extern char *l_token; extern char *in_buffer; /* input buffer */ extern char *in_buffer_limit; /* the end of the input buffer */ extern char *buf_ptr; /* ptr to next character to be taken * from in_buffer */ extern char *buf_end; /* ptr to first after last char in * in_buffer */ extern char sc_buf[sc_size]; /* input text is saved here when looking * for the brace after an if, while, etc */ extern char *save_com; /* start of the comment stored in * sc_buf */ extern char *sc_end; /* pointer into save_com buffer */ extern char *bp_save; /* saved value of buf_ptr when taking * input from save_com */ extern char *be_save; /* similarly saved value of buf_end */ struct options { int blanklines_around_conditional_compilation; int blanklines_after_declarations_at_proctop; /* this is vaguely * similar to blanklines_after_decla except * that in only applies to the first set of * declarations in a procedure (just after * the first '{') and it causes a blank line * to be generated even if there are no * declarations */ int blanklines_after_declarations; int blanklines_after_procs; int blanklines_before_blockcomments; int leave_comma; /* if true, never break declarations after * commas */ int btype_2; /* when true, brace should be on same line * as if, while, etc */ int Bill_Shannon; /* true iff a blank should always be * inserted after sizeof */ int comment_delimiter_on_blankline; int decl_com_ind; /* the column in which comments after * declarations should be put */ int cuddle_else; /* true if else should cuddle up to '}' */ int continuation_indent; /* set to the indentation between the * edge of code and continuation lines */ float case_indent; /* The distance to indent case labels from the * switch statement */ int com_ind; /* the column in which comments to the right * of code should start */ int decl_indent; /* column to indent declared identifiers to */ int ljust_decl; /* true if declarations should be left * justified */ int unindent_displace; /* comments not to the right of code * will be placed this many * indentation levels to the left of * code */ int extra_expression_indent; /* true if continuation lines from * the expression part of "if(e)", * "while(e)", "for(e;e;e)" should be * indented an extra tab stop so that they * don't conflict with the code that follows */ int else_if; /* True iff else if pairs should be handled * specially */ int function_brace_split; /* split function declaration and * brace onto separate lines */ int format_col1_comments; /* If comments which start in column 1 * are to be magically reformatted (just * like comments that begin in later columns) */ int format_block_comments; /* true if comments beginning with * `/ * \n' are to be reformatted */ int indent_parameters; int ind_size; /* the size of one indentation level */ int block_comment_max_col; int local_decl_indent; /* like decl_indent but for locals */ int lineup_to_parens_always; /* if true, do not attempt to keep * lined-up code within the margin */ int lineup_to_parens; /* if true, continued code within parens * will be lined up to the open paren */ int pointer_as_binop; /* if true, the pointer dereference operator * will be treated as a binary operator */ int proc_calls_space; /* If true, procedure calls look like: * foo (bar) rather than foo(bar) */ int procnames_start_line; /* if true, the names of procedures * being defined get placed in column 1 (ie. * a newline is placed between the type of * the procedure and its name) */ int space_after_cast; /* "b = (int) a" vs "b = (int)a" */ int star_comment_cont; /* true iff comment continuation lines * should have stars at the beginning of * each line. */ int swallow_optional_blanklines; int auto_typedefs; /* set true to recognize identifiers * ending in "_t" like typedefs */ int tabsize; /* the size of a tab */ int max_col; /* the maximum allowable line length */ int use_tabs; /* set true to use tabs for spacing, false * uses all spaces */ int verbose; /* when true, non-essential error messages * are printed */ }; extern struct options opt; extern int found_err; extern int n_real_blanklines; extern int prefix_blankline_requested; extern int postfix_blankline_requested; extern int break_comma; /* when true and not in parens, break after a * comma */ extern float case_ind; /* indentation level to be used for a "case * n:" */ extern int code_lines; /* count of lines with code */ extern int had_eof; /* set to true when input is exhausted */ extern int line_no; /* the current line number. */ extern int inhibit_formatting; /* true if INDENT OFF is in effect */ extern int suppress_blanklines;/* set iff following blanklines should be * suppressed */ #define STACKSIZE 256 struct parser_state { int last_token; int p_stack[STACKSIZE]; /* this is the parsers stack */ int il[STACKSIZE]; /* this stack stores indentation levels */ float cstk[STACKSIZE];/* used to store case stmt indentation levels */ int box_com; /* set to true when we are in a "boxed" * comment. In that case, the first non-blank * char should be lined up with the / in / followed by * */ int comment_delta; /* used to set up indentation for all lines * of a boxed comment after the first one */ int n_comment_delta;/* remembers how many columns there were * before the start of a box comment so that * forthcoming lines of the comment are * indented properly */ int cast_mask; /* indicates which close parens potentially * close off casts */ int not_cast_mask; /* indicates which close parens definitely * close off something else than casts */ int block_init; /* true iff inside a block initialization */ int block_init_level; /* The level of brace nesting in an * initialization */ int last_nl; /* this is true if the last thing scanned was * a newline */ int in_or_st; /* Will be true iff there has been a * declarator (e.g. int or char) and no left * paren since the last semicolon. When true, * a '{' is starting a structure definition or * an initialization list */ int bl_line; /* set to 1 by dump_line if the line is blank */ int col_1; /* set to true if the last token started in * column 1 */ int com_col; /* this is the column in which the current * comment should start */ int com_lines; /* the number of lines with comments, set by * dump_line */ int dec_nest; /* current nesting level for structure or init */ int decl_on_line; /* set to true if this line of code has part * of a declaration on it */ int i_l_follow; /* the level to which ind_level should be set * after the current line is printed */ int in_decl; /* set to true when we are in a declaration * stmt. The processing of braces is then * slightly different */ int in_stmt; /* set to 1 while in a stmt */ int ind_level; /* the current indentation level */ int ind_stmt; /* set to 1 if next line should have an extra * indentation level because we are in the * middle of a stmt */ int last_u_d; /* set to true after scanning a token which * forces a following operator to be unary */ int out_coms; /* the number of comments processed, set by * pr_comment */ int out_lines; /* the number of lines written, set by * dump_line */ int p_l_follow; /* used to remember how to indent following * statement */ int paren_level; /* parenthesization level. used to indent * within statements */ short paren_indents[20]; /* column positions of each paren */ int pcase; /* set to 1 if the current line label is a * case. It is printed differently from a * regular label */ int search_brace; /* set to true by parse when it is necessary * to buffer up all info up to the start of a * stmt after an if, while, etc */ int use_ff; /* set to one if the current line should be * terminated with a form feed */ int want_blank; /* set to true when the following token should * be prefixed by a blank. (Said prefixing is * ignored in some cases.) */ int keyword; /* the type of a keyword or 0 */ int dumped_decl_indent; int in_parameter_declaration; int tos; /* pointer to top of stack */ char procname[100]; /* The name of the current procedure */ int just_saw_decl; }; extern struct parser_state ps; extern int ifdef_level; extern struct parser_state state_stack[5]; extern struct parser_state match_state[5]; diff --git a/usr.bin/ktrace/ktrace.h b/usr.bin/ktrace/ktrace.h index 09d5e989ad36..cecd0adc7321 100644 --- a/usr.bin/ktrace/ktrace.h +++ b/usr.bin/ktrace/ktrace.h @@ -1,47 +1,46 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ktrace.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define DEF_POINTS (KTRFAC_SYSCALL | KTRFAC_SYSRET | KTRFAC_NAMEI | \ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL | KTRFAC_CAPFAIL | \ KTRFAC_STRUCT_ARRAY) #define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) #define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS | \ KTRFAC_FAULT | KTRFAC_FAULTEND) #define DEF_TRACEFILE "ktrace.out" int getpoints(char *); diff --git a/usr.bin/locate/locate/locate.h b/usr.bin/locate/locate/locate.h index 18187ca00d84..c66a40cb55b1 100644 --- a/usr.bin/locate/locate/locate.h +++ b/usr.bin/locate/locate/locate.h @@ -1,76 +1,75 @@ /* * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1995 Wolfram Schneider . Berlin. * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)locate.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* Symbolic constants shared by locate.c and code.c */ #define NBG 128 /* number of bigrams considered */ #define OFFSET 14 /* abs value of max likely diff */ #define PARITY 0200 /* parity bit */ #define SWITCH 30 /* switch code */ #define UMLAUT 31 /* an 8 bit char followed */ /* 0-28 likeliest differential counts + offset to make nonnegative */ #define LDC_MIN 0 #define LDC_MAX 28 /* 128-255 bigram codes (128 most common, as determined by 'updatedb') */ #define BIGRAM_MIN (UCHAR_MAX - SCHAR_MAX) #define BIGRAM_MAX UCHAR_MAX /* 32-127 single character (printable) ascii residue (ie, literal) */ #define ASCII_MIN 32 #define ASCII_MAX SCHAR_MAX /* #define TO7BIT(x) (x = ( ((u_char)x) & SCHAR_MAX )) */ #define TO7BIT(x) (x = x & SCHAR_MAX ) #if UCHAR_MAX >= 4096 define TOLOWER(ch) tolower(ch) #else extern u_char myctype[UCHAR_MAX + 1]; #define TOLOWER(ch) (myctype[ch]) #endif #define INTSIZE (sizeof(int)) #define LOCATE_REG "*?[]\\" /* fnmatch(3) meta characters */ /* max. path length for locate. Should be at least 1024 (PATH_MAX), but can be longer */ #ifndef LOCATE_PATH_MAX #define LOCATE_PATH_MAX (1*1024) #endif diff --git a/usr.bin/locate/locate/pathnames.h b/usr.bin/locate/locate/pathnames.h index 21fc9a172f81..53d0d6073736 100644 --- a/usr.bin/locate/locate/pathnames.h +++ b/usr.bin/locate/locate/pathnames.h @@ -1,35 +1,34 @@ /* * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define _PATH_FCODES "/var/db/locate.database" diff --git a/usr.bin/login/pathnames.h b/usr.bin/login/pathnames.h index 5dca6f2cbb4e..9dc97619f4f6 100644 --- a/usr.bin/login/pathnames.h +++ b/usr.bin/login/pathnames.h @@ -1,40 +1,39 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/9/93 - * $FreeBSD$ */ #include #define _PATH_HUSHLOGIN ".hushlogin" #define _PATH_MOTDFILE "/var/run/motd" #define _PATH_FBTAB "/etc/fbtab" #define _PATH_LOGINDEVPERM "/etc/logindevperm" diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h index b2aff26cda1c..07e831796822 100644 --- a/usr.bin/m4/extern.h +++ b/usr.bin/m4/extern.h @@ -1,184 +1,183 @@ /* $OpenBSD: extern.h,v 1.55 2017/06/15 13:48:42 bcallah Exp $ */ /* $NetBSD: extern.h,v 1.3 1996/01/13 23:25:24 pk Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ozan Yigit at York University. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* eval.c */ extern void eval(const char *[], int, int, int); extern void dodefine(const char *, const char *); extern unsigned long expansion_id; /* expr.c */ extern int expr(const char *); /* gnum4.c */ extern void addtoincludepath(const char *); extern struct input_file *fopen_trypath(struct input_file *, const char *); extern void doindir(const char *[], int); extern void dobuiltin(const char *[], int); extern void dopatsubst(const char *[], int); extern void doregexp(const char *[], int); extern void doprintlineno(struct input_file *); extern void doprintfilename(struct input_file *); extern void doesyscmd(const char *); extern void getdivfile(const char *); extern void doformat(const char *[], int); extern void m4_warnx(const char *, ...); /* look.c */ #define FLAG_UNTRACED 0 #define FLAG_TRACED 1 #define FLAG_NO_TRACE 2 extern void init_macros(void); extern ndptr lookup(const char *); extern void mark_traced(const char *, int); extern struct ohash macros; extern struct macro_definition *lookup_macro_definition(const char *); extern void macro_define(const char *, const char *); extern void macro_pushdef(const char *, const char *); extern void macro_popdef(const char *); extern void macro_undefine(const char *); extern void setup_builtin(const char *, unsigned int); extern void macro_for_all(void (*)(const char *, struct macro_definition *)); #define macro_getdef(p) ((p)->d) #define macro_name(p) ((p)->name) #define macro_builtin_type(p) ((p)->builtin_type) #define is_traced(p) ((p)->trace_flags == FLAG_NO_TRACE ? (trace_flags & TRACE_ALL) : (p)->trace_flags) extern ndptr macro_getbuiltin(const char *); /* main.c */ extern void outputstr(const char *); extern void do_emit_synchline(void); extern int exit_code; #define emit_synchline() do { if (synch_lines) do_emit_synchline(); } while(0) /* misc.c */ extern void chrsave(int); extern char *compute_prevep(void); extern void getdiv(int); extern ptrdiff_t indx(const char *, const char *); extern void initspaces(void); extern void killdiv(void); extern void onintr(int); extern void pbnum(int); extern void pbnumbase(int, int, int); extern void pbunsigned(unsigned long); extern void pbstr(const char *); extern void pushback(int); extern void *xalloc(size_t, const char *, ...) __printf0like(2, 3); extern void *xcalloc(size_t, size_t, const char *, ...) __printf0like(3, 4); extern void *xrealloc(void *, size_t, const char *, ...) __printf0like(3, 4); extern void *xreallocarray(void *, size_t, size_t, const char *, ...) __printf0like(4, 5); extern char *xstrdup(const char *); extern void usage(void); extern void resizedivs(int); extern size_t buffer_mark(void); extern void dump_buffer(FILE *, size_t); extern void m4errx(int, const char *, ...) __dead2 __printf0like(2, 3); extern int obtain_char(struct input_file *); extern void set_input(struct input_file *, FILE *, const char *); extern void release_input(struct input_file *); /* speeded-up versions of chrsave/pushback */ #define PUSHBACK(c) \ do { \ if (bp >= endpbb) \ enlarge_bufspace(); \ *bp++ = (c); \ } while(0) #define CHRSAVE(c) \ do { \ if (ep >= endest) \ enlarge_strspace(); \ *ep++ = (c); \ } while(0) /* and corresponding exposure for local symbols */ extern void enlarge_bufspace(void); extern void enlarge_strspace(void); extern unsigned char *endpbb; extern char *endest; /* trace.c */ extern unsigned int trace_flags; #define TRACE_ALL 512 extern void trace_file(const char *); extern size_t trace(const char **, int, struct input_file *); extern void finish_trace(size_t); extern void set_trace_flags(const char *); extern FILE *traceout; extern stae *mstack; /* stack of m4 machine */ extern char *sstack; /* shadow stack, for string space extension */ extern FILE *active; /* active output file pointer */ extern struct input_file infile[];/* input file stack (0=stdin) */ extern FILE **outfile; /* diversion array(0=bitbucket) */ extern int maxout; /* maximum number of diversions */ extern int fp; /* m4 call frame pointer */ extern int ilevel; /* input file stack pointer */ extern int oindex; /* diversion index. */ extern int sp; /* current m4 stack pointer */ extern unsigned char *bp; /* first available character */ extern unsigned char *buf; /* push-back buffer */ extern unsigned char *bufbase; /* buffer base for this ilevel */ extern unsigned char *bbase[]; /* buffer base per ilevel */ extern char ecommt[MAXCCHARS+1];/* end character for comment */ extern char *ep; /* first free char in strspace */ extern char lquote[MAXCCHARS+1];/* left quote character (`) */ extern char **m4wraps; /* m4wrap string default. */ extern int maxwraps; /* size of m4wraps array */ extern int wrapindex; /* current index in m4wraps */ extern const char *null; /* as it says.. just a null. */ extern char rquote[MAXCCHARS+1];/* right quote character (') */ extern char scommt[MAXCCHARS+1];/* start character for comment */ extern int synch_lines; /* line synchronisation directives */ extern int mimic_gnu; /* behaves like gnu-m4 */ extern int prefix_builtins; /* prefix builtin macros with m4_ */ extern int error_warns; /* make warnings cause exit_code = 1 */ extern int fatal_warns; /* make warnings fatal */ diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h index b15f2b5bce38..6d738876b22a 100644 --- a/usr.bin/m4/mdef.h +++ b/usr.bin/m4/mdef.h @@ -1,240 +1,239 @@ /* $OpenBSD: mdef.h,v 1.33 2015/11/03 16:21:47 deraadt Exp $ */ /* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ozan Yigit at York University. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)mdef.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #ifdef __GNUC__ # define UNUSED __attribute__((__unused__)) #else # define UNUSED #endif #define MACRTYPE 1 #define DEFITYPE 2 #define EXPRTYPE 3 #define SUBSTYPE 4 #define IFELTYPE 5 #define LENGTYPE 6 #define CHNQTYPE 7 #define SYSCTYPE 8 #define UNDFTYPE 9 #define INCLTYPE 10 #define SINCTYPE 11 #define PASTTYPE 12 #define SPASTYPE 13 #define INCRTYPE 14 #define IFDFTYPE 15 #define PUSDTYPE 16 #define POPDTYPE 17 #define SHIFTYPE 18 #define DECRTYPE 19 #define DIVRTYPE 20 #define UNDVTYPE 21 #define DIVNTYPE 22 #define MKTMTYPE 23 #define ERRPTYPE 24 #define M4WRTYPE 25 #define TRNLTYPE 26 #define DNLNTYPE 27 #define DUMPTYPE 28 #define CHNCTYPE 29 #define INDXTYPE 30 #define SYSVTYPE 31 #define EXITTYPE 32 #define DEFNTYPE 33 #define SELFTYPE 34 #define INDIRTYPE 35 #define BUILTINTYPE 36 #define PATSTYPE 37 #define FILENAMETYPE 38 #define LINETYPE 39 #define REGEXPTYPE 40 #define ESYSCMDTYPE 41 #define TRACEONTYPE 42 #define TRACEOFFTYPE 43 #define FORMATTYPE 44 #define BUILTIN_MARKER "__builtin_" #define TYPEMASK 63 /* Keep bits really corresponding to a type. */ #define RECDEF 256 /* Pure recursive def, don't expand it */ #define NOARGS 512 /* builtin needs no args */ #define NEEDARGS 1024 /* mark builtin that need args with this */ /* * m4 special characters */ #define ARGFLAG '$' #define LPAREN '(' #define RPAREN ')' #define LQUOTE '`' #define RQUOTE '\'' #define COMMA ',' #define SCOMMT '#' #define ECOMMT '\n' /* * other important constants */ #define EOS '\0' #define MAXINP 10 /* maximum include files */ #define MAXOUT 10 /* maximum # of diversions */ #define BUFSIZE 4096 /* starting size of pushback buffer */ #define INITSTACKMAX 4096 /* starting size of call stack */ #define STRSPMAX 4096 /* starting size of string space */ #define MAXTOK 512 /* maximum chars in a tokn */ #define MAXCCHARS 5 /* max size of comment/quote delim */ #define ALL 1 #define TOP 0 #define TRUE 1 #define FALSE 0 #define cycle for(;;) /* * m4 data structures */ typedef struct ndblock *ndptr; struct macro_definition { struct macro_definition *next; char *defn; /* definition.. */ unsigned int type; /* type of the entry.. */ }; struct ndblock { /* hashtable structure */ unsigned int builtin_type; unsigned int trace_flags; struct macro_definition *d; char name[1]; /* entry name.. */ }; typedef union { /* stack structure */ int sfra; /* frame entry */ char *sstr; /* string entry */ } stae; struct input_file { FILE *file; char *name; unsigned long lineno; unsigned long synch_lineno; /* used for -s */ int c; }; #define STORAGE_STRSPACE 0 #define STORAGE_MACRO 1 #define STORAGE_OTHER 2 #define CURRENT_NAME (infile[ilevel].name) #define CURRENT_LINE (infile[ilevel].lineno) /* * macros for readibility and/or speed * * gpbc() - get a possibly pushed-back character * pushf() - push a call frame entry onto stack * pushs() - push a string pointer onto stack */ #define gpbc() (bp > bufbase) ? *--bp : obtain_char(infile+ilevel) #define pushf(x) \ do { \ if (++sp == (int)STACKMAX) \ enlarge_stack();\ mstack[sp].sfra = (x); \ sstack[sp] = STORAGE_OTHER; \ } while (0) #define pushs(x) \ do { \ if (++sp == (int)STACKMAX) \ enlarge_stack();\ mstack[sp].sstr = (x); \ sstack[sp] = STORAGE_STRSPACE; \ } while (0) #define pushs1(x) \ do { \ if (++sp == (int)STACKMAX) \ enlarge_stack();\ mstack[sp].sstr = (x); \ sstack[sp] = STORAGE_OTHER; \ } while (0) #define pushdef(p) \ do { \ if (++sp == (int)STACKMAX) \ enlarge_stack();\ mstack[sp].sstr = macro_getdef(p)->defn;\ sstack[sp] = STORAGE_MACRO; \ } while (0) /* * . . * | . | <-- sp | . | * +-------+ +-----+ * | arg 3 ----------------------->| str | * +-------+ | . | * | arg 2 ---PREVEP-----+ . * +-------+ | * . | | | * +-------+ | +-----+ * | plev | PARLEV +-------->| str | * +-------+ | . | * | type | CALTYP . * +-------+ * | prcf ---PREVFP--+ * +-------+ | * | . | PREVSP | * . | * +-------+ | * | <----------+ * +-------+ * */ #define PARLEV (mstack[fp].sfra) #define CALTYP (mstack[fp-2].sfra) #define TRACESTATUS (mstack[fp-1].sfra) #define PREVEP (mstack[fp+3].sstr) #define PREVSP (fp-4) #define PREVFP (mstack[fp-3].sfra) diff --git a/usr.bin/m4/pathnames.h b/usr.bin/m4/pathnames.h index 742edc147722..3ec165f08a79 100644 --- a/usr.bin/m4/pathnames.h +++ b/usr.bin/m4/pathnames.h @@ -1,41 +1,40 @@ /* $OpenBSD: pathnames.h,v 1.6 2015/11/03 16:21:47 deraadt Exp $ */ /* $NetBSD: pathnames.h,v 1.6 1995/09/29 00:27:55 cgd Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ozan Yigit at York University. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define _PATH_DIVNAME "/tmp/m4.0XXXXXXXXXX" /* unix diversion files */ diff --git a/usr.bin/m4/stdd.h b/usr.bin/m4/stdd.h index 2ef1bb1f3bdf..3a90bc606885 100644 --- a/usr.bin/m4/stdd.h +++ b/usr.bin/m4/stdd.h @@ -1,58 +1,57 @@ /* $OpenBSD: stdd.h,v 1.6 2010/09/07 19:58:09 marco Exp $ */ /* $NetBSD: stdd.h,v 1.2 1995/09/28 05:37:50 tls Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Ozan Yigit at York University. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)stdd.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * standard defines */ #define max(a,b) ((a) > (b)? (a): (b)) #define min(a,b) ((a) < (b)? (a): (b)) #define iswhite(c) ((c) == ' ' || (c) == '\t') /* * STREQ is an optimised strcmp(a,b)==0 * STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0 */ #define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0) #define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0) #define YES 1 #define NO 0 diff --git a/usr.bin/netstat/common.h b/usr.bin/netstat/common.h index 113180c0a6f4..b40ae5b6a8a1 100644 --- a/usr.bin/netstat/common.h +++ b/usr.bin/netstat/common.h @@ -1,93 +1,92 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)netstat.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #ifndef _NETSTAT_COMMON_H_ #define _NETSTAT_COMMON_H_ struct bits { u_long b_mask; char b_val; const char *b_name; }; extern struct bits rt_bits[]; const char *fmt_flags(const struct bits *p, int f); void print_flags_generic(int flags, const struct bits *pbits, const char *format, const char *tag_name); int p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask, int flags, int width); struct _wid { int dst; int gw; int flags; int pksent; int mtu; int iface; int expire; }; void set_wid(int fam); void pr_rthdr(int af1 __unused); extern struct _wid wid; void p_flags(int f, const char *format); bool p_rtable_netlink(int fibnum, int af); struct ifmap_entry { char ifname[IFNAMSIZ]; uint32_t mtu; }; struct ifmap_entry *prepare_ifmap(size_t *ifmap_size); extern const uint32_t rt_default_weight; struct rt_msghdr; struct nhops_map { uint32_t idx; struct rt_msghdr *rtm; }; struct nhops_dump { void *nh_buf; struct nhops_map *nh_map; size_t nh_count; }; void dump_nhops_sysctl(int fibnum, int af, struct nhops_dump *nd); struct nhop_map; void nhop_map_update(struct nhop_map *map, uint32_t idx, char *gw, char *ifname); #endif diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 32dbbc9d5576..9f23252ee714 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -1,168 +1,167 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992, 1993 * Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)netstat.h 8.2 (Berkeley) 1/4/94 - * $FreeBSD$ */ #include #define satosin(sa) ((struct sockaddr_in *)(sa)) #define satosin6(sa) ((struct sockaddr_in6 *)(sa)) #define sin6tosa(sin6) ((struct sockaddr *)(sin6)) extern int Aflag; /* show addresses of protocol control block */ extern int aflag; /* show all sockets (including servers) */ extern int bflag; /* show i/f total bytes in/out */ extern int cflag; /* show congestion control stats */ extern int Cflag; /* show congestion control algo and stack */ extern int dflag; /* show i/f dropped packets */ extern int gflag; /* show group (multicast) routing or stats */ extern int hflag; /* show counters in human readable format */ extern int iflag; /* show interfaces */ extern int Lflag; /* show size of listen queues */ extern int mflag; /* show memory stats */ extern int noutputs; /* how much outputs before we exit */ extern int numeric_addr; /* show addresses numerically */ extern int numeric_port; /* show ports numerically */ extern int Pflag; /* show TCP log ID */ extern int rflag; /* show routing tables (or routing stats) */ extern int Rflag; /* show flowid / RSS information */ extern int sflag; /* show protocol statistics */ extern int Tflag; /* show TCP control block info */ extern int Wflag; /* wide display */ extern int xflag; /* extended display, includes all socket buffer info */ extern int zflag; /* zero stats */ extern int interval; /* repeat interval for i/f stats */ extern char *interface; /* desired i/f for stats, or NULL for all i/fs */ extern int unit; /* unit number for above */ extern int live; /* true if we are examining a live system */ typedef int kreadfn_t(u_long, void *, size_t); int fetch_stats(const char *, u_long, void *, size_t, kreadfn_t); int fetch_stats_ro(const char *, u_long, void *, size_t, kreadfn_t); int kread(u_long addr, void *buf, size_t size); uint64_t kread_counter(u_long addr); int kread_counters(u_long addr, void *buf, size_t size); void kset_dpcpu(u_int); const char *plural(uintmax_t); const char *plurales(uintmax_t); const char *pluralies(uintmax_t); struct sockaddr; struct socket; struct xsocket; int sotoxsocket(struct socket *, struct xsocket *); void protopr(u_long, const char *, int, int); void tcp_stats(u_long, const char *, int, int); void udp_stats(u_long, const char *, int, int); #ifdef SCTP void sctp_protopr(u_long, const char *, int, int); void sctp_stats(u_long, const char *, int, int); #endif void arp_stats(u_long, const char *, int, int); void divert_stats(u_long, const char *, int, int); void ip_stats(u_long, const char *, int, int); void icmp_stats(u_long, const char *, int, int); void igmp_stats(u_long, const char *, int, int); void pim_stats(u_long, const char *, int, int); void carp_stats(u_long, const char *, int, int); void pfsync_stats(u_long, const char *, int, int); #ifdef IPSEC void ipsec_stats(u_long, const char *, int, int); void esp_stats(u_long, const char *, int, int); void ah_stats(u_long, const char *, int, int); void ipcomp_stats(u_long, const char *, int, int); #endif #ifdef INET struct in_addr; char *inetname(struct in_addr *); #endif #ifdef INET6 struct in6_addr; char *inet6name(struct in6_addr *); void ip6_stats(u_long, const char *, int, int); void ip6_ifstats(char *); void icmp6_stats(u_long, const char *, int, int); void icmp6_ifstats(char *); void pim6_stats(u_long, const char *, int, int); void rip6_stats(u_long, const char *, int, int); void mroute6pr(void); void mrt6_stats(void); struct sockaddr_in6; struct in6_addr; void in6_fillscopeid(struct sockaddr_in6 *); void inet6print(const char *, struct in6_addr *, int, const char *, int); #endif /*INET6*/ #ifdef IPSEC void pfkey_stats(u_long, const char *, int, int); #endif void mbpr(void *, u_long); void netisr_stats(void); void hostpr(u_long, u_long); void impstats(u_long, u_long); void intpr(void (*)(char *), int); void pr_family(int); void rt_stats(void); char *routename(struct sockaddr *, int); const char *netname(struct sockaddr *, struct sockaddr *); void routepr(int, int); int p_sockaddr(const char *name, struct sockaddr *sa, struct sockaddr *mask, int flags, int width); const char *fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags); #ifdef NETGRAPH void netgraphprotopr(u_long, const char *, int, int); #endif void unixpr(u_long, u_long, u_long, u_long, u_long, bool *); void mroutepr(void); void mrt_stats(void); void bpf_stats(char *); void nhops_print(int fibnum, int af); void nhgrp_print(int fibnum, int af); diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c index a35e6fd21dc8..630733009eb6 100644 --- a/usr.bin/patch/backupfile.c +++ b/usr.bin/patch/backupfile.c @@ -1,245 +1,244 @@ /*- * Copyright (C) 1990 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify it * without restriction. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * backupfile.c -- make Emacs style backup file names * * David MacKenzie . Some algorithms adapted from GNU Emacs. * * $OpenBSD: backupfile.c,v 1.20 2009/10/27 23:59:41 deraadt Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include "backupfile.h" #define ISDIGIT(c) (isascii ((unsigned char)c) && isdigit ((unsigned char)c)) /* Which type of backup file names are generated. */ enum backup_type backup_type = none; /* * The extension added to file names to produce a simple (as opposed to * numbered) backup file name. */ const char *simple_backup_suffix = "~"; static char *concat(const char *, const char *); static char *make_version_name(const char *, int); static int max_backup_version(const char *, const char *); static int version_number(const char *, const char *, size_t); static int argmatch(const char *, const char **); static void invalid_arg(const char *, const char *, int); /* * Return the name of the new backup file for file FILE, allocated with * malloc. Return 0 if out of memory. FILE must not end with a '/' unless it * is the root directory. Do not call this function if backup_type == none. */ char * find_backup_file_name(const char *file) { char *dir, *base_versions, *tmp_file; int highest_backup; if (backup_type == simple) return concat(file, simple_backup_suffix); tmp_file = strdup(file); if (tmp_file == NULL) return NULL; base_versions = concat(basename(tmp_file), ".~"); free(tmp_file); if (base_versions == NULL) return NULL; tmp_file = strdup(file); if (tmp_file == NULL) { free(base_versions); return NULL; } dir = dirname(tmp_file); if (dir == NULL) { free(base_versions); free(tmp_file); return NULL; } highest_backup = max_backup_version(base_versions, dir); free(base_versions); free(tmp_file); if (backup_type == numbered_existing && highest_backup == 0) return concat(file, simple_backup_suffix); return make_version_name(file, highest_backup + 1); } /* * Return the number of the highest-numbered backup file for file FILE in * directory DIR. If there are no numbered backups of FILE in DIR, or an * error occurs reading DIR, return 0. FILE should already have ".~" appended * to it. */ static int max_backup_version(const char *file, const char *dir) { DIR *dirp; struct dirent *dp; int highest_version, this_version; size_t file_name_length; dirp = opendir(dir); if (dirp == NULL) return 0; highest_version = 0; file_name_length = strlen(file); while ((dp = readdir(dirp)) != NULL) { if (dp->d_namlen <= file_name_length) continue; this_version = version_number(file, dp->d_name, file_name_length); if (this_version > highest_version) highest_version = this_version; } closedir(dirp); return highest_version; } /* * Return a string, allocated with malloc, containing "FILE.~VERSION~". * Return 0 if out of memory. */ static char * make_version_name(const char *file, int version) { char *backup_name; if (asprintf(&backup_name, "%s.~%d~", file, version) == -1) return NULL; return backup_name; } /* * If BACKUP is a numbered backup of BASE, return its version number; * otherwise return 0. BASE_LENGTH is the length of BASE. BASE should * already have ".~" appended to it. */ static int version_number(const char *base, const char *backup, size_t base_length) { int version; const char *p; version = 0; if (!strncmp(base, backup, base_length) && ISDIGIT(backup[base_length])) { for (p = &backup[base_length]; ISDIGIT(*p); ++p) version = version * 10 + *p - '0'; if (p[0] != '~' || p[1]) version = 0; } return version; } /* * Return the newly-allocated concatenation of STR1 and STR2. If out of * memory, return 0. */ static char * concat(const char *str1, const char *str2) { char *newstr; if (asprintf(&newstr, "%s%s", str1, str2) == -1) return NULL; return newstr; } /* * If ARG is an unambiguous match for an element of the null-terminated array * OPTLIST, return the index in OPTLIST of the matched element, else -1 if it * does not match any element or -2 if it is ambiguous (is a prefix of more * than one element). */ static int argmatch(const char *arg, const char **optlist) { int i; /* Temporary index in OPTLIST. */ size_t arglen; /* Length of ARG. */ int matchind = -1; /* Index of first nonexact match. */ int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ arglen = strlen(arg); /* Test all elements for either exact match or abbreviated matches. */ for (i = 0; optlist[i]; i++) { if (!strncmp(optlist[i], arg, arglen)) { if (strlen(optlist[i]) == arglen) /* Exact match found. */ return i; else if (matchind == -1) /* First nonexact match found. */ matchind = i; else /* Second nonexact match found. */ ambiguous = 1; } } if (ambiguous) return -2; else return matchind; } /* * Error reporting for argmatch. KIND is a description of the type of entity * that was being matched. VALUE is the invalid value that was given. PROBLEM * is the return value from argmatch. */ static void invalid_arg(const char *kind, const char *value, int problem) { fprintf(stderr, "patch: "); if (problem == -1) fprintf(stderr, "invalid"); else /* Assume -2. */ fprintf(stderr, "ambiguous"); fprintf(stderr, " %s `%s'\n", kind, value); } static const char *backup_args[] = { "none", "never", "simple", "nil", "existing", "t", "numbered", 0 }; static enum backup_type backup_types[] = { none, simple, simple, numbered_existing, numbered_existing, numbered, numbered }; /* * Return the type of backup indicated by VERSION. Unique abbreviations are * accepted. */ enum backup_type get_version(const char *version) { int i; if (version == NULL || *version == '\0') return numbered_existing; i = argmatch(version, backup_args); if (i >= 0) return backup_types[i]; invalid_arg("version control type", version, i); exit(2); } diff --git a/usr.bin/patch/backupfile.h b/usr.bin/patch/backupfile.h index 71999f75434b..925212be377a 100644 --- a/usr.bin/patch/backupfile.h +++ b/usr.bin/patch/backupfile.h @@ -1,39 +1,38 @@ /*- * Copyright (C) 1990 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify it * without restriction. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. * * backupfile.h -- declarations for making Emacs style backup file names * * $OpenBSD: backupfile.h,v 1.6 2003/07/28 18:35:36 otto Exp $ - * $FreeBSD$ */ /* When to make backup files. */ enum backup_type { /* Never make backups. */ none, /* Make simple backups of every file. */ simple, /* * Make numbered backups of files that already have numbered backups, * and simple backups of the others. */ numbered_existing, /* Make numbered backups of every file. */ numbered }; extern enum backup_type backup_type; extern const char *simple_backup_suffix; char *find_backup_file_name(const char *file); enum backup_type get_version(const char *version); diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h index 3253df27e684..0e73bd897674 100644 --- a/usr.bin/patch/common.h +++ b/usr.bin/patch/common.h @@ -1,112 +1,111 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: common.h,v 1.26 2006/03/11 19:41:30 otto Exp $ - * $FreeBSD$ */ #include #include #include #define DEBUGGING /* constants */ #define MAXHUNKSIZE 200000 /* is this enough lines? */ #define INITHUNKMAX 125 /* initial dynamic allocation size */ #define INITLINELEN 4096 #define BUFFERSIZE 4096 #define LINENUM_MAX LONG_MAX #define ORIGEXT ".orig" #define REJEXT ".rej" /* handy definitions */ #define strEQ(s1,s2) (strcmp(s1, s2) == 0) #define strnNE(s1,s2,l) (strncmp(s1, s2, l) != 0) #define strnEQ(s1,s2,l) (strncmp(s1, s2, l) == 0) /* typedefs */ typedef long LINENUM; /* must be signed */ /* globals */ extern mode_t filemode; extern char *buf; /* general purpose buffer */ extern size_t buf_size; /* size of general purpose buffer */ extern bool using_plan_a; /* try to keep everything in memory */ extern bool out_of_mem; /* ran out of memory in plan a */ extern bool nonempty_patchf_seen; /* seen a non-zero-length patch file? */ #define MAXFILEC 2 extern char *filearg[MAXFILEC]; extern bool ok_to_create_file; extern char *outname; extern char *origprae; extern char *TMPOUTNAME; extern char *TMPINNAME; extern char *TMPREJNAME; extern char *TMPPATNAME; extern bool toutkeep; extern bool trejkeep; #ifdef DEBUGGING extern int debug; #endif extern bool force; extern bool batch; extern bool verbose; extern bool reverse; extern bool noreverse; extern bool skip_rest_of_patch; extern int strippath; extern bool canonicalize; /* TRUE if -C was specified on command line. */ extern bool check_only; extern bool warn_on_invalid_line; extern bool last_line_missing_eol; #define CONTEXT_DIFF 1 #define NORMAL_DIFF 2 #define ED_DIFF 3 #define NEW_CONTEXT_DIFF 4 #define UNI_DIFF 5 extern int diff_type; extern char *revision; /* prerequisite revision, if any */ extern LINENUM input_lines; /* how long is input file in lines */ extern int posix; diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c index 99be70957f06..24fdcac1b7c6 100644 --- a/usr.bin/patch/inp.c +++ b/usr.bin/patch/inp.c @@ -1,438 +1,437 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: inp.c,v 1.44 2015/07/26 14:32:19 millert Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "util.h" #include "pch.h" #include "inp.h" /* Input-file-with-indexable-lines abstract type */ static size_t i_size; /* size of the input file */ static char *i_womp; /* plan a buffer for entire file */ static char **i_ptr; /* pointers to lines in i_womp */ static char empty_line[] = { '\0' }; static int tifd = -1; /* plan b virtual string array */ static char *tibuf[2]; /* plan b buffers */ static LINENUM tiline[2] = {-1, -1}; /* 1st line in each buffer */ static size_t lines_per_buf; /* how many lines per buffer */ static size_t tibuflen; /* plan b buffer length */ static size_t tireclen; /* length of records in tmp file */ static bool rev_in_string(const char *); static bool reallocate_lines(size_t *); /* returns false if insufficient memory */ static bool plan_a(const char *); static void plan_b(const char *); /* New patch--prepare to edit another file. */ void re_input(void) { if (using_plan_a) { free(i_ptr); i_ptr = NULL; if (i_womp != NULL) { munmap(i_womp, i_size); i_womp = NULL; } i_size = 0; } else { using_plan_a = true; /* maybe the next one is smaller */ close(tifd); tifd = -1; free(tibuf[0]); free(tibuf[1]); tibuf[0] = tibuf[1] = NULL; tiline[0] = tiline[1] = -1; tireclen = 0; } } /* Construct the line index, somehow or other. */ void scan_input(const char *filename) { if (!plan_a(filename)) plan_b(filename); if (verbose) { say("Patching file %s using Plan %s...\n", filename, (using_plan_a ? "A" : "B")); } } static bool reallocate_lines(size_t *lines_allocated) { char **p; size_t new_size; new_size = *lines_allocated * 3 / 2; p = reallocarray(i_ptr, new_size + 2, sizeof(char *)); if (p == NULL) { /* shucks, it was a near thing */ munmap(i_womp, i_size); i_womp = NULL; free(i_ptr); i_ptr = NULL; *lines_allocated = 0; return false; } *lines_allocated = new_size; i_ptr = p; return true; } /* Try keeping everything in memory. */ static bool plan_a(const char *filename) { int ifd, statfailed; char *p, *s; struct stat filestat; ptrdiff_t sz; size_t i; size_t iline, lines_allocated; #ifdef DEBUGGING if (debug & 8) return false; #endif if (filename == NULL || *filename == '\0') return false; statfailed = stat(filename, &filestat); if (statfailed && ok_to_create_file) { if (verbose) say("(Creating file %s...)\n", filename); /* * in check_patch case, we still display `Creating file' even * though we're not. The rule is that -C should be as similar * to normal patch behavior as possible */ if (check_only) return true; makedirs(filename, true); close(creat(filename, 0666)); statfailed = stat(filename, &filestat); } if (statfailed) fatal("can't find %s\n", filename); filemode = filestat.st_mode; if (!S_ISREG(filemode)) fatal("%s is not a normal file--can't patch\n", filename); if ((uint64_t)filestat.st_size > SIZE_MAX) { say("block too large to mmap\n"); return false; } i_size = (size_t)filestat.st_size; if (out_of_mem) { set_hunkmax(); /* make sure dynamic arrays are allocated */ out_of_mem = false; return false; /* force plan b because plan a bombed */ } if ((ifd = open(filename, O_RDONLY)) < 0) pfatal("can't open file %s", filename); if (i_size) { i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0); if (i_womp == MAP_FAILED) { perror("mmap failed"); i_womp = NULL; close(ifd); return false; } } else { i_womp = NULL; } close(ifd); if (i_size) madvise(i_womp, i_size, MADV_SEQUENTIAL); /* estimate the number of lines */ lines_allocated = i_size / 25; if (lines_allocated < 100) lines_allocated = 100; if (!reallocate_lines(&lines_allocated)) return false; /* now scan the buffer and build pointer array */ iline = 1; i_ptr[iline] = i_womp; /* * Testing for NUL here actively breaks files that innocently use NUL * for other reasons. mmap(2) succeeded, just scan the whole buffer. */ for (s = i_womp, i = 0; i < i_size; s++, i++) { if (*s == '\n') { if (iline == lines_allocated) { if (!reallocate_lines(&lines_allocated)) return false; } /* these are NOT NUL terminated */ i_ptr[++iline] = s + 1; } } /* if the last line contains no EOL, append one */ if (i_size > 0 && i_womp[i_size - 1] != '\n') { last_line_missing_eol = true; /* fix last line */ sz = s - i_ptr[iline]; p = malloc(sz + 1); if (p == NULL) { free(i_ptr); i_ptr = NULL; munmap(i_womp, i_size); i_womp = NULL; return false; } memcpy(p, i_ptr[iline], sz); p[sz] = '\n'; i_ptr[iline] = p; /* count the extra line and make it point to some valid mem */ i_ptr[++iline] = empty_line; } else last_line_missing_eol = false; input_lines = iline - 1; /* now check for revision, if any */ if (revision != NULL) { if (i_womp == NULL || !rev_in_string(i_womp)) { if (force) { if (verbose) say("Warning: this file doesn't appear " "to be the %s version--patching anyway.\n", revision); } else if (batch) { fatal("this file doesn't appear to be the " "%s version--aborting.\n", revision); } else { ask("This file doesn't appear to be the " "%s version--patch anyway? [n] ", revision); if (*buf != 'y') fatal("aborted\n"); } } else if (verbose) say("Good. This file appears to be the %s version.\n", revision); } return true; /* plan a will work */ } /* Keep (virtually) nothing in memory. */ static void plan_b(const char *filename) { FILE *ifp; size_t i, j, len, maxlen; char *lbuf = NULL, *p; bool found_revision = (revision == NULL); using_plan_a = false; if ((ifp = fopen(filename, "r")) == NULL) pfatal("can't open file %s", filename); unlink(TMPINNAME); if ((tifd = open(TMPINNAME, O_EXCL | O_CREAT | O_WRONLY, 0666)) < 0) pfatal("can't open file %s", TMPINNAME); len = 0; maxlen = 1; while ((p = fgetln(ifp, &len)) != NULL) { if (p[len - 1] == '\n') p[len - 1] = '\0'; else { /* EOF without EOL, copy and add the NUL */ if ((lbuf = malloc(len + 1)) == NULL) fatal("out of memory\n"); memcpy(lbuf, p, len); lbuf[len] = '\0'; p = lbuf; last_line_missing_eol = true; len++; } if (revision != NULL && !found_revision && rev_in_string(p)) found_revision = true; if (len > maxlen) maxlen = len; /* find longest line */ } free(lbuf); if (ferror(ifp)) pfatal("can't read file %s", filename); if (revision != NULL) { if (!found_revision) { if (force) { if (verbose) say("Warning: this file doesn't appear " "to be the %s version--patching anyway.\n", revision); } else if (batch) { fatal("this file doesn't appear to be the " "%s version--aborting.\n", revision); } else { ask("This file doesn't appear to be the %s " "version--patch anyway? [n] ", revision); if (*buf != 'y') fatal("aborted\n"); } } else if (verbose) say("Good. This file appears to be the %s version.\n", revision); } fseek(ifp, 0L, SEEK_SET); /* rewind file */ tireclen = maxlen; tibuflen = maxlen > BUFFERSIZE ? maxlen : BUFFERSIZE; lines_per_buf = tibuflen / maxlen; tibuf[0] = malloc(tibuflen + 1); if (tibuf[0] == NULL) fatal("out of memory\n"); tibuf[1] = malloc(tibuflen + 1); if (tibuf[1] == NULL) fatal("out of memory\n"); for (i = 1;; i++) { p = tibuf[0] + maxlen * (i % lines_per_buf); if (i % lines_per_buf == 0) /* new block */ if (write(tifd, tibuf[0], tibuflen) != (ssize_t) tibuflen) pfatal("can't write temp file"); if (fgets(p, maxlen + 1, ifp) == NULL) { input_lines = i - 1; if (i % lines_per_buf != 0) if (write(tifd, tibuf[0], tibuflen) != (ssize_t) tibuflen) pfatal("can't write temp file"); break; } j = strlen(p); /* These are '\n' terminated strings, so no need to add a NUL */ if (j == 0 || p[j - 1] != '\n') p[j] = '\n'; } fclose(ifp); close(tifd); if ((tifd = open(TMPINNAME, O_RDONLY)) < 0) pfatal("can't reopen file %s", TMPINNAME); } /* * Fetch a line from the input file, \n terminated, not necessarily \0. */ char * ifetch(LINENUM line, int whichbuf) { if (line < 1 || line > input_lines) { if (warn_on_invalid_line) { say("No such line %ld in input file, ignoring\n", line); warn_on_invalid_line = false; } return NULL; } if (using_plan_a) return i_ptr[line]; else { LINENUM offline = line % lines_per_buf; LINENUM baseline = line - offline; if (tiline[0] == baseline) whichbuf = 0; else if (tiline[1] == baseline) whichbuf = 1; else { tiline[whichbuf] = baseline; if (lseek(tifd, (off_t) (baseline / lines_per_buf * tibuflen), SEEK_SET) < 0) pfatal("cannot seek in the temporary input file"); if (read(tifd, tibuf[whichbuf], tibuflen) != (ssize_t) tibuflen) pfatal("error reading tmp file %s", TMPINNAME); } return tibuf[whichbuf] + (tireclen * offline); } } /* * True if the string argument contains the revision number we want. */ static bool rev_in_string(const char *string) { const char *s; size_t patlen; if (revision == NULL) return true; patlen = strlen(revision); if (strnEQ(string, revision, patlen) && isspace((unsigned char)string[patlen])) return true; for (s = string; *s; s++) { if (isspace((unsigned char)*s) && strnEQ(s + 1, revision, patlen) && isspace((unsigned char)s[patlen + 1])) { return true; } } return false; } diff --git a/usr.bin/patch/inp.h b/usr.bin/patch/inp.h index 062798a69269..bfdc88a8c570 100644 --- a/usr.bin/patch/inp.h +++ b/usr.bin/patch/inp.h @@ -1,32 +1,31 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: inp.h,v 1.8 2003/08/15 08:00:51 otto Exp $ - * $FreeBSD$ */ void re_input(void); void scan_input(const char *); char *ifetch(LINENUM, int); diff --git a/usr.bin/patch/mkpath.c b/usr.bin/patch/mkpath.c index 2214d4d42e43..0fbd58a759a8 100644 --- a/usr.bin/patch/mkpath.c +++ b/usr.bin/patch/mkpath.c @@ -1,80 +1,79 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $OpenBSD: mkpath.c,v 1.2 2005/06/20 07:14:06 otto Exp $ - * $FreeBSD$ */ #include #include #include #include #include int mkpath(char *); /* Code taken directly from mkdir(1). * mkpath -- create directories. * path - path */ int mkpath(char *path) { struct stat sb; char *slash; int done = 0; slash = path; while (!done) { slash += strspn(slash, "/"); slash += strcspn(slash, "/"); done = (*slash == '\0'); *slash = '\0'; if (stat(path, &sb)) { if (errno != ENOENT || (mkdir(path, 0777) && errno != EEXIST)) { warn("%s", path); return (-1); } } else if (!S_ISDIR(sb.st_mode)) { warnx("%s: %s", path, strerror(ENOTDIR)); return (-1); } *slash = '/'; } return (0); } diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index 48d3bd37fe5b..ecaf799fe9b6 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,1226 +1,1225 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: patch.c,v 1.54 2014/12/13 10:31:07 tobias Exp $ - * $FreeBSD$ * */ #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "util.h" #include "pch.h" #include "inp.h" #include "backupfile.h" #include "pathnames.h" mode_t filemode = 0644; char *buf; /* general purpose buffer */ size_t buf_size; /* size of the general purpose buffer */ bool using_plan_a = true; /* try to keep everything in memory */ bool out_of_mem = false; /* ran out of memory in plan a */ bool nonempty_patchf_seen = false; /* seen nonempty patch file? */ #define MAXFILEC 2 char *filearg[MAXFILEC]; bool ok_to_create_file = false; char *outname = NULL; char *origprae = NULL; char *TMPOUTNAME; char *TMPINNAME; char *TMPREJNAME; char *TMPPATNAME; bool toutkeep = false; bool trejkeep = false; bool warn_on_invalid_line; bool last_line_missing_eol; #ifdef DEBUGGING int debug = 0; #endif bool force = false; bool batch = false; bool verbose = true; bool reverse = false; bool noreverse = false; bool skip_rest_of_patch = false; int strippath = 957; bool canonicalize = false; bool check_only = false; int diff_type = 0; char *revision = NULL; /* prerequisite revision, if any */ LINENUM input_lines = 0; /* how long is input file in lines */ int posix = 0; /* strict POSIX mode? */ static void reinitialize_almost_everything(void); static void get_some_switches(void); static LINENUM locate_hunk(LINENUM); static void abort_context_hunk(void); static void rej_line(int, LINENUM); static void abort_hunk(void); static void apply_hunk(LINENUM); static void init_output(const char *); static void init_reject(const char *); static void copy_till(LINENUM, bool); static bool spew_output(void); static void dump_line(LINENUM, bool); static bool patch_match(LINENUM, LINENUM, LINENUM); static bool similar(const char *, const char *, int); static void usage(void); static bool handle_creation(bool, bool *); /* true if -E was specified on command line. */ static bool remove_empty_files = false; /* true if -R was specified on command line. */ static bool reverse_flag_specified = false; static bool Vflag = false; /* buffer holding the name of the rejected patch file. */ static char rejname[PATH_MAX]; /* how many input lines have been irretractibly output */ static LINENUM last_frozen_line = 0; static int Argc; /* guess */ static char **Argv; static int Argc_last; /* for restarting plan_b */ static char **Argv_last; static FILE *ofp = NULL; /* output file pointer */ static FILE *rejfp = NULL; /* reject file pointer */ static int filec = 0; /* how many file arguments? */ static LINENUM last_offset = 0; static LINENUM maxfuzz = 2; /* patch using ifdef, ifndef, etc. */ static bool do_defines = false; /* #ifdef xyzzy */ static char if_defined[128]; /* #ifndef xyzzy */ static char not_defined[128]; /* #else */ static const char else_defined[] = "#else\n"; /* #endif xyzzy */ static char end_defined[128]; /* Apply a set of diffs as appropriate. */ int main(int argc, char *argv[]) { struct stat statbuf; int error = 0, hunk, failed, i, fd; bool out_creating, out_existed, patch_seen, remove_file; bool reverse_seen; LINENUM where = 0, newwhere, fuzz, mymaxfuzz; const char *tmpdir; char *v; setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); for (i = 0; i < MAXFILEC; i++) filearg[i] = NULL; buf_size = INITLINELEN; buf = malloc((unsigned)(buf_size)); if (buf == NULL) fatal("out of memory\n"); /* Cons up the names of the temporary files. */ if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') tmpdir = _PATH_TMP; for (i = strlen(tmpdir) - 1; i > 0 && tmpdir[i] == '/'; i--) ; i++; if (asprintf(&TMPOUTNAME, "%.*s/patchoXXXXXXXXXX", i, tmpdir) == -1) fatal("cannot allocate memory"); if ((fd = mkstemp(TMPOUTNAME)) < 0) pfatal("can't create %s", TMPOUTNAME); close(fd); if (asprintf(&TMPINNAME, "%.*s/patchiXXXXXXXXXX", i, tmpdir) == -1) fatal("cannot allocate memory"); if ((fd = mkstemp(TMPINNAME)) < 0) pfatal("can't create %s", TMPINNAME); close(fd); if (asprintf(&TMPREJNAME, "%.*s/patchrXXXXXXXXXX", i, tmpdir) == -1) fatal("cannot allocate memory"); if ((fd = mkstemp(TMPREJNAME)) < 0) pfatal("can't create %s", TMPREJNAME); close(fd); if (asprintf(&TMPPATNAME, "%.*s/patchpXXXXXXXXXX", i, tmpdir) == -1) fatal("cannot allocate memory"); if ((fd = mkstemp(TMPPATNAME)) < 0) pfatal("can't create %s", TMPPATNAME); close(fd); v = getenv("SIMPLE_BACKUP_SUFFIX"); if (v) simple_backup_suffix = v; else simple_backup_suffix = ORIGEXT; /* parse switches */ Argc = argc; Argv = argv; get_some_switches(); if (!Vflag) { if ((v = getenv("PATCH_VERSION_CONTROL")) == NULL) v = getenv("VERSION_CONTROL"); if (v != NULL || !posix) backup_type = get_version(v); /* OK to pass NULL. */ } /* make sure we clean up /tmp in case of disaster */ set_signals(0); patch_seen = false; for (open_patch_file(filearg[1]); there_is_another_patch(); reinitialize_almost_everything()) { /* for each patch in patch file */ if (source_file != NULL && (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF || diff_type == UNI_DIFF)) out_creating = strcmp(source_file, _PATH_DEVNULL) == 0; else out_creating = false; patch_seen = true; warn_on_invalid_line = true; if (outname == NULL) outname = xstrdup(filearg[0]); /* * At this point, we know if we're supposed to be creating the * file and we know if we should be trying to handle a conflict * between the patch and the file already existing. We defer * handling it until hunk processing because we want to swap * the hunk if they opt to reverse it, but we want to make sure * we *can* swap the hunk without running into memory issues * before we offer it. We also want to be verbose if flags or * user decision cause us to skip -- this is explained a little * more later. */ out_existed = stat(outname, &statbuf) == 0; /* for ed script just up and do it and exit */ if (diff_type == ED_DIFF) { do_ed_script(); continue; } /* initialize the patched file */ if (!skip_rest_of_patch) init_output(TMPOUTNAME); /* initialize reject file */ init_reject(TMPREJNAME); /* find out where all the lines are */ if (!skip_rest_of_patch) scan_input(filearg[0]); /* * from here on, open no standard i/o files, because * malloc might misfire and we can't catch it easily */ /* apply each hunk of patch */ hunk = 0; failed = 0; reverse_seen = false; out_of_mem = false; remove_file = false; while (another_hunk()) { assert(!out_creating || hunk == 0); hunk++; fuzz = 0; /* * There are only three cases in handle_creation() that * results in us skipping hunk location, in order: * * 1.) Potentially reversed but -f/--force'd, * 2.) Potentially reversed but -N/--forward'd * 3.) Reversed and the user's opted to not apply it. * * In all three cases, we still want to inform the user * that we're ignoring it in the standard way, which is * also tied to this hunk processing loop. */ if (out_creating) reverse_seen = handle_creation(out_existed, &remove_file); mymaxfuzz = pch_context(); if (maxfuzz < mymaxfuzz) mymaxfuzz = maxfuzz; if (!skip_rest_of_patch) { do { where = locate_hunk(fuzz); if (hunk == 1 && where == 0 && !force && !reverse_seen) { /* dwim for reversed patch? */ if (!pch_swap()) { if (fuzz == 0) say("Not enough memory to try swapped hunk! Assuming unswapped.\n"); continue; } reverse = !reverse; /* try again */ where = locate_hunk(fuzz); if (where == 0) { /* didn't find it swapped */ if (!pch_swap()) /* put it back to normal */ fatal("lost hunk on alloc error!\n"); reverse = !reverse; } else if (noreverse) { if (!pch_swap()) /* put it back to normal */ fatal("lost hunk on alloc error!\n"); reverse = !reverse; say("Ignoring previously applied (or reversed) patch.\n"); skip_rest_of_patch = true; } else if (batch) { if (verbose) say("%seversed (or previously applied) patch detected! %s -R.", reverse ? "R" : "Unr", reverse ? "Assuming" : "Ignoring"); } else { ask("%seversed (or previously applied) patch detected! %s -R? [y] ", reverse ? "R" : "Unr", reverse ? "Assume" : "Ignore"); if (*buf == 'n') { ask("Apply anyway? [n] "); if (*buf != 'y') skip_rest_of_patch = true; else reverse_seen = true; where = 0; reverse = !reverse; if (!pch_swap()) /* put it back to normal */ fatal("lost hunk on alloc error!\n"); } } } } while (!skip_rest_of_patch && where == 0 && ++fuzz <= mymaxfuzz); if (skip_rest_of_patch) { /* just got decided */ if (ferror(ofp) || fclose(ofp)) { say("Error writing %s\n", TMPOUTNAME); error = 1; } ofp = NULL; } } newwhere = pch_newfirst() + last_offset; if (skip_rest_of_patch) { abort_hunk(); failed++; if (verbose) say("Hunk #%d ignored at %ld.\n", hunk, newwhere); } else if (where == 0) { abort_hunk(); failed++; if (verbose) say("Hunk #%d failed at %ld.\n", hunk, newwhere); } else { apply_hunk(where); if (verbose) { say("Hunk #%d succeeded at %ld", hunk, newwhere); if (fuzz != 0) say(" with fuzz %ld", fuzz); if (last_offset) say(" (offset %ld line%s)", last_offset, last_offset == 1L ? "" : "s"); say(".\n"); } } } if (out_of_mem && using_plan_a) { Argc = Argc_last; Argv = Argv_last; say("\n\nRan out of memory using Plan A--trying again...\n\n"); if (ofp) fclose(ofp); ofp = NULL; if (rejfp) fclose(rejfp); rejfp = NULL; continue; } if (hunk == 0) fatal("Internal error: hunk should not be 0\n"); /* finish spewing out the new file */ if (!skip_rest_of_patch && !spew_output()) { say("Can't write %s\n", TMPOUTNAME); error = 1; } /* and put the output where desired */ ignore_signals(); if (!skip_rest_of_patch) { char *realout = outname; if (!check_only) { if (move_file(TMPOUTNAME, outname) < 0) { toutkeep = true; realout = TMPOUTNAME; chmod(TMPOUTNAME, filemode); } else chmod(outname, filemode); /* * remove_file is a per-patch flag indicating * whether it's OK to remove the empty file. * This is specifically set when we're reversing * the creation of a file and it ends up empty. * This is an exception to the global policy * (remove_empty_files) because the user would * likely not expect the reverse of file * creation to leave an empty file laying * around. */ if ((remove_empty_files || remove_file) && stat(realout, &statbuf) == 0 && statbuf.st_size == 0) { if (verbose) say("Removing %s (empty after patching).\n", realout); unlink(realout); } } } if (ferror(rejfp) || fclose(rejfp)) { say("Error writing %s\n", rejname); error = 1; } rejfp = NULL; if (failed) { error = 1; if (*rejname == '\0') { if (strlcpy(rejname, outname, sizeof(rejname)) >= sizeof(rejname)) fatal("filename %s is too long\n", outname); if (strlcat(rejname, REJEXT, sizeof(rejname)) >= sizeof(rejname)) fatal("filename %s is too long\n", outname); } if (!check_only) say("%d out of %d hunks %s--saving rejects to %s\n", failed, hunk, skip_rest_of_patch ? "ignored" : "failed", rejname); else if (filearg[0] != NULL) say("%d out of %d hunks %s while patching %s\n", failed, hunk, skip_rest_of_patch ? "ignored" : "failed", filearg[0]); else /* File prompt ignored, just note # hunks. */ say("%d out of %d hunks %s\n", failed, hunk, skip_rest_of_patch ? "ignored" : "failed"); if (!check_only && move_file(TMPREJNAME, rejname) < 0) trejkeep = true; } set_signals(1); } if (!patch_seen && nonempty_patchf_seen) error = 2; my_exit(error); /* NOTREACHED */ } /* Prepare to find the next patch to do in the patch file. */ static void reinitialize_almost_everything(void) { re_patch(); re_input(); input_lines = 0; last_frozen_line = 0; filec = 0; if (!out_of_mem) { free(filearg[0]); filearg[0] = NULL; } free(source_file); source_file = NULL; free(outname); outname = NULL; last_offset = 0; diff_type = 0; free(revision); revision = NULL; reverse = reverse_flag_specified; skip_rest_of_patch = false; get_some_switches(); } /* Process switches and filenames. */ static void get_some_switches(void) { const char *options = "b::B:cCd:D:eEfF:i:lnNo:p:r:RstuvV:x:z:"; static struct option longopts[] = { {"backup", no_argument, 0, 'b'}, {"batch", no_argument, 0, 't'}, {"check", no_argument, 0, 'C'}, {"context", no_argument, 0, 'c'}, {"debug", required_argument, 0, 'x'}, {"directory", required_argument, 0, 'd'}, {"dry-run", no_argument, 0, 'C'}, {"ed", no_argument, 0, 'e'}, {"force", no_argument, 0, 'f'}, {"forward", no_argument, 0, 'N'}, {"fuzz", required_argument, 0, 'F'}, {"ifdef", required_argument, 0, 'D'}, {"input", required_argument, 0, 'i'}, {"ignore-whitespace", no_argument, 0, 'l'}, {"normal", no_argument, 0, 'n'}, {"output", required_argument, 0, 'o'}, {"prefix", required_argument, 0, 'B'}, {"quiet", no_argument, 0, 's'}, {"reject-file", required_argument, 0, 'r'}, {"remove-empty-files", no_argument, 0, 'E'}, {"reverse", no_argument, 0, 'R'}, {"silent", no_argument, 0, 's'}, {"strip", required_argument, 0, 'p'}, {"suffix", required_argument, 0, 'z'}, {"unified", no_argument, 0, 'u'}, {"version", no_argument, 0, 'v'}, {"version-control", required_argument, 0, 'V'}, {"posix", no_argument, &posix, 1}, {NULL, 0, 0, 0} }; int ch; rejname[0] = '\0'; Argc_last = Argc; Argv_last = Argv; if (!Argc) return; optreset = optind = 1; while ((ch = getopt_long(Argc, Argv, options, longopts, NULL)) != -1) { switch (ch) { case 'b': if (backup_type == none) backup_type = numbered_existing; if (optarg == NULL) break; if (verbose) say("Warning, the ``-b suffix'' option has been" " obsoleted by the -z option.\n"); /* FALLTHROUGH */ case 'z': /* must directly follow 'b' case for backwards compat */ simple_backup_suffix = xstrdup(optarg); break; case 'B': origprae = xstrdup(optarg); break; case 'c': diff_type = CONTEXT_DIFF; break; case 'C': check_only = true; break; case 'd': if (chdir(optarg) < 0) pfatal("can't cd to %s", optarg); break; case 'D': do_defines = true; if (!isalpha((unsigned char)*optarg) && *optarg != '_') fatal("argument to -D is not an identifier\n"); snprintf(if_defined, sizeof if_defined, "#ifdef %s\n", optarg); snprintf(not_defined, sizeof not_defined, "#ifndef %s\n", optarg); snprintf(end_defined, sizeof end_defined, "#endif /* %s */\n", optarg); break; case 'e': diff_type = ED_DIFF; break; case 'E': remove_empty_files = true; break; case 'f': force = true; break; case 'F': maxfuzz = atoi(optarg); break; case 'i': if (++filec == MAXFILEC) fatal("too many file arguments\n"); filearg[filec] = xstrdup(optarg); break; case 'l': canonicalize = true; break; case 'n': diff_type = NORMAL_DIFF; break; case 'N': noreverse = true; break; case 'o': outname = xstrdup(optarg); break; case 'p': strippath = atoi(optarg); break; case 'r': if (strlcpy(rejname, optarg, sizeof(rejname)) >= sizeof(rejname)) fatal("argument for -r is too long\n"); break; case 'R': reverse = true; reverse_flag_specified = true; break; case 's': verbose = false; break; case 't': batch = true; break; case 'u': diff_type = UNI_DIFF; break; case 'v': version(); break; case 'V': backup_type = get_version(optarg); Vflag = true; break; #ifdef DEBUGGING case 'x': debug = atoi(optarg); break; #endif default: if (ch != '\0') usage(); break; } } Argc -= optind; Argv += optind; if (Argc > 0) { filearg[0] = xstrdup(*Argv++); Argc--; while (Argc > 0) { if (++filec == MAXFILEC) fatal("too many file arguments\n"); filearg[filec] = xstrdup(*Argv++); Argc--; } } if (getenv("POSIXLY_CORRECT") != NULL) posix = 1; } static void usage(void) { fprintf(stderr, "usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory]\n" " [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count]\n" " [-r rej-name] [-V t | nil | never | none] [-x number]\n" " [-z backup-ext] [--posix] [origfile [patchfile]]\n" " patch = first_guess) /* do not try lines < 0 */ max_neg_offset = first_guess - 1; if (first_guess <= input_lines && patch_match(first_guess, 0, fuzz)) return first_guess; for (offset = 1; ; offset++) { bool check_after = (offset <= max_pos_offset); bool check_before = (offset <= max_neg_offset); if (check_after && patch_match(first_guess, offset, fuzz)) { #ifdef DEBUGGING if (debug & 1) say("Offset changing from %ld to %ld\n", last_offset, offset); #endif last_offset = offset; return first_guess + offset; } else if (check_before && patch_match(first_guess, -offset, fuzz)) { #ifdef DEBUGGING if (debug & 1) say("Offset changing from %ld to %ld\n", last_offset, -offset); #endif last_offset = -offset; return first_guess - offset; } else if (!check_before && !check_after) return 0; } } /* We did not find the pattern, dump out the hunk so they can handle it. */ static void abort_context_hunk(void) { LINENUM i; const LINENUM pat_end = pch_end(); /* * add in last_offset to guess the same as the previous successful * hunk */ const LINENUM oldfirst = pch_first() + last_offset; const LINENUM newfirst = pch_newfirst() + last_offset; const LINENUM oldlast = oldfirst + pch_ptrn_lines() - 1; const LINENUM newlast = newfirst + pch_repl_lines() - 1; const char *stars = (diff_type >= NEW_CONTEXT_DIFF ? " ****" : ""); const char *minuses = (diff_type >= NEW_CONTEXT_DIFF ? " ----" : " -----"); fprintf(rejfp, "***************\n"); for (i = 0; i <= pat_end; i++) { switch (pch_char(i)) { case '*': if (oldlast < oldfirst) fprintf(rejfp, "*** 0%s\n", stars); else if (oldlast == oldfirst) fprintf(rejfp, "*** %ld%s\n", oldfirst, stars); else fprintf(rejfp, "*** %ld,%ld%s\n", oldfirst, oldlast, stars); break; case '=': if (newlast < newfirst) fprintf(rejfp, "--- 0%s\n", minuses); else if (newlast == newfirst) fprintf(rejfp, "--- %ld%s\n", newfirst, minuses); else fprintf(rejfp, "--- %ld,%ld%s\n", newfirst, newlast, minuses); break; case '\n': fprintf(rejfp, "%s", pfetch(i)); break; case ' ': case '-': case '+': case '!': fprintf(rejfp, "%c %s", pch_char(i), pfetch(i)); break; default: fatal("fatal internal error in abort_context_hunk\n"); } } } static void rej_line(int ch, LINENUM i) { size_t len; const char *line = pfetch(i); len = strlen(line); fprintf(rejfp, "%c%s", ch, line); if (len == 0 || line[len - 1] != '\n') { if (len >= USHRT_MAX) fprintf(rejfp, "\n\\ Line too long\n"); else fprintf(rejfp, "\n\\ No newline at end of line\n"); } } static void abort_hunk(void) { LINENUM i, j, split; int ch1, ch2; const LINENUM pat_end = pch_end(); const LINENUM oldfirst = pch_first() + last_offset; const LINENUM newfirst = pch_newfirst() + last_offset; if (diff_type != UNI_DIFF) { abort_context_hunk(); return; } split = -1; for (i = 0; i <= pat_end; i++) { if (pch_char(i) == '=') { split = i; break; } } if (split == -1) { fprintf(rejfp, "malformed hunk: no split found\n"); return; } i = 0; j = split + 1; fprintf(rejfp, "@@ -%ld,%ld +%ld,%ld @@\n", pch_ptrn_lines() ? oldfirst : 0, pch_ptrn_lines(), newfirst, pch_repl_lines()); while (i < split || j <= pat_end) { ch1 = i < split ? pch_char(i) : -1; ch2 = j <= pat_end ? pch_char(j) : -1; if (ch1 == '-') { rej_line('-', i); i++; } else if (ch1 == ' ' && ch2 == ' ') { rej_line(' ', i); i++; j++; } else if (ch1 == '!' && ch2 == '!') { while (i < split && ch1 == '!') { rej_line('-', i); i++; ch1 = i < split ? pch_char(i) : -1; } while (j <= pat_end && ch2 == '!') { rej_line('+', j); j++; ch2 = j <= pat_end ? pch_char(j) : -1; } } else if (ch1 == '*') { i++; } else if (ch2 == '+' || ch2 == ' ') { rej_line(ch2, j); j++; } else { fprintf(rejfp, "internal error on (%ld %ld %ld)\n", i, split, j); rej_line(ch1, i); rej_line(ch2, j); return; } } } /* We found where to apply it (we hope), so do it. */ static void apply_hunk(LINENUM where) { LINENUM old = 1; const LINENUM lastline = pch_ptrn_lines(); LINENUM new = lastline + 1; #define OUTSIDE 0 #define IN_IFNDEF 1 #define IN_IFDEF 2 #define IN_ELSE 3 int def_state = OUTSIDE; const LINENUM pat_end = pch_end(); where--; while (pch_char(new) == '=' || pch_char(new) == '\n') new++; while (old <= lastline) { if (pch_char(old) == '-') { copy_till(where + old - 1, false); if (do_defines) { if (def_state == OUTSIDE) { fputs(not_defined, ofp); def_state = IN_IFNDEF; } else if (def_state == IN_IFDEF) { fputs(else_defined, ofp); def_state = IN_ELSE; } fputs(pfetch(old), ofp); } last_frozen_line++; old++; } else if (new > pat_end) { break; } else if (pch_char(new) == '+') { copy_till(where + old - 1, false); if (do_defines) { if (def_state == IN_IFNDEF) { fputs(else_defined, ofp); def_state = IN_ELSE; } else if (def_state == OUTSIDE) { fputs(if_defined, ofp); def_state = IN_IFDEF; } } fputs(pfetch(new), ofp); new++; } else if (pch_char(new) != pch_char(old)) { say("Out-of-sync patch, lines %ld,%ld--mangled text or line numbers, maybe?\n", pch_hunk_beg() + old, pch_hunk_beg() + new); #ifdef DEBUGGING say("oldchar = '%c', newchar = '%c'\n", pch_char(old), pch_char(new)); #endif my_exit(2); } else if (pch_char(new) == '!') { copy_till(where + old - 1, false); if (do_defines) { fputs(not_defined, ofp); def_state = IN_IFNDEF; } while (pch_char(old) == '!') { if (do_defines) { fputs(pfetch(old), ofp); } last_frozen_line++; old++; } if (do_defines) { fputs(else_defined, ofp); def_state = IN_ELSE; } while (pch_char(new) == '!') { fputs(pfetch(new), ofp); new++; } } else { if (pch_char(new) != ' ') fatal("Internal error: expected ' '\n"); old++; new++; if (do_defines && def_state != OUTSIDE) { fputs(end_defined, ofp); def_state = OUTSIDE; } } } if (new <= pat_end && pch_char(new) == '+') { copy_till(where + old - 1, false); if (do_defines) { if (def_state == OUTSIDE) { fputs(if_defined, ofp); def_state = IN_IFDEF; } else if (def_state == IN_IFNDEF) { fputs(else_defined, ofp); def_state = IN_ELSE; } } while (new <= pat_end && pch_char(new) == '+') { fputs(pfetch(new), ofp); new++; } } if (do_defines && def_state != OUTSIDE) { fputs(end_defined, ofp); } } /* * Open the new file. */ static void init_output(const char *name) { ofp = fopen(name, "w"); if (ofp == NULL) pfatal("can't create %s", name); } /* * Open a file to put hunks we can't locate. */ static void init_reject(const char *name) { rejfp = fopen(name, "w"); if (rejfp == NULL) pfatal("can't create %s", name); } /* * Copy input file to output, up to wherever hunk is to be applied. * If endoffile is true, treat the last line specially since it may * lack a newline. */ static void copy_till(LINENUM lastline, bool endoffile) { if (last_frozen_line > lastline) fatal("misordered hunks! output would be garbled\n"); while (last_frozen_line < lastline) { if (++last_frozen_line == lastline && endoffile) dump_line(last_frozen_line, !last_line_missing_eol); else dump_line(last_frozen_line, true); } } /* * Finish copying the input file to the output file. */ static bool spew_output(void) { int rv; #ifdef DEBUGGING if (debug & 256) say("il=%ld lfl=%ld\n", input_lines, last_frozen_line); #endif if (input_lines) copy_till(input_lines, true); /* dump remainder of file */ rv = ferror(ofp) == 0 && fclose(ofp) == 0; ofp = NULL; return rv; } /* * Copy one line from input to output. */ static void dump_line(LINENUM line, bool write_newline) { char *s; s = ifetch(line, 0); if (s == NULL) return; /* Note: string is not NUL terminated. */ for (; *s != '\n'; s++) putc(*s, ofp); if (write_newline) putc('\n', ofp); } /* * Does the patch pattern match at line base+offset? */ static bool patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) { LINENUM pline = 1 + fuzz; LINENUM iline; LINENUM pat_lines = pch_ptrn_lines() - fuzz; const char *ilineptr; const char *plineptr; unsigned short plinelen; /* Patch does not match if we don't have any more context to use */ if (pline > pat_lines) return false; for (iline = base + offset + fuzz; pline <= pat_lines; pline++, iline++) { ilineptr = ifetch(iline, offset >= 0); if (ilineptr == NULL) return false; plineptr = pfetch(pline); plinelen = pch_line_len(pline); if (canonicalize) { if (!similar(ilineptr, plineptr, plinelen)) return false; } else if (strnNE(ilineptr, plineptr, plinelen)) return false; if (iline == input_lines) { /* * We are looking at the last line of the file. * If the file has no eol, the patch line should * not have one either and vice-versa. Note that * plinelen > 0. */ if (last_line_missing_eol) { if (plineptr[plinelen - 1] == '\n') return false; } else { if (plineptr[plinelen - 1] != '\n') return false; } } } return true; } /* * Do two lines match with canonicalized white space? */ static bool similar(const char *a, const char *b, int len) { while (len) { if (isspace((unsigned char)*b)) { /* whitespace (or \n) to match? */ if (!isspace((unsigned char)*a)) /* no corresponding whitespace? */ return false; while (len && isspace((unsigned char)*b) && *b != '\n') b++, len--; /* skip pattern whitespace */ while (isspace((unsigned char)*a) && *a != '\n') a++; /* skip target whitespace */ if (*a == '\n' || *b == '\n') return (*a == *b); /* should end in sync */ } else if (*a++ != *b++) /* match non-whitespace chars */ return false; else len--; /* probably not necessary */ } return true; /* actually, this is not reached */ /* since there is always a \n */ } static bool handle_creation(bool out_existed, bool *remove) { bool reverse_seen; reverse_seen = false; if (reverse && out_existed) { /* * If the patch creates the file and we're reversing the patch, * then we need to indicate to the patch processor that it's OK * to remove this file. */ *remove = true; } else if (!reverse && out_existed) { /* * Otherwise, we need to blow the horn because the patch appears * to be reversed/already applied. For non-batch jobs, we'll * prompt to figure out what we should be trying to do to raise * awareness of the issue. batch (-t) processing suppresses the * questions and just assumes that we're reversed if it looks * like we are, which is always the case if we've reached this * branch. */ if (force) { skip_rest_of_patch = true; return (false); } if (noreverse) { /* If -N is supplied, however, we bail out/ignore. */ say("Ignoring previously applied (or reversed) patch.\n"); skip_rest_of_patch = true; return (false); } /* Unreversed... suspicious if the file existed. */ if (!pch_swap()) fatal("lost hunk on alloc error!\n"); reverse = !reverse; if (batch) { if (verbose) say("Patch creates file that already exists, %s %seversed", reverse ? "Assuming" : "Ignoring", reverse ? "R" : "Unr"); } else { ask("Patch creates file that already exists! %s -R? [y] ", reverse ? "Assume" : "Ignore"); if (*buf == 'n') { ask("Apply anyway? [n]"); if (*buf != 'y') /* Don't apply; error out. */ skip_rest_of_patch = true; else /* Attempt to apply. */ reverse_seen = true; reverse = !reverse; if (!pch_swap()) fatal("lost hunk on alloc error!\n"); } else { /* * They've opted to assume -R; effectively the * same as the first branch in this function, * but the decision is here rather than in a * prior patch/hunk as in that branch. */ *remove = true; } } } /* * The return value indicates if we offered a chance to reverse but the * user declined. This keeps the main patch processor in the loop since * we've taken this out of the normal flow of hunk processing to * simplify logic a little bit. */ return (reverse_seen); } diff --git a/usr.bin/patch/pathnames.h b/usr.bin/patch/pathnames.h index 79d8faea6285..4d4672fd83f2 100644 --- a/usr.bin/patch/pathnames.h +++ b/usr.bin/patch/pathnames.h @@ -1,12 +1,11 @@ /*- * Placed in the public domain by Todd C. Miller * on July 29, 2003. * * $OpenBSD: pathnames.h,v 1.1 2003/07/29 20:10:17 millert Exp $ - * $FreeBSD$ */ #include #define _PATH_RED "/bin/red" diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index e180c7075712..d528f06235bf 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -1,1660 +1,1659 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: pch.c,v 1.43 2014/11/18 17:03:35 tobias Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "util.h" #include "pch.h" #include "pathnames.h" /* Patch (diff listing) abstract type. */ static off_t p_filesize; /* size of the patch file */ static LINENUM p_first; /* 1st line number */ static LINENUM p_newfirst; /* 1st line number of replacement */ static LINENUM p_ptrn_lines; /* # lines in pattern */ static LINENUM p_repl_lines; /* # lines in replacement text */ static LINENUM p_end = -1; /* last line in hunk */ static LINENUM p_max; /* max allowed value of p_end */ static LINENUM p_context = 3; /* # of context lines */ static LINENUM p_input_line = 0; /* current line # from patch file */ static char **p_line = NULL;/* the text of the hunk */ static unsigned short *p_len = NULL; /* length of each line */ static char *p_char = NULL; /* +, -, and ! */ static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ static int p_indent; /* indent to patch */ static off_t p_base; /* where to intuit this time */ static LINENUM p_bline; /* line # of p_base */ static off_t p_start; /* where intuit found a patch */ static LINENUM p_sline; /* and the line number for it */ static LINENUM p_hunk_beg; /* line number of current hunk */ static LINENUM p_efake = -1; /* end of faked up lines--don't free */ static LINENUM p_bfake = -1; /* beg of faked up lines */ static FILE *pfp = NULL; /* patch file pointer */ static char *bestguess = NULL; /* guess at correct filename */ char *source_file; static void grow_hunkmax(void); static int intuit_diff_type(void); static void next_intuit_at(off_t, LINENUM); static void skip_to(off_t, LINENUM); static size_t pgets(bool _do_indent); static char *best_name(const struct file_name *, bool); static char *posix_name(const struct file_name *, bool); static size_t num_components(const char *); static LINENUM strtolinenum(char *, char **); /* * Prepare to look for the next patch in the patch file. */ void re_patch(void) { p_first = 0; p_newfirst = 0; p_ptrn_lines = 0; p_repl_lines = 0; p_end = (LINENUM) - 1; p_max = 0; p_indent = 0; } /* * Open the patch file at the beginning of time. */ void open_patch_file(const char *filename) { struct stat filestat; int nr, nw; if (filename == NULL || *filename == '\0' || strEQ(filename, "-")) { pfp = fopen(TMPPATNAME, "w"); if (pfp == NULL) pfatal("can't create %s", TMPPATNAME); while ((nr = fread(buf, 1, buf_size, stdin)) > 0) { nw = fwrite(buf, 1, nr, pfp); if (nr != nw) pfatal("write error to %s", TMPPATNAME); } if (ferror(pfp) || fclose(pfp)) pfatal("can't write %s", TMPPATNAME); filename = TMPPATNAME; } pfp = fopen(filename, "r"); if (pfp == NULL) pfatal("patch file %s not found", filename); if (fstat(fileno(pfp), &filestat)) pfatal("can't stat %s", filename); p_filesize = filestat.st_size; next_intuit_at(0, 1L); /* start at the beginning */ set_hunkmax(); } /* * Make sure our dynamically realloced tables are malloced to begin with. */ void set_hunkmax(void) { if (p_line == NULL) p_line = malloc(hunkmax * sizeof(char *)); if (p_len == NULL) p_len = malloc(hunkmax * sizeof(unsigned short)); if (p_char == NULL) p_char = malloc(hunkmax * sizeof(char)); } /* * Enlarge the arrays containing the current hunk of patch. */ static void grow_hunkmax(void) { int new_hunkmax = hunkmax * 2; if (p_line == NULL || p_len == NULL || p_char == NULL) fatal("Internal memory allocation error\n"); p_line = reallocf(p_line, new_hunkmax * sizeof(char *)); p_len = reallocf(p_len, new_hunkmax * sizeof(unsigned short)); p_char = reallocf(p_char, new_hunkmax * sizeof(char)); if (p_line != NULL && p_len != NULL && p_char != NULL) { hunkmax = new_hunkmax; return; } if (!using_plan_a) fatal("out of memory\n"); out_of_mem = true; /* whatever is null will be allocated again */ /* from within plan_a(), of all places */ } /* True if the remainder of the patch file contains a diff of some sort. */ bool there_is_another_patch(void) { bool exists = false; if (p_base != 0 && p_base >= p_filesize) { if (verbose) say("done\n"); return false; } if (p_filesize == 0) return false; nonempty_patchf_seen = true; if (verbose) say("Hmm..."); diff_type = intuit_diff_type(); if (!diff_type) { if (p_base != 0) { if (verbose) say(" Ignoring the trailing garbage.\ndone\n"); } else say(" I can't seem to find a patch in there anywhere.\n"); return false; } if (verbose) say(" %sooks like %s to me...\n", (p_base == 0 ? "L" : "The next patch l"), diff_type == UNI_DIFF ? "a unified diff" : diff_type == CONTEXT_DIFF ? "a context diff" : diff_type == NEW_CONTEXT_DIFF ? "a new-style context diff" : diff_type == NORMAL_DIFF ? "a normal diff" : "an ed script"); if (p_indent && verbose) say("(Patch is indented %d space%s.)\n", p_indent, p_indent == 1 ? "" : "s"); skip_to(p_start, p_sline); while (filearg[0] == NULL) { if (force || batch) { say("No file to patch. Skipping...\n"); filearg[0] = xstrdup(bestguess); skip_rest_of_patch = true; return true; } ask("File to patch: "); if (*buf != '\n') { free(bestguess); bestguess = xstrdup(buf); filearg[0] = fetchname(buf, &exists, 0); } /* * fetchname can now return buf = NULL, exists = true, to * indicate to the caller that /dev/null was specified. Retain * previous behavior for now until this can be better evaluted. */ if (filearg[0] == NULL || !exists) { int def_skip = *bestguess == '\0'; ask("No file found--skip this patch? [%c] ", def_skip ? 'y' : 'n'); if (*buf == 'n' || (!def_skip && *buf != 'y')) continue; if (verbose) say("Skipping patch...\n"); free(filearg[0]); filearg[0] = fetchname(bestguess, &exists, 0); skip_rest_of_patch = true; return true; } } return true; } static void p4_fetchname(struct file_name *name, char *str) { char *t, *h; /* Skip leading whitespace. */ while (isspace((unsigned char)*str)) str++; /* Remove the file revision number. */ for (t = str, h = NULL; *t != '\0' && !isspace((unsigned char)*t); t++) if (*t == '#') h = t; if (h != NULL) *h = '\0'; name->path = fetchname(str, &name->exists, strippath); } /* Determine what kind of diff is in the remaining part of the patch file. */ static int intuit_diff_type(void) { off_t this_line = 0, previous_line; off_t first_command_line = -1; LINENUM fcl_line = -1; bool last_line_was_command = false, this_is_a_command = false; bool stars_last_line = false, stars_this_line = false; char *s, *t; int indent, retval; struct file_name names[MAX_FILE]; int piece_of_git = 0; memset(names, 0, sizeof(names)); ok_to_create_file = false; fseeko(pfp, p_base, SEEK_SET); p_input_line = p_bline - 1; for (;;) { previous_line = this_line; last_line_was_command = this_is_a_command; stars_last_line = stars_this_line; this_line = ftello(pfp); indent = 0; p_input_line++; if (pgets(false) == 0) { if (first_command_line >= 0) { /* nothing but deletes!? */ p_start = first_command_line; p_sline = fcl_line; retval = ED_DIFF; goto scan_exit; } else { p_start = this_line; p_sline = p_input_line; retval = 0; goto scan_exit; } } for (s = buf; *s == ' ' || *s == '\t' || *s == 'X'; s++) { if (*s == '\t') indent += 8 - (indent % 8); else indent++; } for (t = s; isdigit((unsigned char)*t) || *t == ','; t++) ; this_is_a_command = (isdigit((unsigned char)*s) && (*t == 'd' || *t == 'c' || *t == 'a')); if (first_command_line < 0 && this_is_a_command) { first_command_line = this_line; fcl_line = p_input_line; p_indent = indent; /* assume this for now */ } if (!stars_last_line && strnEQ(s, "*** ", 4)) names[OLD_FILE].path = fetchname(s + 4, &names[OLD_FILE].exists, strippath); else if (strnEQ(s, "--- ", 4)) { size_t off = 4; if (piece_of_git && strippath == 957 && strnEQ(s, "--- a/", 6)) off = 6; names[NEW_FILE].path = fetchname(s + off, &names[NEW_FILE].exists, strippath); } else if (strnEQ(s, "+++ ", 4)) { /* pretend it is the old name */ size_t off = 4; if (piece_of_git && strippath == 957 && strnEQ(s, "+++ b/", 6)) off = 6; names[OLD_FILE].path = fetchname(s + off, &names[OLD_FILE].exists, strippath); } else if (strnEQ(s, "Index:", 6)) names[INDEX_FILE].path = fetchname(s + 6, &names[INDEX_FILE].exists, strippath); else if (strnEQ(s, "Prereq:", 7)) { for (t = s + 7; isspace((unsigned char)*t); t++) ; revision = xstrdup(t); for (t = revision; *t && !isspace((unsigned char)*t); t++) ; *t = '\0'; if (*revision == '\0') { free(revision); revision = NULL; } } else if (strnEQ(s, "diff --git a/", 13)) { /* Git-style diffs. */ piece_of_git = 1; } else if (strnEQ(s, "==== ", 5)) { /* Perforce-style diffs. */ if ((t = strstr(s + 5, " - ")) != NULL) p4_fetchname(&names[NEW_FILE], t + 3); p4_fetchname(&names[OLD_FILE], s + 5); } if ((!diff_type || diff_type == ED_DIFF) && first_command_line >= 0 && strEQ(s, ".\n")) { p_indent = indent; p_start = first_command_line; p_sline = fcl_line; retval = ED_DIFF; goto scan_exit; } if ((!diff_type || diff_type == UNI_DIFF) && strnEQ(s, "@@ -", 4)) { if (strnEQ(s + 4, "0,0", 3)) ok_to_create_file = true; p_indent = indent; p_start = this_line; p_sline = p_input_line; retval = UNI_DIFF; goto scan_exit; } stars_this_line = strnEQ(s, "********", 8); if ((!diff_type || diff_type == CONTEXT_DIFF) && stars_last_line && strnEQ(s, "*** ", 4)) { if (strtolinenum(s + 4, &s) == 0) ok_to_create_file = true; /* * If this is a new context diff the character just * at the end of the line is a '*'. */ while (*s && *s != '\n') s++; p_indent = indent; p_start = previous_line; p_sline = p_input_line - 1; retval = (*(s - 1) == '*' ? NEW_CONTEXT_DIFF : CONTEXT_DIFF); goto scan_exit; } if ((!diff_type || diff_type == NORMAL_DIFF) && last_line_was_command && (strnEQ(s, "< ", 2) || strnEQ(s, "> ", 2))) { p_start = previous_line; p_sline = p_input_line - 1; p_indent = indent; retval = NORMAL_DIFF; goto scan_exit; } } scan_exit: if (retval == UNI_DIFF) { /* unswap old and new */ struct file_name tmp = names[OLD_FILE]; names[OLD_FILE] = names[NEW_FILE]; names[NEW_FILE] = tmp; } /* Invalidated */ free(source_file); source_file = NULL; if (retval != 0) { /* * If we've successfully determined a diff type, stored in * retval, path == NULL means _PATH_DEVNULL if exists is set. * Explicitly specify it here to make it easier to detect later * on that we're actually creating a file and not that we've * just goofed something up. */ if (names[OLD_FILE].path != NULL) source_file = xstrdup(names[OLD_FILE].path); else if (names[OLD_FILE].exists) source_file = xstrdup(_PATH_DEVNULL); } if (filearg[0] == NULL) { if (posix) filearg[0] = posix_name(names, ok_to_create_file); else { /* Ignore the Index: name for context diffs, like GNU */ if (names[OLD_FILE].path != NULL || names[NEW_FILE].path != NULL) { free(names[INDEX_FILE].path); names[INDEX_FILE].path = NULL; } filearg[0] = best_name(names, ok_to_create_file); } } free(bestguess); bestguess = NULL; if (filearg[0] != NULL) bestguess = xstrdup(filearg[0]); else if (!ok_to_create_file) { /* * We don't want to create a new file but we need a * filename to set bestguess. Avoid setting filearg[0] * so the file is not created automatically. */ if (posix) bestguess = posix_name(names, true); else bestguess = best_name(names, true); } free(names[OLD_FILE].path); free(names[NEW_FILE].path); free(names[INDEX_FILE].path); return retval; } /* * Remember where this patch ends so we know where to start up again. */ static void next_intuit_at(off_t file_pos, LINENUM file_line) { p_base = file_pos; p_bline = file_line; } /* * Basically a verbose fseeko() to the actual diff listing. */ static void skip_to(off_t file_pos, LINENUM file_line) { size_t len; if (p_base > file_pos) fatal("Internal error: seek %lld>%lld\n", (long long)p_base, (long long)file_pos); if (verbose && p_base < file_pos) { fseeko(pfp, p_base, SEEK_SET); say("The text leading up to this was:\n--------------------------\n"); while (ftello(pfp) < file_pos) { len = pgets(false); if (len == 0) fatal("Unexpected end of file\n"); say("|%s", buf); } say("--------------------------\n"); } else fseeko(pfp, file_pos, SEEK_SET); p_input_line = file_line - 1; } /* Make this a function for better debugging. */ static void malformed(void) { fatal("malformed patch at line %ld: %s", p_input_line, buf); /* about as informative as "Syntax error" in C */ } /* * True if the line has been discarded (i.e. it is a line saying * "\ No newline at end of file".) */ static bool remove_special_line(void) { int c; c = fgetc(pfp); if (c == '\\') { do { c = fgetc(pfp); } while (c != EOF && c != '\n'); return true; } if (c != EOF) fseeko(pfp, -1, SEEK_CUR); return false; } /* * True if there is more of the current diff listing to process. */ bool another_hunk(void) { off_t line_beginning; /* file pos of the current line */ LINENUM repl_beginning; /* index of --- line */ LINENUM fillcnt; /* #lines of missing ptrn or repl */ LINENUM fillsrc; /* index of first line to copy */ LINENUM filldst; /* index of first missing line */ bool ptrn_spaces_eaten; /* ptrn was slightly malformed */ bool repl_could_be_missing; /* no + or ! lines in this hunk */ bool repl_missing; /* we are now backtracking */ off_t repl_backtrack_position; /* file pos of first repl line */ LINENUM repl_patch_line; /* input line number for same */ LINENUM ptrn_copiable; /* # of copiable lines in ptrn */ char *s; size_t len; int context = 0; while (p_end >= 0) { if (p_end == p_efake) p_end = p_bfake; /* don't free twice */ else free(p_line[p_end]); p_end--; } p_efake = -1; p_max = hunkmax; /* gets reduced when --- found */ if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) { line_beginning = ftello(pfp); repl_beginning = 0; fillcnt = 0; fillsrc = 0; filldst = 0; ptrn_spaces_eaten = false; repl_could_be_missing = true; repl_missing = false; repl_backtrack_position = 0; repl_patch_line = 0; ptrn_copiable = 0; len = pgets(true); p_input_line++; if (len == 0 || strnNE(buf, "********", 8)) { next_intuit_at(line_beginning, p_input_line); return false; } p_context = 100; p_hunk_beg = p_input_line + 1; while (p_end < p_max) { line_beginning = ftello(pfp); len = pgets(true); p_input_line++; if (len == 0) { if (repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } fatal("unexpected end of file in patch\n"); } p_end++; if (p_end >= hunkmax) fatal("Internal error: hunk larger than hunk " "buffer size"); p_char[p_end] = *buf; p_line[p_end] = NULL; switch (*buf) { case '*': if (strnEQ(buf, "********", 8)) { if (repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } else fatal("unexpected end of hunk " "at line %ld\n", p_input_line); } if (p_end != 0) { if (repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } fatal("unexpected *** at line %ld: %s", p_input_line, buf); } context = 0; p_line[p_end] = savestr(buf); if (out_of_mem) { p_end--; return false; } for (s = buf; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed(); if (strnEQ(s, "0,0", 3)) memmove(s, s + 2, strlen(s + 2) + 1); p_first = strtolinenum(s, &s); if (*s == ',') { for (; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed(); p_ptrn_lines = strtolinenum(s, &s) - p_first + 1; if (p_ptrn_lines < 0) malformed(); } else if (p_first) p_ptrn_lines = 1; else { p_ptrn_lines = 0; p_first = 1; } if (p_first >= LINENUM_MAX - p_ptrn_lines || p_ptrn_lines >= LINENUM_MAX - 6) malformed(); /* we need this much at least */ p_max = p_ptrn_lines + 6; while (p_max >= hunkmax) grow_hunkmax(); p_max = hunkmax; break; case '-': if (buf[1] == '-') { if (repl_beginning || (p_end != p_ptrn_lines + 1 + (p_char[p_end - 1] == '\n'))) { if (p_end == 1) { /* * `old' lines were omitted; * set up to fill them in * from 'new' context lines. */ p_end = p_ptrn_lines + 1; fillsrc = p_end + 1; filldst = 1; fillcnt = p_ptrn_lines; } else { if (repl_beginning) { if (repl_could_be_missing) { repl_missing = true; goto hunk_done; } fatal("duplicate \"---\" at line %ld--check line numbers at line %ld\n", p_input_line, p_hunk_beg + repl_beginning); } else { fatal("%s \"---\" at line %ld--check line numbers at line %ld\n", (p_end <= p_ptrn_lines ? "Premature" : "Overdue"), p_input_line, p_hunk_beg); } } } repl_beginning = p_end; repl_backtrack_position = ftello(pfp); repl_patch_line = p_input_line; p_line[p_end] = savestr(buf); if (out_of_mem) { p_end--; return false; } p_char[p_end] = '='; for (s = buf; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed(); p_newfirst = strtolinenum(s, &s); if (*s == ',') { for (; *s && !isdigit((unsigned char)*s); s++) ; if (!*s) malformed(); p_repl_lines = strtolinenum(s, &s) - p_newfirst + 1; if (p_repl_lines < 0) malformed(); } else if (p_newfirst) p_repl_lines = 1; else { p_repl_lines = 0; p_newfirst = 1; } if (p_newfirst >= LINENUM_MAX - p_repl_lines || p_repl_lines >= LINENUM_MAX - p_end) malformed(); p_max = p_repl_lines + p_end; if (p_max > MAXHUNKSIZE) fatal("hunk too large (%ld lines) at line %ld: %s", p_max, p_input_line, buf); while (p_max >= hunkmax) grow_hunkmax(); if (p_repl_lines != ptrn_copiable && (p_context != 0 || p_repl_lines != 1)) repl_could_be_missing = false; break; } goto change_line; case '+': case '!': repl_could_be_missing = false; change_line: if (buf[1] == '\n' && canonicalize) strlcpy(buf + 1, " \n", buf_size - 1); if (!isspace((unsigned char)buf[1]) && buf[1] != '>' && buf[1] != '<' && repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } if (context >= 0) { if (context < p_context) p_context = context; context = -1000; } p_line[p_end] = savestr(buf + 2); if (out_of_mem) { p_end--; return false; } if (p_end == p_ptrn_lines) { if (remove_special_line()) { int l; l = strlen(p_line[p_end]) - 1; (p_line[p_end])[l] = 0; } } break; case '\t': case '\n': /* assume the 2 spaces got eaten */ if (repl_beginning && repl_could_be_missing && (!ptrn_spaces_eaten || diff_type == NEW_CONTEXT_DIFF)) { repl_missing = true; goto hunk_done; } p_line[p_end] = savestr(buf); if (out_of_mem) { p_end--; return false; } if (p_end != p_ptrn_lines + 1) { ptrn_spaces_eaten |= (repl_beginning != 0); context++; if (!repl_beginning) ptrn_copiable++; p_char[p_end] = ' '; } break; case ' ': if (!isspace((unsigned char)buf[1]) && repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } context++; if (!repl_beginning) ptrn_copiable++; p_line[p_end] = savestr(buf + 2); if (out_of_mem) { p_end--; return false; } break; default: if (repl_beginning && repl_could_be_missing) { repl_missing = true; goto hunk_done; } malformed(); } /* set up p_len for strncmp() so we don't have to */ /* assume null termination */ if (p_line[p_end]) p_len[p_end] = strlen(p_line[p_end]); else p_len[p_end] = 0; } hunk_done: if (p_end >= 0 && !repl_beginning) fatal("no --- found in patch at line %ld\n", pch_hunk_beg()); if (repl_missing) { /* reset state back to just after --- */ p_input_line = repl_patch_line; for (p_end--; p_end > repl_beginning; p_end--) free(p_line[p_end]); fseeko(pfp, repl_backtrack_position, SEEK_SET); /* redundant 'new' context lines were omitted - set */ /* up to fill them in from the old file context */ if (!p_context && p_repl_lines == 1) { p_repl_lines = 0; p_max--; } fillsrc = 1; filldst = repl_beginning + 1; fillcnt = p_repl_lines; p_end = p_max; } else if (!p_context && fillcnt == 1) { /* the first hunk was a null hunk with no context */ /* and we were expecting one line -- fix it up. */ while (filldst < p_end) { p_line[filldst] = p_line[filldst + 1]; p_char[filldst] = p_char[filldst + 1]; p_len[filldst] = p_len[filldst + 1]; filldst++; } #if 0 repl_beginning--; /* this doesn't need to be fixed */ #endif p_end--; p_first++; /* do append rather than insert */ fillcnt = 0; p_ptrn_lines = 0; } if (diff_type == CONTEXT_DIFF && (fillcnt || (p_first > 1 && ptrn_copiable > 2 * p_context))) { if (verbose) say("%s\n%s\n%s\n", "(Fascinating--this is really a new-style context diff but without", "the telltale extra asterisks on the *** line that usually indicate", "the new style...)"); diff_type = NEW_CONTEXT_DIFF; } /* if there were omitted context lines, fill them in now */ if (fillcnt) { p_bfake = filldst; /* remember where not to free() */ p_efake = filldst + fillcnt - 1; while (fillcnt-- > 0) { while (fillsrc <= p_end && p_char[fillsrc] != ' ') fillsrc++; if (fillsrc > p_end) fatal("replacement text or line numbers mangled in hunk at line %ld\n", p_hunk_beg); p_line[filldst] = p_line[fillsrc]; p_char[filldst] = p_char[fillsrc]; p_len[filldst] = p_len[fillsrc]; fillsrc++; filldst++; } while (fillsrc <= p_end && fillsrc != repl_beginning && p_char[fillsrc] != ' ') fillsrc++; #ifdef DEBUGGING if (debug & 64) printf("fillsrc %ld, filldst %ld, rb %ld, e+1 %ld\n", fillsrc, filldst, repl_beginning, p_end + 1); #endif if (fillsrc != p_end + 1 && fillsrc != repl_beginning) malformed(); if (filldst != p_end + 1 && filldst != repl_beginning) malformed(); } if (p_line[p_end] != NULL) { if (remove_special_line()) { p_len[p_end] -= 1; (p_line[p_end])[p_len[p_end]] = 0; } } } else if (diff_type == UNI_DIFF) { LINENUM fillold; /* index of old lines */ LINENUM fillnew; /* index of new lines */ char ch; line_beginning = ftello(pfp); /* file pos of the current line */ len = pgets(true); p_input_line++; if (len == 0 || strnNE(buf, "@@ -", 4)) { next_intuit_at(line_beginning, p_input_line); return false; } s = buf + 4; if (!*s) malformed(); p_first = strtolinenum(s, &s); if (*s == ',') { p_ptrn_lines = strtolinenum(s + 1, &s); } else p_ptrn_lines = 1; if (*s == ' ') s++; if (*s != '+' || !*++s) malformed(); p_newfirst = strtolinenum(s, &s); if (*s == ',') { p_repl_lines = strtolinenum(s + 1, &s); } else p_repl_lines = 1; if (*s == ' ') s++; if (*s != '@') malformed(); if (p_first >= LINENUM_MAX - p_ptrn_lines || p_newfirst > LINENUM_MAX - p_repl_lines || p_ptrn_lines >= LINENUM_MAX - p_repl_lines - 1) malformed(); if (!p_ptrn_lines) p_first++; /* do append rather than insert */ p_max = p_ptrn_lines + p_repl_lines + 1; while (p_max >= hunkmax) grow_hunkmax(); fillold = 1; fillnew = fillold + p_ptrn_lines; p_end = fillnew + p_repl_lines; snprintf(buf, buf_size, "*** %ld,%ld ****\n", p_first, p_first + p_ptrn_lines - 1); p_line[0] = savestr(buf); if (out_of_mem) { p_end = -1; return false; } p_char[0] = '*'; snprintf(buf, buf_size, "--- %ld,%ld ----\n", p_newfirst, p_newfirst + p_repl_lines - 1); p_line[fillnew] = savestr(buf); if (out_of_mem) { p_end = 0; return false; } p_char[fillnew++] = '='; p_context = 100; context = 0; p_hunk_beg = p_input_line + 1; while (fillold <= p_ptrn_lines || fillnew <= p_end) { line_beginning = ftello(pfp); len = pgets(true); p_input_line++; if (len == 0) { if (p_max - fillnew < 3) { /* assume blank lines got chopped */ strlcpy(buf, " \n", buf_size); } else { fatal("unexpected end of file in patch\n"); } } if (*buf == '\t' || *buf == '\n') { ch = ' '; /* assume the space got eaten */ s = savestr(buf); } else { ch = *buf; s = savestr(buf + 1); } if (out_of_mem) { while (--fillnew > p_ptrn_lines) free(p_line[fillnew]); p_end = fillold - 1; return false; } switch (ch) { case '-': if (fillold > p_ptrn_lines) { free(s); p_end = fillnew - 1; malformed(); } p_char[fillold] = ch; p_line[fillold] = s; p_len[fillold++] = strlen(s); if (fillold > p_ptrn_lines) { if (remove_special_line()) { p_len[fillold - 1] -= 1; s[p_len[fillold - 1]] = 0; } } break; case '=': ch = ' '; /* FALL THROUGH */ case ' ': if (fillold > p_ptrn_lines) { free(s); while (--fillnew > p_ptrn_lines) free(p_line[fillnew]); p_end = fillold - 1; malformed(); } context++; p_char[fillold] = ch; p_line[fillold] = s; p_len[fillold++] = strlen(s); s = savestr(s); if (out_of_mem) { while (--fillnew > p_ptrn_lines) free(p_line[fillnew]); p_end = fillold - 1; return false; } if (fillold > p_ptrn_lines) { if (remove_special_line()) { p_len[fillold - 1] -= 1; s[p_len[fillold - 1]] = 0; } } /* FALL THROUGH */ case '+': if (fillnew > p_end) { free(s); while (--fillnew > p_ptrn_lines) free(p_line[fillnew]); p_end = fillold - 1; malformed(); } p_char[fillnew] = ch; p_line[fillnew] = s; p_len[fillnew++] = strlen(s); if (fillold > p_ptrn_lines) { if (remove_special_line()) { p_len[fillnew - 1] -= 1; s[p_len[fillnew - 1]] = 0; } } break; default: p_end = fillnew; malformed(); } if (ch != ' ' && context > 0) { if (context < p_context) p_context = context; context = -1000; } } /* while */ } else { /* normal diff--fake it up */ char hunk_type; int i; LINENUM min, max; line_beginning = ftello(pfp); p_context = 0; len = pgets(true); p_input_line++; if (len == 0 || !isdigit((unsigned char)*buf)) { next_intuit_at(line_beginning, p_input_line); return false; } p_first = strtolinenum(buf, &s); if (*s == ',') { p_ptrn_lines = strtolinenum(s + 1, &s) - p_first + 1; if (p_ptrn_lines < 0) malformed(); } else p_ptrn_lines = (*s != 'a'); hunk_type = *s; if (hunk_type == 'a') p_first++; /* do append rather than insert */ min = strtolinenum(s + 1, &s); if (*s == ',') max = strtolinenum(s + 1, &s); else max = min; if (min < 0 || min > max || max - min == LINENUM_MAX) malformed(); if (hunk_type == 'd') min++; p_newfirst = min; p_repl_lines = max - min + 1; if (p_newfirst > LINENUM_MAX - p_repl_lines || p_ptrn_lines >= LINENUM_MAX - p_repl_lines - 1) malformed(); p_end = p_ptrn_lines + p_repl_lines + 1; if (p_end > MAXHUNKSIZE) fatal("hunk too large (%ld lines) at line %ld: %s", p_end, p_input_line, buf); while (p_end >= hunkmax) grow_hunkmax(); snprintf(buf, buf_size, "*** %ld,%ld\n", p_first, p_first + p_ptrn_lines - 1); p_line[0] = savestr(buf); if (out_of_mem) { p_end = -1; return false; } p_char[0] = '*'; for (i = 1; i <= p_ptrn_lines; i++) { len = pgets(true); p_input_line++; if (len == 0) fatal("unexpected end of file in patch at line %ld\n", p_input_line); if (*buf != '<') fatal("< expected at line %ld of patch\n", p_input_line); p_line[i] = savestr(buf + 2); if (out_of_mem) { p_end = i - 1; return false; } p_len[i] = strlen(p_line[i]); p_char[i] = '-'; } if (remove_special_line()) { p_len[i - 1] -= 1; (p_line[i - 1])[p_len[i - 1]] = 0; } if (hunk_type == 'c') { len = pgets(true); p_input_line++; if (len == 0) fatal("unexpected end of file in patch at line %ld\n", p_input_line); if (*buf != '-') fatal("--- expected at line %ld of patch\n", p_input_line); } snprintf(buf, buf_size, "--- %ld,%ld\n", min, max); p_line[i] = savestr(buf); if (out_of_mem) { p_end = i - 1; return false; } p_char[i] = '='; for (i++; i <= p_end; i++) { len = pgets(true); p_input_line++; if (len == 0) fatal("unexpected end of file in patch at line %ld\n", p_input_line); if (*buf != '>') fatal("> expected at line %ld of patch\n", p_input_line); /* Don't overrun if we don't have enough line */ if (len > 2) p_line[i] = savestr(buf + 2); else p_line[i] = savestr(""); if (out_of_mem) { p_end = i - 1; return false; } p_len[i] = strlen(p_line[i]); p_char[i] = '+'; } if (remove_special_line()) { p_len[i - 1] -= 1; (p_line[i - 1])[p_len[i - 1]] = 0; } } if (reverse) /* backwards patch? */ if (!pch_swap()) say("Not enough memory to swap next hunk!\n"); #ifdef DEBUGGING if (debug & 2) { LINENUM i; char special; for (i = 0; i <= p_end; i++) { if (i == p_ptrn_lines) special = '^'; else special = ' '; fprintf(stderr, "%3ld %c %c %s", i, p_char[i], special, p_line[i]); fflush(stderr); } } #endif if (p_end + 1 < hunkmax)/* paranoia reigns supreme... */ p_char[p_end + 1] = '^'; /* add a stopper for apply_hunk */ return true; } /* * Input a line from the patch file. * Worry about indentation if do_indent is true. * The line is read directly into the buf global variable which * is resized if necessary in order to hold the complete line. * Returns the number of characters read including the terminating * '\n', if any. */ size_t pgets(bool do_indent) { char *line; size_t len = 0; int indent = 0, skipped = 0; line = fgetln(pfp, &len); if (line != NULL) { if (len + 1 > buf_size) { while (len + 1 > buf_size) buf_size *= 2; free(buf); buf = malloc(buf_size); if (buf == NULL) fatal("out of memory\n"); } if (do_indent == 1 && p_indent) { for (; indent < p_indent && (*line == ' ' || *line == '\t' || *line == 'X'); line++, skipped++) { if (*line == '\t') indent += 8 - (indent %7); else indent++; } } memcpy(buf, line, len - skipped); buf[len - skipped] = '\0'; } return len; } /* * Reverse the old and new portions of the current hunk. */ bool pch_swap(void) { char **tp_line; /* the text of the hunk */ unsigned short *tp_len;/* length of each line */ char *tp_char; /* +, -, and ! */ LINENUM i; LINENUM n; bool blankline = false; char *s; i = p_first; p_first = p_newfirst; p_newfirst = i; /* make a scratch copy */ tp_line = p_line; tp_len = p_len; tp_char = p_char; p_line = NULL; /* force set_hunkmax to allocate again */ p_len = NULL; p_char = NULL; set_hunkmax(); if (p_line == NULL || p_len == NULL || p_char == NULL) { free(p_line); p_line = tp_line; free(p_len); p_len = tp_len; free(p_char); p_char = tp_char; return false; /* not enough memory to swap hunk! */ } /* now turn the new into the old */ i = p_ptrn_lines + 1; if (tp_char[i] == '\n') { /* account for possible blank line */ blankline = true; i++; } if (p_efake >= 0) { /* fix non-freeable ptr range */ if (p_efake <= i) n = p_end - i + 1; else n = -i; p_efake += n; p_bfake += n; } for (n = 0; i <= p_end; i++, n++) { p_line[n] = tp_line[i]; p_char[n] = tp_char[i]; if (p_char[n] == '+') p_char[n] = '-'; p_len[n] = tp_len[i]; } if (blankline) { i = p_ptrn_lines + 1; p_line[n] = tp_line[i]; p_char[n] = tp_char[i]; p_len[n] = tp_len[i]; n++; } if (p_char[0] != '=') fatal("Malformed patch at line %ld: expected '=' found '%c'\n", p_input_line, p_char[0]); p_char[0] = '*'; for (s = p_line[0]; *s; s++) if (*s == '-') *s = '*'; /* now turn the old into the new */ if (p_char[0] != '*') fatal("Malformed patch at line %ld: expected '*' found '%c'\n", p_input_line, p_char[0]); tp_char[0] = '='; for (s = tp_line[0]; *s; s++) if (*s == '*') *s = '-'; for (i = 0; n <= p_end; i++, n++) { p_line[n] = tp_line[i]; p_char[n] = tp_char[i]; if (p_char[n] == '-') p_char[n] = '+'; p_len[n] = tp_len[i]; } if (i != p_ptrn_lines + 1) fatal("Malformed patch at line %ld: expected %ld lines, " "got %ld\n", p_input_line, p_ptrn_lines + 1, i); i = p_ptrn_lines; p_ptrn_lines = p_repl_lines; p_repl_lines = i; free(tp_line); free(tp_len); free(tp_char); return true; } /* * Return the specified line position in the old file of the old context. */ LINENUM pch_first(void) { return p_first; } /* * Return the number of lines of old context. */ LINENUM pch_ptrn_lines(void) { return p_ptrn_lines; } /* * Return the probable line position in the new file of the first line. */ LINENUM pch_newfirst(void) { return p_newfirst; } /* * Return the number of lines in the replacement text including context. */ LINENUM pch_repl_lines(void) { return p_repl_lines; } /* * Return the number of lines in the whole hunk. */ LINENUM pch_end(void) { return p_end; } /* * Return the number of context lines before the first changed line. */ LINENUM pch_context(void) { return p_context; } /* * Return the length of a particular patch line. */ unsigned short pch_line_len(LINENUM line) { return p_len[line]; } /* * Return the control character (+, -, *, !, etc) for a patch line. */ char pch_char(LINENUM line) { return p_char[line]; } /* * Return a pointer to a particular patch line. */ char * pfetch(LINENUM line) { return p_line[line]; } /* * Return where in the patch file this hunk began, for error messages. */ LINENUM pch_hunk_beg(void) { return p_hunk_beg; } /* * Apply an ed script by feeding ed itself. */ void do_ed_script(void) { char *t; off_t beginning_of_this_line; FILE *pipefp = NULL; int continuation; if (!skip_rest_of_patch) { if (copy_file(filearg[0], TMPOUTNAME) < 0) { unlink(TMPOUTNAME); fatal("can't create temp file %s", TMPOUTNAME); } snprintf(buf, buf_size, "%s%s%s", _PATH_RED, verbose ? " " : " -s ", TMPOUTNAME); pipefp = popen(buf, "w"); } for (;;) { beginning_of_this_line = ftello(pfp); if (pgets(true) == 0) { next_intuit_at(beginning_of_this_line, p_input_line); break; } p_input_line++; for (t = buf; isdigit((unsigned char)*t) || *t == ','; t++) ; /* POSIX defines allowed commands as {a,c,d,i,s} */ if (isdigit((unsigned char)*buf) && (*t == 'a' || *t == 'c' || *t == 'd' || *t == 'i' || *t == 's')) { if (pipefp != NULL) fputs(buf, pipefp); if (*t == 's') { for (;;) { continuation = 0; t = strchr(buf, '\0') - 1; while (--t >= buf && *t == '\\') continuation = !continuation; if (!continuation || pgets(true) == 0) break; if (pipefp != NULL) fputs(buf, pipefp); } } else if (*t != 'd') { while (pgets(true)) { p_input_line++; if (pipefp != NULL) fputs(buf, pipefp); if (strEQ(buf, ".\n")) break; } } } else { next_intuit_at(beginning_of_this_line, p_input_line); break; } } if (pipefp == NULL) return; fprintf(pipefp, "w\n"); fprintf(pipefp, "q\n"); fflush(pipefp); pclose(pipefp); ignore_signals(); if (!check_only) { if (move_file(TMPOUTNAME, outname) < 0) { toutkeep = true; chmod(TMPOUTNAME, filemode); } else chmod(outname, filemode); } set_signals(1); } /* * Choose the name of the file to be patched based on POSIX rules. * NOTE: the POSIX rules are amazingly stupid and we only follow them * if the user specified --posix or set POSIXLY_CORRECT. */ static char * posix_name(const struct file_name *names, bool assume_exists) { char *path = NULL; int i; /* * POSIX states that the filename will be chosen from one * of the old, new and index names (in that order) if * the file exists relative to CWD after -p stripping. */ for (i = 0; i < MAX_FILE; i++) { if (names[i].path != NULL && names[i].exists) { path = names[i].path; break; } } if (path == NULL && !assume_exists) { /* * No files found, check to see if the diff could be * creating a new file. */ if (path == NULL && ok_to_create_file && names[NEW_FILE].path != NULL) path = names[NEW_FILE].path; } return path ? xstrdup(path) : NULL; } static char * compare_names(const struct file_name *names, bool assume_exists) { size_t min_components, min_baselen, min_len, tmp; char *best = NULL; char *path; int i; /* * The "best" name is the one with the fewest number of path * components, the shortest basename length, and the shortest * overall length (in that order). We only use the Index: file * if neither of the old or new files could be intuited from * the diff header. */ min_components = min_baselen = min_len = SIZE_MAX; for (i = INDEX_FILE; i >= OLD_FILE; i--) { path = names[i].path; if (path == NULL || (!names[i].exists && !assume_exists)) continue; if ((tmp = num_components(path)) > min_components) continue; if (tmp < min_components) { min_components = tmp; best = path; } if ((tmp = strlen(basename(path))) > min_baselen) continue; if (tmp < min_baselen) { min_baselen = tmp; best = path; } if ((tmp = strlen(path)) > min_len) continue; min_len = tmp; best = path; } return best; } /* * Choose the name of the file to be patched based the "best" one * available. */ static char * best_name(const struct file_name *names, bool assume_exists) { char *best; best = compare_names(names, assume_exists); /* No match? Check to see if the diff could be creating a new file. */ if (best == NULL && ok_to_create_file) best = names[NEW_FILE].path; return best ? xstrdup(best) : NULL; } static size_t num_components(const char *path) { size_t n; const char *cp; for (n = 0, cp = path; (cp = strchr(cp, '/')) != NULL; n++) { cp++; while (*cp == '/') cp++; /* skip consecutive slashes */ } return n; } /* * Convert number at NPTR into LINENUM and save address of first * character that is not a digit in ENDPTR. If conversion is not * possible, call fatal. */ static LINENUM strtolinenum(char *nptr, char **endptr) { LINENUM rv; char c; char *p; const char *errstr; for (p = nptr; isdigit((unsigned char)*p); p++) ; if (p == nptr) malformed(); c = *p; *p = '\0'; rv = strtonum(nptr, 0, LINENUM_MAX, &errstr); if (errstr != NULL) fatal("invalid line number at line %ld: `%s' is %s\n", p_input_line, nptr, errstr); *p = c; *endptr = p; return rv; } diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h index 53ed71780e26..5ce4f72497c7 100644 --- a/usr.bin/patch/pch.h +++ b/usr.bin/patch/pch.h @@ -1,58 +1,57 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: pch.h,v 1.9 2003/10/31 20:20:45 millert Exp $ - * $FreeBSD$ */ #define OLD_FILE 0 #define NEW_FILE 1 #define INDEX_FILE 2 #define MAX_FILE 3 struct file_name { char *path; bool exists; }; extern char *source_file; void re_patch(void); void open_patch_file(const char *); void set_hunkmax(void); bool there_is_another_patch(void); bool another_hunk(void); bool pch_swap(void); char *pfetch(LINENUM); unsigned short pch_line_len(LINENUM); LINENUM pch_first(void); LINENUM pch_ptrn_lines(void); LINENUM pch_newfirst(void); LINENUM pch_repl_lines(void); LINENUM pch_end(void); LINENUM pch_context(void); LINENUM pch_hunk_beg(void); char pch_char(LINENUM); void do_ed_script(void); diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c index 080a3a266e3b..bb4c97e42112 100644 --- a/usr.bin/patch/util.c +++ b/usr.bin/patch/util.c @@ -1,424 +1,423 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "common.h" #include "util.h" #include "backupfile.h" #include "pathnames.h" /* Rename a file, copying it if necessary. */ int move_file(const char *from, const char *to) { int fromfd; ssize_t i; /* to stdout? */ if (strEQ(to, "-")) { #ifdef DEBUGGING if (debug & 4) say("Moving %s to stdout.\n", from); #endif fromfd = open(from, O_RDONLY); if (fromfd < 0) pfatal("internal error, can't reopen %s", from); while ((i = read(fromfd, buf, buf_size)) > 0) if (write(STDOUT_FILENO, buf, i) != i) pfatal("write failed"); close(fromfd); return 0; } if (backup_file(to) < 0) { say("Can't backup %s, output is in %s: %s\n", to, from, strerror(errno)); return -1; } #ifdef DEBUGGING if (debug & 4) say("Moving %s to %s.\n", from, to); #endif if (rename(from, to) < 0) { if (errno != EXDEV || copy_file(from, to) < 0) { say("Can't create %s, output is in %s: %s\n", to, from, strerror(errno)); return -1; } } return 0; } /* Backup the original file. */ int backup_file(const char *orig) { struct stat filestat; char bakname[PATH_MAX], *s, *simplename; dev_t orig_device; ino_t orig_inode; if (backup_type == none || stat(orig, &filestat) != 0) return 0; /* nothing to do */ /* * If the user used zero prefixes or suffixes, then * he doesn't want backups. Yet we have to remove * orig to break possible hardlinks. */ if ((origprae && *origprae == 0) || *simple_backup_suffix == 0) { unlink(orig); return 0; } orig_device = filestat.st_dev; orig_inode = filestat.st_ino; if (origprae) { if (strlcpy(bakname, origprae, sizeof(bakname)) >= sizeof(bakname) || strlcat(bakname, orig, sizeof(bakname)) >= sizeof(bakname)) fatal("filename %s too long for buffer\n", origprae); } else { if ((s = find_backup_file_name(orig)) == NULL) fatal("out of memory\n"); if (strlcpy(bakname, s, sizeof(bakname)) >= sizeof(bakname)) fatal("filename %s too long for buffer\n", s); free(s); } if ((simplename = strrchr(bakname, '/')) != NULL) simplename = simplename + 1; else simplename = bakname; /* * Find a backup name that is not the same file. Change the * first lowercase char into uppercase; if that isn't * sufficient, chop off the first char and try again. */ while (stat(bakname, &filestat) == 0 && orig_device == filestat.st_dev && orig_inode == filestat.st_ino) { /* Skip initial non-lowercase chars. */ for (s = simplename; *s && !islower((unsigned char)*s); s++) ; if (*s) *s = toupper((unsigned char)*s); else memmove(simplename, simplename + 1, strlen(simplename + 1) + 1); } #ifdef DEBUGGING if (debug & 4) say("Moving %s to %s.\n", orig, bakname); #endif if (rename(orig, bakname) < 0) { if (errno != EXDEV || copy_file(orig, bakname) < 0) return -1; } return 0; } /* * Copy a file. */ int copy_file(const char *from, const char *to) { int tofd, fromfd; ssize_t i; tofd = open(to, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (tofd < 0) return -1; fromfd = open(from, O_RDONLY, 0); if (fromfd < 0) pfatal("internal error, can't reopen %s", from); while ((i = read(fromfd, buf, buf_size)) > 0) if (write(tofd, buf, i) != i) pfatal("write to %s failed", to); close(fromfd); close(tofd); return 0; } /* * Allocate a unique area for a string. */ char * savestr(const char *s) { char *rv; if (!s) s = "Oops"; rv = strdup(s); if (rv == NULL) { if (using_plan_a) out_of_mem = true; else fatal("out of memory\n"); } return rv; } /* * Allocate a unique area for a string. Call fatal if out of memory. */ char * xstrdup(const char *s) { char *rv; if (!s) s = "Oops"; rv = strdup(s); if (rv == NULL) fatal("out of memory\n"); return rv; } /* * Vanilla terminal output (buffered). */ void say(const char *fmt, ...) { va_list ap; va_start(ap, fmt); vfprintf(stdout, fmt, ap); va_end(ap); fflush(stdout); } /* * Terminal output, pun intended. */ void fatal(const char *fmt, ...) { va_list ap; va_start(ap, fmt); fprintf(stderr, "patch: **** "); vfprintf(stderr, fmt, ap); va_end(ap); my_exit(2); } /* * Say something from patch, something from the system, then silence . . . */ void pfatal(const char *fmt, ...) { va_list ap; int errnum = errno; fprintf(stderr, "patch: **** "); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, ": %s\n", strerror(errnum)); my_exit(2); } /* * Get a response from the user via /dev/tty */ void ask(const char *fmt, ...) { va_list ap; ssize_t nr = 0; static int ttyfd = -1; va_start(ap, fmt); vfprintf(stdout, fmt, ap); va_end(ap); fflush(stdout); if (ttyfd < 0) ttyfd = open(_PATH_TTY, O_RDONLY); if (ttyfd >= 0) { if ((nr = read(ttyfd, buf, buf_size)) > 0 && buf[nr - 1] == '\n') buf[nr - 1] = '\0'; } if (ttyfd < 0 || nr <= 0) { /* no tty or error reading, pretend user entered 'return' */ putchar('\n'); buf[0] = '\0'; } } /* * How to handle certain events when not in a critical region. */ void set_signals(int reset) { static sig_t hupval, intval; if (!reset) { hupval = signal(SIGHUP, SIG_IGN); if (hupval != SIG_IGN) hupval = my_exit; intval = signal(SIGINT, SIG_IGN); if (intval != SIG_IGN) intval = my_exit; } signal(SIGHUP, hupval); signal(SIGINT, intval); } /* * How to handle certain events when in a critical region. */ void ignore_signals(void) { signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); } /* * Make sure we'll have the directories to create a file. If `striplast' is * true, ignore the last element of `filename'. */ void makedirs(const char *filename, bool striplast) { char *tmpbuf; if ((tmpbuf = strdup(filename)) == NULL) fatal("out of memory\n"); if (striplast) { char *s = strrchr(tmpbuf, '/'); if (s == NULL) { free(tmpbuf); return; /* nothing to be done */ } *s = '\0'; } if (mkpath(tmpbuf) != 0) pfatal("creation of %s failed", tmpbuf); free(tmpbuf); } /* * Make filenames more reasonable. */ char * fetchname(const char *at, bool *exists, int strip_leading) { char *fullname, *name, *t; int sleading, tab; struct stat filestat; if (at == NULL || *at == '\0') return NULL; while (isspace((unsigned char)*at)) at++; #ifdef DEBUGGING if (debug & 128) say("fetchname %s %d\n", at, strip_leading); #endif /* So files can be created by diffing against /dev/null. */ if (strnEQ(at, _PATH_DEVNULL, sizeof(_PATH_DEVNULL) - 1)) { *exists = true; return NULL; } name = fullname = t = savestr(at); tab = strchr(t, '\t') != NULL; /* Strip off up to `strip_leading' path components and NUL terminate. */ for (sleading = strip_leading; *t != '\0' && ((tab && *t != '\t') || !isspace((unsigned char)*t)); t++) { if (t[0] == '/' && t[1] != '/' && t[1] != '\0') if (--sleading >= 0) name = t + 1; } *t = '\0'; /* * If no -p option was given (957 is the default value!), we were * given a relative pathname, and the leading directories that we * just stripped off all exist, put them back on. */ if (strip_leading == 957 && name != fullname && *fullname != '/') { name[-1] = '\0'; if (stat(fullname, &filestat) == 0 && S_ISDIR(filestat.st_mode)) { name[-1] = '/'; name = fullname; } } name = savestr(name); free(fullname); *exists = stat(name, &filestat) == 0; return name; } void version(void) { printf("patch 2.0-12u11 FreeBSD\n"); my_exit(EXIT_SUCCESS); } /* * Exit with cleanup. */ void my_exit(int status) { unlink(TMPINNAME); if (!toutkeep) unlink(TMPOUTNAME); if (!trejkeep) unlink(TMPREJNAME); unlink(TMPPATNAME); exit(status); } diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h index 2ef6b2f3ec18..a968a64aa196 100644 --- a/usr.bin/patch/util.h +++ b/usr.bin/patch/util.h @@ -1,51 +1,50 @@ /*- * Copyright 1986, Larry Wall * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following condition is met: * 1. Redistributions of source code must retain the above copyright notice, * this condition and the following disclaimer. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * patch - a program to apply diffs to original files * * -C option added in 1998, original code by Marc Espie, based on FreeBSD * behaviour * * $OpenBSD: util.h,v 1.16 2014/12/13 10:31:07 tobias Exp $ - * $FreeBSD$ */ char *fetchname(const char *, bool *, int); int backup_file(const char *); int move_file(const char *, const char *); int copy_file(const char *, const char *); void say(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void fatal(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void pfatal(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); void ask(const char *, ...) __attribute__((__format__(__printf__, 1, 2))); char *savestr(const char *); char *xstrdup(const char *); void set_signals(int); void ignore_signals(void); void makedirs(const char *, bool); void version(void); void my_exit(int) __attribute__((noreturn)); /* in mkpath.c */ extern int mkpath(char *); diff --git a/usr.bin/pr/extern.h b/usr.bin/pr/extern.h index b44eb4187757..d84bca5d144e 100644 --- a/usr.bin/pr/extern.h +++ b/usr.bin/pr/extern.h @@ -1,65 +1,64 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1991 Keith Muller. * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ extern int eopterr; extern int eoptind; extern int eoptopt; extern char *eoptarg; void addnum(char *, int, int); int egetopt(int, char * const *, const char *); void flsh_errs(void); int horzcol(int, char **); int inln(FILE *, char *, int, int *, int, int *); int inskip(FILE *, int, int); void mfail(void); int mulfile(int, char **); FILE *nxtfile(int, char **, const char **, char *, int); int onecol(int, char **); int otln(char *, int, int *, int *, int); void pfail(void); int prhead(char *, const char *, int); int prtail(int, int); int setup(int, char **); void terminate(int); void usage(void); int vertcol(int, char **); diff --git a/usr.bin/pr/pr.h b/usr.bin/pr/pr.h index 2c9e50f6b4fa..6c0c810f371a 100644 --- a/usr.bin/pr/pr.h +++ b/usr.bin/pr/pr.h @@ -1,76 +1,75 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1991 Keith Muller. * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Keith Muller of the University of California, San Diego. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pr.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * parameter defaults */ #define CLCNT 1 #define INCHAR '\t' #define INGAP 8 #define OCHAR '\t' #define OGAP 8 #define LINES 66 #define NMWD 5 #define NMCHAR '\t' #define SCHAR '\t' #define PGWD 72 #define SPGWD 512 /* * misc default values */ #define HDFMT "%s %s Page %d\n\n\n" #define HEADLEN 5 #define TAILLEN 5 #define TIMEFMTD "%e %b %H:%M %Y" #define TIMEFMTM "%b %e %H:%M %Y" #define FNAME "" #define LBUF 8192 #define HDBUF 512 /* * structure for vertical columns. Used to balance cols on last page */ struct vcol { char *pt; /* ptr to col */ int cnt; /* char count */ }; diff --git a/usr.bin/primes/primes.h b/usr.bin/primes/primes.h index ae0bbcba5427..9c8d29a50419 100644 --- a/usr.bin/primes/primes.h +++ b/usr.bin/primes/primes.h @@ -1,74 +1,73 @@ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Landon Curt Noll. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)primes.h 8.2 (Berkeley) 3/1/94 - * $FreeBSD$ */ /* * primes - generate a table of primes between two values * * By: Landon Curt Noll chongo@toad.com, ...!{sun,tolsoft}!hoptoad!chongo * * chongo /\oo/\ */ #include /* ubig is the type that holds a large unsigned value */ typedef uint64_t ubig; /* must be >=32 bit unsigned value */ #define BIG ULONG_MAX /* largest value will sieve */ /* bytes in sieve table (must be > 3*5*7*11) */ #define TABSIZE 256*1024 /* * prime[i] is the (i-1)th prime. * * We are able to sieve 2^32-1 because this byte table yields all primes * up to 65537 and 65537^2 > 2^32-1. */ extern const ubig prime[]; extern const ubig *const pr_limit; /* largest prime in the prime array */ /* Maximum size sieving alone can handle. */ #define SIEVEMAX 4295098368ULL /* * To avoid excessive sieves for small factors, we use the table below to * setup our sieve blocks. Each element represents an odd number starting * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13. */ extern const char pattern[]; extern const size_t pattern_size; /* length of pattern array */ /* Test for primality using strong pseudoprime tests. */ int isprime(ubig); diff --git a/usr.bin/rpcgen/rpc_parse.h b/usr.bin/rpcgen/rpc_parse.h index 3ca874e44945..1e1716bb507a 100644 --- a/usr.bin/rpcgen/rpc_parse.h +++ b/usr.bin/rpcgen/rpc_parse.h @@ -1,200 +1,199 @@ /* - * $FreeBSD$ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * 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 */ /* #pragma ident "@(#)rpc_parse.h 1.10 94/05/15 SMI" */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ /* The copyright notice above does not evidence any */ /* actual or intended publication of such source code. */ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * PROPRIETARY NOTICE (Combined) * * This source code is unpublished proprietary information * constituting, or derived under license from AT&T's UNIX(r) System V. * In addition, portions of such source code were derived from Berkeley * 4.3 BSD under license from the Regents of the University of * California. * * * * Copyright Notice * * Notice of copyright on this source code product does not indicate * publication. * * (c) 1986,1987,1988.1989 Sun Microsystems, Inc * (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. * All rights reserved. */ /* @(#)rpc_parse.h 1.3 90/08/29 (C) 1987 SMI */ /* * rpc_parse.h, Definitions for the RPCL parser */ enum defkind { DEF_CONST, DEF_STRUCT, DEF_UNION, DEF_ENUM, DEF_TYPEDEF, DEF_PROGRAM }; typedef enum defkind defkind; typedef const char *const_def; enum relation { REL_VECTOR, /* fixed length array */ REL_ARRAY, /* variable length array */ REL_POINTER, /* pointer */ REL_ALIAS, /* simple */ }; typedef enum relation relation; struct typedef_def { const char *old_prefix; const char *old_type; relation rel; const char *array_max; }; typedef struct typedef_def typedef_def; struct enumval_list { const char *name; const char *assignment; struct enumval_list *next; }; typedef struct enumval_list enumval_list; struct enum_def { enumval_list *vals; }; typedef struct enum_def enum_def; struct declaration { const char *prefix; const char *type; const char *name; relation rel; const char *array_max; }; typedef struct declaration declaration; struct decl_list { declaration decl; struct decl_list *next; }; typedef struct decl_list decl_list; struct struct_def { decl_list *decls; }; typedef struct struct_def struct_def; struct case_list { const char *case_name; int contflag; declaration case_decl; struct case_list *next; }; typedef struct case_list case_list; struct union_def { declaration enum_decl; case_list *cases; declaration *default_decl; }; typedef struct union_def union_def; struct arg_list { char *argname; /* name of struct for arg*/ decl_list *decls; }; typedef struct arg_list arg_list; struct proc_list { const char *proc_name; const char *proc_num; arg_list args; int arg_num; const char *res_type; const char *res_prefix; struct proc_list *next; }; typedef struct proc_list proc_list; struct version_list { const char *vers_name; const char *vers_num; proc_list *procs; struct version_list *next; }; typedef struct version_list version_list; struct program_def { const char *prog_num; version_list *versions; }; typedef struct program_def program_def; struct definition { const char *def_name; defkind def_kind; union { const_def co; struct_def st; union_def un; enum_def en; typedef_def ty; program_def pr; } def; }; typedef struct definition definition; definition *get_definition(void); struct bas_type { const char *name; int length; struct bas_type *next; }; typedef struct bas_type bas_type; diff --git a/usr.bin/rpcgen/rpc_scan.h b/usr.bin/rpcgen/rpc_scan.h index a57eb3bb1948..1c86498780e6 100644 --- a/usr.bin/rpcgen/rpc_scan.h +++ b/usr.bin/rpcgen/rpc_scan.h @@ -1,136 +1,135 @@ /* - * $FreeBSD$ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * 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 */ /* #pragma ident "@(#)rpc_scan.h 1.11 94/05/15 SMI" */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ /* The copyright notice above does not evidence any */ /* actual or intended publication of such source code. */ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * PROPRIETARY NOTICE (Combined) * * This source code is unpublished proprietary information * constituting, or derived under license from AT&T's UNIX(r) System V. * In addition, portions of such source code were derived from Berkeley * 4.3 BSD under license from the Regents of the University of * California. * * * * Copyright Notice * * Notice of copyright on this source code product does not indicate * publication. * * (c) 1986,1987,1988.1989 Sun Microsystems, Inc * (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. * All rights reserved. */ /* @(#)rpc_scan.h 1.3 90/08/29 (C) 1987 SMI */ /* * rpc_scan.h, Definitions for the RPCL scanner */ /* * kinds of tokens */ enum tok_kind { TOK_IDENT, TOK_CHARCONST, TOK_STRCONST, TOK_LPAREN, TOK_RPAREN, TOK_LBRACE, TOK_RBRACE, TOK_LBRACKET, TOK_RBRACKET, TOK_LANGLE, TOK_RANGLE, TOK_STAR, TOK_COMMA, TOK_EQUAL, TOK_COLON, TOK_SEMICOLON, TOK_CONST, TOK_STRUCT, TOK_UNION, TOK_SWITCH, TOK_CASE, TOK_DEFAULT, TOK_ENUM, TOK_TYPEDEF, TOK_INT, TOK_SHORT, TOK_LONG, TOK_HYPER, TOK_UNSIGNED, TOK_FLOAT, TOK_DOUBLE, TOK_QUAD, TOK_OPAQUE, TOK_CHAR, TOK_STRING, TOK_BOOL, TOK_VOID, TOK_PROGRAM, TOK_VERSION, TOK_EOF }; typedef enum tok_kind tok_kind; /* * a token */ struct token { tok_kind kind; const char *str; }; typedef struct token token; /* * routine interface */ void scan(tok_kind expect, token *tokp); void scan2(tok_kind expect1, tok_kind expect2, token *tokp); void scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp); void scan_num(token *tokp); void peek(token *tokp); int peekscan(tok_kind expect, token *tokp); void get_token(token *tokp); diff --git a/usr.bin/rpcgen/rpc_util.h b/usr.bin/rpcgen/rpc_util.h index 59f38eec23fe..375ec0f627f4 100644 --- a/usr.bin/rpcgen/rpc_util.h +++ b/usr.bin/rpcgen/rpc_util.h @@ -1,230 +1,229 @@ /* - * $FreeBSD$ */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * 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 */ /* #pragma ident "@(#)rpc_util.h 1.16 94/05/15 SMI" */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ /* The copyright notice above does not evidence any */ /* actual or intended publication of such source code. */ /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * PROPRIETARY NOTICE (Combined) * * This source code is unpublished proprietary information * constituting, or derived under license from AT&T's UNIX(r) System V. * In addition, portions of such source code were derived from Berkeley * 4.3 BSD under license from the Regents of the University of * California. * * * * Copyright Notice * * Notice of copyright on this source code product does not indicate * publication. * * (c) 1986,1987,1988.1989 Sun Microsystems, Inc * (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. * All rights reserved. */ /* @(#)rpc_util.h 1.5 90/08/29 (C) 1987 SMI */ /* * rpc_util.h, Useful definitions for the RPC protocol compiler */ #include #include #define XALLOC(object) (object *) xmalloc(sizeof(object)) #define s_print (void) sprintf #define f_print (void) fprintf struct list { definition *val; struct list *next; }; typedef struct list list; struct xdrfunc { const char *name; int pointerp; struct xdrfunc *next; }; typedef struct xdrfunc xdrfunc; struct commandline { int cflag; /* xdr C routines */ int hflag; /* header file */ int lflag; /* client side stubs */ int mflag; /* server side stubs */ int nflag; /* netid flag */ int sflag; /* server stubs for the given transport */ int tflag; /* dispatch Table file */ int Ssflag; /* produce server sample code */ int Scflag; /* produce client sample code */ int makefileflag; /* Generate a template Makefile */ const char *infile; /* input module name */ const char *outfile; /* output module name */ }; #define PUT 1 #define GET 2 /* * Global variables */ #define MAXLINESIZE 1024 extern char curline[MAXLINESIZE]; extern char *where; extern int linenum; extern int tirpc_socket; extern const char *infilename; extern FILE *fout; extern FILE *fin; extern list *defined; extern bas_type *typ_list_h; extern bas_type *typ_list_t; extern xdrfunc *xdrfunc_head, *xdrfunc_tail; /* * All the option flags */ extern int inetdflag; extern int pmflag; extern int tblflag; extern int logflag; extern int newstyle; extern int CCflag; /* C++ flag */ extern int tirpcflag; /* flag for generating tirpc code */ extern int inline_size; /* if this is 0, then do not generate inline code */ extern int mtflag; /* * Other flags related with inetd jumpstart. */ extern int indefinitewait; extern int exitnow; extern int timerflag; extern int nonfatalerrors; extern pid_t childpid; /* * rpc_util routines */ void reinitialize(void); void crash(void) __dead2; void add_type(int len, const char *type); void storeval(list **lstp, definition *val); void *xmalloc(size_t size); void *xrealloc(void *ptr, size_t size); char *xstrdup(const char *); char *make_argname(const char *pname, const char *vname); #define STOREVAL(list,item) \ storeval(list,item) definition *findval(list *lst, const char *val, int (*cmp)(definition *, const char *)); #define FINDVAL(list,item,finder) \ findval(list, item, finder) const char *fixtype(const char *type); const char *stringfix(const char *type); char *locase(const char *str); void pvname_svc(const char *pname, const char *vnum); void pvname(const char *pname, const char *vnum); void ptype(const char *prefix, const char *type, int follow); int isvectordef(const char *type, relation rel); int streq(const char *a, const char *b); void error(const char *msg); void expected1(tok_kind exp1); void expected2(tok_kind exp1, tok_kind exp2); void expected3(tok_kind exp1, tok_kind exp2, tok_kind exp3); void tabify(FILE *f, int tab); void record_open(const char *file); bas_type *find_type(const char *type); /* * rpc_cout routines */ void emit(definition *def); /* * rpc_hout routines */ void pdeclaration(const char *name, declaration *dec, int tab, const char *separator); void print_datadef(definition *def, int headeronly); void print_funcdef(definition *def, int headeronly); void print_xdr_func_def(const char* name, int pointerp); /* * rpc_svcout routines */ void write_most(const char *infile, int netflag, int nomain); void write_rest(void); void write_programs(const char *storage); void write_svc_aux(int nomain); void write_inetd_register(const char *transp); void write_netid_register(const char *transp); void write_nettype_register(const char *transp); int nullproc(proc_list *proc); /* * rpc_clntout routines */ void write_stubs(void); void printarglist(proc_list *proc, const char *result, const char *addargname, const char *addargtype); /* * rpc_tblout routines */ void write_tables(void); /* * rpc_sample routines */ void write_sample_svc(definition *); int write_sample_clnt(definition *); void write_sample_clnt_main(void); void add_sample_msg(void); diff --git a/usr.bin/sed/defs.h b/usr.bin/sed/defs.h index 3a95fcf82e3b..460152a344ec 100644 --- a/usr.bin/sed/defs.h +++ b/usr.bin/sed/defs.h @@ -1,151 +1,150 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Diomidis Spinellis of Imperial College, University of London. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)defs.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * Types of address specifications */ enum e_atype { AT_RE = 1, /* Line that match RE */ AT_LINE, /* Specific line */ AT_RELLINE, /* Relative line */ AT_LAST, /* Last line */ }; /* * Format of an address */ struct s_addr { enum e_atype type; /* Address type */ union { u_long l; /* Line number */ regex_t *r; /* Regular expression */ } u; }; /* * Substitution command */ struct s_subst { int n; /* Occurrence to subst. */ int p; /* True if p flag */ int icase; /* True if I flag */ char *wfile; /* NULL if no wfile */ int wfd; /* Cached file descriptor */ regex_t *re; /* Regular expression */ unsigned int maxbref; /* Largest backreference. */ u_long linenum; /* Line number. */ char *new; /* Replacement text */ }; /* * Translate command. */ struct s_tr { unsigned char bytetab[256]; struct trmulti { size_t fromlen; char from[MB_LEN_MAX]; size_t tolen; char to[MB_LEN_MAX]; } *multis; int nmultis; }; /* * An internally compiled command. * Initially, label references are stored in t, on a second pass they * are updated to pointers. */ struct s_command { struct s_command *next; /* Pointer to next command */ struct s_addr *a1, *a2; /* Start and end address */ u_long startline; /* Start line number or zero */ char *t; /* Text for : a c i r w */ union { struct s_command *c; /* Command(s) for b t { */ struct s_subst *s; /* Substitute command */ struct s_tr *y; /* Replace command array */ int fd; /* File descriptor for w */ } u; char code; /* Command code */ u_int nonsel:1; /* True if ! */ }; /* * Types of command arguments recognised by the parser */ enum e_args { EMPTY, /* d D g G h H l n N p P q x = \0 */ TEXT, /* a c i */ NONSEL, /* ! */ GROUP, /* { */ ENDGROUP, /* } */ COMMENT, /* # */ BRANCH, /* b t */ LABEL, /* : */ RFILE, /* r */ WFILE, /* w */ SUBST, /* s */ TR /* y */ }; /* * Structure containing things to append before a line is read */ struct s_appends { enum {AP_STRING, AP_FILE} type; char *s; size_t len; }; enum e_spflag { APPEND, /* Append to the contents. */ REPLACE, /* Replace the contents. */ }; /* * Structure for a space (process, hold, otherwise). */ typedef struct { char *space; /* Current space pointer. */ size_t len; /* Current length. */ int deleted; /* If deleted. */ int append_newline; /* If originally terminated by \n. */ char *back; /* Backing memory. */ size_t blen; /* Backing memory length. */ } SPACE; diff --git a/usr.bin/sed/extern.h b/usr.bin/sed/extern.h index 4d88650417a3..2dee73587e59 100644 --- a/usr.bin/sed/extern.h +++ b/usr.bin/sed/extern.h @@ -1,60 +1,59 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1992 Diomidis Spinellis. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Diomidis Spinellis of Imperial College, University of London. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ extern struct s_command *prog; extern struct s_appends *appends; extern regmatch_t *match; extern size_t maxnsub; extern u_long linenum; extern unsigned int appendnum; extern int aflag, eflag, nflag; extern const char *fname, *outfname; extern FILE *infile, *outfile; extern int rflags; /* regex flags to use */ extern const char *inplace; extern int quit; void cfclose(struct s_command *, struct s_command *); void compile(void); void cspace(SPACE *, const char *, size_t, enum e_spflag); char *cu_fgets(char *, int, int *); int mf_fgets(SPACE *, enum e_spflag); int lastline(void); void process(void); void resetstate(void); char *strregerror(int, regex_t *); diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h index fc58b7a2af9c..c44a06a1a82d 100644 --- a/usr.bin/systat/extern.h +++ b/usr.bin/systat/extern.h @@ -1,192 +1,191 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include extern struct cmdtab *curcmd; extern struct cmdtab cmdtab[]; extern struct text *xtext; extern WINDOW *wnd; extern char **dr_name; extern char c, *namp, hostname[]; extern double avenrun[3]; extern float *dk_mspw; extern kvm_t *kd; extern long ntext, textp; extern int *dk_select; extern int CMDLINE; extern int dk_ndrive; extern int hz, stathz; extern double hertz; /* sampling frequency for cp_time and dk_time */ extern int col; extern int nhosts; extern int nports; extern int protos; extern int verbose; extern unsigned int delay; extern int curscale; extern char *matchline; extern int showpps; extern int needsort; struct in_conninfo; extern struct device_selection *dev_select; extern long generation; extern int num_devices; extern int num_selected; extern int num_selections; extern long select_generation; extern struct nlist namelist[]; int checkhost(struct in_conninfo *); int checkport(struct in_conninfo *); void closeicmp(WINDOW *); void closeicmp6(WINDOW *); void closeifstat(WINDOW *); void closeiostat(WINDOW *); void closeip(WINDOW *); void closeip6(WINDOW *); void closekre(WINDOW *); void closenetstat(WINDOW *); void closepigs(WINDOW *); void closeswap(WINDOW *); void closetcp(WINDOW *); int cmdifstat(const char *, const char *); int cmdiolat(const char *, const char *); int cmdiostat(const char *, const char *); int cmdkre(const char *, const char *); int cmdnetstat(const char *, const char *); struct cmdtab *lookup(const char *); void command(const char *); void die(int); void display(void); int dkinit(void); int dkcmd(char *, char *); void error(const char *fmt, ...) __printflike(1, 2); void fetchicmp(void); void fetchicmp6(void); void fetchifstat(void); void fetchip(void); void fetchip6(void); void fetchiostat(void); void fetchkre(void); void fetchnetstat(void); void fetchpigs(void); void fetchswap(void); void fetchtcp(void); void getsysctl(const char *, void *, size_t); int ifcmd(const char *cmd, const char *args); int initicmp(void); int initicmp6(void); int initifstat(void); int initip(void); int initip6(void); int initiostat(void); int initkre(void); int initnetstat(void); int initpigs(void); int initswap(void); int inittcp(void); int keyboard(void); int kvm_ckread(void *, void *, int); void labelicmp(void); void labelicmp6(void); void labelifstat(void); void labelip(void); void labelip6(void); void labeliostat(void); void labelkre(void); void labelnetstat(void); void labelpigs(void); void labels(void); void labelswap(void); void labeltcp(void); void load(void); int netcmd(const char *, const char *); void nlisterr(struct nlist []); WINDOW *openicmp(void); WINDOW *openicmp6(void); WINDOW *openifstat(void); WINDOW *openip(void); WINDOW *openip6(void); WINDOW *openiostat(void); WINDOW *openkre(void); WINDOW *opennetstat(void); WINDOW *openpigs(void); WINDOW *openswap(void); WINDOW *opentcp(void); int prefix(const char *, const char *); void reseticmp(void); void reseticmp6(void); void resetip(void); void resetip6(void); void resettcp(void); void showicmp(void); void showicmp6(void); void showifstat(void); void showip(void); void showip6(void); void showiostat(void); void showkre(void); void shownetstat(void); void showpigs(void); void showswap(void); void showtcp(void); void status(void); void suspend(int); char *sysctl_dynread(const char *, size_t *); void sysputpage(WINDOW* , int, int, int, uint64_t, int); void sysputspaces(WINDOW* , int, int, int); void sysputstrs(WINDOW* , int, int, int); void sysputXs(WINDOW* , int, int, int); void sysputuint64(WINDOW* , int, int, int, uint64_t, int); void sysputwuint64(WINDOW* , int, int, int, uint64_t, int); #define SYSTAT_CMD(name) \ void close ## name(WINDOW *); \ void fetch ## name(void); \ int init ## name(void); \ void label ## name(void); \ WINDOW *open ## name(void); \ void reset ## name(void); \ void show ## name(void) SYSTAT_CMD( zarc ); SYSTAT_CMD( sctp ); SYSTAT_CMD( iolat ); diff --git a/usr.bin/systat/systat.h b/usr.bin/systat/systat.h index 4ced36c32932..e64a0ad4fb53 100644 --- a/usr.bin/systat/systat.h +++ b/usr.bin/systat/systat.h @@ -1,80 +1,79 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1989, 1992, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * From: @(#)systat.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include struct cmdtab { const char *c_name; /* command name */ void (*c_refresh)(void); /* display refresh */ void (*c_fetch)(void); /* sets up data structures */ void (*c_label)(void); /* label display */ int (*c_init)(void); /* initialize namelist, etc. */ WINDOW *(*c_open)(void); /* open display */ void (*c_close)(WINDOW *); /* close display */ int (*c_cmd)(const char *, const char *); /* display command interpreter */ void (*c_reset)(void); /* reset ``mode since'' display */ char c_flags; /* see below */ }; /* * If we are started with privileges, use a kmem interface for netstat handling, * otherwise use sysctl. * In case of many open sockets, the sysctl handling might become slow. */ extern int use_kvm; #define CF_INIT 0x1 /* been initialized */ #define CF_LOADAV 0x2 /* display w/ load average */ #define CF_ZFSARC 0x4 /* display w/ ZFS cache usage */ #define TCP 0x1 #define UDP 0x2 #define MAINWIN_ROW 3 /* top row for the main/lower window */ #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var)) #define KREAD(addr, buf, len) kvm_ckread((addr), (buf), (len)) #define NVAL(indx) namelist[(indx)].n_value #define NPTR(indx) (void *)NVAL((indx)) #define NREAD(indx, buf, len) kvm_ckread(NPTR((indx)), (buf), (len)) extern void putint(int, int, int, int); extern void putfloat(double, int, int, int, int, int); extern void putlongdouble(long double, int, int, int, int, int); int procinit(void); void procgetinfo(void); void proclabel(int col); void procshow(int col, int hight, uint64_t totalswappages); diff --git a/usr.bin/talk/talk.h b/usr.bin/talk/talk.h index 04960b8a52c4..41e8281305f1 100644 --- a/usr.bin/talk/talk.h +++ b/usr.bin/talk/talk.h @@ -1,96 +1,95 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)talk.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include extern int sockt; extern int curses_initialized; extern int invitation_waiting; extern const char *current_state; extern int current_line; extern volatile sig_atomic_t gotwinch; typedef struct xwin { WINDOW *x_win; int x_nlines; int x_ncols; int x_line; int x_col; char kill; char cerase; char werase; } xwin_t; extern xwin_t my_win; extern xwin_t his_win; extern WINDOW *line_win; extern void announce_invite(void); extern int check_local(void); extern void check_writeable(void); extern void ctl_transact(struct in_addr,CTL_MSG,int,CTL_RESPONSE *); extern void disp_msg(int); extern void end_msgs(void); extern void get_addrs(const char *, const char *); extern int get_iface(struct in_addr *, struct in_addr *); extern void get_names(int, char **); extern void init_display(void); extern void invite_remote(void); extern int look_for_invite(CTL_RESPONSE *); extern int max(int, int); extern void message(const char *); extern void open_ctl(void); extern void open_sockt(void); extern void p_error(const char *); extern void print_addr(struct sockaddr_in); extern void quit(void); extern int readwin(WINDOW *, int, int); extern void re_invite(int); extern void send_delete(void); extern void set_edit_chars(void); extern void sig_sent(int); extern void sig_winch(int); extern void start_msgs(void); extern void talk(void); extern void resize_display(void); diff --git a/usr.bin/tftp/tftp.h b/usr.bin/tftp/tftp.h index 680ea2ea4fb6..59e5c9f39913 100644 --- a/usr.bin/tftp/tftp.h +++ b/usr.bin/tftp/tftp.h @@ -1,39 +1,38 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ int recvfile(int peer, char *port, int fd, char *name, char *mode); int xmitfile(int peer, char *port, int fd, char *name, char *mode); extern int verbose; extern int maxtimeout; diff --git a/usr.bin/top/machine.h b/usr.bin/top/machine.h index af66eaead76b..57f2846cdba5 100644 --- a/usr.bin/top/machine.h +++ b/usr.bin/top/machine.h @@ -1,99 +1,98 @@ /* - * $FreeBSD$ */ /* * This file defines the interface between top and the machine-dependent * module. It is NOT machine dependent and should not need to be changed * for any specific machine. */ #ifndef MACHINE_H #define MACHINE_H #include #include #define NUM_AVERAGES 3 /* Log base 2 of 1024 is 10 (2^10 == 1024) */ #define LOG1024 10 /* * the statics struct is filled in by machine_init */ struct statics { const char * const *procstate_names; const char * const *cpustate_names; const char * const *memory_names; const char * const *arc_names; const char * const *carc_names; const char * const *swap_names; const char * const *order_names; int nbatteries; int ncpus; }; /* * the system_info struct is filled in by a machine dependent routine. */ struct system_info { int last_pid; double load_avg[NUM_AVERAGES]; int p_total; int p_pactive; /* number of procs considered "active" */ int *procstates; int *cpustates; int *memory; int *arc; int *carc; int *swap; struct timeval boottime; int battery; int ncpus; }; /* * the process_select struct tells get_process_info what processes * and information we are interested in seeing */ struct process_select { bool idle; /* show idle processes */ bool self; /* show self */ bool system; /* show system processes */ bool thread; /* show threads */ bool thread_id; /* show thread ids */ #define TOP_MAX_UIDS 8 int uid[TOP_MAX_UIDS]; /* only these uids (unless uid[0] == -1) */ bool wcpu; /* show weighted cpu */ int jid; /* only this jid (unless jid == -1) */ bool jail; /* show jail ID */ bool swap; /* show swap usage */ bool kidle; /* show per-CPU idle threads */ int pid; /* only this pid (unless pid == -1) */ char *command; /* only this command (unless == NULL) */ }; /* routines defined by the machine dependent module */ struct handle; char *format_header(const char *uname_field); char *format_next_process(struct handle* handle, char *(*get_userid)(int), int flags); void toggle_pcpustats(void); void get_system_info(struct system_info *si); int machine_init(struct statics *statics); /* non-int routines typically used by the machine dependent module */ extern struct process_select ps; void * get_process_info(struct system_info *si, struct process_select *sel, int (*compare)(const void *, const void *)); #endif /* MACHINE_H */ diff --git a/usr.bin/top/utils.h b/usr.bin/top/utils.h index 2688f5518575..a730e339d200 100644 --- a/usr.bin/top/utils.h +++ b/usr.bin/top/utils.h @@ -1,25 +1,24 @@ /* - * $FreeBSD$ * * Top users/processes display for Unix * * This program may be freely redistributed, * but this entire comment MUST remain intact. * * Copyright (c) 1984, 1989, William LeFebvre, Rice University * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University */ #include int atoiwi(const char *); char *itoa(unsigned int); char *itoa7(int); int digits(int); const char **argparse(char *, int *); long percentages(int, int *, long *, long *, long *); const char *format_time(long); char *format_k(int64_t); int string_index(const char *string, const char * const *array); int find_pid(pid_t pid); diff --git a/usr.bin/tr/extern.h b/usr.bin/tr/extern.h index e939d2cf780d..f7e15b9db3a8 100644 --- a/usr.bin/tr/extern.h +++ b/usr.bin/tr/extern.h @@ -1,53 +1,52 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #define NCHARS_SB (UCHAR_MAX + 1) /* Number of single-byte characters. */ #define OOBCH -1 /* Out of band character value. */ typedef struct { enum { STRING1, STRING2 } which; enum { EOS, INFINITE, NORMAL, RANGE, SEQUENCE, CCLASS, CCLASS_UPPER, CCLASS_LOWER, SET } state; int cnt; /* character count */ wint_t lastch; /* last character */ wctype_t cclass; /* character class from wctype() */ wint_t equiv[NCHARS_SB]; /* equivalence set */ wint_t *set; /* set of characters */ char *str; /* user's string */ } STR; wint_t next(STR *); int charcoll(const void *, const void *); diff --git a/usr.bin/vgrind/extern.h b/usr.bin/vgrind/extern.h index e9d57b6e0372..45d139c61ee4 100644 --- a/usr.bin/vgrind/extern.h +++ b/usr.bin/vgrind/extern.h @@ -1,62 +1,61 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ extern bool _escaped; /* if last character was an escape */ extern char *s_start; /* start of the current string */ extern char *l_acmbeg; /* string introducing a comment */ extern char *l_acmend; /* string ending a comment */ extern char *l_blkbeg; /* string beginning of a block */ extern char *l_blkend; /* string ending a block */ extern char *l_chrbeg; /* delimiter for character constant */ extern char *l_chrend; /* delimiter for character constant */ extern char *l_combeg; /* string introducing a comment */ extern char *l_comend; /* string ending a comment */ extern char l_escape; /* character used to escape characters */ extern char *l_keywds[]; /* keyword table address */ extern bool l_onecase; /* upper and lower case are equivalent */ extern char *l_prcbeg; /* regular expr for procedure begin */ extern char *l_strbeg; /* delimiter for string constant */ extern char *l_strend; /* delimiter for string constant */ extern bool l_toplex; /* procedures only defined at top lex level */ extern const char *language; /* the language indicator */ #include __BEGIN_DECLS extern int STRNCMP(char *, char *, int); extern char *convexp(char *); extern char *expmatch(char *, char *, char *); __END_DECLS diff --git a/usr.bin/w/extern.h b/usr.bin/w/extern.h index 427f479f3d3f..c1dc3804bb7b 100644 --- a/usr.bin/w/extern.h +++ b/usr.bin/w/extern.h @@ -1,40 +1,39 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ extern int use_ampm; struct kinfo_proc; int pr_attime(time_t *, time_t *); int pr_idle(time_t); int proc_compare(struct kinfo_proc *, struct kinfo_proc *); diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c index 053c1c61ec3e..44c39ca66368 100644 --- a/usr.sbin/acpi/acpiconf/acpiconf.c +++ b/usr.sbin/acpi/acpiconf/acpiconf.c @@ -1,303 +1,302 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 1999 Mitsuru IWASAKI * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: acpiconf.c,v 1.5 2000/08/08 14:12:19 iwasaki Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #define ACPIDEV "/dev/acpi" static int acpifd; static void acpi_init(void) { acpifd = open(ACPIDEV, O_RDWR); if (acpifd == -1) acpifd = open(ACPIDEV, O_RDONLY); if (acpifd == -1) err(EX_OSFILE, ACPIDEV); } /* Prepare to sleep and then wait for the signal that sleeping can occur. */ static void acpi_sleep(int sleep_type) { int ret; /* Notify OS that we want to sleep. devd(8) gets this notify. */ ret = ioctl(acpifd, ACPIIO_REQSLPSTATE, &sleep_type); if (ret != 0) err(EX_IOERR, "request sleep type (%d) failed", sleep_type); } /* Ack or abort a pending suspend request. */ static void acpi_sleep_ack(int err_val) { int ret; ret = ioctl(acpifd, ACPIIO_ACKSLPSTATE, &err_val); if (ret != 0) err(EX_IOERR, "ack sleep type failed"); } /* should be a acpi define, but doesn't appear to be */ #define UNKNOWN_CAP 0xffffffff #define UNKNOWN_VOLTAGE 0xffffffff static int acpi_battinfo(int num) { union acpi_battery_ioctl_arg battio; const char *pwr_units; int hours, min, amp; uint32_t volt; if (num < 0 || num > 64) errx(EX_USAGE, "invalid battery %d", num); /* Print battery design information. */ battio.unit = num; if (ioctl(acpifd, ACPIIO_BATT_GET_BIX, &battio) == -1) err(EX_IOERR, "get battery info (%d) failed", num); amp = battio.bix.units; pwr_units = amp ? "mA" : "mW"; if (battio.bix.dcap == UNKNOWN_CAP) printf("Design capacity:\tunknown\n"); else printf("Design capacity:\t%d %sh\n", battio.bix.dcap, pwr_units); if (battio.bix.lfcap == UNKNOWN_CAP) printf("Last full capacity:\tunknown\n"); else printf("Last full capacity:\t%d %sh\n", battio.bix.lfcap, pwr_units); printf("Technology:\t\t%s\n", battio.bix.btech == 0 ? "primary (non-rechargeable)" : "secondary (rechargeable)"); if (ACPI_BIX_REV_MIN_CHECK(battio.bix.rev, ACPI_BIX_REV_1)) { printf("Battery Swappable Capability:\t"); if (battio.bix.scap == ACPI_BIX_SCAP_NO) printf("Non-swappable\n"); else if (battio.bix.scap == ACPI_BIX_SCAP_COLD) printf("cold swap\n"); else if (battio.bix.scap == ACPI_BIX_SCAP_HOT) printf("hot swap\n"); else printf("unknown\n"); } if (battio.bix.dvol == UNKNOWN_CAP) printf("Design voltage:\t\tunknown\n"); else printf("Design voltage:\t\t%d mV\n", battio.bix.dvol); printf("Capacity (warn):\t%d %sh\n", battio.bix.wcap, pwr_units); printf("Capacity (low):\t\t%d %sh\n", battio.bix.lcap, pwr_units); if (ACPI_BIX_REV_MIN_CHECK(battio.bix.rev, ACPI_BIX_REV_0)) { if (battio.bix.cycles != ACPI_BATT_UNKNOWN) printf("Cycle Count:\t\t%d\n", battio.bix.cycles); printf("Measurement Accuracy:\t%d %%\n", battio.bix.accuracy / 1000); if (battio.bix.stmax != ACPI_BATT_UNKNOWN) printf("Max Sampling Time:\t%d ms\n", battio.bix.stmax); if (battio.bix.stmin != ACPI_BATT_UNKNOWN) printf("Min Sampling Time:\t%d ms\n", battio.bix.stmin); printf("Max Average Interval:\t%d ms\n", battio.bix.aimax); printf("Min Average Interval:\t%d ms\n", battio.bix.aimin); } printf("Low/warn granularity:\t%d %sh\n", battio.bix.gra1, pwr_units); printf("Warn/full granularity:\t%d %sh\n", battio.bix.gra2, pwr_units); printf("Model number:\t\t%s\n", battio.bix.model); printf("Serial number:\t\t%s\n", battio.bix.serial); printf("Type:\t\t\t%s\n", battio.bix.type); printf("OEM info:\t\t%s\n", battio.bix.oeminfo); /* Fetch battery voltage information. */ volt = UNKNOWN_VOLTAGE; battio.unit = num; if (ioctl(acpifd, ACPIIO_BATT_GET_BST, &battio) == -1) err(EX_IOERR, "get battery status (%d) failed", num); if (battio.bst.state != ACPI_BATT_STAT_NOT_PRESENT) volt = battio.bst.volt; /* Print current battery state information. */ battio.unit = num; if (ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1) err(EX_IOERR, "get battery user info (%d) failed", num); if (battio.battinfo.state != ACPI_BATT_STAT_NOT_PRESENT) { const char *state; switch (battio.battinfo.state & ACPI_BATT_STAT_BST_MASK) { case 0: state = "high"; break; case ACPI_BATT_STAT_DISCHARG: state = "discharging"; break; case ACPI_BATT_STAT_CHARGING: state = "charging"; break; case ACPI_BATT_STAT_CRITICAL: state = "critical"; break; case ACPI_BATT_STAT_DISCHARG | ACPI_BATT_STAT_CRITICAL: state = "critical discharging"; break; case ACPI_BATT_STAT_CHARGING | ACPI_BATT_STAT_CRITICAL: state = "critical charging"; break; default: state = "invalid"; } printf("State:\t\t\t%s\n", state); if (battio.battinfo.cap == -1) printf("Remaining capacity:\tunknown\n"); else printf("Remaining capacity:\t%d%%\n", battio.battinfo.cap); if (battio.battinfo.min == -1) printf("Remaining time:\t\tunknown\n"); else { hours = battio.battinfo.min / 60; min = battio.battinfo.min % 60; printf("Remaining time:\t\t%d:%02d\n", hours, min); } if (battio.battinfo.rate == -1) printf("Present rate:\t\tunknown\n"); else if (amp && volt != UNKNOWN_VOLTAGE) { printf("Present rate:\t\t%d mA (%d mW)\n", battio.battinfo.rate, battio.battinfo.rate * volt / 1000); } else printf("Present rate:\t\t%d %s\n", battio.battinfo.rate, pwr_units); } else printf("State:\t\t\tnot present\n"); /* Print battery voltage information. */ if (volt == UNKNOWN_VOLTAGE) printf("Present voltage:\tunknown\n"); else printf("Present voltage:\t%d mV\n", volt); return (0); } static void usage(const char* prog) { printf("usage: %s [-h] [-i batt] [-k ack] [-s 1-4]\n", prog); exit(0); } int main(int argc, char *argv[]) { char *prog, *end; int c, sleep_type, battery, ack; int iflag = 0, kflag = 0, sflag = 0; prog = argv[0]; if (argc < 2) usage(prog); /* NOTREACHED */ sleep_type = -1; acpi_init(); while ((c = getopt(argc, argv, "hi:k:s:")) != -1) { switch (c) { case 'i': iflag = 1; battery = strtol(optarg, &end, 10); if ((size_t)(end - optarg) != strlen(optarg)) errx(EX_USAGE, "invalid battery"); break; case 'k': kflag = 1; ack = strtol(optarg, &end, 10); if ((size_t)(end - optarg) != strlen(optarg)) errx(EX_USAGE, "invalid ack argument"); break; case 's': sflag = 1; if (optarg[0] == 'S') optarg++; sleep_type = strtol(optarg, &end, 10); if ((size_t)(end - optarg) != strlen(optarg)) errx(EX_USAGE, "invalid sleep type"); if (sleep_type < 1 || sleep_type > 4) errx(EX_USAGE, "invalid sleep type (%d)", sleep_type); break; case 'h': default: usage(prog); /* NOTREACHED */ } } argc -= optind; argv += optind; if (iflag != 0 && kflag != 0 && sflag != 0) errx(EX_USAGE, "-i, -k and -s are mutually exclusive"); if (iflag != 0) { if (kflag != 0) errx(EX_USAGE, "-i and -k are mutually exclusive"); if (sflag != 0) errx(EX_USAGE, "-i and -s are mutually exclusive"); acpi_battinfo(battery); } if (kflag != 0) { if (sflag != 0) errx(EX_USAGE, "-k and -s are mutually exclusive"); acpi_sleep_ack(ack); } if (sflag != 0) acpi_sleep(sleep_type); close(acpifd); exit (0); } diff --git a/usr.sbin/bluetooth/bcmfw/bcmfw.c b/usr.sbin/bluetooth/bcmfw/bcmfw.c index 328790b1b837..1361c7fe6d51 100644 --- a/usr.sbin/bluetooth/bcmfw/bcmfw.c +++ b/usr.sbin/bluetooth/bcmfw/bcmfw.c @@ -1,310 +1,309 @@ /*- * bcmfw.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bcmfw.c,v 1.4 2003/04/27 19:28:09 max Exp $ - * $FreeBSD$ * * Based on Linux BlueZ BlueFW-0.9 package * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define BCMFW "bcmfw" #define BCMFW_INTR_EP 1 #define BCMFW_BULK_EP 2 #define BCMFW_BSIZE 4096 #define USB_VENDOR_BROADCOM 0x0a5c #define USB_PRODUCT_BROADCOM_BCM2033 0x2033 static int bcmfw_check_device (char const *name); static int bcmfw_load_firmware (char const *name, char const *md, char const *fw); static void bcmfw_usage (void); /* * Main */ int main(int argc, char *argv[]) { char *name = NULL, *md = NULL, *fw = NULL; int x; while ((x = getopt(argc, argv, "f:hn:m:")) != -1) { switch (x) { case 'f': /* firmware file */ fw = optarg; break; case 'n': /* name */ name = optarg; break; case 'm': /* Mini-driver */ md = optarg; break; case 'h': default: bcmfw_usage(); /* NOT REACHED */ } } if (name == NULL || md == NULL || fw == NULL) bcmfw_usage(); /* NOT REACHED */ openlog(BCMFW, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_USER); if (bcmfw_check_device(name) < 0) exit(1); if (bcmfw_load_firmware(name, md, fw) < 0) exit(1); closelog(); return (0); } /* main */ /* * Check device VendorID/ProductID */ static int bcmfw_check_device(char const *name) { usb_device_descriptor_t desc; char path[BCMFW_BSIZE]; int fd = -1, error = -1; snprintf(path, sizeof(path), "/dev/%s", name); if ((fd = open(path, O_WRONLY)) < 0) { syslog(LOG_ERR, "Could not open(%s). %s (%d)", path, strerror(errno), errno); goto out; } if (ioctl(fd, USB_GET_DEVICE_DESC, &desc) < 0) { syslog(LOG_ERR, "Could not ioctl(%d, %ld, %p). %s (%d)", fd, USB_GET_DEVICE_DESC, &desc, strerror(errno), errno); goto out; } if (UGETW(desc.idVendor) != USB_VENDOR_BROADCOM || UGETW(desc.idProduct) != USB_PRODUCT_BROADCOM_BCM2033) { syslog(LOG_ERR, "Unsupported device, VendorID=%#x, " \ "ProductID=%#x", UGETW(desc.idVendor), UGETW(desc.idProduct)); error = -1; } else error = 0; out: if (fd != -1) close(fd); return (error); } /* bcmfw_check_device */ /* * Download minidriver and firmware */ static int bcmfw_load_firmware(char const *name, char const *md, char const *fw) { char buf[BCMFW_BSIZE]; int intr = -1, bulk = -1, fd = -1, error = -1, len; /* Open interrupt endpoint device */ snprintf(buf, sizeof(buf), "/dev/%s.%d", name, BCMFW_INTR_EP); if ((intr = open(buf, O_RDONLY)) < 0) { syslog(LOG_ERR, "Could not open(%s). %s (%d)", buf, strerror(errno), errno); goto out; } /* Open bulk endpoint device */ snprintf(buf, sizeof(buf), "/dev/%s.%d", name, BCMFW_BULK_EP); if ((bulk = open(buf, O_WRONLY)) < 0) { syslog(LOG_ERR, "Could not open(%s). %s (%d)", buf, strerror(errno), errno); goto out; } /* * Load mini-driver */ if ((fd = open(md, O_RDONLY)) < 0) { syslog(LOG_ERR, "Could not open(%s). %s (%d)", md, strerror(errno), errno); goto out; } for (;;) { len = read(fd, buf, sizeof(buf)); if (len < 0) { syslog(LOG_ERR, "Could not read(%s). %s (%d)", md, strerror(errno), errno); goto out; } if (len == 0) break; len = write(bulk, buf, len); if (len < 0) { syslog(LOG_ERR, "Could not write(/dev/%s.%d). %s (%d)", name, BCMFW_BULK_EP, strerror(errno), errno); goto out; } } close(fd); fd = -1; usleep(10); /* * Memory select */ if (write(bulk, "#", 1) < 0) { syslog(LOG_ERR, "Could not write(/dev/%s.%d). %s (%d)", name, BCMFW_BULK_EP, strerror(errno), errno); goto out; } if (read(intr, buf, sizeof(buf)) < 0) { syslog(LOG_ERR, "Could not read(/dev/%s.%d). %s (%d)", name, BCMFW_INTR_EP, strerror(errno), errno); goto out; } if (buf[0] != '#') { syslog(LOG_ERR, "%s: Memory select failed (%c)", name, buf[0]); goto out; } /* * Load firmware */ if ((fd = open(fw, O_RDONLY)) < 0) { syslog(LOG_ERR, "Could not open(%s). %s (%d)", fw, strerror(errno), errno); goto out; } for (;;) { len = read(fd, buf, sizeof(buf)); if (len < 0) { syslog(LOG_ERR, "Could not read(%s). %s (%d)", fw, strerror(errno), errno); goto out; } if (len == 0) break; len = write(bulk, buf, len); if (len < 0) { syslog(LOG_ERR, "Could not write(/dev/%s.%d). %s (%d)", name, BCMFW_BULK_EP, strerror(errno), errno); goto out; } } close(fd); fd = -1; if (read(intr, buf, sizeof(buf)) < 0) { syslog(LOG_ERR, "Could not read(/dev/%s.%d). %s (%d)", name, BCMFW_INTR_EP, strerror(errno), errno); goto out; } if (buf[0] != '.') { syslog(LOG_ERR, "%s: Could not load firmware (%c)", name, buf[0]); goto out; } usleep(500000); error = 0; out: if (fd != -1) close(fd); if (bulk != -1) close(bulk); if (intr != -1) close(intr); return (error); } /* bcmfw_load_firmware */ /* * Display usage message and quit */ static void bcmfw_usage(void) { fprintf(stdout, "Usage: %s -n name -m md_file -f fw_file\n" "Where:\n" \ "\t-n name device name\n" \ "\t-m mini-driver image mini-driver image file name for download\n" \ "\t-f firmware image firmware image file name for download\n" \ "\t-h display this message\n", BCMFW); exit(255); } /* bcmfw_usage */ diff --git a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c index c7d4369e5f6d..40ece6ce0635 100644 --- a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c +++ b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.c @@ -1,218 +1,217 @@ /*- * bthidcontrol.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthidcontrol.c,v 1.2 2004/02/13 21:44:41 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidcontrol.h" static int do_bthid_command(bdaddr_p bdaddr, int argc, char **argv); static struct bthid_command * find_bthid_command(char const *command, struct bthid_command *category); static void print_bthid_command(struct bthid_command *category); static void usage(void) __dead2; int32_t hid_sdp_query(bdaddr_t const *local, bdaddr_t const *remote, int32_t *error); uint32_t verbose = 0; /* * bthidcontrol */ int main(int argc, char *argv[]) { bdaddr_t bdaddr; int opt; hid_init(NULL); memcpy(&bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr)); while ((opt = getopt(argc, argv, "a:c:H:hv")) != -1) { switch (opt) { case 'a': /* bdaddr */ if (!bt_aton(optarg, &bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&bdaddr, he->h_addr, sizeof(bdaddr)); } break; case 'c': /* config file */ config_file = optarg; break; case 'H': /* HIDs file */ hids_file = optarg; break; case 'v': /* verbose */ verbose++; break; case 'h': default: usage(); /* NOT REACHED */ } } argc -= optind; argv += optind; if (*argv == NULL) usage(); return (do_bthid_command(&bdaddr, argc, argv)); } /* main */ /* Execute commands */ static int do_bthid_command(bdaddr_p bdaddr, int argc, char **argv) { char *cmd = argv[0]; struct bthid_command *c = NULL; int e, help; help = 0; if (strcasecmp(cmd, "help") == 0) { argc --; argv ++; if (argc <= 0) { fprintf(stdout, "Supported commands:\n"); print_bthid_command(sdp_commands); print_bthid_command(hid_commands); fprintf(stdout, "\nFor more information use " \ "'help command'\n"); return (OK); } help = 1; cmd = argv[0]; } c = find_bthid_command(cmd, sdp_commands); if (c == NULL) c = find_bthid_command(cmd, hid_commands); if (c == NULL) { fprintf(stdout, "Unknown command: \"%s\"\n", cmd); return (ERROR); } if (!help) e = (c->handler)(bdaddr, -- argc, ++ argv); else e = USAGE; switch (e) { case OK: case FAILED: break; case ERROR: fprintf(stdout, "Could not execute command \"%s\". %s\n", cmd, strerror(errno)); break; case USAGE: fprintf(stdout, "Usage: %s\n%s\n", c->command, c->description); break; default: assert(0); break; } return (e); } /* do_bthid_command */ /* Try to find command in specified category */ static struct bthid_command * find_bthid_command(char const *command, struct bthid_command *category) { struct bthid_command *c = NULL; for (c = category; c->command != NULL; c++) { char *c_end = strchr(c->command, ' '); if (c_end != NULL) { int len = c_end - c->command; if (strncasecmp(command, c->command, len) == 0) return (c); } else if (strcasecmp(command, c->command) == 0) return (c); } return (NULL); } /* find_bthid_command */ /* Print commands in specified category */ static void print_bthid_command(struct bthid_command *category) { struct bthid_command *c = NULL; for (c = category; c->command != NULL; c++) fprintf(stdout, "\t%s\n", c->command); } /* print_bthid_command */ /* Usage */ static void usage(void) { fprintf(stderr, "Usage: bthidcontrol options command\n" \ "Where options are:\n" " -a bdaddr specify bdaddr\n" \ " -c file specify path to the bthidd config file\n" \ " -H file specify path to the bthidd HIDs file\n" \ " -h display usage and quit\n" \ " -v be verbose\n" \ " command one of the supported commands\n"); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h index 26706698994a..e44b670f8f7e 100644 --- a/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h +++ b/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.h @@ -1,52 +1,51 @@ /*- * bthidcontrol.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthidcontrol.h,v 1.1 2004/02/12 23:25:51 max Exp $ - * $FreeBSD$ */ #ifndef __BTHIDCONTROL_H__ #define __BTHIDCONTROL_H__ #define OK 0 /* everything was OK */ #define ERROR 1 /* could not execute command */ #define FAILED 2 /* error was reported */ #define USAGE 3 /* invalid parameters */ struct bthid_command { char const *command; char const *description; int (*handler)(bdaddr_t *, int, char **); }; extern struct bthid_command hid_commands[]; extern struct bthid_command sdp_commands[]; #endif /* __BTHIDCONTROL_H__ */ diff --git a/usr.sbin/bluetooth/bthidcontrol/hid.c b/usr.sbin/bluetooth/bthidcontrol/hid.c index 05c06e20bbf0..727eb8a716e7 100644 --- a/usr.sbin/bluetooth/bthidcontrol/hid.c +++ b/usr.sbin/bluetooth/bthidcontrol/hid.c @@ -1,217 +1,216 @@ /*- * hid.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hid.c,v 1.3 2004/02/17 22:14:57 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include "bthid_config.h" #include "bthidcontrol.h" extern uint32_t verbose; static void hid_dump_descriptor (report_desc_t r); static void hid_dump_item (char const *label, struct hid_item *h); static int hid_dump(bdaddr_t *bdaddr, int argc, char **argv) { struct hid_device *hd = NULL; int e = FAILED; if (read_config_file() == 0) { if ((hd = get_hid_device(bdaddr)) != NULL) { hid_dump_descriptor(hd->desc); e = OK; } clean_config(); } return (e); } static int hid_forget(bdaddr_t *bdaddr, int argc, char **argv) { struct hid_device *hd = NULL; int e = FAILED; if (read_config_file() == 0) { if (read_hids_file() == 0) { if ((hd = get_hid_device(bdaddr)) != NULL) { hd->new_device = 1; if (write_hids_file() == 0) e = OK; } } clean_config(); } return (e); } static int hid_known(bdaddr_t *bdaddr, int argc, char **argv) { struct hid_device *hd = NULL; struct hostent *he = NULL; int e = FAILED; if (read_config_file() == 0) { if (read_hids_file() == 0) { e = OK; for (hd = get_next_hid_device(hd); hd != NULL; hd = get_next_hid_device(hd)) { if (hd->new_device) continue; he = bt_gethostbyaddr((char *) &hd->bdaddr, sizeof(hd->bdaddr), AF_BLUETOOTH); fprintf(stdout, "%s %s\n", bt_ntoa(&hd->bdaddr, NULL), (he != NULL && he->h_name != NULL)? he->h_name : ""); } } clean_config(); } return (e); } static void hid_dump_descriptor(report_desc_t r) { struct hid_data *d = NULL; struct hid_item h; for (d = hid_start_parse(r, ~0, -1); hid_get_item(d, &h); ) { switch (h.kind) { case hid_collection: fprintf(stdout, "Collection page=%s usage=%s\n", hid_usage_page(HID_PAGE(h.usage)), hid_usage_in_page(h.usage)); break; case hid_endcollection: fprintf(stdout, "End collection\n"); break; case hid_input: hid_dump_item("Input ", &h); break; case hid_output: hid_dump_item("Output ", &h); break; case hid_feature: hid_dump_item("Feature", &h); break; } } hid_end_parse(d); } static void hid_dump_item(char const *label, struct hid_item *h) { if ((h->flags & HIO_CONST) && !verbose) return; fprintf(stdout, "%s id=%u size=%u count=%u page=%s usage=%s%s%s%s%s%s%s%s%s%s", label, (uint8_t) h->report_ID, h->report_size, h->report_count, hid_usage_page(HID_PAGE(h->usage)), hid_usage_in_page(h->usage), h->flags & HIO_CONST ? " Const" : "", h->flags & HIO_VARIABLE ? " Variable" : "", h->flags & HIO_RELATIVE ? " Relative" : "", h->flags & HIO_WRAP ? " Wrap" : "", h->flags & HIO_NONLINEAR ? " NonLinear" : "", h->flags & HIO_NOPREF ? " NoPref" : "", h->flags & HIO_NULLSTATE ? " NullState" : "", h->flags & HIO_VOLATILE ? " Volatile" : "", h->flags & HIO_BUFBYTES ? " BufBytes" : ""); fprintf(stdout, ", logical range %d..%d", h->logical_minimum, h->logical_maximum); if (h->physical_minimum != h->physical_maximum) fprintf(stdout, ", physical range %d..%d", h->physical_minimum, h->physical_maximum); if (h->unit) fprintf(stdout, ", unit=0x%02x exp=%d", h->unit, h->unit_exponent); fprintf(stdout, "\n"); } struct bthid_command hid_commands[] = { { "Dump", "Dump HID descriptor for the specified device in human readable form. The\n" \ "device must have an entry in the Bluetooth HID daemon configuration file.\n", hid_dump }, { "Known", "List all known to the Bluetooth HID daemon devices.\n", hid_known }, { "Forget", "Forget (mark as new) specified HID device. This command is useful when it\n" \ "is required to remove device from the known HIDs file. This should be done\n" \ "when reset button was pressed on the device or the battery was changed. The\n"\ "Bluetooth HID daemon should be restarted.\n", hid_forget }, { NULL, NULL, NULL } }; diff --git a/usr.sbin/bluetooth/bthidcontrol/sdp.c b/usr.sbin/bluetooth/bthidcontrol/sdp.c index 38b3dbc24a9d..dc83229f080c 100644 --- a/usr.sbin/bluetooth/bthidcontrol/sdp.c +++ b/usr.sbin/bluetooth/bthidcontrol/sdp.c @@ -1,504 +1,503 @@ /*- * sdp.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sdp.c,v 1.3 2004/02/17 22:14:57 max Exp $ - * $FreeBSD$ */ #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidcontrol.h" static int32_t hid_sdp_query (bdaddr_t const *local, struct hid_device *hd, int32_t *error); static int32_t hid_sdp_parse_protocol_descriptor_list (sdp_attr_p a); static int32_t hid_sdp_parse_hid_descriptor (sdp_attr_p a); static int32_t hid_sdp_parse_boolean (sdp_attr_p a); /* * Hard coded attribute IDs taken from the * DEVICE IDENTIFICATION PROFILE SPECIFICATION V13 p.12 */ #define SDP_ATTR_DEVICE_ID_SERVICE_VENDORID 0x0201 #define SDP_ATTR_DEVICE_ID_SERVICE_PRODUCTID 0x0202 #define SDP_ATTR_DEVICE_ID_SERVICE_VERSION 0x0203 #define SDP_ATTR_DEVICE_ID_RANGE SDP_ATTR_RANGE( \ SDP_ATTR_DEVICE_ID_SERVICE_VENDORID, SDP_ATTR_DEVICE_ID_SERVICE_VERSION ) static uint16_t service = SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE; static uint16_t service_devid = SDP_SERVICE_CLASS_PNP_INFORMATION; static uint32_t attrs_devid = SDP_ATTR_DEVICE_ID_RANGE; static uint32_t attrs[] = { SDP_ATTR_RANGE( SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST), SDP_ATTR_RANGE (SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS, SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS), SDP_ATTR_RANGE( 0x0205, /* HIDReconnectInitiate */ 0x0205), SDP_ATTR_RANGE( 0x0206, /* HIDDescriptorList */ 0x0206), SDP_ATTR_RANGE( 0x0209, /* HIDBatteryPower */ 0x0209), SDP_ATTR_RANGE( 0x020d, /* HIDNormallyConnectable */ 0x020d) }; #define nattrs (sizeof(attrs)/sizeof(attrs[0])) static sdp_attr_t values[8]; #define nvalues (sizeof(values)/sizeof(values[0])) static uint8_t buffer[nvalues][512]; /* * Query remote device */ #undef hid_sdp_query_exit #define hid_sdp_query_exit(e) { \ if (error != NULL) \ *error = (e); \ if (ss != NULL) { \ sdp_close(ss); \ ss = NULL; \ } \ return (((e) == 0)? 0 : -1); \ } static void hid_init_return_values() { int i; for (i = 0; i < nvalues; i ++) { values[i].flags = SDP_ATTR_INVALID; values[i].attr = 0; values[i].vlen = sizeof(buffer[i]); values[i].value = buffer[i]; } } static int32_t hid_sdp_query(bdaddr_t const *local, struct hid_device *hd, int32_t *error) { void *ss = NULL; uint8_t *hid_descriptor = NULL, *v; int32_t i, control_psm = -1, interrupt_psm = -1, reconnect_initiate = -1, normally_connectable = 0, battery_power = 0, hid_descriptor_length = -1, type; int16_t vendor_id = 0, product_id = 0, version = 0; bdaddr_t sdp_local; char devname[HCI_DEVNAME_SIZE]; if (local == NULL) local = NG_HCI_BDADDR_ANY; if (hd == NULL) hid_sdp_query_exit(EINVAL); hid_init_return_values(); if ((ss = sdp_open(local, &hd->bdaddr)) == NULL) hid_sdp_query_exit(ENOMEM); if (sdp_error(ss) != 0) hid_sdp_query_exit(sdp_error(ss)); if (sdp_search(ss, 1, &service, nattrs, attrs, nvalues, values) != 0) hid_sdp_query_exit(sdp_error(ss)); for (i = 0; i < nvalues; i ++) { if (values[i].flags != SDP_ATTR_OK) continue; switch (values[i].attr) { case SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST: control_psm = hid_sdp_parse_protocol_descriptor_list(&values[i]); break; case SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS: interrupt_psm = hid_sdp_parse_protocol_descriptor_list(&values[i]); break; case 0x0205: /* HIDReconnectInitiate */ reconnect_initiate = hid_sdp_parse_boolean(&values[i]); break; case 0x0206: /* HIDDescriptorList */ if (hid_sdp_parse_hid_descriptor(&values[i]) == 0) { hid_descriptor = values[i].value; hid_descriptor_length = values[i].vlen; } break; case 0x0209: /* HIDBatteryPower */ battery_power = hid_sdp_parse_boolean(&values[i]); break; case 0x020d: /* HIDNormallyConnectable */ normally_connectable = hid_sdp_parse_boolean(&values[i]); break; } } hid_init_return_values(); if (sdp_search(ss, 1, &service_devid, 1, &attrs_devid, nvalues, values) != 0) hid_sdp_query_exit(sdp_error(ss)); /* Try extract HCI bdaddr from opened SDP session */ if (sdp_get_lcaddr(ss, &sdp_local) != 0 || bt_devname(devname, &sdp_local) == 0) hid_sdp_query_exit(ENOATTR); sdp_close(ss); ss = NULL; /* If search is successful, scan through return vals */ for (i = 0; i < 3; i ++ ) { if (values[i].flags == SDP_ATTR_INVALID ) continue; /* Expecting tag + uint16_t on all 3 attributes */ if (values[i].vlen != 3) continue; /* Make sure, we're reading a uint16_t */ v = values[i].value; SDP_GET8(type, v); if (type != SDP_DATA_UINT16 ) continue; switch (values[i].attr) { case SDP_ATTR_DEVICE_ID_SERVICE_VENDORID: SDP_GET16(vendor_id, v); break; case SDP_ATTR_DEVICE_ID_SERVICE_PRODUCTID: SDP_GET16(product_id, v); break; case SDP_ATTR_DEVICE_ID_SERVICE_VERSION: SDP_GET16(version, v); break; default: break; } } if (control_psm == -1 || interrupt_psm == -1 || reconnect_initiate == -1 || hid_descriptor == NULL || hid_descriptor_length == -1) hid_sdp_query_exit(ENOATTR); hd->name = bt_devremote_name_gen(devname, &hd->bdaddr); hd->vendor_id = vendor_id; hd->product_id = product_id; hd->version = version; hd->control_psm = control_psm; hd->interrupt_psm = interrupt_psm; hd->reconnect_initiate = reconnect_initiate? 1 : 0; hd->battery_power = battery_power? 1 : 0; hd->normally_connectable = normally_connectable? 1 : 0; hd->desc = hid_use_report_desc(hid_descriptor, hid_descriptor_length); if (hd->desc == NULL) hid_sdp_query_exit(ENOMEM); return (0); } /* * seq len 2 * seq len 2 * uuid value 3 * uint16 value 3 * seq len 2 * uuid value 3 */ static int32_t hid_sdp_parse_protocol_descriptor_list(sdp_attr_p a) { uint8_t *ptr = a->value; uint8_t *end = a->value + a->vlen; int32_t type, len, uuid, psm; if (end - ptr < 15) return (-1); if (a->attr == SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS) { SDP_GET8(type, ptr); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, ptr); break; case SDP_DATA_SEQ16: SDP_GET16(len, ptr); break; case SDP_DATA_SEQ32: SDP_GET32(len, ptr); break; default: return (-1); } if (ptr + len > end) return (-1); } SDP_GET8(type, ptr); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, ptr); break; case SDP_DATA_SEQ16: SDP_GET16(len, ptr); break; case SDP_DATA_SEQ32: SDP_GET32(len, ptr); break; default: return (-1); } if (ptr + len > end) return (-1); /* Protocol */ SDP_GET8(type, ptr); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, ptr); break; case SDP_DATA_SEQ16: SDP_GET16(len, ptr); break; case SDP_DATA_SEQ32: SDP_GET32(len, ptr); break; default: return (-1); } if (ptr + len > end) return (-1); /* UUID */ if (ptr + 3 > end) return (-1); SDP_GET8(type, ptr); switch (type) { case SDP_DATA_UUID16: SDP_GET16(uuid, ptr); if (uuid != SDP_UUID_PROTOCOL_L2CAP) return (-1); break; case SDP_DATA_UUID32: /* XXX FIXME can we have 32-bit UUID */ case SDP_DATA_UUID128: /* XXX FIXME can we have 128-bit UUID */ default: return (-1); } /* PSM */ if (ptr + 3 > end) return (-1); SDP_GET8(type, ptr); if (type != SDP_DATA_UINT16) return (-1); SDP_GET16(psm, ptr); return (psm); } /* * seq len 2 * seq len 2 * uint8 value8 2 * str value 3 */ static int32_t hid_sdp_parse_hid_descriptor(sdp_attr_p a) { uint8_t *ptr = a->value; uint8_t *end = a->value + a->vlen; int32_t type, len, descriptor_type; if (end - ptr < 9) return (-1); SDP_GET8(type, ptr); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, ptr); break; case SDP_DATA_SEQ16: SDP_GET16(len, ptr); break; case SDP_DATA_SEQ32: SDP_GET32(len, ptr); break; default: return (-1); } if (ptr + len > end) return (-1); while (ptr < end) { /* Descriptor */ SDP_GET8(type, ptr); switch (type) { case SDP_DATA_SEQ8: if (ptr + 1 > end) return (-1); SDP_GET8(len, ptr); break; case SDP_DATA_SEQ16: if (ptr + 2 > end) return (-1); SDP_GET16(len, ptr); break; case SDP_DATA_SEQ32: if (ptr + 4 > end) return (-1); SDP_GET32(len, ptr); break; default: return (-1); } /* Descripor type */ if (ptr + 1 > end) return (-1); SDP_GET8(type, ptr); if (type != SDP_DATA_UINT8 || ptr + 1 > end) return (-1); SDP_GET8(descriptor_type, ptr); /* Descriptor value */ if (ptr + 1 > end) return (-1); SDP_GET8(type, ptr); switch (type) { case SDP_DATA_STR8: if (ptr + 1 > end) return (-1); SDP_GET8(len, ptr); break; case SDP_DATA_STR16: if (ptr + 2 > end) return (-1); SDP_GET16(len, ptr); break; case SDP_DATA_STR32: if (ptr + 4 > end) return (-1); SDP_GET32(len, ptr); break; default: return (-1); } if (ptr + len > end) return (-1); if (descriptor_type == UDESC_REPORT && len > 0) { a->value = ptr; a->vlen = len; return (0); } ptr += len; } return (-1); } /* bool8 int8 */ static int32_t hid_sdp_parse_boolean(sdp_attr_p a) { if (a->vlen != 2 || a->value[0] != SDP_DATA_BOOL) return (-1); return (a->value[1]); } /* Perform SDP query */ static int32_t hid_query(bdaddr_t *bdaddr, int argc, char **argv) { struct hid_device hd; int e; memcpy(&hd.bdaddr, bdaddr, sizeof(hd.bdaddr)); if (hid_sdp_query(NULL, &hd, &e) < 0) { fprintf(stderr, "Could not perform SDP query on the " \ "device %s. %s (%d)\n", bt_ntoa(bdaddr, NULL), strerror(e), e); return (FAILED); } print_hid_device(&hd, stdout); return (OK); } struct bthid_command sdp_commands[] = { { "Query", "Perform SDP query to the specified device and print HID configuration entry\n"\ "for the device. The configuration entry should be appended to the Bluetooth\n"\ "HID daemon configuration file and the daemon should be restarted.\n", hid_query }, { NULL, NULL, NULL } }; diff --git a/usr.sbin/bluetooth/bthidd/bthid_config.h b/usr.sbin/bluetooth/bthidd/bthid_config.h index bccadd3be59a..829af57aff45 100644 --- a/usr.sbin/bluetooth/bthidd/bthid_config.h +++ b/usr.sbin/bluetooth/bthidd/bthid_config.h @@ -1,80 +1,79 @@ /* * bthid_config.h */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthid_config.h,v 1.4 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #ifndef _BTHID_CONFIG_H_ #define _BTHID_CONFIG_H_ 1 #define BTHIDD_CONFFILE "/etc/bluetooth/bthidd.conf" #define BTHIDD_HIDSFILE "/var/db/bthidd.hids" struct hid_device { bdaddr_t bdaddr; /* HID device BDADDR */ char * name; /* HID device name */ uint16_t control_psm; /* control PSM */ uint16_t interrupt_psm; /* interrupt PSM */ uint16_t vendor_id; /* primary vendor id */ uint16_t product_id; uint16_t version; unsigned new_device : 1; unsigned reconnect_initiate : 1; unsigned battery_power : 1; unsigned normally_connectable : 1; unsigned keyboard : 1; unsigned mouse : 1; unsigned has_wheel : 1; unsigned has_hwheel : 1; unsigned has_cons : 1; unsigned reserved : 7; report_desc_t desc; /* HID report descriptor */ LIST_ENTRY(hid_device) next; /* link to the next */ }; typedef struct hid_device hid_device_t; typedef struct hid_device * hid_device_p; extern char const *config_file; extern char const *hids_file; int32_t read_config_file (void); void clean_config (void); hid_device_p get_hid_device (bdaddr_p bdaddr); hid_device_p get_next_hid_device (hid_device_p d); void print_hid_device (hid_device_p hid_device, FILE *f); int32_t read_hids_file (void); int32_t write_hids_file (void); #endif /* ndef _BTHID_CONFIG_H_ */ diff --git a/usr.sbin/bluetooth/bthidd/bthidd.c b/usr.sbin/bluetooth/bthidd/bthidd.c index 83471936365b..fad467667bd1 100644 --- a/usr.sbin/bluetooth/bthidd/bthidd.c +++ b/usr.sbin/bluetooth/bthidd/bthidd.c @@ -1,277 +1,276 @@ /* * bthidd.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthidd.c,v 1.8 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" static int32_t write_pid_file (char const *file); static int32_t remove_pid_file (char const *file); static int32_t elapsed (int32_t tval); static void sighandler (int32_t s); static void usage (void); /* * bthidd */ static int32_t done = 0; /* are we done? */ int32_t main(int32_t argc, char *argv[]) { struct bthid_server srv; struct sigaction sa; char const *pid_file = BTHIDD_PIDFILE; char *ep; int32_t opt, detach, tval, uinput; memset(&srv, 0, sizeof(srv)); memset(&srv.bdaddr, 0, sizeof(srv.bdaddr)); detach = 1; tval = 10; /* sec */ uinput = 0; while ((opt = getopt(argc, argv, "a:c:dH:hp:t:u")) != -1) { switch (opt) { case 'a': /* BDADDR */ if (!bt_aton(optarg, &srv.bdaddr)) { struct hostent *he; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&srv.bdaddr, he->h_addr, sizeof(srv.bdaddr)); } break; case 'c': /* config file */ config_file = optarg; break; case 'd': /* do not detach */ detach = 0; break; case 'H': /* hids file */ hids_file = optarg; break; case 'p': /* pid file */ pid_file = optarg; break; case 't': /* rescan interval */ tval = strtol(optarg, (char **) &ep, 10); if (*ep != '\0' || tval <= 0) usage(); break; case 'u': /* enable evdev support */ uinput = 1; break; case 'h': default: usage(); /* NOT REACHED */ } } openlog(BTHIDD_IDENT, LOG_PID|LOG_PERROR|LOG_NDELAY, LOG_USER); /* Become daemon if required */ if (detach && daemon(0, 0) < 0) { syslog(LOG_CRIT, "Could not become daemon. %s (%d)", strerror(errno), errno); exit(1); } /* Install signal handler */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sighandler; if (sigaction(SIGTERM, &sa, NULL) < 0 || sigaction(SIGHUP, &sa, NULL) < 0 || sigaction(SIGINT, &sa, NULL) < 0) { syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)", strerror(errno), errno); exit(1); } sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) < 0) { syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)", strerror(errno), errno); exit(1); } sa.sa_handler = SIG_IGN; sa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT; if (sigaction(SIGCHLD, &sa, NULL) < 0) { syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)", strerror(errno), errno); exit(1); } if (read_config_file() < 0 || read_hids_file() < 0 || server_init(&srv) < 0 || write_pid_file(pid_file) < 0) exit(1); srv.uinput = uinput; for (done = 0; !done; ) { if (elapsed(tval)) client_rescan(&srv); if (server_do(&srv) < 0) break; } server_shutdown(&srv); remove_pid_file(pid_file); clean_config(); closelog(); return (0); } /* * Write pid file */ static int32_t write_pid_file(char const *file) { FILE *pid; assert(file != NULL); if ((pid = fopen(file, "w")) == NULL) { syslog(LOG_ERR, "Could not open file %s. %s (%d)", file, strerror(errno), errno); return (-1); } fprintf(pid, "%d", getpid()); fclose(pid); return (0); } /* * Remote pid file */ static int32_t remove_pid_file(char const *file) { assert(file != NULL); if (unlink(file) < 0) { syslog(LOG_ERR, "Could not unlink file %s. %s (%d)", file, strerror(errno), errno); return (-1); } return (0); } /* * Returns true if desired time interval has elapsed */ static int32_t elapsed(int32_t tval) { static struct timeval last = { 0, 0 }; struct timeval now; gettimeofday(&now, NULL); if (now.tv_sec - last.tv_sec >= tval) { last = now; return (1); } return (0); } /* * Signal handler */ static void sighandler(int32_t s) { syslog(LOG_NOTICE, "Got signal %d, total number of signals %d", s, ++ done); } /* * Display usage and exit */ static void usage(void) { fprintf(stderr, "Usage: %s [options]\n" \ "Where options are:\n" \ " -a address specify address to listen on (default ANY)\n" \ " -c file specify config file name\n" \ " -d run in foreground\n" \ " -H file specify known HIDs file name\n" \ " -h display this message\n" \ " -p file specify PID file name\n" \ " -t tval specify client rescan interval (sec)\n" \ " -u enable evdev protocol support\n" \ "", BTHIDD_IDENT); exit(255); } diff --git a/usr.sbin/bluetooth/bthidd/bthidd.h b/usr.sbin/bluetooth/bthidd/bthidd.h index 842b59a9c04f..55fd03e57334 100644 --- a/usr.sbin/bluetooth/bthidd/bthidd.h +++ b/usr.sbin/bluetooth/bthidd/bthidd.h @@ -1,103 +1,102 @@ /* * bthidd.h */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bthidd.h,v 1.7 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #ifndef _BTHIDD_H_ #define _BTHIDD_H_ 1 #define BTHIDD_IDENT "bthidd" #define BTHIDD_PIDFILE "/var/run/" BTHIDD_IDENT ".pid" struct bthid_session; struct bthid_server { bdaddr_t bdaddr; /* local bdaddr */ int32_t cons; /* /dev/consolectl */ int32_t ctrl; /* control channel (listen) */ int32_t intr; /* intr. channel (listen) */ int32_t maxfd; /* max fd in sets */ int32_t uinput; /* enable evdev support */ fd_set rfdset; /* read descriptor set */ fd_set wfdset; /* write descriptor set */ LIST_HEAD(, bthid_session) sessions; }; typedef struct bthid_server bthid_server_t; typedef struct bthid_server * bthid_server_p; struct bthid_session { bthid_server_p srv; /* pointer back to server */ int32_t ctrl; /* control channel */ int32_t intr; /* interrupt channel */ int32_t vkbd; /* virual keyboard */ void *ctx; /* product specific dev state */ int32_t ukbd; /* evdev user input */ int32_t umouse;/* evdev user input */ int32_t obutt; /* previous mouse buttons */ int32_t consk; /* last consumer page key */ bdaddr_t bdaddr;/* remote bdaddr */ uint16_t state; /* session state */ #define CLOSED 0 #define W4CTRL 1 #define W4INTR 2 #define OPEN 3 bitstr_t *keys1; /* keys map (new) */ bitstr_t *keys2; /* keys map (old) */ LIST_ENTRY(bthid_session) next; /* link to next */ }; typedef struct bthid_session bthid_session_t; typedef struct bthid_session * bthid_session_p; int32_t server_init (bthid_server_p srv); void server_shutdown (bthid_server_p srv); int32_t server_do (bthid_server_p srv); int32_t client_rescan (bthid_server_p srv); int32_t client_connect (bthid_server_p srv, int fd); bthid_session_p session_open (bthid_server_p srv, hid_device_p const d); bthid_session_p session_by_bdaddr(bthid_server_p srv, bdaddr_p bdaddr); bthid_session_p session_by_fd (bthid_server_p srv, int32_t fd); int32_t session_run (bthid_session_p s); void session_close (bthid_session_p s); void hid_initialise (bthid_session_p s); int32_t hid_control (bthid_session_p s, uint8_t *data, int32_t len); int32_t hid_interrupt (bthid_session_p s, uint8_t *data, int32_t len); #endif /* ndef _BTHIDD_H_ */ diff --git a/usr.sbin/bluetooth/bthidd/client.c b/usr.sbin/bluetooth/bthidd/client.c index 6fa7baf915b0..63fef5867b98 100644 --- a/usr.sbin/bluetooth/bthidd/client.c +++ b/usr.sbin/bluetooth/bthidd/client.c @@ -1,258 +1,257 @@ /* * client.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: client.c,v 1.7 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" static int32_t client_socket(bdaddr_p bdaddr, uint16_t psm); /* * Get next config entry and create outbound connection (if required) * * XXX Do only one device at a time. At least one of my devices (3COM * Bluetooth PCCARD) rejects Create_Connection command if another * Create_Connection command is still pending. Weird... */ static int32_t connect_in_progress = 0; int32_t client_rescan(bthid_server_p srv) { static hid_device_p d; bthid_session_p s; assert(srv != NULL); if (connect_in_progress) return (0); /* another connect is still pending */ d = get_next_hid_device(d); if (d == NULL) return (0); /* XXX should not happen? empty config? */ if ((s = session_by_bdaddr(srv, &d->bdaddr)) != NULL) return (0); /* session already active */ if (!d->new_device) { if (d->reconnect_initiate) return (0); /* device will initiate reconnect */ } syslog(LOG_NOTICE, "Opening outbound session for %s " \ "(new_device=%d, reconnect_initiate=%d)", bt_ntoa(&d->bdaddr, NULL), d->new_device, d->reconnect_initiate); if ((s = session_open(srv, d)) == NULL) { syslog(LOG_CRIT, "Could not create outbound session for %s", bt_ntoa(&d->bdaddr, NULL)); return (-1); } /* Open control channel */ s->ctrl = client_socket(&s->bdaddr, d->control_psm); if (s->ctrl < 0) { syslog(LOG_ERR, "Could not open control channel to %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); session_close(s); return (-1); } s->state = W4CTRL; FD_SET(s->ctrl, &srv->wfdset); if (s->ctrl > srv->maxfd) srv->maxfd = s->ctrl; connect_in_progress = 1; return (0); } /* * Process connect on the socket */ int32_t client_connect(bthid_server_p srv, int32_t fd) { bthid_session_p s; hid_device_p d; int32_t error; socklen_t len; assert(srv != NULL); assert(fd >= 0); s = session_by_fd(srv, fd); assert(s != NULL); d = get_hid_device(&s->bdaddr); assert(d != NULL); error = 0; len = sizeof(error); if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { syslog(LOG_ERR, "Could not get socket error for %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); session_close(s); connect_in_progress = 0; return (-1); } if (error != 0) { syslog(LOG_ERR, "Could not connect to %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(error), error); session_close(s); connect_in_progress = 0; return (0); } switch (s->state) { case W4CTRL: /* Control channel is open */ assert(s->ctrl == fd); assert(s->intr == -1); /* Open interrupt channel */ s->intr = client_socket(&s->bdaddr, d->interrupt_psm); if (s->intr < 0) { syslog(LOG_ERR, "Could not open interrupt channel " \ "to %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); session_close(s); connect_in_progress = 0; return (-1); } s->state = W4INTR; FD_SET(s->intr, &srv->wfdset); if (s->intr > srv->maxfd) srv->maxfd = s->intr; d->new_device = 0; /* reset new device flag */ write_hids_file(); break; case W4INTR: /* Interrupt channel is open */ assert(s->ctrl != -1); assert(s->intr == fd); s->state = OPEN; connect_in_progress = 0; /* Create kbd/mouse after both channels are established */ if (session_run(s) < 0) { session_close(s); return (-1); } break; default: assert(0); break; } /* Move fd to from the write fd set into read fd set */ FD_CLR(fd, &srv->wfdset); FD_SET(fd, &srv->rfdset); return (0); } /* * Create bound non-blocking socket and initiate connect */ static int client_socket(bdaddr_p bdaddr, uint16_t psm) { struct sockaddr_l2cap l2addr; int32_t s, m; s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP); if (s < 0) return (-1); m = fcntl(s, F_GETFL); if (m < 0) { close(s); return (-1); } if (fcntl(s, F_SETFL, (m|O_NONBLOCK)) < 0) { close(s); return (-1); } l2addr.l2cap_len = sizeof(l2addr); l2addr.l2cap_family = AF_BLUETOOTH; memset(&l2addr.l2cap_bdaddr, 0, sizeof(l2addr.l2cap_bdaddr)); l2addr.l2cap_psm = 0; l2addr.l2cap_bdaddr_type = BDADDR_BREDR; l2addr.l2cap_cid = 0; if (bind(s, (struct sockaddr *) &l2addr, sizeof(l2addr)) < 0) { close(s); return (-1); } memcpy(&l2addr.l2cap_bdaddr, bdaddr, sizeof(l2addr.l2cap_bdaddr)); l2addr.l2cap_psm = htole16(psm); if (connect(s, (struct sockaddr *) &l2addr, sizeof(l2addr)) < 0 && errno != EINPROGRESS) { close(s); return (-1); } return (s); } diff --git a/usr.sbin/bluetooth/bthidd/hid.c b/usr.sbin/bluetooth/bthidd/hid.c index 17c2d92f8316..4de3c07119e2 100644 --- a/usr.sbin/bluetooth/bthidd/hid.c +++ b/usr.sbin/bluetooth/bthidd/hid.c @@ -1,579 +1,578 @@ /* * hid.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hid.c,v 1.5 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" #include "btuinput.h" #include "kbd.h" /* * Inoffical and unannounced report ids for Apple Mice and trackpad */ #define TRACKPAD_REPORT_ID 0x28 #define AMM_REPORT_ID 0x29 #define BATT_STAT_REPORT_ID 0x30 #define BATT_STRENGTH_REPORT_ID 0x47 #define SURFACE_REPORT_ID 0x61 /* * Apple magic mouse (AMM) specific device state */ #define AMM_MAX_BUTTONS 16 struct apple_state { int y [AMM_MAX_BUTTONS]; int button_state; }; #define MAGIC_MOUSE(D) (((D)->vendor_id == 0x5ac) && ((D)->product_id == 0x30d)) #define AMM_BASIC_BLOCK 5 #define AMM_FINGER_BLOCK 8 #define AMM_VALID_REPORT(L) (((L) >= AMM_BASIC_BLOCK) && \ ((L) <= 16*AMM_FINGER_BLOCK + AMM_BASIC_BLOCK) && \ ((L) % AMM_FINGER_BLOCK) == AMM_BASIC_BLOCK) #define AMM_WHEEL_SPEED 100 /* * Probe for per-device initialisation */ void hid_initialise(bthid_session_p s) { hid_device_p hid_device = get_hid_device(&s->bdaddr); if (hid_device && MAGIC_MOUSE(hid_device)) { /* Magic report to enable trackpad on Apple's Magic Mouse */ static uint8_t rep[] = {0x53, 0xd7, 0x01}; if ((s->ctx = calloc(1, sizeof(struct apple_state))) == NULL) return; write(s->ctrl, rep, 3); } } /* * Process data from control channel */ int32_t hid_control(bthid_session_p s, uint8_t *data, int32_t len) { assert(s != NULL); assert(data != NULL); assert(len > 0); switch (data[0] >> 4) { case 0: /* Handshake (response to command) */ if (data[0] & 0xf) syslog(LOG_ERR, "Got handshake message with error " \ "response 0x%x from %s", data[0], bt_ntoa(&s->bdaddr, NULL)); break; case 1: /* HID Control */ switch (data[0] & 0xf) { case 0: /* NOP */ break; case 1: /* Hard reset */ case 2: /* Soft reset */ syslog(LOG_WARNING, "Device %s requested %s reset", bt_ntoa(&s->bdaddr, NULL), ((data[0] & 0xf) == 1)? "hard" : "soft"); break; case 3: /* Suspend */ syslog(LOG_NOTICE, "Device %s requested Suspend", bt_ntoa(&s->bdaddr, NULL)); break; case 4: /* Exit suspend */ syslog(LOG_NOTICE, "Device %s requested Exit Suspend", bt_ntoa(&s->bdaddr, NULL)); break; case 5: /* Virtual cable unplug */ syslog(LOG_NOTICE, "Device %s unplugged virtual cable", bt_ntoa(&s->bdaddr, NULL)); session_close(s); break; default: syslog(LOG_WARNING, "Device %s sent unknown " \ "HID_Control message 0x%x", bt_ntoa(&s->bdaddr, NULL), data[0]); break; } break; default: syslog(LOG_WARNING, "Got unexpected message 0x%x on Control " \ "channel from %s", data[0], bt_ntoa(&s->bdaddr, NULL)); break; } return (0); } /* * Process data from the interrupt channel */ int32_t hid_interrupt(bthid_session_p s, uint8_t *data, int32_t len) { hid_device_p hid_device; hid_data_t d; hid_item_t h; int32_t report_id, usage, page, val, mouse_x, mouse_y, mouse_z, mouse_t, mouse_butt, mevents, kevents, i; assert(s != NULL); assert(s->srv != NULL); assert(data != NULL); if (len < 3) { syslog(LOG_ERR, "Got short message (%d bytes) on Interrupt " \ "channel from %s", len, bt_ntoa(&s->bdaddr, NULL)); return (-1); } if (data[0] != 0xa1) { syslog(LOG_ERR, "Got unexpected message 0x%x on " \ "Interrupt channel from %s", data[0], bt_ntoa(&s->bdaddr, NULL)); return (-1); } report_id = data[1]; data ++; len --; hid_device = get_hid_device(&s->bdaddr); assert(hid_device != NULL); mouse_x = mouse_y = mouse_z = mouse_t = mouse_butt = 0; mevents = kevents = 0; for (d = hid_start_parse(hid_device->desc, 1 << hid_input, -1); hid_get_item(d, &h) > 0; ) { if ((h.flags & HIO_CONST) || (h.report_ID != report_id) || (h.kind != hid_input)) continue; page = HID_PAGE(h.usage); val = hid_get_data(data, &h); /* * When the input field is an array and the usage is specified * with a range instead of an ID, we have to derive the actual * usage by using the item value as an index in the usage range * list. */ if ((h.flags & HIO_VARIABLE)) { usage = HID_USAGE(h.usage); } else { const uint32_t usage_offset = val - h.logical_minimum; usage = HID_USAGE(h.usage_minimum + usage_offset); } switch (page) { case HUP_GENERIC_DESKTOP: switch (usage) { case HUG_X: mouse_x = val; mevents ++; break; case HUG_Y: mouse_y = val; mevents ++; break; case HUG_WHEEL: mouse_z = -val; mevents ++; break; case HUG_SYSTEM_SLEEP: if (val) syslog(LOG_NOTICE, "Sleep button pressed"); break; } break; case HUP_KEYBOARD: kevents ++; if (h.flags & HIO_VARIABLE) { if (val && usage < kbd_maxkey()) bit_set(s->keys1, usage); } else { if (val && val < kbd_maxkey()) bit_set(s->keys1, val); for (i = 1; i < h.report_count; i++) { h.pos += h.report_size; val = hid_get_data(data, &h); if (val && val < kbd_maxkey()) bit_set(s->keys1, val); } } break; case HUP_BUTTON: if (usage != 0) { if (usage == 2) usage = 3; else if (usage == 3) usage = 2; mouse_butt |= (val << (usage - 1)); mevents ++; } break; case HUP_CONSUMER: if (hid_device->keyboard && s->srv->uinput) { if (h.flags & HIO_VARIABLE) { uinput_rep_cons(s->ukbd, usage, !!val); } else { if (s->consk > 0) uinput_rep_cons(s->ukbd, s->consk, 0); if (uinput_rep_cons(s->ukbd, val, 1) == 0) s->consk = val; } } if (!val) break; switch (usage) { case HUC_AC_PAN: /* Horizontal scroll */ mouse_t = val; mevents ++; val = 0; break; case 0xb5: /* Scan Next Track */ val = 0x19; break; case 0xb6: /* Scan Previous Track */ val = 0x10; break; case 0xb7: /* Stop */ val = 0x24; break; case 0xcd: /* Play/Pause */ val = 0x22; break; case 0xe2: /* Mute */ val = 0x20; break; case 0xe9: /* Volume Up */ val = 0x30; break; case 0xea: /* Volume Down */ val = 0x2E; break; case 0x183: /* Media Select */ val = 0x6D; break; case 0x018a: /* Mail */ val = 0x6C; break; case 0x192: /* Calculator */ val = 0x21; break; case 0x194: /* My Computer */ val = 0x6B; break; case 0x221: /* WWW Search */ val = 0x65; break; case 0x223: /* WWW Home */ val = 0x32; break; case 0x224: /* WWW Back */ val = 0x6A; break; case 0x225: /* WWW Forward */ val = 0x69; break; case 0x226: /* WWW Stop */ val = 0x68; break; case 0x227: /* WWW Refresh */ val = 0x67; break; case 0x22a: /* WWW Favorites */ val = 0x66; break; default: val = 0; break; } /* XXX FIXME - UGLY HACK */ if (val != 0) { if (hid_device->keyboard) { int32_t buf[4] = { 0xe0, val, 0xe0, val|0x80 }; assert(s->vkbd != -1); write(s->vkbd, buf, sizeof(buf)); } else syslog(LOG_ERR, "Keyboard events " \ "received from non-keyboard " \ "device %s. Please report", bt_ntoa(&s->bdaddr, NULL)); } break; case HUP_MICROSOFT: switch (usage) { case 0xfe01: if (!hid_device->battery_power) break; switch (val) { case 1: syslog(LOG_INFO, "Battery is OK on %s", bt_ntoa(&s->bdaddr, NULL)); break; case 2: syslog(LOG_NOTICE, "Low battery on %s", bt_ntoa(&s->bdaddr, NULL)); break; case 3: syslog(LOG_WARNING, "Very low battery "\ "on %s", bt_ntoa(&s->bdaddr, NULL)); break; } break; } break; } } hid_end_parse(d); /* * Apple adheres to no standards and sends reports it does * not introduce in its hid descriptor for its magic mouse. * Handle those reports here. */ if (MAGIC_MOUSE(hid_device) && s->ctx) { struct apple_state *c = (struct apple_state *)s->ctx; int firm = 0, middle = 0; int16_t v; data++, len--; /* Chomp report_id */ if (report_id != AMM_REPORT_ID || !AMM_VALID_REPORT(len)) goto check_middle_button; /* * The basics. When touches are detected, no normal mouse * reports are sent. Collect clicks and dx/dy */ if (data[2] & 1) mouse_butt |= 0x1; if (data[2] & 2) mouse_butt |= 0x4; if ((v = data[0] + ((data[2] & 0x0C) << 6))) mouse_x += ((int16_t)(v << 6)) >> 6, mevents++; if ((v = data[1] + ((data[2] & 0x30) << 4))) mouse_y += ((int16_t)(v << 6)) >> 6, mevents++; /* * The hard part: accumulate touch events and emulate middle */ for (data += AMM_BASIC_BLOCK, len -= AMM_BASIC_BLOCK; len >= AMM_FINGER_BLOCK; data += AMM_FINGER_BLOCK, len -= AMM_FINGER_BLOCK) { int x, y, z, force, id; v = data[0] | ((data[1] & 0xf) << 8); x = ((int16_t)(v << 4)) >> 4; v = (data[1] >> 4) | (data[2] << 4); y = -(((int16_t)(v << 4)) >> 4); force = data[5] & 0x3f; id = 0xf & ((data[5] >> 6) | (data[6] << 2)); z = (y - c->y[id]) / AMM_WHEEL_SPEED; switch ((data[7] >> 4) & 0x7) { /* Phase */ case 3: /* First touch */ c->y[id] = y; break; case 4: /* Touch dragged */ if (z) { mouse_z += z; c->y[id] += z * AMM_WHEEL_SPEED; mevents++; } break; default: break; } /* Count firm touches vs. firm+middle touches */ if (force >= 8 && ++firm && x > -350 && x < 350) ++middle; } /* * If a new click is registered by mouse and there are firm * touches which are all in center, make it a middle click */ if (mouse_butt && !c->button_state && firm && middle == firm) mouse_butt = 0x2; /* * If we're still clicking and have converted the click * to a middle click, keep it middle clicking */ check_middle_button: if (mouse_butt && c->button_state == 0x2) mouse_butt = 0x2; if (mouse_butt != c->button_state) c->button_state = mouse_butt, mevents++; } /* * XXX FIXME Feed keyboard events into kernel. * The code below works, bit host also needs to track * and handle repeat. * * Key repeat currently works in X, but not in console. */ if (kevents > 0) { if (hid_device->keyboard) { assert(s->vkbd != -1); kbd_process_keys(s); } else syslog(LOG_ERR, "Keyboard events received from " \ "non-keyboard device %s. Please report", bt_ntoa(&s->bdaddr, NULL)); } /* * XXX FIXME Feed mouse events into kernel. * The code block below works, but it is not good enough. * Need to track double-clicks etc. * * Double click currently works in X, but not in console. */ if (mevents > 0) { struct mouse_info mi; memset(&mi, 0, sizeof(mi)); mi.operation = MOUSE_ACTION; mi.u.data.buttons = mouse_butt; /* translate T-axis into button presses */ if (mouse_t != 0) { mi.u.data.buttons |= 1 << (mouse_t > 0 ? 6 : 5); if (ioctl(s->srv->cons, CONS_MOUSECTL, &mi) < 0) syslog(LOG_ERR, "Could not process mouse " \ "events from %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); } mi.u.data.x = mouse_x; mi.u.data.y = mouse_y; mi.u.data.z = mouse_z; mi.u.data.buttons = mouse_butt; if (ioctl(s->srv->cons, CONS_MOUSECTL, &mi) < 0) syslog(LOG_ERR, "Could not process mouse events from " \ "%s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); if (hid_device->mouse && s->srv->uinput && uinput_rep_mouse(s->umouse, mouse_x, mouse_y, mouse_z, mouse_t, mouse_butt, s->obutt) < 0) syslog(LOG_ERR, "Could not process mouse events from " \ "%s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); s->obutt = mouse_butt; } return (0); } diff --git a/usr.sbin/bluetooth/bthidd/kbd.c b/usr.sbin/bluetooth/bthidd/kbd.c index a3b6ec95c190..c1616c7e4bd3 100644 --- a/usr.sbin/bluetooth/bthidd/kbd.c +++ b/usr.sbin/bluetooth/bthidd/kbd.c @@ -1,614 +1,613 @@ /* * kbd.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: kbd.c,v 1.4 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" #include "btuinput.h" #include "kbd.h" static void kbd_write(bitstr_t *m, int32_t fb, int32_t make, int32_t fd); static int32_t kbd_xlate(int32_t code, int32_t make, int32_t *b, int32_t const *eob); static void uinput_kbd_write(bitstr_t *m, int32_t fb, int32_t make, int32_t fd); /* * HID code to PS/2 set 1 code translation table. * * http://www.microsoft.com/whdc/device/input/Scancode.mspx * * The table only contains "make" (key pressed) codes. * The "break" (key released) code is generated as "make" | 0x80 */ #define E0PREFIX (1U << 31) #define NOBREAK (1 << 30) #define CODEMASK (~(E0PREFIX|NOBREAK)) static int32_t const x[] = { /*==================================================*/ /* Name HID code Make Break*/ /*==================================================*/ /* No Event 00 */ -1, /* None */ /* Overrun Error 01 */ NOBREAK|0xFF, /* None */ /* POST Fail 02 */ NOBREAK|0xFC, /* None */ /* ErrorUndefined 03 */ -1, /* Unassigned */ /* a A 04 */ 0x1E, /* 9E */ /* b B 05 */ 0x30, /* B0 */ /* c C 06 */ 0x2E, /* AE */ /* d D 07 */ 0x20, /* A0 */ /* e E 08 */ 0x12, /* 92 */ /* f F 09 */ 0x21, /* A1 */ /* g G 0A */ 0x22, /* A2 */ /* h H 0B */ 0x23, /* A3 */ /* i I 0C */ 0x17, /* 97 */ /* j J 0D */ 0x24, /* A4 */ /* k K 0E */ 0x25, /* A5 */ /* l L 0F */ 0x26, /* A6 */ /* m M 10 */ 0x32, /* B2 */ /* n N 11 */ 0x31, /* B1 */ /* o O 12 */ 0x18, /* 98 */ /* p P 13 */ 0x19, /* 99 */ /* q Q 14 */ 0x10, /* 90 */ /* r R 15 */ 0x13, /* 93 */ /* s S 16 */ 0x1F, /* 9F */ /* t T 17 */ 0x14, /* 94 */ /* u U 18 */ 0x16, /* 96 */ /* v V 19 */ 0x2F, /* AF */ /* w W 1A */ 0x11, /* 91 */ /* x X 1B */ 0x2D, /* AD */ /* y Y 1C */ 0x15, /* 95 */ /* z Z 1D */ 0x2C, /* AC */ /* 1 ! 1E */ 0x02, /* 82 */ /* 2 @ 1F */ 0x03, /* 83 */ /* 3 # 20 */ 0x04, /* 84 */ /* 4 $ 21 */ 0x05, /* 85 */ /* 5 % 22 */ 0x06, /* 86 */ /* 6 ^ 23 */ 0x07, /* 87 */ /* 7 & 24 */ 0x08, /* 88 */ /* 8 * 25 */ 0x09, /* 89 */ /* 9 ( 26 */ 0x0A, /* 8A */ /* 0 ) 27 */ 0x0B, /* 8B */ /* Return 28 */ 0x1C, /* 9C */ /* Escape 29 */ 0x01, /* 81 */ /* Backspace 2A */ 0x0E, /* 8E */ /* Tab 2B */ 0x0F, /* 8F */ /* Space 2C */ 0x39, /* B9 */ /* - _ 2D */ 0x0C, /* 8C */ /* = + 2E */ 0x0D, /* 8D */ /* [ { 2F */ 0x1A, /* 9A */ /* ] } 30 */ 0x1B, /* 9B */ /* \ | 31 */ 0x2B, /* AB */ /* Europe 1 32 */ 0x2B, /* AB */ /* ; : 33 */ 0x27, /* A7 */ /* " ' 34 */ 0x28, /* A8 */ /* ` ~ 35 */ 0x29, /* A9 */ /* comma < 36 */ 0x33, /* B3 */ /* . > 37 */ 0x34, /* B4 */ /* / ? 38 */ 0x35, /* B5 */ /* Caps Lock 39 */ 0x3A, /* BA */ /* F1 3A */ 0x3B, /* BB */ /* F2 3B */ 0x3C, /* BC */ /* F3 3C */ 0x3D, /* BD */ /* F4 3D */ 0x3E, /* BE */ /* F5 3E */ 0x3F, /* BF */ /* F6 3F */ 0x40, /* C0 */ /* F7 40 */ 0x41, /* C1 */ /* F8 41 */ 0x42, /* C2 */ /* F9 42 */ 0x43, /* C3 */ /* F10 43 */ 0x44, /* C4 */ /* F11 44 */ 0x57, /* D7 */ /* F12 45 */ 0x58, /* D8 */ /* Print Screen 46 */ E0PREFIX|0x37, /* E0 B7 */ /* Scroll Lock 47 */ 0x46, /* C6 */ #if 0 /* Break (Ctrl-Pause) 48 */ E0 46 E0 C6, /* None */ /* Pause 48 */ E1 1D 45 E1 9D C5, /* None */ #else /* Break (Ctrl-Pause)/Pause 48 */ NOBREAK /* Special case */, /* None */ #endif /* Insert 49 */ E0PREFIX|0x52, /* E0 D2 */ /* Home 4A */ E0PREFIX|0x47, /* E0 C7 */ /* Page Up 4B */ E0PREFIX|0x49, /* E0 C9 */ /* Delete 4C */ E0PREFIX|0x53, /* E0 D3 */ /* End 4D */ E0PREFIX|0x4F, /* E0 CF */ /* Page Down 4E */ E0PREFIX|0x51, /* E0 D1 */ /* Right Arrow 4F */ E0PREFIX|0x4D, /* E0 CD */ /* Left Arrow 50 */ E0PREFIX|0x4B, /* E0 CB */ /* Down Arrow 51 */ E0PREFIX|0x50, /* E0 D0 */ /* Up Arrow 52 */ E0PREFIX|0x48, /* E0 C8 */ /* Num Lock 53 */ 0x45, /* C5 */ /* Keypad / 54 */ E0PREFIX|0x35, /* E0 B5 */ /* Keypad * 55 */ 0x37, /* B7 */ /* Keypad - 56 */ 0x4A, /* CA */ /* Keypad + 57 */ 0x4E, /* CE */ /* Keypad Enter 58 */ E0PREFIX|0x1C, /* E0 9C */ /* Keypad 1 End 59 */ 0x4F, /* CF */ /* Keypad 2 Down 5A */ 0x50, /* D0 */ /* Keypad 3 PageDn 5B */ 0x51, /* D1 */ /* Keypad 4 Left 5C */ 0x4B, /* CB */ /* Keypad 5 5D */ 0x4C, /* CC */ /* Keypad 6 Right 5E */ 0x4D, /* CD */ /* Keypad 7 Home 5F */ 0x47, /* C7 */ /* Keypad 8 Up 60 */ 0x48, /* C8 */ /* Keypad 9 PageUp 61 */ 0x49, /* C9 */ /* Keypad 0 Insert 62 */ 0x52, /* D2 */ /* Keypad . Delete 63 */ 0x53, /* D3 */ /* Europe 2 64 */ 0x56, /* D6 */ /* App 65 */ E0PREFIX|0x5D, /* E0 DD */ /* Keyboard Power 66 */ E0PREFIX|0x5E, /* E0 DE */ /* Keypad = 67 */ 0x59, /* D9 */ /* F13 68 */ 0x64, /* E4 */ /* F14 69 */ 0x65, /* E5 */ /* F15 6A */ 0x66, /* E6 */ /* F16 6B */ 0x67, /* E7 */ /* F17 6C */ 0x68, /* E8 */ /* F18 6D */ 0x69, /* E9 */ /* F19 6E */ 0x6A, /* EA */ /* F20 6F */ 0x6B, /* EB */ /* F21 70 */ 0x6C, /* EC */ /* F22 71 */ 0x6D, /* ED */ /* F23 72 */ 0x6E, /* EE */ /* F24 73 */ 0x76, /* F6 */ /* Keyboard Execute 74 */ -1, /* Unassigned */ /* Keyboard Help 75 */ -1, /* Unassigned */ /* Keyboard Menu 76 */ -1, /* Unassigned */ /* Keyboard Select 77 */ -1, /* Unassigned */ /* Keyboard Stop 78 */ -1, /* Unassigned */ /* Keyboard Again 79 */ -1, /* Unassigned */ /* Keyboard Undo 7A */ -1, /* Unassigned */ /* Keyboard Cut 7B */ -1, /* Unassigned */ /* Keyboard Copy 7C */ -1, /* Unassigned */ /* Keyboard Paste 7D */ -1, /* Unassigned */ /* Keyboard Find 7E */ -1, /* Unassigned */ /* Keyboard Mute 7F */ -1, /* Unassigned */ /* Keyboard Volume Up 80 */ -1, /* Unassigned */ /* Keyboard Volume Dn 81 */ -1, /* Unassigned */ /* Keyboard Locking Caps Lock 82 */ -1, /* Unassigned */ /* Keyboard Locking Num Lock 83 */ -1, /* Unassigned */ /* Keyboard Locking Scroll Lock 84 */ -1, /* Unassigned */ /* Keypad comma 85 */ 0x7E, /* FE */ /* Keyboard Equal Sign 86 */ -1, /* Unassigned */ /* Keyboard Int'l 1 87 */ 0x73, /* F3 */ /* Keyboard Int'l 2 88 */ 0x70, /* F0 */ /* Keyboard Int'l 2 89 */ 0x7D, /* FD */ /* Keyboard Int'l 4 8A */ 0x79, /* F9 */ /* Keyboard Int'l 5 8B */ 0x7B, /* FB */ /* Keyboard Int'l 6 8C */ 0x5C, /* DC */ /* Keyboard Int'l 7 8D */ -1, /* Unassigned */ /* Keyboard Int'l 8 8E */ -1, /* Unassigned */ /* Keyboard Int'l 9 8F */ -1, /* Unassigned */ /* Keyboard Lang 1 90 */ 0x71, /* Kana */ /* Keyboard Lang 2 91 */ 0x72, /* Eisu */ /* Keyboard Lang 3 92 */ 0x78, /* F8 */ /* Keyboard Lang 4 93 */ 0x77, /* F7 */ /* Keyboard Lang 5 94 */ 0x76, /* F6 */ /* Keyboard Lang 6 95 */ -1, /* Unassigned */ /* Keyboard Lang 7 96 */ -1, /* Unassigned */ /* Keyboard Lang 8 97 */ -1, /* Unassigned */ /* Keyboard Lang 9 98 */ -1, /* Unassigned */ /* Keyboard Alternate Erase 99 */ -1, /* Unassigned */ /* Keyboard SysReq/Attention 9A */ -1, /* Unassigned */ /* Keyboard Cancel 9B */ -1, /* Unassigned */ /* Keyboard Clear 9C */ -1, /* Unassigned */ /* Keyboard Prior 9D */ -1, /* Unassigned */ /* Keyboard Return 9E */ -1, /* Unassigned */ /* Keyboard Separator 9F */ -1, /* Unassigned */ /* Keyboard Out A0 */ -1, /* Unassigned */ /* Keyboard Oper A1 */ -1, /* Unassigned */ /* Keyboard Clear/Again A2 */ -1, /* Unassigned */ /* Keyboard CrSel/Props A3 */ -1, /* Unassigned */ /* Keyboard ExSel A4 */ -1, /* Unassigned */ /* Reserved A5 */ -1, /* Reserved */ /* Reserved A6 */ -1, /* Reserved */ /* Reserved A7 */ -1, /* Reserved */ /* Reserved A8 */ -1, /* Reserved */ /* Reserved A9 */ -1, /* Reserved */ /* Reserved AA */ -1, /* Reserved */ /* Reserved AB */ -1, /* Reserved */ /* Reserved AC */ -1, /* Reserved */ /* Reserved AD */ -1, /* Reserved */ /* Reserved AE */ -1, /* Reserved */ /* Reserved AF */ -1, /* Reserved */ /* Reserved B0 */ -1, /* Reserved */ /* Reserved B1 */ -1, /* Reserved */ /* Reserved B2 */ -1, /* Reserved */ /* Reserved B3 */ -1, /* Reserved */ /* Reserved B4 */ -1, /* Reserved */ /* Reserved B5 */ -1, /* Reserved */ /* Reserved B6 */ -1, /* Reserved */ /* Reserved B7 */ -1, /* Reserved */ /* Reserved B8 */ -1, /* Reserved */ /* Reserved B9 */ -1, /* Reserved */ /* Reserved BA */ -1, /* Reserved */ /* Reserved BB */ -1, /* Reserved */ /* Reserved BC */ -1, /* Reserved */ /* Reserved BD */ -1, /* Reserved */ /* Reserved BE */ -1, /* Reserved */ /* Reserved BF */ -1, /* Reserved */ /* Reserved C0 */ -1, /* Reserved */ /* Reserved C1 */ -1, /* Reserved */ /* Reserved C2 */ -1, /* Reserved */ /* Reserved C3 */ -1, /* Reserved */ /* Reserved C4 */ -1, /* Reserved */ /* Reserved C5 */ -1, /* Reserved */ /* Reserved C6 */ -1, /* Reserved */ /* Reserved C7 */ -1, /* Reserved */ /* Reserved C8 */ -1, /* Reserved */ /* Reserved C9 */ -1, /* Reserved */ /* Reserved CA */ -1, /* Reserved */ /* Reserved CB */ -1, /* Reserved */ /* Reserved CC */ -1, /* Reserved */ /* Reserved CD */ -1, /* Reserved */ /* Reserved CE */ -1, /* Reserved */ /* Reserved CF */ -1, /* Reserved */ /* Reserved D0 */ -1, /* Reserved */ /* Reserved D1 */ -1, /* Reserved */ /* Reserved D2 */ -1, /* Reserved */ /* Reserved D3 */ -1, /* Reserved */ /* Reserved D4 */ -1, /* Reserved */ /* Reserved D5 */ -1, /* Reserved */ /* Reserved D6 */ -1, /* Reserved */ /* Reserved D7 */ -1, /* Reserved */ /* Reserved D8 */ -1, /* Reserved */ /* Reserved D9 */ -1, /* Reserved */ /* Reserved DA */ -1, /* Reserved */ /* Reserved DB */ -1, /* Reserved */ /* Reserved DC */ -1, /* Reserved */ /* Reserved DD */ -1, /* Reserved */ /* Reserved DE */ -1, /* Reserved */ /* Reserved DF */ -1, /* Reserved */ /* Left Control E0 */ 0x1D, /* 9D */ /* Left Shift E1 */ 0x2A, /* AA */ /* Left Alt E2 */ 0x38, /* B8 */ /* Left GUI E3 */ E0PREFIX|0x5B, /* E0 DB */ /* Right Control E4 */ E0PREFIX|0x1D, /* E0 9D */ /* Right Shift E5 */ 0x36, /* B6 */ /* Right Alt E6 */ E0PREFIX|0x38, /* E0 B8 */ /* Right GUI E7 */ E0PREFIX|0x5C /* E0 DC */ }; #define xsize ((int32_t)(sizeof(x)/sizeof(x[0]))) /* * Get a max HID keycode (aligned) */ int32_t kbd_maxkey(void) { return (xsize); } /* * Process keys */ int32_t kbd_process_keys(bthid_session_p s) { bitstr_t diff[bitstr_size(xsize)]; int32_t f1, f2, i; assert(s != NULL); assert(s->srv != NULL); /* Check if the new keys have been pressed */ bit_ffs(s->keys1, xsize, &f1); /* Check if old keys still pressed */ bit_ffs(s->keys2, xsize, &f2); if (f1 == -1) { /* no new key pressed */ if (f2 != -1) { /* release old keys */ kbd_write(s->keys2, f2, 0, s->vkbd); uinput_kbd_write(s->keys2, f2, 0, s->ukbd); memset(s->keys2, 0, bitstr_size(xsize)); } return (0); } if (f2 == -1) { /* no old keys, but new keys pressed */ assert(f1 != -1); memcpy(s->keys2, s->keys1, bitstr_size(xsize)); kbd_write(s->keys1, f1, 1, s->vkbd); uinput_kbd_write(s->keys1, f1, 1, s->ukbd); memset(s->keys1, 0, bitstr_size(xsize)); return (0); } /* new keys got pressed, old keys got released */ memset(diff, 0, bitstr_size(xsize)); for (i = f2; i < xsize; i ++) { if (bit_test(s->keys2, i)) { if (!bit_test(s->keys1, i)) { bit_clear(s->keys2, i); bit_set(diff, i); } } } for (i = f1; i < xsize; i++) { if (bit_test(s->keys1, i)) { if (!bit_test(s->keys2, i)) bit_set(s->keys2, i); else bit_clear(s->keys1, i); } } bit_ffs(diff, xsize, &f2); if (f2 > 0) { kbd_write(diff, f2, 0, s->vkbd); uinput_kbd_write(diff, f2, 0, s->ukbd); } bit_ffs(s->keys1, xsize, &f1); if (f1 > 0) { kbd_write(s->keys1, f1, 1, s->vkbd); uinput_kbd_write(s->keys1, f1, 1, s->ukbd); memset(s->keys1, 0, bitstr_size(xsize)); } return (0); } /* * Translate given keymap and write keyscodes */ void uinput_kbd_write(bitstr_t *m, int32_t fb, int32_t make, int32_t fd) { int32_t i; if (fd >= 0) { for (i = fb; i < xsize; i++) { if (bit_test(m, i)) uinput_rep_key(fd, i, make); } } } /* * Translate given keymap and write keyscodes */ static void kbd_write(bitstr_t *m, int32_t fb, int32_t make, int32_t fd) { int32_t i, *b, *eob, n, buf[64]; b = buf; eob = b + sizeof(buf)/sizeof(buf[0]); i = fb; while (i < xsize) { if (bit_test(m, i)) { n = kbd_xlate(i, make, b, eob); if (n == -1) { write(fd, buf, (b - buf) * sizeof(buf[0])); b = buf; continue; } b += n; } i ++; } if (b != buf) write(fd, buf, (b - buf) * sizeof(buf[0])); } /* * Translate HID code into PS/2 code and put codes into buffer b. * Returns the number of codes put in b. Return -1 if buffer has not * enough space. */ #undef PUT #define PUT(c, n, b, eob) \ do { \ if ((b) >= (eob)) \ return (-1); \ *(b) = (c); \ (b) ++; \ (n) ++; \ } while (0) static int32_t kbd_xlate(int32_t code, int32_t make, int32_t *b, int32_t const *eob) { int32_t c, n; n = 0; if (code >= xsize) return (0); /* HID code is not in the table */ /* Handle special case - Pause/Break */ if (code == 0x48) { if (!make) return (0); /* No break code */ #if 0 XXX FIXME if (ctrl_is_pressed) { /* Break (Ctrl-Pause) */ PUT(0xe0, n, b, eob); PUT(0x46, n, b, eob); PUT(0xe0, n, b, eob); PUT(0xc6, n, b, eob); } else { /* Pause */ PUT(0xe1, n, b, eob); PUT(0x1d, n, b, eob); PUT(0x45, n, b, eob); PUT(0xe1, n, b, eob); PUT(0x9d, n, b, eob); PUT(0xc5, n, b, eob); } #endif return (n); } if ((c = x[code]) == -1) return (0); /* HID code translation is not defined */ if (make) { if (c & E0PREFIX) PUT(0xe0, n, b, eob); PUT((c & CODEMASK), n, b, eob); } else if (!(c & NOBREAK)) { if (c & E0PREFIX) PUT(0xe0, n, b, eob); PUT((0x80|(c & CODEMASK)), n, b, eob); } return (n); } /* * Process status change from vkbd(4) */ int32_t kbd_status_changed(bthid_session_p s, uint8_t *data, int32_t len) { vkbd_status_t st; uint8_t found, report_id; hid_device_p hid_device; hid_data_t d; hid_item_t h; uint8_t leds_mask = 0; assert(s != NULL); assert(len == sizeof(vkbd_status_t)); memcpy(&st, data, sizeof(st)); found = 0; report_id = NO_REPORT_ID; hid_device = get_hid_device(&s->bdaddr); assert(hid_device != NULL); data[0] = 0xa2; /* DATA output (HID output report) */ data[1] = 0x00; data[2] = 0x00; for (d = hid_start_parse(hid_device->desc, 1 << hid_output, -1); hid_get_item(d, &h) > 0; ) { if (HID_PAGE(h.usage) == HUP_LEDS) { found++; if (report_id == NO_REPORT_ID) report_id = h.report_ID; else if (h.report_ID != report_id) syslog(LOG_WARNING, "Output HID report IDs " \ "for %s do not match: %d vs. %d. " \ "Please report", bt_ntoa(&s->bdaddr, NULL), h.report_ID, report_id); switch(HID_USAGE(h.usage)) { case 0x01: /* Num Lock LED */ if (st.leds & LED_NUM) hid_set_data(&data[1], &h, 1); leds_mask |= LED_NUM; break; case 0x02: /* Caps Lock LED */ if (st.leds & LED_CAP) hid_set_data(&data[1], &h, 1); leds_mask |= LED_CAP; break; case 0x03: /* Scroll Lock LED */ if (st.leds & LED_SCR) hid_set_data(&data[1], &h, 1); leds_mask |= LED_SCR; break; /* XXX add other LEDs ? */ } } } hid_end_parse(d); if (report_id != NO_REPORT_ID) { data[2] = data[1]; data[1] = report_id; } if (found) write(s->intr, data, (report_id != NO_REPORT_ID) ? 3 : 2); if (found && s->srv->uinput && hid_device->keyboard) uinput_rep_leds(s->ukbd, st.leds, leds_mask); return (0); } diff --git a/usr.sbin/bluetooth/bthidd/kbd.h b/usr.sbin/bluetooth/bthidd/kbd.h index 80988139f1a4..d12d51d0e62f 100644 --- a/usr.sbin/bluetooth/bthidd/kbd.h +++ b/usr.sbin/bluetooth/bthidd/kbd.h @@ -1,43 +1,42 @@ /* * kbd.h */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: kbd.h,v 1.3 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #ifndef _KBD_H_ #define _KBD_H_ int32_t kbd_maxkey (void); int32_t kbd_process_keys (bthid_session_p s); int32_t kbd_status_changed(bthid_session_p s, uint8_t *data, int32_t len); #endif /* ndef _KBD_H_ */ diff --git a/usr.sbin/bluetooth/bthidd/lexer.l b/usr.sbin/bluetooth/bthidd/lexer.l index d8b1921fc9ae..d8933e4ea5d7 100644 --- a/usr.sbin/bluetooth/bthidd/lexer.l +++ b/usr.sbin/bluetooth/bthidd/lexer.l @@ -1,133 +1,132 @@ %{ /* * lexer.l */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: lexer.l,v 1.3 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include "parser.h" int yylex (void); #define YY_DECL int yylex(void) %} %option yylineno noyywrap nounput noinput delim [ \t\n] ws {delim}+ empty {delim}* comment \#.* hexdigit [0-9a-fA-F] hexbyte {hexdigit}{hexdigit}? hexword {hexdigit}{hexdigit}?{hexdigit}?{hexdigit}? device_word device bdaddr_word bdaddr name_word name vendor_id_word vendor_id product_id_word product_id version_word version control_psm_word control_psm interrupt_psm_word interrupt_psm reconnect_initiate_word reconnect_initiate battery_power_word battery_power normally_connectable_word normally_connectable hid_descriptor_word hid_descriptor true_word true false_word false bdaddrstring {hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte} hexbytestring 0x{hexbyte} hexwordstring 0x{hexword} string \".+\" %% \; return (';'); \: return (':'); \{ return ('{'); \} return ('}'); {ws} ; {empty} ; {comment} ; {device_word} return (T_DEVICE); {bdaddr_word} return (T_BDADDR); {name_word} return (T_NAME); {vendor_id_word} return (T_VENDOR_ID); {product_id_word} return (T_PRODUCT_ID); {version_word} return (T_VERSION); {control_psm_word} return (T_CONTROL_PSM); {interrupt_psm_word} return (T_INTERRUPT_PSM); {reconnect_initiate_word} return (T_RECONNECT_INITIATE); {battery_power_word} return (T_BATTERY_POWER); {normally_connectable_word} return (T_NORMALLY_CONNECTABLE); {hid_descriptor_word} return (T_HID_DESCRIPTOR); {true_word} return (T_TRUE); {false_word} return (T_FALSE); {bdaddrstring} { return (bt_aton(yytext, &yylval.bdaddr)? T_BDADDRSTRING : T_ERROR); } {hexbytestring} { char *ep; yylval.num = strtoul(yytext, &ep, 16); return (*ep == '\0'? T_HEXBYTE : T_ERROR); } {hexwordstring} { char *ep; yylval.num = strtoul(yytext, &ep, 16); return (*ep == '\0'? T_HEXWORD : T_ERROR); } {string} { yytext[strlen(yytext) - 1] = 0; yylval.string = &yytext[1]; return (T_STRING); } . return (T_ERROR); %% diff --git a/usr.sbin/bluetooth/bthidd/parser.y b/usr.sbin/bluetooth/bthidd/parser.y index 40c62686eeeb..a18ef3515b8b 100644 --- a/usr.sbin/bluetooth/bthidd/parser.y +++ b/usr.sbin/bluetooth/bthidd/parser.y @@ -1,566 +1,565 @@ %{ /* * parser.y */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: parser.y,v 1.7 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #ifndef BTHIDCONTROL #include #include #define SYSLOG syslog #define LOGCRIT LOG_CRIT #define LOGERR LOG_ERR #define LOGWARNING LOG_WARNING #define EOL #else #define SYSLOG fprintf #define LOGCRIT stderr #define LOGERR stderr #define LOGWARNING stderr #define EOL "\n" #endif /* ndef BTHIDCONTROL */ #define NAMELESS_DEVICE "No Name" #include "bthid_config.h" int yylex (void); void yyerror (char const *); static int32_t check_hid_device(hid_device_p hid_device); static void free_hid_device (hid_device_p hid_device); extern FILE *yyin; extern int yylineno; char const *config_file = BTHIDD_CONFFILE; char const *hids_file = BTHIDD_HIDSFILE; static char buffer[1024]; static int32_t hid_descriptor_size; static hid_device_t *hid_device = NULL; static LIST_HEAD(, hid_device) hid_devices; %} %union { bdaddr_t bdaddr; int32_t num; char *string; } %token T_BDADDRSTRING %token T_HEXBYTE %token T_HEXWORD %token T_STRING %token T_NAME %token T_DEVICE T_BDADDR T_VENDOR_ID T_PRODUCT_ID T_VERSION T_CONTROL_PSM %token T_INTERRUPT_PSM T_RECONNECT_INITIATE T_BATTERY_POWER %token T_NORMALLY_CONNECTABLE T_HID_DESCRIPTOR %token T_TRUE T_FALSE T_ERROR %% config: line | config line ; line: T_DEVICE { hid_device = (hid_device_t *) calloc(1, sizeof(*hid_device)); if (hid_device == NULL) { SYSLOG(LOGCRIT, "Could not allocate new " \ "config entry" EOL); YYABORT; } hid_device->new_device = 1; } '{' options '}' { if (check_hid_device(hid_device)) LIST_INSERT_HEAD(&hid_devices,hid_device,next); else free_hid_device(hid_device); hid_device = NULL; } ; options: option ';' | options option ';' ; option: bdaddr | name | vendor_id | product_id | version | control_psm | interrupt_psm | reconnect_initiate | battery_power | normally_connectable | hid_descriptor | parser_error ; bdaddr: T_BDADDR T_BDADDRSTRING { memcpy(&hid_device->bdaddr, &$2, sizeof(hid_device->bdaddr)); } ; name: T_NAME T_STRING { if (hid_device->name != NULL) { free(hid_device->name); hid_device->name = NULL; } if (strcmp($2, NAMELESS_DEVICE)) { hid_device->name = strdup($2); if (hid_device->name == NULL) { SYSLOG(LOGCRIT, "Could not allocate new " \ "device name" EOL); YYABORT; } } } ; vendor_id: T_VENDOR_ID T_HEXWORD { hid_device->vendor_id = $2; } ; product_id: T_PRODUCT_ID T_HEXWORD { hid_device->product_id = $2; } ; version: T_VERSION T_HEXWORD { hid_device->version = $2; } ; control_psm: T_CONTROL_PSM T_HEXBYTE { hid_device->control_psm = $2; } ; interrupt_psm: T_INTERRUPT_PSM T_HEXBYTE { hid_device->interrupt_psm = $2; } ; reconnect_initiate: T_RECONNECT_INITIATE T_TRUE { hid_device->reconnect_initiate = 1; } | T_RECONNECT_INITIATE T_FALSE { hid_device->reconnect_initiate = 0; } ; battery_power: T_BATTERY_POWER T_TRUE { hid_device->battery_power = 1; } | T_BATTERY_POWER T_FALSE { hid_device->battery_power = 0; } ; normally_connectable: T_NORMALLY_CONNECTABLE T_TRUE { hid_device->normally_connectable = 1; } | T_NORMALLY_CONNECTABLE T_FALSE { hid_device->normally_connectable = 0; } ; hid_descriptor: T_HID_DESCRIPTOR { hid_descriptor_size = 0; } '{' hid_descriptor_bytes '}' { if (hid_device->desc != NULL) hid_dispose_report_desc(hid_device->desc); hid_device->desc = hid_use_report_desc((unsigned char *) buffer, hid_descriptor_size); if (hid_device->desc == NULL) { SYSLOG(LOGCRIT, "Could not use HID descriptor" EOL); YYABORT; } } ; hid_descriptor_bytes: hid_descriptor_byte | hid_descriptor_bytes hid_descriptor_byte ; hid_descriptor_byte: T_HEXBYTE { if (hid_descriptor_size >= (int32_t) sizeof(buffer)) { SYSLOG(LOGCRIT, "HID descriptor is too big" EOL); YYABORT; } buffer[hid_descriptor_size ++] = $1; } ; parser_error: T_ERROR { YYABORT; } %% /* Display parser error message */ void yyerror(char const *message) { SYSLOG(LOGERR, "%s in line %d" EOL, message, yylineno); } /* Re-read config file */ int32_t read_config_file(void) { int32_t e; if (config_file == NULL) { SYSLOG(LOGERR, "Unknown config file name!" EOL); return (-1); } if ((yyin = fopen(config_file, "r")) == NULL) { SYSLOG(LOGERR, "Could not open config file '%s'. %s (%d)" EOL, config_file, strerror(errno), errno); return (-1); } clean_config(); if (yyparse() < 0) { SYSLOG(LOGERR, "Could not parse config file '%s'" EOL, config_file); e = -1; } else e = 0; fclose(yyin); yyin = NULL; return (e); } /* Clean config */ void clean_config(void) { while (!LIST_EMPTY(&hid_devices)) { hid_device_p d = LIST_FIRST(&hid_devices); LIST_REMOVE(d, next); free_hid_device(d); } } /* Lookup config entry */ hid_device_p get_hid_device(bdaddr_p bdaddr) { hid_device_p d; LIST_FOREACH(d, &hid_devices, next) if (memcmp(&d->bdaddr, bdaddr, sizeof(bdaddr_t)) == 0) break; return (d); } /* Get next config entry */ hid_device_p get_next_hid_device(hid_device_p d) { return ((d == NULL)? LIST_FIRST(&hid_devices) : LIST_NEXT(d, next)); } /* Print config entry */ void print_hid_device(hid_device_p d, FILE *f) { /* XXX FIXME hack! */ struct report_desc { unsigned int size; unsigned char data[1]; }; /* XXX FIXME hack! */ struct report_desc *desc = (struct report_desc *) d->desc; uint32_t i; fprintf(f, "device {\n" \ " bdaddr %s;\n" \ " name \"%s\";\n" \ " vendor_id 0x%04x;\n" \ " product_id 0x%04x;\n" \ " version 0x%04x;\n" \ " control_psm 0x%x;\n" \ " interrupt_psm 0x%x;\n" \ " reconnect_initiate %s;\n" \ " battery_power %s;\n" \ " normally_connectable %s;\n" \ " hid_descriptor {", bt_ntoa(&d->bdaddr, NULL), (d->name != NULL)? d->name : NAMELESS_DEVICE, d->vendor_id, d->product_id, d->version, d->control_psm, d->interrupt_psm, d->reconnect_initiate? "true" : "false", d->battery_power? "true" : "false", d->normally_connectable? "true" : "false"); for (i = 0; i < desc->size; i ++) { if ((i % 8) == 0) fprintf(f, "\n "); fprintf(f, "0x%2.2x ", desc->data[i]); } fprintf(f, "\n" \ " };\n" \ "}\n"); } /* Check config entry */ static int32_t check_hid_device(hid_device_p d) { hid_data_t hd; hid_item_t hi; int32_t page, mdepth; if (get_hid_device(&d->bdaddr) != NULL) { SYSLOG(LOGERR, "Ignoring duplicated entry for bdaddr %s" EOL, bt_ntoa(&d->bdaddr, NULL)); return (0); } if (d->control_psm == 0) { SYSLOG(LOGERR, "Ignoring entry with invalid control PSM" EOL); return (0); } if (d->interrupt_psm == 0) { SYSLOG(LOGERR, "Ignoring entry with invalid interrupt PSM" EOL); return (0); } if (d->desc == NULL) { SYSLOG(LOGERR, "Ignoring entry without HID descriptor" EOL); return (0); } mdepth = 0; /* XXX somehow need to make sure descriptor is valid */ for (hd = hid_start_parse(d->desc, ~0, -1); hid_get_item(hd, &hi) > 0; ) { switch (hi.kind) { case hid_collection: if (mdepth != 0) mdepth++; else if (hi.collection == 1 && hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)) mdepth++; break; case hid_endcollection: if (mdepth != 0) mdepth--; break; case hid_output: case hid_feature: break; case hid_input: /* Check if the device may send keystrokes */ page = HID_PAGE(hi.usage); if (page == HUP_KEYBOARD) d->keyboard = 1; if (page == HUP_CONSUMER && (hi.flags & (HIO_CONST|HIO_RELATIVE)) == 0) d->has_cons = 1; /* Check if the device may send relative motion events */ if (mdepth == 0) break; if (hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X) && (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) d->mouse = 1; if (hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y) && (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) d->mouse = 1; if (hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL) && (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) d->has_wheel = 1; if (hi.usage == HID_USAGE2(HUP_CONSUMER, HUC_AC_PAN) && (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) d->has_hwheel = 1; break; } } hid_end_parse(hd); return (1); } /* Free config entry */ static void free_hid_device(hid_device_p d) { if (d->desc != NULL) hid_dispose_report_desc(d->desc); free(d->name); memset(d, 0, sizeof(*d)); free(d); } /* Re-read hids file */ int32_t read_hids_file(void) { FILE *f; hid_device_t *d; char *line; bdaddr_t bdaddr; int32_t lineno; if (hids_file == NULL) { SYSLOG(LOGERR, "Unknown HIDs file name!" EOL); return (-1); } if ((f = fopen(hids_file, "r")) == NULL) { if (errno == ENOENT) return (0); SYSLOG(LOGERR, "Could not open HIDs file '%s'. %s (%d)" EOL, hids_file, strerror(errno), errno); return (-1); } for (lineno = 1; fgets(buffer, sizeof(buffer), f) != NULL; lineno ++) { if ((line = strtok(buffer, "\r\n\t ")) == NULL) continue; /* ignore empty lines */ if (!bt_aton(line, &bdaddr)) { SYSLOG(LOGWARNING, "Ignoring unparseable BD_ADDR in " \ "%s:%d" EOL, hids_file, lineno); continue; } if ((d = get_hid_device(&bdaddr)) != NULL) d->new_device = 0; } fclose(f); return (0); } /* Write hids file */ int32_t write_hids_file(void) { char path[PATH_MAX]; FILE *f; hid_device_t *d; if (hids_file == NULL) { SYSLOG(LOGERR, "Unknown HIDs file name!" EOL); return (-1); } snprintf(path, sizeof(path), "%s.new", hids_file); if ((f = fopen(path, "w")) == NULL) { SYSLOG(LOGERR, "Could not open HIDs file '%s'. %s (%d)" EOL, path, strerror(errno), errno); return (-1); } LIST_FOREACH(d, &hid_devices, next) if (!d->new_device) fprintf(f, "%s\n", bt_ntoa(&d->bdaddr, NULL)); fclose(f); if (rename(path, hids_file) < 0) { SYSLOG(LOGERR, "Could not rename new HIDs file '%s' to '%s'. " \ "%s (%d)" EOL, path, hids_file, strerror(errno), errno); unlink(path); return (-1); } return (0); } diff --git a/usr.sbin/bluetooth/bthidd/server.c b/usr.sbin/bluetooth/bthidd/server.c index dc9cf891faa5..c532561265cd 100644 --- a/usr.sbin/bluetooth/bthidd/server.c +++ b/usr.sbin/bluetooth/bthidd/server.c @@ -1,357 +1,356 @@ /* * server.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: server.c,v 1.9 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" #include "btuinput.h" #include "kbd.h" #undef max #define max(x, y) (((x) > (y))? (x) : (y)) static int32_t server_accept (bthid_server_p srv, int32_t fd); static int32_t server_process(bthid_server_p srv, int32_t fd); /* * Initialize server */ int32_t server_init(bthid_server_p srv) { struct sockaddr_l2cap l2addr; assert(srv != NULL); srv->ctrl = srv->intr = -1; FD_ZERO(&srv->rfdset); FD_ZERO(&srv->wfdset); LIST_INIT(&srv->sessions); /* Open /dev/consolectl */ srv->cons = open("/dev/consolectl", O_RDWR); if (srv->cons < 0) { syslog(LOG_ERR, "Could not open /dev/consolectl. %s (%d)", strerror(errno), errno); return (-1); } /* Create control socket */ srv->ctrl = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP); if (srv->ctrl < 0) { syslog(LOG_ERR, "Could not create control L2CAP socket. " \ "%s (%d)", strerror(errno), errno); close(srv->cons); return (-1); } l2addr.l2cap_len = sizeof(l2addr); l2addr.l2cap_family = AF_BLUETOOTH; memcpy(&l2addr.l2cap_bdaddr, &srv->bdaddr, sizeof(l2addr.l2cap_bdaddr)); l2addr.l2cap_psm = htole16(0x11); l2addr.l2cap_bdaddr_type = BDADDR_BREDR; l2addr.l2cap_cid = 0; if (bind(srv->ctrl, (struct sockaddr *) &l2addr, sizeof(l2addr)) < 0) { syslog(LOG_ERR, "Could not bind control L2CAP socket. " \ "%s (%d)", strerror(errno), errno); close(srv->ctrl); close(srv->cons); return (-1); } if (listen(srv->ctrl, 10) < 0) { syslog(LOG_ERR, "Could not listen on control L2CAP socket. " \ "%s (%d)", strerror(errno), errno); close(srv->ctrl); close(srv->cons); return (-1); } /* Create interrupt socket */ srv->intr = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP); if (srv->intr < 0) { syslog(LOG_ERR, "Could not create interrupt L2CAP socket. " \ "%s (%d)", strerror(errno), errno); close(srv->ctrl); close(srv->cons); return (-1); } l2addr.l2cap_psm = htole16(0x13); if (bind(srv->intr, (struct sockaddr *) &l2addr, sizeof(l2addr)) < 0) { syslog(LOG_ERR, "Could not bind interrupt L2CAP socket. " \ "%s (%d)", strerror(errno), errno); close(srv->intr); close(srv->ctrl); close(srv->cons); return (-1); } if (listen(srv->intr, 10) < 0) { syslog(LOG_ERR, "Could not listen on interrupt L2CAP socket. "\ "%s (%d)", strerror(errno), errno); close(srv->intr); close(srv->ctrl); close(srv->cons); return (-1); } FD_SET(srv->ctrl, &srv->rfdset); FD_SET(srv->intr, &srv->rfdset); srv->maxfd = max(srv->ctrl, srv->intr); return (0); } /* * Shutdown server */ void server_shutdown(bthid_server_p srv) { assert(srv != NULL); close(srv->cons); close(srv->ctrl); close(srv->intr); while (!LIST_EMPTY(&srv->sessions)) session_close(LIST_FIRST(&srv->sessions)); memset(srv, 0, sizeof(*srv)); } /* * Do one server iteration */ int32_t server_do(bthid_server_p srv) { struct timeval tv; fd_set rfdset, wfdset; int32_t n, fd; assert(srv != NULL); tv.tv_sec = 1; tv.tv_usec = 0; /* Copy cached version of the fd sets and call select */ memcpy(&rfdset, &srv->rfdset, sizeof(rfdset)); memcpy(&wfdset, &srv->wfdset, sizeof(wfdset)); n = select(srv->maxfd + 1, &rfdset, &wfdset, NULL, &tv); if (n < 0) { if (errno == EINTR) return (0); syslog(LOG_ERR, "Could not select(%d, %p, %p). %s (%d)", srv->maxfd + 1, &rfdset, &wfdset, strerror(errno), errno); return (-1); } /* Process descriptors (if any) */ for (fd = 0; fd < srv->maxfd + 1 && n > 0; fd ++) { if (FD_ISSET(fd, &rfdset)) { n --; if (fd == srv->ctrl || fd == srv->intr) server_accept(srv, fd); else server_process(srv, fd); } else if (FD_ISSET(fd, &wfdset)) { n --; client_connect(srv, fd); } } return (0); } /* * Accept new connection */ static int32_t server_accept(bthid_server_p srv, int32_t fd) { bthid_session_p s; hid_device_p d; struct sockaddr_l2cap l2addr; int32_t new_fd; socklen_t len; len = sizeof(l2addr); if ((new_fd = accept(fd, (struct sockaddr *) &l2addr, &len)) < 0) { syslog(LOG_ERR, "Could not accept %s connection. %s (%d)", (fd == srv->ctrl)? "control" : "interrupt", strerror(errno), errno); return (-1); } /* Is device configured? */ if ((d = get_hid_device(&l2addr.l2cap_bdaddr)) == NULL) { syslog(LOG_ERR, "Rejecting %s connection from %s. " \ "Device not configured", (fd == srv->ctrl)? "control" : "interrupt", bt_ntoa(&l2addr.l2cap_bdaddr, NULL)); close(new_fd); return (-1); } /* Check if we have session for the device */ if ((s = session_by_bdaddr(srv, &l2addr.l2cap_bdaddr)) == NULL) { d->new_device = 0; /* reset new device flag */ write_hids_file(); /* Create new inbound session */ if ((s = session_open(srv, d)) == NULL) { syslog(LOG_CRIT, "Could not open inbound session " "for %s", bt_ntoa(&l2addr.l2cap_bdaddr, NULL)); close(new_fd); return (-1); } } /* Update descriptors */ if (fd == srv->ctrl) { assert(s->ctrl == -1); s->ctrl = new_fd; s->state = (s->intr == -1)? W4INTR : OPEN; } else { assert(s->intr == -1); s->intr = new_fd; s->state = (s->ctrl == -1)? W4CTRL : OPEN; } FD_SET(new_fd, &srv->rfdset); if (new_fd > srv->maxfd) srv->maxfd = new_fd; syslog(LOG_NOTICE, "Accepted %s connection from %s", (fd == srv->ctrl)? "control" : "interrupt", bt_ntoa(&l2addr.l2cap_bdaddr, NULL)); /* Create virtual kbd/mouse after both channels are established */ if (s->state == OPEN && session_run(s) < 0) { session_close(s); return (-1); } return (0); } /* * Process data on the connection */ static int32_t server_process(bthid_server_p srv, int32_t fd) { bthid_session_p s = session_by_fd(srv, fd); int32_t len, to_read; int32_t (*cb)(bthid_session_p, uint8_t *, int32_t); union { uint8_t b[1024]; vkbd_status_t s; struct input_event ie; } data; if (s == NULL) return (0); /* can happen on device disconnect */ if (fd == s->ctrl) { cb = hid_control; to_read = sizeof(data.b); } else if (fd == s->intr) { cb = hid_interrupt; to_read = sizeof(data.b); } else if (fd == s->ukbd) { cb = uinput_kbd_status_changed; to_read = sizeof(data.ie); } else { assert(fd == s->vkbd); cb = kbd_status_changed; to_read = sizeof(data.s); } do { len = read(fd, &data, to_read); } while (len < 0 && errno == EINTR); if (len < 0) { syslog(LOG_ERR, "Could not read data from %s (%s). %s (%d)", bt_ntoa(&s->bdaddr, NULL), (fd == s->ctrl)? "control" : "interrupt", strerror(errno), errno); session_close(s); return (0); } if (len == 0) { syslog(LOG_NOTICE, "Remote device %s has closed %s connection", bt_ntoa(&s->bdaddr, NULL), (fd == s->ctrl)? "control" : "interrupt"); session_close(s); return (0); } (*cb)(s, (uint8_t *) &data, len); return (0); } diff --git a/usr.sbin/bluetooth/bthidd/session.c b/usr.sbin/bluetooth/bthidd/session.c index 0cac823c9406..ab9fa59dab65 100644 --- a/usr.sbin/bluetooth/bthidd/session.c +++ b/usr.sbin/bluetooth/bthidd/session.c @@ -1,250 +1,249 @@ /* * session.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: session.c,v 1.3 2006/09/07 21:06:53 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include "bthid_config.h" #include "bthidd.h" #include "btuinput.h" #include "kbd.h" /* * Create new session */ bthid_session_p session_open(bthid_server_p srv, hid_device_p const d) { bthid_session_p s; assert(srv != NULL); assert(d != NULL); if ((s = (bthid_session_p) malloc(sizeof(*s))) == NULL) return (NULL); s->srv = srv; memcpy(&s->bdaddr, &d->bdaddr, sizeof(s->bdaddr)); s->ctrl = -1; s->intr = -1; s->vkbd = -1; s->ctx = NULL; s->state = CLOSED; s->ukbd = -1; s->umouse = -1; s->obutt = 0; s->keys1 = bit_alloc(kbd_maxkey()); if (s->keys1 == NULL) { free(s); return (NULL); } s->keys2 = bit_alloc(kbd_maxkey()); if (s->keys2 == NULL) { free(s->keys1); free(s); return (NULL); } LIST_INSERT_HEAD(&srv->sessions, s, next); return (s); } /* * Initialize virtual keyboard and mouse after both channels are established */ int32_t session_run(bthid_session_p s) { hid_device_p d = get_hid_device(&s->bdaddr); struct sockaddr_l2cap local; socklen_t len; if (d->keyboard) { /* Open /dev/vkbdctl */ s->vkbd = open("/dev/vkbdctl", O_RDWR); if (s->vkbd < 0) { syslog(LOG_ERR, "Could not open /dev/vkbdctl " \ "for %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); return (-1); } /* Register session's vkbd descriptor (if needed) for read */ FD_SET(s->vkbd, &s->srv->rfdset); if (s->vkbd > s->srv->maxfd) s->srv->maxfd = s->vkbd; } /* Pass device for probing */ hid_initialise(s); /* Take local bdaddr */ len = sizeof(local); getsockname(s->ctrl, (struct sockaddr *) &local, &len); if (d->mouse && s->srv->uinput) { s->umouse = uinput_open_mouse(d, &local.l2cap_bdaddr); if (s->umouse < 0) { syslog(LOG_ERR, "Could not open /dev/uinput " \ "for %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); return (-1); } } if (d->keyboard && s->srv->uinput) { s->ukbd = uinput_open_keyboard(d, &local.l2cap_bdaddr); if (s->ukbd < 0) { syslog(LOG_ERR, "Could not open /dev/uinput " \ "for %s. %s (%d)", bt_ntoa(&s->bdaddr, NULL), strerror(errno), errno); return (-1); } /* Register session's ukbd descriptor (if needed) for read */ FD_SET(s->ukbd, &s->srv->rfdset); if (s->ukbd > s->srv->maxfd) s->srv->maxfd = s->ukbd; } return (0); } /* * Lookup session by bdaddr */ bthid_session_p session_by_bdaddr(bthid_server_p srv, bdaddr_p bdaddr) { bthid_session_p s; assert(srv != NULL); assert(bdaddr != NULL); LIST_FOREACH(s, &srv->sessions, next) if (memcmp(&s->bdaddr, bdaddr, sizeof(s->bdaddr)) == 0) break; return (s); } /* * Lookup session by fd */ bthid_session_p session_by_fd(bthid_server_p srv, int32_t fd) { bthid_session_p s; assert(srv != NULL); assert(fd >= 0); LIST_FOREACH(s, &srv->sessions, next) if (s->ctrl == fd || s->intr == fd || s->vkbd == fd || s->ukbd == fd) break; return (s); } /* * Close session */ void session_close(bthid_session_p s) { assert(s != NULL); assert(s->srv != NULL); LIST_REMOVE(s, next); if (s->intr != -1) { FD_CLR(s->intr, &s->srv->rfdset); FD_CLR(s->intr, &s->srv->wfdset); close(s->intr); if (s->srv->maxfd == s->intr) s->srv->maxfd --; } if (s->ctrl != -1) { FD_CLR(s->ctrl, &s->srv->rfdset); FD_CLR(s->ctrl, &s->srv->wfdset); close(s->ctrl); if (s->srv->maxfd == s->ctrl) s->srv->maxfd --; } if (s->vkbd != -1) { FD_CLR(s->vkbd, &s->srv->rfdset); close(s->vkbd); if (s->srv->maxfd == s->vkbd) s->srv->maxfd --; } if (s->umouse != -1) close(s->umouse); if (s->ukbd != -1) { FD_CLR(s->ukbd, &s->srv->rfdset); close(s->ukbd); if (s->srv->maxfd == s->ukbd) s->srv->maxfd --; } free(s->ctx); free(s->keys1); free(s->keys2); memset(s, 0, sizeof(*s)); free(s); } diff --git a/usr.sbin/bluetooth/hccontrol/adv_data.c b/usr.sbin/bluetooth/hccontrol/adv_data.c index 35ca7f2ab664..e8d91ff59151 100644 --- a/usr.sbin/bluetooth/hccontrol/adv_data.c +++ b/usr.sbin/bluetooth/hccontrol/adv_data.c @@ -1,249 +1,248 @@ /*- * adv_data.c * * SPDX-License-Identifier: BSD-2-Clause * Copyright (c) 2020 Marc Veldman * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id$ - * $FreeBSD$ */ #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include "hccontrol.h" static char* const adv_data2str(int len, uint8_t* data, char* buffer, int size); static char* const adv_name2str(int len, uint8_t* advdata, char* buffer, int size); static char* const adv_uuid2str(int datalen, uint8_t* data, char* buffer, int size); void dump_adv_data(int len, uint8_t* advdata) { int n=0; fprintf(stdout, "\tADV Data: "); for (n = 0; n < len+1; n++) { fprintf(stdout, "%02x ", advdata[n]); } fprintf(stdout, "\n"); } void print_adv_data(int len, uint8_t* advdata) { int n=0; while(n < len) { char buffer[2048]; uint8_t datalen = advdata[n]; uint8_t datatype = advdata[++n]; /* Skip type */ ++n; datalen--; switch (datatype) { case 0x01: fprintf(stdout, "\tFlags: %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x02: fprintf(stdout, "\tIncomplete list of service" " class UUIDs (16-bit): %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x03: fprintf(stdout, "\tComplete list of service " "class UUIDs (16-bit): %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x07: fprintf(stdout, "\tComplete list of service " "class UUIDs (128 bit): %s\n", adv_uuid2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x08: fprintf(stdout, "\tShortened local name: %s\n", adv_name2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x09: fprintf(stdout, "\tComplete local name: %s\n", adv_name2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x0a: fprintf(stdout, "\tTx Power level: %d dBm\n", (int8_t)advdata[n]); break; case 0x0d: fprintf(stdout, "\tClass of device: %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x16: fprintf(stdout, "\tService data: %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0x19: fprintf(stdout, "\tAppearance: %s\n", adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); break; case 0xff: fprintf(stdout, "\tManufacturer: %s\n", hci_manufacturer2str( advdata[n]|advdata[n+1]<<8)); fprintf(stdout, "\tManufacturer specific data: %s\n", adv_data2str( datalen-2, &advdata[n+2], buffer, sizeof(buffer))); break; default: fprintf(stdout, "\tUNKNOWN datatype: %02x data %s\n", datatype, adv_data2str( datalen, &advdata[n], buffer, sizeof(buffer))); } n += datalen; } } static char* const adv_data2str(int datalen, uint8_t* data, char* buffer, int size) { int i = 0; char tmpbuf[5]; if (buffer == NULL) return NULL; memset(buffer, 0, size); while(i < datalen) { (void)snprintf(tmpbuf, sizeof(tmpbuf), "%02x ", data[i]); /* Check if buffer is full */ if (strlcat(buffer, tmpbuf, size) > size) break; i++; } return buffer; } static char* const adv_name2str(int datalen, uint8_t* data, char* buffer, int size) { if (buffer == NULL) return NULL; memset(buffer, 0, size); (void)strlcpy(buffer, (char*)data, datalen+1); return buffer; } static char* const adv_uuid2str(int datalen, uint8_t* data, char* buffer, int size) { int i; uuid_t uuid; uint32_t ustatus; char* tmpstr; if (buffer == NULL) return NULL; memset(buffer, 0, size); if (datalen < 16) return buffer; uuid.time_low = le32dec(data+12); uuid.time_mid = le16dec(data+10); uuid.time_hi_and_version = le16dec(data+8); uuid.clock_seq_hi_and_reserved = data[7]; uuid.clock_seq_low = data[6]; for(i = 0; i < _UUID_NODE_LEN; i++){ uuid.node[i] = data[5 - i]; } uuid_to_string(&uuid, &tmpstr, &ustatus); if(ustatus == uuid_s_ok) { strlcpy(buffer, tmpstr, size); } free(tmpstr); return buffer; } diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.c b/usr.sbin/bluetooth/hccontrol/hccontrol.c index b74d7b6fa84f..c1ce016e6246 100644 --- a/usr.sbin/bluetooth/hccontrol/hccontrol.c +++ b/usr.sbin/bluetooth/hccontrol/hccontrol.c @@ -1,334 +1,333 @@ /*- * hccontrol.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hccontrol.c,v 1.5 2003/09/05 00:38:24 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include "hccontrol.h" /* Prototypes */ static int do_hci_command (char const *, int, char **); static struct hci_command * find_hci_command (char const *, struct hci_command *); static int find_hci_nodes (struct nodeinfo **); static void print_hci_command (struct hci_command *); static void usage (void); /* Globals */ int verbose = 0; int timeout; int numeric_bdaddr = 0; /* Main */ int main(int argc, char *argv[]) { char *node = NULL; int n; /* Process command line arguments */ while ((n = getopt(argc, argv, "n:Nvh")) != -1) { switch (n) { case 'n': node = optarg; break; case 'N': numeric_bdaddr = 1; break; case 'v': verbose = 1; break; case 'h': default: usage(); } } argc -= optind; argv += optind; if (*argv == NULL) usage(); n = do_hci_command(node, argc, argv); return (n); } /* main */ /* Create socket and bind it */ static int socket_open(char const *node) { struct sockaddr_hci addr; struct ng_btsocket_hci_raw_filter filter; int s, mib[4], num; size_t size; struct nodeinfo *nodes; char *lnode = NULL; num = find_hci_nodes(&nodes); if (num == 0) errx(7, "Could not find HCI nodes"); if (node == NULL) { node = lnode = strdup(nodes[0].name); if (num > 1) fprintf(stdout, "Using HCI node: %s\n", node); } free(nodes); s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); if (s < 0) err(1, "Could not create socket"); memset(&addr, 0, sizeof(addr)); addr.hci_len = sizeof(addr); addr.hci_family = AF_BLUETOOTH; strncpy(addr.hci_node, node, sizeof(addr.hci_node)); if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) err(2, "Could not bind socket, node=%s", node); if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) err(3, "Could not connect socket, node=%s", node); free(lnode); memset(&filter, 0, sizeof(filter)); bit_set(filter.event_mask, NG_HCI_EVENT_COMMAND_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_COMMAND_STATUS - 1); bit_set(filter.event_mask, NG_HCI_EVENT_INQUIRY_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_INQUIRY_RESULT - 1); bit_set(filter.event_mask, NG_HCI_EVENT_CON_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_DISCON_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_RETURN_LINK_KEYS - 1); bit_set(filter.event_mask, NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL - 1); bit_set(filter.event_mask, NG_HCI_EVENT_CON_PKT_TYPE_CHANGED - 1); bit_set(filter.event_mask, NG_HCI_EVENT_ROLE_CHANGE - 1); bit_set(filter.event_mask, NG_HCI_EVENT_LE -1); if (setsockopt(s, SOL_HCI_RAW, SO_HCI_RAW_FILTER, (void * const) &filter, sizeof(filter)) < 0) err(4, "Could not setsockopt()"); size = (sizeof(mib)/sizeof(mib[0])); if (sysctlnametomib("net.bluetooth.hci.command_timeout",mib,&size) < 0) err(5, "Could not sysctlnametomib()"); if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), (void *) &timeout, &size, NULL, 0) < 0) err(6, "Could not sysctl()"); timeout ++; return (s); } /* socket_open */ /* Execute commands */ static int do_hci_command(char const *node, int argc, char **argv) { char *cmd = argv[0]; struct hci_command *c = NULL; int s, e, help; help = 0; if (strcasecmp(cmd, "help") == 0) { argc --; argv ++; if (argc <= 0) { fprintf(stdout, "Supported commands:\n"); print_hci_command(link_control_commands); print_hci_command(link_policy_commands); print_hci_command(host_controller_baseband_commands); print_hci_command(info_commands); print_hci_command(status_commands); print_hci_command(le_commands); print_hci_command(node_commands); fprintf(stdout, "\nFor more information use " \ "'help command'\n"); return (OK); } help = 1; cmd = argv[0]; } c = find_hci_command(cmd, link_control_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, link_policy_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, host_controller_baseband_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, info_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, status_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, le_commands); if (c != NULL) goto execute; c = find_hci_command(cmd, node_commands); if (c == NULL) { fprintf(stdout, "Unknown command: \"%s\"\n", cmd); return (ERROR); } execute: if (!help) { s = socket_open(node); e = (c->handler)(s, -- argc, ++ argv); close(s); } else e = USAGE; switch (e) { case OK: case FAILED: break; case ERROR: fprintf(stdout, "Could not execute command \"%s\". %s\n", cmd, strerror(errno)); break; case USAGE: fprintf(stdout, "Usage: %s\n%s\n", c->command, c->description); break; default: assert(0); break; } return (e); } /* do_hci_command */ /* Try to find command in specified category */ static struct hci_command * find_hci_command(char const *command, struct hci_command *category) { struct hci_command *c = NULL; for (c = category; c->command != NULL; c++) { char *c_end = strchr(c->command, ' '); if (c_end != NULL) { int len = c_end - c->command; if (strncasecmp(command, c->command, len) == 0) return (c); } else if (strcasecmp(command, c->command) == 0) return (c); } return (NULL); } /* find_hci_command */ /* Find all HCI nodes */ static int find_hci_nodes(struct nodeinfo** nodes) { struct ng_btsocket_hci_raw_node_list_names r; struct sockaddr_hci addr; int s; const char * node = "ubt0hci"; r.num_names = MAX_NODE_NUM; r.names = (struct nodeinfo*)calloc(MAX_NODE_NUM, sizeof(struct nodeinfo)); if (r.names == NULL) err(8, "Could not allocate memory"); s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); if (s < 0) err(9, "Could not create socket"); memset(&addr, 0, sizeof(addr)); addr.hci_len = sizeof(addr); addr.hci_family = AF_BLUETOOTH; strncpy(addr.hci_node, node, sizeof(addr.hci_node)); if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) err(10, "Could not bind socket"); if (ioctl(s, SIOC_HCI_RAW_NODE_LIST_NAMES, &r, sizeof(r)) < 0) err(11, "Could not get list of HCI nodes"); close(s); *nodes = r.names; return (r.num_names); } /* find_hci_nodes */ /* Print commands in specified category */ static void print_hci_command(struct hci_command *category) { struct hci_command *c = NULL; for (c = category; c->command != NULL; c++) fprintf(stdout, "\t%s\n", c->command); } /* print_hci_command */ /* Usage */ static void usage(void) { fprintf(stdout, "Usage: hccontrol [-hN] [-n HCI_node_name] cmd [p1] [..]\n"); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.h b/usr.sbin/bluetooth/hccontrol/hccontrol.h index 2cb7e8017da8..9dd6345dd59f 100644 --- a/usr.sbin/bluetooth/hccontrol/hccontrol.h +++ b/usr.sbin/bluetooth/hccontrol/hccontrol.h @@ -1,91 +1,90 @@ /*- * hccontrol.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hccontrol.h,v 1.2 2003/05/19 17:29:29 max Exp $ - * $FreeBSD$ */ #ifndef _HCCONTROL_H_ #define _HCCONTROL_H_ #define OK 0 /* everything was OK */ #define ERROR 1 /* could not execute command */ #define FAILED 2 /* error was reported */ #define USAGE 3 /* invalid parameters */ #define MAX_NODE_NUM 16 /* max number of nodes */ struct hci_command { char const *command; char const *description; int (*handler)(int, int, char **); }; extern int timeout; extern int verbose; extern struct hci_command link_control_commands[]; extern struct hci_command link_policy_commands[]; extern struct hci_command host_controller_baseband_commands[]; extern struct hci_command info_commands[]; extern struct hci_command status_commands[]; extern struct hci_command node_commands[]; extern struct hci_command le_commands[]; int hci_request (int, int, char const *, int, char *, int *); int hci_simple_request (int, int, char *, int *); int hci_send (int, char const *, int); int hci_recv (int, char *, int *); char const * hci_link2str (int); char const * hci_pin2str (int); char const * hci_scan2str (int); char const * hci_encrypt2str (int, int); char const * hci_coding2str (int); char const * hci_vdata2str (int); char const * hci_hmode2str (int, char *, int); char const * hci_ver2str (int); char const * hci_lmpver2str (int); char const * hci_manufacturer2str(int); char const * hci_commands2str (uint8_t *, char *, int); char const * hci_features2str (uint8_t *, char *, int); char const * hci_le_features2str (uint8_t *, char *, int); char const * hci_cc2str (int); char const * hci_con_state2str (int); char const * hci_status2str (int); char const * hci_bdaddr2str (bdaddr_t const *); char const * hci_addrtype2str (int type); char const * hci_role2str (int role); char const * hci_mc_accuracy2str (int accuracy); char const * hci_le_chanmap2str (uint8_t *, char *, int); void dump_adv_data(int len, uint8_t* advdata); void print_adv_data(int len, uint8_t* advdata); #endif /* _HCCONTROL_H_ */ diff --git a/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c b/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c index d89a481e8e20..38bfcc321046 100644 --- a/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c +++ b/usr.sbin/bluetooth/hccontrol/host_controller_baseband.c @@ -1,1963 +1,1962 @@ /*- * host_controller_baseband.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: host_controller_baseband.c,v 1.4 2003/08/18 19:19:53 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "hccontrol.h" /* Convert hex ASCII to int4 */ static int hci_hexa2int4(const char *a) { if ('0' <= *a && *a <= '9') return (*a - '0'); if ('A' <= *a && *a <= 'F') return (*a - 'A' + 0xa); if ('a' <= *a && *a <= 'f') return (*a - 'a' + 0xa); return (-1); } /* Convert hex ASCII to int8 */ static int hci_hexa2int8(const char *a) { int hi = hci_hexa2int4(a); int lo = hci_hexa2int4(a + 1); if (hi < 0 || lo < 0) return (-1); return ((hi << 4) | lo); } /* Convert ascii hex string to the uint8_t[] */ static int hci_hexstring2array(char const *s, uint8_t *a, int asize) { int i, l, b; l = strlen(s) / 2; if (l > asize) l = asize; for (i = 0; i < l; i++) { b = hci_hexa2int8(s + i * 2); if (b < 0) return (-1); a[i] = (b & 0xff); } return (0); } /* Send RESET to the unit */ static int hci_reset(int s, int argc, char **argv) { ng_hci_status_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_RESET), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_reset */ /* Send Read_PIN_Type command to the unit */ static int hci_read_pin_type(int s, int argc, char **argv) { ng_hci_read_pin_type_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_PIN_TYPE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "PIN type: %s [%#02x]\n", hci_pin2str(rp.pin_type), rp.pin_type); return (OK); } /* hci_read_pin_type */ /* Send Write_PIN_Type command to the unit */ static int hci_write_pin_type(int s, int argc, char **argv) { ng_hci_write_pin_type_cp cp; ng_hci_write_pin_type_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1) return (USAGE); cp.pin_type = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_PIN_TYPE), (char const *) &cp, sizeof(cp), (char *) &rp , &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_pin_type */ /* Send Read_Stored_Link_Key command to the unit */ static int hci_read_stored_link_key(int s, int argc, char **argv) { struct { ng_hci_cmd_pkt_t hdr; ng_hci_read_stored_link_key_cp cp; } __attribute__ ((packed)) cmd; struct { ng_hci_event_pkt_t hdr; union { ng_hci_command_compl_ep cc; ng_hci_return_link_keys_ep key; uint8_t b[NG_HCI_EVENT_PKT_SIZE]; } ep; } __attribute__ ((packed)) event; int n, n1; /* Send command */ memset(&cmd, 0, sizeof(cmd)); cmd.hdr.type = NG_HCI_CMD_PKT; cmd.hdr.opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_STORED_LINK_KEY)); cmd.hdr.length = sizeof(cmd.cp); switch (argc) { case 1: /* parse BD_ADDR */ if (!bt_aton(argv[0], &cmd.cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cmd.cp.bdaddr, he->h_addr, sizeof(cmd.cp.bdaddr)); } break; default: cmd.cp.read_all = 1; break; } if (hci_send(s, (char const *) &cmd, sizeof(cmd)) != OK) return (ERROR); /* Receive events */ again: memset(&event, 0, sizeof(event)); n = sizeof(event); if (hci_recv(s, (char *) &event, &n) != OK) return (ERROR); if (n <= sizeof(event.hdr)) { errno = EMSGSIZE; return (ERROR); } if (event.hdr.type != NG_HCI_EVENT_PKT) { errno = EIO; return (ERROR); } /* Parse event */ switch (event.hdr.event) { case NG_HCI_EVENT_COMMAND_COMPL: { ng_hci_read_stored_link_key_rp *rp = NULL; if (event.ep.cc.opcode == 0x0000 || event.ep.cc.opcode != cmd.hdr.opcode) goto again; rp = (ng_hci_read_stored_link_key_rp *)(event.ep.b + sizeof(event.ep.cc)); fprintf(stdout, "Complete: Status: %s [%#x]\n", hci_status2str(rp->status), rp->status); fprintf(stdout, "Maximum Number of keys: %d\n", le16toh(rp->max_num_keys)); fprintf(stdout, "Number of keys read: %d\n", le16toh(rp->num_keys_read)); } break; case NG_HCI_EVENT_RETURN_LINK_KEYS: { struct _key { bdaddr_t bdaddr; uint8_t key[NG_HCI_KEY_SIZE]; } __attribute__ ((packed)) *k = NULL; fprintf(stdout, "Event: Number of keys: %d\n", event.ep.key.num_keys); k = (struct _key *)(event.ep.b + sizeof(event.ep.key)); for (n = 0; n < event.ep.key.num_keys; n++) { fprintf(stdout, "\t%d: %s ", n + 1, hci_bdaddr2str(&k->bdaddr)); for (n1 = 0; n1 < sizeof(k->key); n1++) fprintf(stdout, "%02x", k->key[n1]); fprintf(stdout, "\n"); k ++; } goto again; } break; default: goto again; } return (OK); } /* hci_read_store_link_key */ /* Send Write_Stored_Link_Key command to the unit */ static int hci_write_stored_link_key(int s, int argc, char **argv) { struct { ng_hci_write_stored_link_key_cp p; bdaddr_t bdaddr; uint8_t key[NG_HCI_KEY_SIZE]; } cp; ng_hci_write_stored_link_key_rp rp; int32_t n; memset(&cp, 0, sizeof(cp)); switch (argc) { case 2: cp.p.num_keys_write = 1; /* parse BD_ADDR */ if (!bt_aton(argv[0], &cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); } /* parse key */ if (hci_hexstring2array(argv[1], cp.key, sizeof(cp.key)) < 0) return (USAGE); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_STORED_LINK_KEY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Number of keys written: %d\n", rp.num_keys_written); return (OK); } /* hci_write_stored_link_key */ /* Send Delete_Stored_Link_Key command to the unit */ static int hci_delete_stored_link_key(int s, int argc, char **argv) { ng_hci_delete_stored_link_key_cp cp; ng_hci_delete_stored_link_key_rp rp; int32_t n; memset(&cp, 0, sizeof(cp)); switch (argc) { case 1: /* parse BD_ADDR */ if (!bt_aton(argv[0], &cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); } break; default: cp.delete_all = 1; break; } /* send command */ n = sizeof(cp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_DELETE_STORED_LINK_KEY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Number of keys deleted: %d\n", rp.num_keys_deleted); return (OK); } /* hci_delete_stored_link_key */ /* Send Change_Local_Name command to the unit */ static int hci_change_local_name(int s, int argc, char **argv) { ng_hci_change_local_name_cp cp; ng_hci_change_local_name_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: snprintf(cp.name, sizeof(cp.name), "%s", argv[0]); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_CHANGE_LOCAL_NAME), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_change_local_name */ /* Send Read_Local_Name command to the unit */ static int hci_read_local_name(int s, int argc, char **argv) { ng_hci_read_local_name_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_LOCAL_NAME), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Local name: %s\n", rp.name); return (OK); } /* hci_read_local_name */ /* Send Read_Connection_Accept_Timeout to the unit */ static int hci_read_connection_accept_timeout(int s, int argc, char **argv) { ng_hci_read_con_accept_timo_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_CON_ACCEPT_TIMO), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.timeout = le16toh(rp.timeout); fprintf(stdout, "Connection accept timeout: %.2f msec [%d slots]\n", rp.timeout * 0.625, rp.timeout); return (OK); } /* hci_read_connection_accept_timeout */ /* Send Write_Connection_Accept_Timeout to the unit */ static int hci_write_connection_accept_timeout(int s, int argc, char **argv) { ng_hci_write_con_accept_timo_cp cp; ng_hci_write_con_accept_timo_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 1 || n > 0xb540) return (USAGE); cp.timeout = (uint16_t) n; cp.timeout = htole16(cp.timeout); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_CON_ACCEPT_TIMO), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_connection_accept_timeout */ /* Send Read_Page_Timeout command to the unit */ static int hci_read_page_timeout(int s, int argc, char **argv) { ng_hci_read_page_timo_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_PAGE_TIMO), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.timeout = le16toh(rp.timeout); fprintf(stdout, "Page timeout: %.2f msec [%d slots]\n", rp.timeout * 0.625, rp.timeout); return (OK); } /* hci_read_page_timeoout */ /* Send Write_Page_Timeout command to the unit */ static int hci_write_page_timeout(int s, int argc, char **argv) { ng_hci_write_page_timo_cp cp; ng_hci_write_page_timo_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 1 || n > 0xffff) return (USAGE); cp.timeout = (uint16_t) n; cp.timeout = htole16(cp.timeout); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_PAGE_TIMO), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_page_timeout */ /* Send Read_Scan_Enable command to the unit */ static int hci_read_scan_enable(int s, int argc, char **argv) { ng_hci_read_scan_enable_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_SCAN_ENABLE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Scan enable: %s [%#02x]\n", hci_scan2str(rp.scan_enable), rp.scan_enable); return (OK); } /* hci_read_scan_enable */ /* Send Write_Scan_Enable command to the unit */ static int hci_write_scan_enable(int s, int argc, char **argv) { ng_hci_write_scan_enable_cp cp; ng_hci_write_scan_enable_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 3) return (USAGE); cp.scan_enable = (uint8_t) n; break; default: return (USAGE); } n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_SCAN_ENABLE), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_scan_enable */ /* Send Read_Page_Scan_Activity command to the unit */ static int hci_read_page_scan_activity(int s, int argc, char **argv) { ng_hci_read_page_scan_activity_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_PAGE_SCAN_ACTIVITY), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.page_scan_interval = le16toh(rp.page_scan_interval); rp.page_scan_window = le16toh(rp.page_scan_window); fprintf(stdout, "Page Scan Interval: %.2f msec [%d slots]\n", rp.page_scan_interval * 0.625, rp.page_scan_interval); fprintf(stdout, "Page Scan Window: %.2f msec [%d slots]\n", rp.page_scan_window * 0.625, rp.page_scan_window); return (OK); } /* hci_read_page_scan_activity */ /* Send Write_Page_Scan_Activity command to the unit */ static int hci_write_page_scan_activity(int s, int argc, char **argv) { ng_hci_write_page_scan_activity_cp cp; ng_hci_write_page_scan_activity_rp rp; int n; /* parse command parameters */ switch (argc) { case 2: /* page scan interval */ if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000) return (USAGE); cp.page_scan_interval = (uint16_t) n; /* page scan window */ if (sscanf(argv[1], "%d", &n) != 1 || n < 0x12 || n > 0x1000) return (USAGE); cp.page_scan_window = (uint16_t) n; if (cp.page_scan_window > cp.page_scan_interval) return (USAGE); cp.page_scan_interval = htole16(cp.page_scan_interval); cp.page_scan_window = htole16(cp.page_scan_window); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_PAGE_SCAN_ACTIVITY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_page_scan_activity */ /* Send Read_Inquiry_Scan_Activity command to the unit */ static int hci_read_inquiry_scan_activity(int s, int argc, char **argv) { ng_hci_read_inquiry_scan_activity_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_INQUIRY_SCAN_ACTIVITY), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.inquiry_scan_interval = le16toh(rp.inquiry_scan_interval); rp.inquiry_scan_window = le16toh(rp.inquiry_scan_window); fprintf(stdout, "Inquiry Scan Interval: %.2f msec [%d slots]\n", rp.inquiry_scan_interval * 0.625, rp.inquiry_scan_interval); fprintf(stdout, "Inquiry Scan Window: %.2f msec [%d slots]\n", rp.inquiry_scan_window * 0.625, rp.inquiry_scan_interval); return (OK); } /* hci_read_inquiry_scan_activity */ /* Send Write_Inquiry_Scan_Activity command to the unit */ static int hci_write_inquiry_scan_activity(int s, int argc, char **argv) { ng_hci_write_inquiry_scan_activity_cp cp; ng_hci_write_inquiry_scan_activity_rp rp; int n; /* parse command parameters */ switch (argc) { case 2: /* inquiry scan interval */ if (sscanf(argv[0], "%d", &n) != 1 || n < 0x12 || n > 0x1000) return (USAGE); cp.inquiry_scan_interval = (uint16_t) n; /* inquiry scan window */ if (sscanf(argv[1], "%d", &n) != 1 || n < 0x12 || n > 0x1000) return (USAGE); cp.inquiry_scan_window = (uint16_t) n; if (cp.inquiry_scan_window > cp.inquiry_scan_interval) return (USAGE); cp.inquiry_scan_interval = htole16(cp.inquiry_scan_interval); cp.inquiry_scan_window = htole16(cp.inquiry_scan_window); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_INQUIRY_SCAN_ACTIVITY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_inquiry_scan_activity */ /* Send Read_Authentication_Enable command to the unit */ static int hci_read_authentication_enable(int s, int argc, char **argv) { ng_hci_read_auth_enable_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_AUTH_ENABLE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Authentication Enable: %s [%d]\n", rp.auth_enable? "Enabled" : "Disabled", rp.auth_enable); return (OK); } /* hci_read_authentication_enable */ /* Send Write_Authentication_Enable command to the unit */ static int hci_write_authentication_enable(int s, int argc, char **argv) { ng_hci_write_auth_enable_cp cp; ng_hci_write_auth_enable_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1) return (USAGE); cp.auth_enable = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_AUTH_ENABLE), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_authentication_enable */ /* Send Read_Encryption_Mode command to the unit */ static int hci_read_encryption_mode(int s, int argc, char **argv) { ng_hci_read_encryption_mode_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_ENCRYPTION_MODE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Encryption mode: %s [%#02x]\n", hci_encrypt2str(rp.encryption_mode, 0), rp.encryption_mode); return (OK); } /* hci_read_encryption_mode */ /* Send Write_Encryption_Mode command to the unit */ static int hci_write_encryption_mode(int s, int argc, char **argv) { ng_hci_write_encryption_mode_cp cp; ng_hci_write_encryption_mode_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 2) return (USAGE); cp.encryption_mode = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_ENCRYPTION_MODE), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_encryption_mode */ /* Send Read_Class_Of_Device command to the unit */ static int hci_read_class_of_device(int s, int argc, char **argv) { ng_hci_read_unit_class_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_UNIT_CLASS), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Class: %02x:%02x:%02x\n", rp.uclass[2], rp.uclass[1], rp.uclass[0]); return (0); } /* hci_read_class_of_device */ /* Send Write_Class_Of_Device command to the unit */ static int hci_write_class_of_device(int s, int argc, char **argv) { ng_hci_write_unit_class_cp cp; ng_hci_write_unit_class_rp rp; int n0, n1, n2; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%x:%x:%x", &n2, &n1, &n0) != 3) return (USAGE); cp.uclass[0] = (n0 & 0xff); cp.uclass[1] = (n1 & 0xff); cp.uclass[2] = (n2 & 0xff); break; default: return (USAGE); } /* send command */ n0 = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_UNIT_CLASS), (char const *) &cp, sizeof(cp), (char *) &rp, &n0) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_class_of_device */ /* Send Read_Voice_Settings command to the unit */ static int hci_read_voice_settings(int s, int argc, char **argv) { ng_hci_read_voice_settings_rp rp; int n, input_coding, input_data_format, input_sample_size; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_VOICE_SETTINGS), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.settings = le16toh(rp.settings); input_coding = (rp.settings & 0x0300) >> 8; input_data_format = (rp.settings & 0x00c0) >> 6; input_sample_size = (rp.settings & 0x0020) >> 5; fprintf(stdout, "Voice settings: %#04x\n", rp.settings); fprintf(stdout, "Input coding: %s [%d]\n", hci_coding2str(input_coding), input_coding); fprintf(stdout, "Input data format: %s [%d]\n", hci_vdata2str(input_data_format), input_data_format); if (input_coding == 0x00) /* Only for Linear PCM */ fprintf(stdout, "Input sample size: %d bit [%d]\n", input_sample_size? 16 : 8, input_sample_size); return (OK); } /* hci_read_voice_settings */ /* Send Write_Voice_Settings command to the unit */ static int hci_write_voice_settings(int s, int argc, char **argv) { ng_hci_write_voice_settings_cp cp; ng_hci_write_voice_settings_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%x", &n) != 1) return (USAGE); cp.settings = (uint16_t) n; cp.settings = htole16(cp.settings); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_VOICE_SETTINGS), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_voice_settings */ /* Send Read_Number_Broadcast_Restransmissions */ static int hci_read_number_broadcast_retransmissions(int s, int argc, char **argv) { ng_hci_read_num_broadcast_retrans_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_NUM_BROADCAST_RETRANS), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Number of broadcast retransmissions: %d\n", rp.counter); return (OK); } /* hci_read_number_broadcast_retransmissions */ /* Send Write_Number_Broadcast_Restransmissions */ static int hci_write_number_broadcast_retransmissions(int s, int argc, char **argv) { ng_hci_write_num_broadcast_retrans_cp cp; ng_hci_write_num_broadcast_retrans_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0xff) return (USAGE); cp.counter = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_NUM_BROADCAST_RETRANS), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_number_broadcast_retransmissions */ /* Send Read_Hold_Mode_Activity command to the unit */ static int hci_read_hold_mode_activity(int s, int argc, char **argv) { ng_hci_read_hold_mode_activity_rp rp; int n; char buffer[1024]; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_HOLD_MODE_ACTIVITY), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Hold Mode Activities: %#02x\n", rp.hold_mode_activity); if (rp.hold_mode_activity == 0) fprintf(stdout, "Maintain current Power State"); else fprintf(stdout, "%s", hci_hmode2str(rp.hold_mode_activity, buffer, sizeof(buffer))); fprintf(stdout, "\n"); return (OK); } /* hci_read_hold_mode_activity */ /* Send Write_Hold_Mode_Activity command to the unit */ static int hci_write_hold_mode_activity(int s, int argc, char **argv) { ng_hci_write_hold_mode_activity_cp cp; ng_hci_write_hold_mode_activity_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 4) return (USAGE); cp.hold_mode_activity = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_HOLD_MODE_ACTIVITY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_hold_mode_activity */ /* Send Read_SCO_Flow_Control_Enable command to the unit */ static int hci_read_sco_flow_control_enable(int s, int argc, char **argv) { ng_hci_read_sco_flow_control_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_SCO_FLOW_CONTROL), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "SCO flow control %s [%d]\n", rp.flow_control? "enabled" : "disabled", rp.flow_control); return (OK); } /* hci_read_sco_flow_control_enable */ /* Send Write_SCO_Flow_Control_Enable command to the unit */ static int hci_write_sco_flow_control_enable(int s, int argc, char **argv) { ng_hci_write_sco_flow_control_cp cp; ng_hci_write_sco_flow_control_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 1) return (USAGE); cp.flow_control = (uint8_t) n; break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_SCO_FLOW_CONTROL), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_sco_flow_control_enable */ /* Send Read_Link_Supervision_Timeout command to the unit */ static int hci_read_link_supervision_timeout(int s, int argc, char **argv) { ng_hci_read_link_supervision_timo_cp cp; ng_hci_read_link_supervision_timo_rp rp; int n; switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_LINK_SUPERVISION_TIMO), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.timeout = le16toh(rp.timeout); fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "Link supervision timeout: %.2f msec [%d slots]\n", rp.timeout * 0.625, rp.timeout); return (OK); } /* hci_read_link_supervision_timeout */ /* Send Write_Link_Supervision_Timeout command to the unit */ static int hci_write_link_supervision_timeout(int s, int argc, char **argv) { ng_hci_write_link_supervision_timo_cp cp; ng_hci_write_link_supervision_timo_rp rp; int n; switch (argc) { case 2: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); /* link supervision timeout */ if (sscanf(argv[1], "%d", &n) != 1 || n < 0 || n > 0xffff) return (USAGE); cp.timeout = (uint16_t) (n & 0x0fff); cp.timeout = htole16(cp.timeout); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_LINK_SUPERVISION_TIMO), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_link_supervision_timeout */ /* Send Read_Page_Scan_Period_Mode command to the unit */ static int hci_read_page_scan_period_mode(int s, int argc, char **argv) { ng_hci_read_page_scan_period_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_PAGE_SCAN_PERIOD), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Page scan period mode: %#02x\n", rp.page_scan_period_mode); return (OK); } /* hci_read_page_scan_period_mode */ /* Send Write_Page_Scan_Period_Mode command to the unit */ static int hci_write_page_scan_period_mode(int s, int argc, char **argv) { ng_hci_write_page_scan_period_cp cp; ng_hci_write_page_scan_period_rp rp; int n; /* parse command arguments */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 2) return (USAGE); cp.page_scan_period_mode = (n & 0xff); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_PAGE_SCAN_PERIOD), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_page_scan_period_mode */ /* Send Read_Page_Scan_Mode command to the unit */ static int hci_read_page_scan_mode(int s, int argc, char **argv) { ng_hci_read_page_scan_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_PAGE_SCAN), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Page scan mode: %#02x\n", rp.page_scan_mode); return (OK); } /* hci_read_page_scan_mode */ /* Send Write_Page_Scan_Mode command to the unit */ static int hci_write_page_scan_mode(int s, int argc, char **argv) { ng_hci_write_page_scan_cp cp; ng_hci_write_page_scan_rp rp; int n; /* parse command arguments */ switch (argc) { case 1: if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 3) return (USAGE); cp.page_scan_mode = (n & 0xff); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_PAGE_SCAN), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_page_scan_mode */ static int hci_read_le_host_support(int s, int argc, char **argv) { ng_hci_read_le_host_supported_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_READ_LE_HOST_SUPPORTED), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "LE Host support: %#02x\n", rp.le_supported_host); fprintf(stdout, "Simultaneous LE Host : %#02x\n", rp.simultaneous_le_host); return (OK); } static int hci_write_le_host_support(int s, int argc, char **argv) { ng_hci_write_le_host_supported_cp cp; ng_hci_write_le_host_supported_rp rp; int n; cp.le_supported_host = 0; cp.simultaneous_le_host = 0; switch (argc) { case 2: if (sscanf(argv[1], "%d", &n) != 1 || (n != 0 && n != 1)){ printf("-ARGC2: %d\n", n); return (USAGE); } cp.simultaneous_le_host = (n &1); case 1: if (sscanf(argv[0], "%d", &n) != 1 || (n != 0 && n != 1)){ printf("+ARGC1: %d\n", n); return (USAGE); } cp.le_supported_host = (n &1); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } struct hci_command host_controller_baseband_commands[] = { { "reset", "\nThe Reset command will reset the Host Controller and the Link Manager.\n" \ "After the reset is completed, the current operational state will be lost,\n" \ "the Bluetooth unit will enter standby mode and the Host Controller will\n" \ "automatically revert to the default values for the parameters for which\n" \ "default values are defined in the specification.", &hci_reset }, { "read_pin_type", "\nThe Read_PIN_Type command is used for the Host to read whether the Link\n" \ "Manager assumes that the Host supports variable PIN codes only a fixed PIN\n" \ "code.", &hci_read_pin_type }, { "write_pin_type ", "\nThe Write_PIN_Type command is used for the Host to write to the Host\n" \ "Controller whether the Host supports variable PIN codes or only a fixed PIN\n"\ "code.\n\n" \ "\t - dd; 0 - Variable; 1 - Fixed", &hci_write_pin_type }, { "read_stored_link_key []", "\nThe Read_Stored_Link_Key command provides the ability to read one or\n" \ "more link keys stored in the Bluetooth Host Controller. The Bluetooth Host\n" \ "Controller can store a limited number of link keys for other Bluetooth\n" \ "devices.\n\n" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name", &hci_read_stored_link_key }, { "write_stored_link_key ", "\nThe Write_Stored_Link_Key command provides the ability to write one\n" \ "or more link keys to be stored in the Bluetooth Host Controller. The\n" \ "Bluetooth Host Controller can store a limited number of link keys for other\n"\ "Bluetooth devices. If no additional space is available in the Bluetooth\n"\ "Host Controller then no additional link keys will be stored.\n\n" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name\n" \ "\t - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx up to 16 bytes link key", &hci_write_stored_link_key }, { "delete_stored_link_key []", "\nThe Delete_Stored_Link_Key command provides the ability to remove one\n" \ "or more of the link keys stored in the Bluetooth Host Controller. The\n" \ "Bluetooth Host Controller can store a limited number of link keys for other\n"\ "Bluetooth devices.\n\n" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name", &hci_delete_stored_link_key }, { "change_local_name ", "\nThe Change_Local_Name command provides the ability to modify the user\n" \ "friendly name for the Bluetooth unit.\n\n" \ "\t - string", &hci_change_local_name }, { "read_local_name", "\nThe Read_Local_Name command provides the ability to read the\n" \ "stored user-friendly name for the Bluetooth unit.", &hci_read_local_name }, { "read_connection_accept_timeout", "\nThis command will read the value for the Connection_Accept_Timeout\n" \ "configuration parameter. The Connection_Accept_Timeout configuration\n" \ "parameter allows the Bluetooth hardware to automatically deny a\n" \ "connection request after a specified time period has occurred and\n" \ "the new connection is not accepted. Connection Accept Timeout\n" \ "measured in Number of Baseband slots.", &hci_read_connection_accept_timeout }, { "write_connection_accept_timeout ", "\nThis command will write the value for the Connection_Accept_Timeout\n" \ "configuration parameter.\n\n" \ "\t - dddd; measured in number of baseband slots.", &hci_write_connection_accept_timeout }, { "read_page_timeout", "\nThis command will read the value for the Page_Timeout configuration\n" \ "parameter. The Page_Timeout configuration parameter defines the\n" \ "maximum time the local Link Manager will wait for a baseband page\n" \ "response from the remote unit at a locally initiated connection\n" \ "attempt. Page Timeout measured in Number of Baseband slots.", &hci_read_page_timeout }, { "write_page_timeout ", "\nThis command will write the value for the Page_Timeout configuration\n" \ "parameter.\n\n" \ "\t - dddd; measured in number of baseband slots.", &hci_write_page_timeout }, { "read_scan_enable", "\nThis command will read the value for the Scan_Enable parameter. The\n" \ "Scan_Enable parameter controls whether or not the Bluetooth uint\n" \ "will periodically scan for page attempts and/or inquiry requests\n" \ "from other Bluetooth unit.\n\n" \ "\t0x00 - No Scans enabled.\n" \ "\t0x01 - Inquiry Scan enabled. Page Scan disabled.\n" \ "\t0x02 - Inquiry Scan disabled. Page Scan enabled.\n" \ "\t0x03 - Inquiry Scan enabled. Page Scan enabled.", &hci_read_scan_enable }, { "write_scan_enable ", "\nThis command will write the value for the Scan_Enable parameter.\n" \ "The Scan_Enable parameter controls whether or not the Bluetooth\n" \ "unit will periodically scan for page attempts and/or inquiry\n" \ "requests from other Bluetooth unit.\n\n" \ "\t - dd;\n" \ "\t0 - No Scans enabled.\n" \ "\t1 - Inquiry Scan enabled. Page Scan disabled.\n" \ "\t2 - Inquiry Scan disabled. Page Scan enabled.\n" \ "\t3 - Inquiry Scan enabled. Page Scan enabled.", &hci_write_scan_enable }, { "read_page_scan_activity", "\nThis command will read the value for Page_Scan_Activity configuration\n" \ "parameters. The Page_Scan_Interval configuration parameter defines the\n" \ "amount of time between consecutive page scans. This time interval is \n" \ "defined from when the Host Controller started its last page scan until\n" \ "it begins the next page scan. The Page_Scan_Window configuration parameter\n" \ "defines the amount of time for the duration of the page scan. The\n" \ "Page_Scan_Window can only be less than or equal to the Page_Scan_Interval.", &hci_read_page_scan_activity }, { "write_page_scan_activity interval(dddd) window(dddd)", "\nThis command will write the value for Page_Scan_Activity configuration\n" \ "parameter. The Page_Scan_Interval configuration parameter defines the\n" \ "amount of time between consecutive page scans. This is defined as the time\n" \ "interval from when the Host Controller started its last page scan until it\n" \ "begins the next page scan. The Page_Scan_Window configuration parameter\n" \ "defines the amount of time for the duration of the page scan. \n" \ "The Page_Scan_Window can only be less than or equal to the Page_Scan_Interval.\n\n" \ "\t - Range: 0x0012 -- 0x100, Time = N * 0.625 msec\n" \ "\t - Range: 0x0012 -- 0x100, Time = N * 0.625 msec", &hci_write_page_scan_activity }, { "read_inquiry_scan_activity", "\nThis command will read the value for Inquiry_Scan_Activity configuration\n" \ "parameter. The Inquiry_Scan_Interval configuration parameter defines the\n" \ "amount of time between consecutive inquiry scans. This is defined as the\n" \ "time interval from when the Host Controller started its last inquiry scan\n" \ "until it begins the next inquiry scan.", &hci_read_inquiry_scan_activity }, { "write_inquiry_scan_activity interval(dddd) window(dddd)", "\nThis command will write the value for Inquiry_Scan_Activity configuration\n"\ "parameter. The Inquiry_Scan_Interval configuration parameter defines the\n" \ "amount of time between consecutive inquiry scans. This is defined as the\n" \ "time interval from when the Host Controller started its last inquiry scan\n" \ "until it begins the next inquiry scan. The Inquiry_Scan_Window configuration\n" \ "parameter defines the amount of time for the duration of the inquiry scan.\n" \ "The Inquiry_Scan_Window can only be less than or equal to the Inquiry_Scan_Interval.\n\n" \ "\t - Range: 0x0012 -- 0x100, Time = N * 0.625 msec\n" \ "\t - Range: 0x0012 -- 0x100, Time = N * 0.625 msec", &hci_write_inquiry_scan_activity }, { "read_authentication_enable", "\nThis command will read the value for the Authentication_Enable parameter.\n"\ "The Authentication_Enable parameter controls if the local unit requires\n"\ "to authenticate the remote unit at connection setup (between the\n" \ "Create_Connection command or acceptance of an incoming ACL connection\n"\ "and the corresponding Connection Complete event). At connection setup, only\n"\ "the unit(s) with the Authentication_Enable parameter enabled will try to\n"\ "authenticate the other unit.", &hci_read_authentication_enable }, { "write_authentication_enable enable(0|1)", "\nThis command will write the value for the Authentication_Enable parameter.\n"\ "The Authentication_Enable parameter controls if the local unit requires to\n"\ "authenticate the remote unit at connection setup (between the\n" \ "Create_Connection command or acceptance of an incoming ACL connection\n" \ "and the corresponding Connection Complete event). At connection setup, only\n"\ "the unit(s) with the Authentication_Enable parameter enabled will try to\n"\ "authenticate the other unit.", &hci_write_authentication_enable }, { "read_encryption_mode", "\nThis command will read the value for the Encryption_Mode parameter. The\n" \ "Encryption_Mode parameter controls if the local unit requires encryption\n" \ "to the remote unit at connection setup (between the Create_Connection\n" \ "command or acceptance of an incoming ACL connection and the corresponding\n" \ "Connection Complete event). At connection setup, only the unit(s) with\n" \ "the Authentication_Enable parameter enabled and Encryption_Mode parameter\n" \ "enabled will try to encrypt the connection to the other unit.\n\n" \ "\t:\n" \ "\t0x00 - Encryption disabled.\n" \ "\t0x01 - Encryption only for point-to-point packets.\n" \ "\t0x02 - Encryption for both point-to-point and broadcast packets.", &hci_read_encryption_mode }, { "write_encryption_mode mode(0|1|2)", "\tThis command will write the value for the Encryption_Mode parameter.\n" \ "The Encryption_Mode parameter controls if the local unit requires\n" \ "encryption to the remote unit at connection setup (between the\n" \ "Create_Connection command or acceptance of an incoming ACL connection\n" \ "and the corresponding Connection Complete event). At connection setup,\n" \ "only the unit(s) with the Authentication_Enable parameter enabled and\n" \ "Encryption_Mode parameter enabled will try to encrypt the connection to\n" \ "the other unit.\n\n" \ "\t (dd)\n" \ "\t0 - Encryption disabled.\n" \ "\t1 - Encryption only for point-to-point packets.\n" \ "\t2 - Encryption for both point-to-point and broadcast packets.", &hci_write_encryption_mode }, { "read_class_of_device", "\nThis command will read the value for the Class_of_Device parameter.\n" \ "The Class_of_Device parameter is used to indicate the capabilities of\n" \ "the local unit to other units.", &hci_read_class_of_device }, { "write_class_of_device class(xx:xx:xx)", "\nThis command will write the value for the Class_of_Device parameter.\n" \ "The Class_of_Device parameter is used to indicate the capabilities of \n" \ "the local unit to other units.\n\n" \ "\t (xx:xx:xx) - class of device", &hci_write_class_of_device }, { "read_voice_settings", "\nThis command will read the values for the Voice_Setting parameter.\n" \ "The Voice_Setting parameter controls all the various settings for voice\n" \ "connections. These settings apply to all voice connections, and cannot be\n" \ "set for individual voice connections. The Voice_Setting parameter controls\n" \ "the configuration for voice connections: Input Coding, Air coding format,\n" \ "input data format, Input sample size, and linear PCM parameter.", &hci_read_voice_settings }, { "write_voice_settings settings(xxxx)", "\nThis command will write the values for the Voice_Setting parameter.\n" \ "The Voice_Setting parameter controls all the various settings for voice\n" \ "connections. These settings apply to all voice connections, and cannot be\n" \ "set for individual voice connections. The Voice_Setting parameter controls\n" \ "the configuration for voice connections: Input Coding, Air coding format,\n" \ "input data format, Input sample size, and linear PCM parameter.\n\n" \ "\t (xxxx) - voice settings", &hci_write_voice_settings }, { "read_number_broadcast_retransmissions", "\nThis command will read the unit's parameter value for the Number of\n" \ "Broadcast Retransmissions. Broadcast packets are not acknowledged and are\n" \ "unreliable.", &hci_read_number_broadcast_retransmissions }, { "write_number_broadcast_retransmissions count(dd)", "\nThis command will write the unit's parameter value for the Number of\n" \ "Broadcast Retransmissions. Broadcast packets are not acknowledged and are\n" \ "unreliable.\n\n" \ "\t (dd) - number of broadcast retransimissions", &hci_write_number_broadcast_retransmissions }, { "read_hold_mode_activity", "\nThis command will read the value for the Hold_Mode_Activity parameter.\n" \ "The Hold_Mode_Activity value is used to determine what activities should\n" \ "be suspended when the unit is in hold mode.", &hci_read_hold_mode_activity }, { "write_hold_mode_activity settings(0|1|2|4)", "\nThis command will write the value for the Hold_Mode_Activity parameter.\n" \ "The Hold_Mode_Activity value is used to determine what activities should\n" \ "be suspended when the unit is in hold mode.\n\n" \ "\t (dd) - bit mask:\n" \ "\t0 - Maintain current Power State. Default\n" \ "\t1 - Suspend Page Scan.\n" \ "\t2 - Suspend Inquiry Scan.\n" \ "\t4 - Suspend Periodic Inquiries.", &hci_write_hold_mode_activity }, { "read_sco_flow_control_enable", "\nThe Read_SCO_Flow_Control_Enable command provides the ability to read\n" \ "the SCO_Flow_Control_Enable setting. By using this setting, the Host can\n" \ "decide if the Host Controller will send Number Of Completed Packets events\n" \ "for SCO Connection Handles. This setting allows the Host to enable and\n" \ "disable SCO flow control.", &hci_read_sco_flow_control_enable }, { "write_sco_flow_control_enable enable(0|1)", "\nThe Write_SCO_Flow_Control_Enable command provides the ability to write\n" \ "the SCO_Flow_Control_Enable setting. By using this setting, the Host can\n" \ "decide if the Host Controller will send Number Of Completed Packets events\n" \ "for SCO Connection Handles. This setting allows the Host to enable and\n" \ "disable SCO flow control. The SCO_Flow_Control_Enable setting can only be\n" \ "changed if no connections exist.", &hci_write_sco_flow_control_enable }, { "read_link_supervision_timeout ", "\nThis command will read the value for the Link_Supervision_Timeout\n" \ "parameter for the device. The Link_Supervision_Timeout parameter is used\n" \ "by the master or slave Bluetooth device to monitor link loss. If, for any\n" \ "reason, no Baseband packets are received from that Connection Handle for a\n" \ "duration longer than the Link_Supervision_Timeout, the connection is\n" "disconnected.\n\n" \ "\t - dddd; connection handle\n", &hci_read_link_supervision_timeout }, { "write_link_supervision_timeout ", "\nThis command will write the value for the Link_Supervision_Timeout\n" \ "parameter for the device. The Link_Supervision_Timeout parameter is used\n" \ "by the master or slave Bluetooth device to monitor link loss. If, for any\n" \ "reason, no Baseband packets are received from that connection handle for a\n" \ "duration longer than the Link_Supervision_Timeout, the connection is\n" \ "disconnected.\n\n" \ "\t - dddd; connection handle\n" \ "\t - dddd; timeout measured in number of baseband slots\n", &hci_write_link_supervision_timeout }, { "read_page_scan_period_mode", "\nThis command is used to read the mandatory Page_Scan_Period_Mode of the\n" \ "local Bluetooth device. Every time an inquiry response message is sent, the\n"\ "Bluetooth device will start a timer (T_mandatory_pscan), the value of which\n"\ "is dependent on the Page_Scan_Period_Mode. As long as this timer has not\n" \ "expired, the Bluetooth device will use the Page_Scan_Period_Mode for all\n" \ "following page scans.", &hci_read_page_scan_period_mode }, { "write_page_scan_period_mode ", "\nThis command is used to write the mandatory Page_Scan_Period_Mode of the\n" \ "local Bluetooth device. Every time an inquiry response message is sent, the\n"\ "Bluetooth device will start a timer (T_mandatory_pscan), the value of which\n"\ "is dependent on the Page_Scan_Period_Mode. As long as this timer has not\n" \ "expired, the Bluetooth device will use the Page_Scan_Period_Mode for all\n" \ "following page scans.\n\n" \ "\t - dd; page scan period mode:\n" \ "\t0x00 - P0 (Default)\n" \ "\t0x01 - P1\n" \ "\t0x02 - P2", &hci_write_page_scan_period_mode }, { "read_page_scan_mode", "\nThis command is used to read the default page scan mode of the local\n" \ "Bluetooth device. The Page_Scan_Mode parameter indicates the page scan mode\n"\ "that is used for the default page scan. Currently one mandatory page scan\n"\ "mode and three optional page scan modes are defined. Following an inquiry\n" \ "response, if the Baseband timer T_mandatory_pscan has not expired, the\n" \ "mandatory page scan mode must be applied.", &hci_read_page_scan_mode }, { "write_page_scan_mode ", "\nThis command is used to write the default page scan mode of the local\n" \ "Bluetooth device. The Page_Scan_Mode parameter indicates the page scan mode\n"\ "that is used for the default page scan. Currently, one mandatory page scan\n"\ "mode and three optional page scan modes are defined. Following an inquiry\n"\ "response, if the Baseband timer T_mandatory_pscan has not expired, the\n" \ "mandatory page scan mode must be applied.\n\n" \ "\t - dd; page scan mode:\n" \ "\t0x00 - Mandatory Page Scan Mode (Default)\n" \ "\t0x01 - Optional Page Scan Mode I\n" \ "\t0x02 - Optional Page Scan Mode II\n" \ "\t0x03 - Optional Page Scan Mode III", &hci_write_page_scan_mode }, { "read_le_host_support", \ "Read if this host is in LE supported mode and simultaneous LE supported mode", &hci_read_le_host_support, }, { "write_le_host_support", \ "write_le_host_support le_host[0|1] simultaneous_le[0|1]", &hci_write_le_host_support, }, { NULL, } }; diff --git a/usr.sbin/bluetooth/hccontrol/info.c b/usr.sbin/bluetooth/hccontrol/info.c index b8d6e3b234f9..b1b2aa36c593 100644 --- a/usr.sbin/bluetooth/hccontrol/info.c +++ b/usr.sbin/bluetooth/hccontrol/info.c @@ -1,256 +1,255 @@ /*- * info.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: info.c,v 1.3 2003/08/18 19:19:54 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "hccontrol.h" /* Send Read_Local_Version_Information command to the unit */ static int hci_read_local_version_information(int s, int argc, char **argv) { ng_hci_read_local_ver_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_LOCAL_VER), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } rp.manufacturer = le16toh(rp.manufacturer); fprintf(stdout, "HCI version: %s [%#02x]\n", hci_ver2str(rp.hci_version), rp.hci_version); fprintf(stdout, "HCI revision: %#04x\n", le16toh(rp.hci_revision)); fprintf(stdout, "LMP version: %s [%#02x]\n", hci_lmpver2str(rp.lmp_version), rp.lmp_version); fprintf(stdout, "LMP sub-version: %#04x\n", le16toh(rp.lmp_subversion)); fprintf(stdout, "Manufacturer: %s [%#04x]\n", hci_manufacturer2str(rp.manufacturer), rp.manufacturer); return (OK); } /* hci_read_local_version_information */ /* Send Read_Local_Supported_Commands command to the unit */ static int hci_read_local_supported_commands(int s, int argc, char **argv) { ng_hci_read_local_commands_rp rp; int n; char buffer[16384]; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_LOCAL_COMMANDS), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Supported commands:"); for (n = 0; n < sizeof(rp.features); n++) { if (n % 8 == 0) fprintf(stdout, "\n"); fprintf(stdout, "%#02x ", rp.features[n]); } fprintf(stdout, "\n%s\n", hci_commands2str(rp.features, buffer, sizeof(buffer))); return (OK); } /* hci_read_local_supported_commands */ /* Send Read_Local_Supported_Features command to the unit */ static int hci_read_local_supported_features(int s, int argc, char **argv) { ng_hci_read_local_features_rp rp; int n; char buffer[2048]; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_LOCAL_FEATURES), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Features: "); for (n = 0; n < sizeof(rp.features); n++) fprintf(stdout, "%#02x ", rp.features[n]); fprintf(stdout, "\n%s\n", hci_features2str(rp.features, buffer, sizeof(buffer))); return (OK); } /* hci_read_local_supported_features */ /* Sent Read_Buffer_Size command to the unit */ static int hci_read_buffer_size(int s, int argc, char **argv) { ng_hci_read_buffer_size_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_BUFFER_SIZE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Max. ACL packet size: %d bytes\n", le16toh(rp.max_acl_size)); fprintf(stdout, "Number of ACL packets: %d\n", le16toh(rp.num_acl_pkt)); fprintf(stdout, "Max. SCO packet size: %d bytes\n", rp.max_sco_size); fprintf(stdout, "Number of SCO packets: %d\n", le16toh(rp.num_sco_pkt)); return (OK); } /* hci_read_buffer_size */ /* Send Read_Country_Code command to the unit */ static int hci_read_country_code(int s, int argc, char **argv) { ng_hci_read_country_code_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_COUNTRY_CODE), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Country code: %s [%#02x]\n", hci_cc2str(rp.country_code), rp.country_code); return (OK); } /* hci_read_country_code */ /* Send Read_BD_ADDR command to the unit */ static int hci_read_bd_addr(int s, int argc, char **argv) { ng_hci_read_bdaddr_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_INFO, NG_HCI_OCF_READ_BDADDR), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "BD_ADDR: %s\n", bt_ntoa(&rp.bdaddr, NULL)); return (OK); } /* hci_read_bd_addr */ struct hci_command info_commands[] = { { "read_local_version_information", "\nThis command will read the values for the version information for the\n" \ "local Bluetooth unit.", &hci_read_local_version_information }, { "read_local_supported_commands", "\nThis command will read the commands the local Bluetooth unit supports.\n", &hci_read_local_supported_commands }, { "read_local_supported_features", "\nThis command requests a list of the supported features for the local\n" \ "unit. This command will return a list of the LMP features.", &hci_read_local_supported_features }, { "read_buffer_size", "\nThe Read_Buffer_Size command is used to read the maximum size of the\n" \ "data portion of HCI ACL and SCO Data Packets sent from the Host to the\n" \ "Host Controller.", &hci_read_buffer_size }, { "read_country_code", "\nThis command will read the value for the Country_Code return parameter.\n" \ "The Country_Code defines which range of frequency band of the ISM 2.4 GHz\n" \ "band will be used by the unit.", &hci_read_country_code }, { "read_bd_addr", "\nThis command will read the value for the BD_ADDR parameter. The BD_ADDR\n" \ "is a 48-bit unique identifier for a Bluetooth unit.", &hci_read_bd_addr }, { NULL, }}; diff --git a/usr.sbin/bluetooth/hccontrol/le.c b/usr.sbin/bluetooth/hccontrol/le.c index c8ae335fcbe0..6d5440643b45 100644 --- a/usr.sbin/bluetooth/hccontrol/le.c +++ b/usr.sbin/bluetooth/hccontrol/le.c @@ -1,1371 +1,1370 @@ /* * le.c * * Copyright (c) 2015 Takanori Watanabe * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hccontrol.c,v 1.5 2003/09/05 00:38:24 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include "hccontrol.h" static int le_set_scan_param(int s, int argc, char *argv[]); static int le_set_scan_enable(int s, int argc, char *argv[]); static int parse_param(int argc, char *argv[], char *buf, int *len); static int le_set_scan_response(int s, int argc, char *argv[]); static int le_read_supported_states(int s, int argc, char *argv[]); static int le_read_local_supported_features(int s, int argc ,char *argv[]); static int set_le_event_mask(int s, uint64_t mask); static int set_event_mask(int s, uint64_t mask); static int le_enable(int s, int argc, char *argv[]); static int le_set_advertising_enable(int s, int argc, char *argv[]); static int le_set_advertising_param(int s, int argc, char *argv[]); static int le_read_advertising_channel_tx_power(int s, int argc, char *argv[]); static int le_scan(int s, int argc, char *argv[]); static void handle_le_event(ng_hci_event_pkt_t* e, bool verbose); static int le_read_white_list_size(int s, int argc, char *argv[]); static int le_clear_white_list(int s, int argc, char *argv[]); static int le_add_device_to_white_list(int s, int argc, char *argv[]); static int le_remove_device_from_white_list(int s, int argc, char *argv[]); static int le_connect(int s, int argc, char *argv[]); static void handle_le_connection_event(ng_hci_event_pkt_t* e, bool verbose); static int le_read_channel_map(int s, int argc, char *argv[]); static void handle_le_remote_features_event(ng_hci_event_pkt_t* e); static int le_rand(int s, int argc, char *argv[]); static int le_set_scan_param(int s, int argc, char *argv[]) { int type; int interval; int window; int adrtype; int policy; int n; ng_hci_le_set_scan_parameters_cp cp; ng_hci_le_set_scan_parameters_rp rp; if (argc != 5) return (USAGE); if (strcmp(argv[0], "active") == 0) type = 1; else if (strcmp(argv[0], "passive") == 0) type = 0; else return (USAGE); interval = (int)(atof(argv[1])/0.625); interval = (interval < 4)? 4: interval; window = (int)(atof(argv[2])/0.625); window = (window < 4) ? 4 : interval; if (strcmp(argv[3], "public") == 0) adrtype = 0; else if (strcmp(argv[3], "random") == 0) adrtype = 1; else return (USAGE); if (strcmp(argv[4], "all") == 0) policy = 0; else if (strcmp(argv[4], "whitelist") == 0) policy = 1; else return (USAGE); cp.le_scan_type = type; cp.le_scan_interval = interval; cp.own_address_type = adrtype; cp.le_scan_window = window; cp.scanning_filter_policy = policy; n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_PARAMETERS), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int le_set_scan_enable(int s, int argc, char *argv[]) { ng_hci_le_set_scan_enable_cp cp; ng_hci_le_set_scan_enable_rp rp; int n, enable = 0; if (argc != 1) return (USAGE); if (strcmp(argv[0], "enable") == 0) enable = 1; else if (strcmp(argv[0], "disable") != 0) return (USAGE); n = sizeof(rp); cp.le_scan_enable = enable; cp.filter_duplicates = 0; if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_ENABLE), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "LE Scan: %s\n", enable? "Enabled" : "Disabled"); return (OK); } static int parse_param(int argc, char *argv[], char *buf, int *len) { char *buflast = buf + (*len); char *curbuf = buf; char *token,*lenpos; int ch; int datalen; uint16_t value; optreset = 1; optind = 0; while ((ch = getopt(argc, argv , "n:f:u:")) != -1) { switch(ch){ case 'n': datalen = strlen(optarg); if ((curbuf + datalen + 2) >= buflast) goto done; curbuf[0] = datalen + 1; curbuf[1] = 8; curbuf += 2; memcpy(curbuf, optarg, datalen); curbuf += datalen; break; case 'f': if (curbuf+3 > buflast) goto done; curbuf[0] = 2; curbuf[1] = 1; curbuf[2] = (uint8_t)strtol(optarg, NULL, 16); curbuf += 3; break; case 'u': if ((buf+2) >= buflast) goto done; lenpos = curbuf; curbuf[1] = 2; *lenpos = 1; curbuf += 2; while ((token = strsep(&optarg, ",")) != NULL) { value = strtol(token, NULL, 16); if ((curbuf+2) >= buflast) break; curbuf[0] = value &0xff; curbuf[1] = (value>>8)&0xff; curbuf += 2; *lenpos += 2; } } } done: *len = curbuf - buf; return (OK); } static int le_set_scan_response(int s, int argc, char *argv[]) { ng_hci_le_set_scan_response_data_cp cp; ng_hci_le_set_scan_response_data_rp rp; int n; int len; char buf[NG_HCI_ADVERTISING_DATA_SIZE]; len = sizeof(buf); parse_param(argc, argv, buf, &len); memset(cp.scan_response_data, 0, sizeof(cp.scan_response_data)); cp.scan_response_data_length = len; memcpy(cp.scan_response_data, buf, len); n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_RESPONSE_DATA), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int le_read_local_supported_features(int s, int argc ,char *argv[]) { ng_hci_le_read_local_supported_features_rp rp; int n = sizeof(rp); union { uint64_t raw; uint8_t octets[8]; } le_features; char buffer[2048]; if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_LOCAL_SUPPORTED_FEATURES), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } le_features.raw = rp.le_features; fprintf(stdout, "LE Features: "); for(int i = 0; i < 8; i++) fprintf(stdout, " %#02x", le_features.octets[i]); fprintf(stdout, "\n%s\n", hci_le_features2str(le_features.octets, buffer, sizeof(buffer))); fprintf(stdout, "\n"); return (OK); } static int le_read_supported_states(int s, int argc, char *argv[]) { ng_hci_le_read_supported_states_rp rp; int n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE( NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_SUPPORTED_STATES), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "LE States: %jx\n", rp.le_states); return (OK); } static int set_le_event_mask(int s, uint64_t mask) { ng_hci_le_set_event_mask_cp semc; ng_hci_le_set_event_mask_rp rp; int i, n; n = sizeof(rp); for (i=0; i < NG_HCI_LE_EVENT_MASK_SIZE; i++) { semc.event_mask[i] = mask&0xff; mask >>= 8; } if(hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_EVENT_MASK), (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int set_event_mask(int s, uint64_t mask) { ng_hci_set_event_mask_cp semc; ng_hci_set_event_mask_rp rp; int i, n; n = sizeof(rp); for (i=0; i < NG_HCI_EVENT_MASK_SIZE; i++) { semc.event_mask[i] = mask&0xff; mask >>= 8; } if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, NG_HCI_OCF_SET_EVENT_MASK), (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int le_enable(int s, int argc, char *argv[]) { int result; if (argc != 1) return (USAGE); if (strcasecmp(argv[0], "enable") == 0) { result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT | NG_HCI_EVENT_MASK_LE); if (result != OK) return result; result = set_le_event_mask(s, NG_HCI_LE_EVENT_MASK_ALL); if (result == OK) { fprintf(stdout, "LE enabled\n"); return (OK); } else return result; } else if (strcasecmp(argv[0], "disable") == 0) { result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT); if (result == OK) { fprintf(stdout, "LE disabled\n"); return (OK); } else return result; } else return (USAGE); } static int le_set_advertising_enable(int s, int argc, char *argv[]) { ng_hci_le_set_advertise_enable_cp cp; ng_hci_le_set_advertise_enable_rp rp; int n, enable = 0; if (argc != 1) return USAGE; if (strcmp(argv[0], "enable") == 0) enable = 1; else if (strcmp(argv[0], "disable") != 0) return USAGE; n = sizeof(rp); cp.advertising_enable = enable; if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_ADVERTISE_ENABLE), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "LE Advertising %s\n", (enable ? "enabled" : "disabled")); return (OK); } static int le_set_advertising_param(int s, int argc, char *argv[]) { ng_hci_le_set_advertising_parameters_cp cp; ng_hci_le_set_advertising_parameters_rp rp; int n, ch; cp.advertising_interval_min = 0x800; cp.advertising_interval_max = 0x800; cp.advertising_type = 0; cp.own_address_type = 0; cp.direct_address_type = 0; cp.advertising_channel_map = 7; cp.advertising_filter_policy = 0; optreset = 1; optind = 0; while ((ch = getopt(argc, argv , "m:M:t:o:p:a:c:f:")) != -1) { switch(ch) { case 'm': cp.advertising_interval_min = (uint16_t)(strtod(optarg, NULL)/0.625); break; case 'M': cp.advertising_interval_max = (uint16_t)(strtod(optarg, NULL)/0.625); break; case 't': cp.advertising_type = (uint8_t)strtod(optarg, NULL); break; case 'o': cp.own_address_type = (uint8_t)strtod(optarg, NULL); break; case 'p': cp.direct_address_type = (uint8_t)strtod(optarg, NULL); break; case 'a': if (!bt_aton(optarg, &cp.direct_address)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) return (USAGE); memcpy(&cp.direct_address, he->h_addr, sizeof(cp.direct_address)); } break; case 'c': cp.advertising_channel_map = (uint8_t)strtod(optarg, NULL); break; case 'f': cp.advertising_filter_policy = (uint8_t)strtod(optarg, NULL); break; } } n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_ADVERTISING_PARAMETERS), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int le_read_advertising_channel_tx_power(int s, int argc, char *argv[]) { ng_hci_le_read_advertising_channel_tx_power_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_ADVERTISING_CHANNEL_TX_POWER), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Advertising transmit power level: %d dBm\n", (int8_t)rp.transmit_power_level); return (OK); } static int le_set_advertising_data(int s, int argc, char *argv[]) { ng_hci_le_set_advertising_data_cp cp; ng_hci_le_set_advertising_data_rp rp; int n, len; n = sizeof(rp); char buf[NG_HCI_ADVERTISING_DATA_SIZE]; len = sizeof(buf); parse_param(argc, argv, buf, &len); memset(cp.advertising_data, 0, sizeof(cp.advertising_data)); cp.advertising_data_length = len; memcpy(cp.advertising_data, buf, len); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_ADVERTISING_DATA), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } static int le_read_buffer_size(int s, int argc, char *argv[]) { union { ng_hci_le_read_buffer_size_rp v1; ng_hci_le_read_buffer_size_rp_v2 v2; } rp; int n, ch; uint8_t v; uint16_t cmd; optreset = 1; optind = 0; /* Default to version 1*/ v = 1; cmd = NG_HCI_OCF_LE_READ_BUFFER_SIZE; while ((ch = getopt(argc, argv , "v:")) != -1) { switch(ch) { case 'v': v = (uint8_t)strtol(optarg, NULL, 16); if (v == 2) cmd = NG_HCI_OCF_LE_READ_BUFFER_SIZE_V2; else if (v > 2) return (USAGE); break; default: v = 1; } } n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, cmd), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.v1.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.v1.status), rp.v1.status); return (FAILED); } fprintf(stdout, "ACL data packet length: %d\n", rp.v1.hc_le_data_packet_length); fprintf(stdout, "Number of ACL data packets: %d\n", rp.v1.hc_total_num_le_data_packets); if (v == 2) { fprintf(stdout, "ISO data packet length: %d\n", rp.v2.hc_iso_data_packet_length); fprintf(stdout, "Number of ISO data packets: %d\n", rp.v2.hc_total_num_iso_data_packets); } return (OK); } static int le_scan(int s, int argc, char *argv[]) { int n, bufsize, scancount, numscans; bool verbose; uint8_t active = 0; char ch; char b[512]; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; ng_hci_le_set_scan_parameters_cp scan_param_cp; ng_hci_le_set_scan_parameters_rp scan_param_rp; ng_hci_le_set_scan_enable_cp scan_enable_cp; ng_hci_le_set_scan_enable_rp scan_enable_rp; optreset = 1; optind = 0; verbose = false; numscans = 1; while ((ch = getopt(argc, argv , "an:v")) != -1) { switch(ch) { case 'a': active = 1; break; case 'n': numscans = (uint8_t)strtol(optarg, NULL, 10); break; case 'v': verbose = true; break; } } scan_param_cp.le_scan_type = active; scan_param_cp.le_scan_interval = (uint16_t)(100/0.625); scan_param_cp.le_scan_window = (uint16_t)(50/0.625); /* Address type public */ scan_param_cp.own_address_type = 0; /* 'All' filter policy */ scan_param_cp.scanning_filter_policy = 0; n = sizeof(scan_param_rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_PARAMETERS), (void *)&scan_param_cp, sizeof(scan_param_cp), (void *)&scan_param_rp, &n) == ERROR) return (ERROR); if (scan_param_rp.status != 0x00) { fprintf(stdout, "LE_Set_Scan_Parameters failed. Status: %s [%#02x]\n", hci_status2str(scan_param_rp.status), scan_param_rp.status); return (FAILED); } /* Enable scanning */ n = sizeof(scan_enable_rp); scan_enable_cp.le_scan_enable = 1; scan_enable_cp.filter_duplicates = 1; if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_ENABLE), (void *)&scan_enable_cp, sizeof(scan_enable_cp), (void *)&scan_enable_rp, &n) == ERROR) return (ERROR); if (scan_enable_rp.status != 0x00) { fprintf(stdout, "LE_Scan_Enable enable failed. Status: %s [%#02x]\n", hci_status2str(scan_enable_rp.status), scan_enable_rp.status); return (FAILED); } scancount = 0; while (scancount < numscans) { /* wait for scan events */ bufsize = sizeof(b); if (hci_recv(s, b, &bufsize) == ERROR) { return (ERROR); } if (bufsize < sizeof(*e)) { errno = EIO; return (ERROR); } scancount++; if (e->event == NG_HCI_EVENT_LE) { fprintf(stdout, "Scan %d\n", scancount); handle_le_event(e, verbose); } } fprintf(stdout, "Scan complete\n"); /* Disable scanning */ n = sizeof(scan_enable_rp); scan_enable_cp.le_scan_enable = 0; if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_SET_SCAN_ENABLE), (void *)&scan_enable_cp, sizeof(scan_enable_cp), (void *)&scan_enable_rp, &n) == ERROR) return (ERROR); if (scan_enable_rp.status != 0x00) { fprintf(stdout, "LE_Scan_Enable disable failed. Status: %s [%#02x]\n", hci_status2str(scan_enable_rp.status), scan_enable_rp.status); return (FAILED); } return (OK); } static void handle_le_event(ng_hci_event_pkt_t* e, bool verbose) { int rc; ng_hci_le_ep *leer = (ng_hci_le_ep *)(e + 1); ng_hci_le_advertising_report_ep *advrep = (ng_hci_le_advertising_report_ep *)(leer + 1); ng_hci_le_advreport *reports = (ng_hci_le_advreport *)(advrep + 1); if (leer->subevent_code == NG_HCI_LEEV_ADVREP) { fprintf(stdout, "Scan result, num_reports: %d\n", advrep->num_reports); for(rc = 0; rc < advrep->num_reports; rc++) { uint8_t length = (uint8_t)reports[rc].length_data; fprintf(stdout, "\tBD_ADDR %s \n", hci_bdaddr2str(&reports[rc].bdaddr)); fprintf(stdout, "\tAddress type: %s\n", hci_addrtype2str(reports[rc].addr_type)); if (length > 0 && verbose) { dump_adv_data(length, reports[rc].data); print_adv_data(length, reports[rc].data); fprintf(stdout, "\tRSSI: %d dBm\n", (int8_t)reports[rc].data[length]); fprintf(stdout, "\n"); } } } } static int le_read_white_list_size(int s, int argc, char *argv[]) { ng_hci_le_read_white_list_size_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_WHITE_LIST_SIZE), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "White list size: %d\n", (uint8_t)rp.white_list_size); return (OK); } static int le_clear_white_list(int s, int argc, char *argv[]) { ng_hci_le_clear_white_list_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_CLEAR_WHITE_LIST), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "White list cleared\n"); return (OK); } static int le_add_device_to_white_list(int s, int argc, char *argv[]) { ng_hci_le_add_device_to_white_list_cp cp; ng_hci_le_add_device_to_white_list_rp rp; int n; char ch; optreset = 1; optind = 0; bool addr_set = false; n = sizeof(rp); cp.address_type = 0x00; while ((ch = getopt(argc, argv , "t:a:")) != -1) { switch(ch) { case 't': if (strcmp(optarg, "public") == 0) cp.address_type = 0x00; else if (strcmp(optarg, "random") == 0) cp.address_type = 0x01; else return (USAGE); break; case 'a': addr_set = true; if (!bt_aton(optarg, &cp.address)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) return (USAGE); memcpy(&cp.address, he->h_addr, sizeof(cp.address)); } break; } } if (addr_set == false) return (USAGE); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_ADD_DEVICE_TO_WHITE_LIST), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Address added to white list\n"); return (OK); } static int le_remove_device_from_white_list(int s, int argc, char *argv[]) { ng_hci_le_remove_device_from_white_list_cp cp; ng_hci_le_remove_device_from_white_list_rp rp; int n; char ch; optreset = 1; optind = 0; bool addr_set = false; n = sizeof(rp); cp.address_type = 0x00; while ((ch = getopt(argc, argv , "t:a:")) != -1) { switch(ch) { case 't': if (strcmp(optarg, "public") == 0) cp.address_type = 0x00; else if (strcmp(optarg, "random") == 0) cp.address_type = 0x01; else return (USAGE); break; case 'a': addr_set = true; if (!bt_aton(optarg, &cp.address)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) return (USAGE); memcpy(&cp.address, he->h_addr, sizeof(cp.address)); } break; } } if (addr_set == false) return (USAGE); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_ADD_DEVICE_TO_WHITE_LIST), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Address removed from white list\n"); return (OK); } static int le_connect(int s, int argc, char *argv[]) { ng_hci_le_create_connection_cp cp; ng_hci_status_rp rp; char b[512]; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; int n, scancount, bufsize; char ch; bool addr_set = false; bool verbose = false; optreset = 1; optind = 0; /* minimal scan interval (2.5ms) */ cp.scan_interval = htole16(4); cp.scan_window = htole16(4); /* Don't use the whitelist */ cp.filter_policy = 0x00; /* Default to public peer address */ cp.peer_addr_type = 0x00; /* Own address type public */ cp.own_address_type = 0x00; /* 18.75ms min connection interval */ cp.conn_interval_min = htole16(0x000F); /* 18.75ms max connection interval */ cp.conn_interval_max = htole16(0x000F); /* 0 events connection latency */ cp.conn_latency = htole16(0x0000); /* 32s supervision timeout */ cp.supervision_timeout = htole16(0x0C80); /* Min CE Length 0.625 ms */ cp.min_ce_length = htole16(1); /* Max CE Length 0.625 ms */ cp.max_ce_length = htole16(1); while ((ch = getopt(argc, argv , "a:t:v")) != -1) { switch(ch) { case 't': if (strcmp(optarg, "public") == 0) cp.peer_addr_type = 0x00; else if (strcmp(optarg, "random") == 0) cp.peer_addr_type = 0x01; else return (USAGE); break; case 'a': addr_set = true; if (!bt_aton(optarg, &cp.peer_addr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) return (USAGE); memcpy(&cp.peer_addr, he->h_addr, sizeof(cp.peer_addr)); } break; case 'v': verbose = true; break; } } if (addr_set == false) return (USAGE); n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_CREATE_CONNECTION), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Create connection failed. Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } scancount = 0; while (scancount < 3) { /* wait for connection events */ bufsize = sizeof(b); if (hci_recv(s, b, &bufsize) == ERROR) { return (ERROR); } if (bufsize < sizeof(*e)) { errno = EIO; return (ERROR); } scancount++; if (e->event == NG_HCI_EVENT_LE) { handle_le_connection_event(e, verbose); break; } } return (OK); } static void handle_le_connection_event(ng_hci_event_pkt_t* e, bool verbose) { ng_hci_le_ep *ev_pkt; ng_hci_le_connection_complete_ep *conn_event; ev_pkt = (ng_hci_le_ep *)(e + 1); if (ev_pkt->subevent_code == NG_HCI_LEEV_CON_COMPL) { conn_event =(ng_hci_le_connection_complete_ep *)(ev_pkt + 1); fprintf(stdout, "Handle: %d\n", le16toh(conn_event->handle)); if (verbose) { fprintf(stdout, "Status: %s\n", hci_status2str(conn_event->status)); fprintf(stdout, "Role: %s\n", hci_role2str(conn_event->role)); fprintf(stdout, "Address Type: %s\n", hci_addrtype2str(conn_event->address_type)); fprintf(stdout, "Address: %s\n", hci_bdaddr2str(&conn_event->address)); fprintf(stdout, "Interval: %.2fms\n", 6.25 * le16toh(conn_event->interval)); fprintf(stdout, "Latency: %d events\n", conn_event->latency); fprintf(stdout, "Supervision timeout: %dms\n", 10 * le16toh(conn_event->supervision_timeout)); fprintf(stdout, "Master clock accuracy: %s\n", hci_mc_accuracy2str( conn_event->master_clock_accuracy)); } } } static int le_read_channel_map(int s, int argc, char *argv[]) { ng_hci_le_read_channel_map_cp cp; ng_hci_le_read_channel_map_rp rp; int n; char buffer[2048]; /* parse command parameters */ switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.connection_handle = (uint16_t) (n & 0x0fff); cp.connection_handle = htole16(cp.connection_handle); break; default: return (USAGE); } n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_CHANNEL_MAP), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Read channel map failed. Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.connection_handle)); fprintf(stdout, "Used channels:\n"); fprintf(stdout, "\n%s\n", hci_le_chanmap2str(rp.le_channel_map, buffer, sizeof(buffer))); return (OK); } /* le_read_channel_map */ static int le_read_remote_features(int s, int argc, char *argv[]) { ng_hci_le_read_remote_used_features_cp cp; ng_hci_status_rp rp; int n, bufsize; char b[512]; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* parse command parameters */ switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.connection_handle = (uint16_t) (n & 0x0fff); cp.connection_handle = htole16(cp.connection_handle); break; default: return (USAGE); } n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_READ_REMOTE_USED_FEATURES), (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Read remote features failed. Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } /* wait for connection events */ bufsize = sizeof(b); if (hci_recv(s, b, &bufsize) == ERROR) { return (ERROR); } if (bufsize < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_LE) { handle_le_remote_features_event(e); } return (OK); } /* le_read_remote_features */ static void handle_le_remote_features_event(ng_hci_event_pkt_t* e) { ng_hci_le_ep *ev_pkt; ng_hci_le_read_remote_features_ep *feat_event; char buffer[2048]; ev_pkt = (ng_hci_le_ep *)(e + 1); if (ev_pkt->subevent_code == NG_HCI_LEEV_READ_REMOTE_FEATURES_COMPL) { feat_event =(ng_hci_le_read_remote_features_ep *)(ev_pkt + 1); fprintf(stdout, "Handle: %d\n", le16toh(feat_event->connection_handle)); fprintf(stdout, "Status: %s\n", hci_status2str(feat_event->status)); fprintf(stdout, "Features:\n%s\n", hci_le_features2str(feat_event->features, buffer, sizeof(buffer))); } } /* handle_le_remote_features_event */ static int le_rand(int s, int argc, char *argv[]) { ng_hci_le_rand_rp rp; int n; n = sizeof(rp); if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, NG_HCI_OCF_LE_RAND), (void *)&rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Random number : %08llx\n", (unsigned long long)le64toh(rp.random_number)); return (OK); } struct hci_command le_commands[] = { { "le_enable", "le_enable [enable|disable] \n" "Enable LE event ", &le_enable, }, { "le_read_local_supported_features", "le_read_local_supported_features\n" "read local supported features mask", &le_read_local_supported_features, }, { "le_read_supported_states", "le_read_supported_states\n" "read supported status" , &le_read_supported_states, }, { "le_set_scan_response", "le_set_scan_response -n $name -f $flag -u $uuid16,$uuid16 \n" "set LE scan response data" , &le_set_scan_response, }, { "le_set_scan_enable", "le_set_scan_enable [enable|disable] \n" "enable or disable LE device scan", &le_set_scan_enable }, { "le_set_scan_param", "le_set_scan_param [active|passive] interval(ms) window(ms) [public|random] [all|whitelist] \n" "set LE device scan parameter", &le_set_scan_param }, { "le_set_advertising_enable", "le_set_advertising_enable [enable|disable] \n" "start or stop advertising", &le_set_advertising_enable }, { "le_read_advertising_channel_tx_power", "le_read_advertising_channel_tx_power\n" "read host advertising transmit poser level (dBm)", &le_read_advertising_channel_tx_power }, { "le_set_advertising_param", "le_set_advertising_param [-m min_interval(ms)] [-M max_interval(ms)]\n" "[-t advertising_type] [-o own_address_type] [-p peer_address_type]\n" "[-c advertising_channel_map] [-f advertising_filter_policy]\n" "[-a peer_address]\n" "set LE device advertising parameters", &le_set_advertising_param }, { "le_set_advertising_data", "le_set_advertising_data -n $name -f $flag -u $uuid16,$uuid16 \n" "set LE device advertising packed data", &le_set_advertising_data }, { "le_read_buffer_size", "le_read_buffer_size [-v 1|2]\n" "Read the maximum size of ACL and ISO data packets", &le_read_buffer_size }, { "le_scan", "le_scan [-a] [-v] [-n number_of_scans]\n" "Do an LE scan", &le_scan }, { "le_read_white_list_size", "le_read_white_list_size\n" "Read total number of white list entries that can be stored", &le_read_white_list_size }, { "le_clear_white_list", "le_clear_white_list\n" "Clear the white list in the controller", &le_clear_white_list }, { "le_add_device_to_white_list", "le_add_device_to_white_list\n" "[-t public|random] -a address\n" "Add device to the white list", &le_add_device_to_white_list }, { "le_remove_device_from_white_list", "le_remove_device_from_white_list\n" "[-t public|random] -a address\n" "Remove device from the white list", &le_remove_device_from_white_list }, { "le_connect", "le_connect -a address [-t public|random] [-v]\n" "Connect to an LE device", &le_connect }, { "le_read_channel_map", "le_read_channel_map \n" "Read the channel map for a connection", &le_read_channel_map }, { "le_read_remote_features", "le_read_remote_features \n" "Read supported features for the device\n" "identified by the connection handle", &le_read_remote_features }, { "le_rand", "le_rand\n" "Generate 64 bits of random data", &le_rand }, { NULL, } }; diff --git a/usr.sbin/bluetooth/hccontrol/link_control.c b/usr.sbin/bluetooth/hccontrol/link_control.c index db84a58a4371..b43515aa0d5b 100644 --- a/usr.sbin/bluetooth/hccontrol/link_control.c +++ b/usr.sbin/bluetooth/hccontrol/link_control.c @@ -1,963 +1,962 @@ /*- * link_control.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: link_control.c,v 1.4 2003/08/18 19:19:54 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "hccontrol.h" static void hci_inquiry_response (int n, uint8_t **b); /* Send Inquiry command to the unit */ static int hci_inquiry(int s, int argc, char **argv) { int n0, n1, n2, timo; char b[512]; ng_hci_inquiry_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* set defaults */ cp.lap[2] = 0x9e; cp.lap[1] = 0x8b; cp.lap[0] = 0x33; cp.inquiry_length = 5; cp.num_responses = 8; /* parse command parameters */ switch (argc) { case 3: /* number of responses, range 0x00 - 0xff */ if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0 || n0 > 0xff) return (USAGE); cp.num_responses = (n0 & 0xff); case 2: /* inquiry length (N * 1.28) sec, range 0x01 - 0x30 */ if (sscanf(argv[1], "%d", &n0) != 1 || n0 < 0x1 || n0 > 0x30) return (USAGE); cp.inquiry_length = (n0 & 0xff); case 1: /* LAP */ if (sscanf(argv[0], "%x:%x:%x", &n2, &n1, &n0) != 3) return (USAGE); cp.lap[0] = (n0 & 0xff); cp.lap[1] = (n1 & 0xff); cp.lap[2] = (n2 & 0xff); case 0: /* use defaults */ break; default: return (USAGE); } /* send request and expect status back */ n0 = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_INQUIRY), (char const *) &cp, sizeof(cp), b, &n0) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); timo = timeout; timeout = cp.inquiry_length * 1.28 + 1; wait_for_more: /* wait for inquiry events */ n0 = sizeof(b); if (hci_recv(s, b, &n0) == ERROR) { timeout = timo; return (ERROR); } if (n0 < sizeof(*e)) { timeout = timo; errno = EIO; return (ERROR); } switch (e->event) { case NG_HCI_EVENT_INQUIRY_RESULT: { ng_hci_inquiry_result_ep *ir = (ng_hci_inquiry_result_ep *)(e + 1); uint8_t *r = (uint8_t *)(ir + 1); fprintf(stdout, "Inquiry result, num_responses=%d\n", ir->num_responses); for (n0 = 0; n0 < ir->num_responses; n0++) hci_inquiry_response(n0, &r); goto wait_for_more; } case NG_HCI_EVENT_INQUIRY_COMPL: fprintf(stdout, "Inquiry complete. Status: %s [%#02x]\n", hci_status2str(*(b + sizeof(*e))), *(b + sizeof(*e))); break; default: goto wait_for_more; } timeout = timo; return (OK); } /* hci_inquiry */ /* Print Inquiry_Result event */ static void hci_inquiry_response(int n, uint8_t **b) { ng_hci_inquiry_response *ir = (ng_hci_inquiry_response *)(*b); fprintf(stdout, "Inquiry result #%d\n", n); fprintf(stdout, "\tBD_ADDR: %s\n", hci_bdaddr2str(&ir->bdaddr)); fprintf(stdout, "\tPage Scan Rep. Mode: %#02x\n", ir->page_scan_rep_mode); fprintf(stdout, "\tPage Scan Period Mode: %#02x\n", ir->page_scan_period_mode); fprintf(stdout, "\tPage Scan Mode: %#02x\n", ir->page_scan_mode); fprintf(stdout, "\tClass: %02x:%02x:%02x\n", ir->uclass[2], ir->uclass[1], ir->uclass[0]); fprintf(stdout, "\tClock offset: %#04x\n", le16toh(ir->clock_offset)); *b += sizeof(*ir); } /* hci_inquiry_response */ /* Send Create_Connection command to the unit */ static int hci_create_connection(int s, int argc, char **argv) { int n0; char b[512]; ng_hci_create_con_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* Set defaults */ memset(&cp, 0, sizeof(cp)); cp.pkt_type = htole16( NG_HCI_PKT_DM1 | NG_HCI_PKT_DH1 | NG_HCI_PKT_DM3 | NG_HCI_PKT_DH3 | NG_HCI_PKT_DM5); cp.page_scan_rep_mode = NG_HCI_SCAN_REP_MODE0; cp.page_scan_mode = NG_HCI_MANDATORY_PAGE_SCAN_MODE; cp.clock_offset = 0; cp.accept_role_switch = 1; /* parse command parameters */ switch (argc) { case 6: /* accept role switch */ if (sscanf(argv[5], "%d", &n0) != 1) return (USAGE); cp.accept_role_switch = n0 ? 1 : 0; case 5: /* clock offset */ if (sscanf(argv[4], "%d", &n0) != 1) return (USAGE); cp.clock_offset = (n0 & 0xffff); cp.clock_offset = htole16(cp.clock_offset); case 4: /* page scan mode */ if (sscanf(argv[3], "%d", &n0) != 1 || n0 < 0 || n0 > 3) return (USAGE); cp.page_scan_mode = (n0 & 0xff); case 3: /* page scan rep mode */ if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0 || n0 > 2) return (USAGE); cp.page_scan_rep_mode = (n0 & 0xff); case 2: /* packet type */ if (sscanf(argv[1], "%x", &n0) != 1) return (USAGE); n0 &= ( NG_HCI_PKT_DM1 | NG_HCI_PKT_DH1 | NG_HCI_PKT_DM3 | NG_HCI_PKT_DH3 | NG_HCI_PKT_DM5); if (n0 == 0) return (USAGE); cp.pkt_type = (n0 & 0xffff); cp.pkt_type = htole16(cp.pkt_type); case 1: /* BD_ADDR */ if (!bt_aton(argv[0], &cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); } break; default: return (USAGE); } /* send request and expect status response */ n0 = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_CREATE_CON), (char const *) &cp, sizeof(cp), b, &n0) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n0 = sizeof(b); if (hci_recv(s, b, &n0) == ERROR) return (ERROR); if (n0 < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_CON_COMPL) { ng_hci_con_compl_ep *ep = (ng_hci_con_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Encryption mode: %s [%d]\n", hci_encrypt2str(ep->encryption_mode, 0), ep->encryption_mode); } else goto again; return (OK); } /* hci_create_connection */ /* Send Disconnect command to the unit */ static int hci_disconnect(int s, int argc, char **argv) { int n; char b[512]; ng_hci_discon_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* Set defaults */ memset(&cp, 0, sizeof(cp)); cp.reason = 0x13; /* parse command parameters */ switch (argc) { case 2: /* reason */ if (sscanf(argv[1], "%d", &n) != 1 || n <= 0x00 || n > 0xff) return (USAGE); cp.reason = (uint8_t) (n & 0xff); case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_DISCON), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_DISCON_COMPL) { ng_hci_discon_compl_ep *ep = (ng_hci_discon_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Reason: %s [%#02x]\n", hci_status2str(ep->reason), ep->reason); } else goto again; return (OK); } /* hci_disconnect */ /* Send Add_SCO_Connection command to the unit */ static int hci_add_sco_connection(int s, int argc, char **argv) { int n; char b[512]; ng_hci_add_sco_con_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* Set defaults */ memset(&cp, 0, sizeof(cp)); cp.pkt_type = htole16(NG_HCI_PKT_HV1 | NG_HCI_PKT_HV2 | NG_HCI_PKT_HV3); /* parse command parameters */ switch (argc) { case 2: /* packet type */ if (sscanf(argv[1], "%x", &n) != 1) return (USAGE); n &= (NG_HCI_PKT_HV1 | NG_HCI_PKT_HV2 | NG_HCI_PKT_HV3); if (n == 0) return (USAGE); cp.pkt_type = (uint16_t) (n & 0x0fff); cp.pkt_type = htole16(cp.pkt_type); case 1: /* acl connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_ADD_SCO_CON), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_CON_COMPL) { ng_hci_con_compl_ep *ep = (ng_hci_con_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Encryption mode: %s [%d]\n", hci_encrypt2str(ep->encryption_mode, 0), ep->encryption_mode); } else goto again; return (OK); } /* Add_SCO_Connection */ /* Send Change_Connection_Packet_Type command to the unit */ static int hci_change_connection_packet_type(int s, int argc, char **argv) { int n; char b[512]; ng_hci_change_con_pkt_type_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; switch (argc) { case 2: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); /* packet type */ if (sscanf(argv[1], "%x", &n) != 1) return (USAGE); cp.pkt_type = (uint16_t) (n & 0xffff); cp.pkt_type = htole16(cp.pkt_type); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_CHANGE_CON_PKT_TYPE), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_CON_PKT_TYPE_CHANGED) { ng_hci_con_pkt_type_changed_ep *ep = (ng_hci_con_pkt_type_changed_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Packet type: %#04x\n", le16toh(ep->pkt_type)); } else goto again; return (OK); } /* hci_change_connection_packet_type */ /* Send Remote_Name_Request command to the unit */ static int hci_remote_name_request(int s, int argc, char **argv) { int n0; char b[512]; ng_hci_remote_name_req_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; memset(&cp, 0, sizeof(cp)); cp.page_scan_rep_mode = NG_HCI_SCAN_REP_MODE0; cp.page_scan_mode = NG_HCI_MANDATORY_PAGE_SCAN_MODE; /* parse command parameters */ switch (argc) { case 4: /* clock_offset */ if (sscanf(argv[3], "%x", &n0) != 1) return (USAGE); cp.clock_offset = (n0 & 0xffff); cp.clock_offset = htole16(cp.clock_offset); case 3: /* page_scan_mode */ if (sscanf(argv[2], "%d", &n0) != 1 || n0 < 0x00 || n0 > 0x03) return (USAGE); cp.page_scan_mode = (n0 & 0xff); case 2: /* page_scan_rep_mode */ if (sscanf(argv[1], "%d", &n0) != 1 || n0 < 0x00 || n0 > 0x02) return (USAGE); cp.page_scan_rep_mode = (n0 & 0xff); case 1: /* BD_ADDR */ if (!bt_aton(argv[0], &cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); } break; default: return (USAGE); } /* send request and expect status response */ n0 = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_REMOTE_NAME_REQ), (char const *) &cp, sizeof(cp), b, &n0) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n0 = sizeof(b); if (hci_recv(s, b, &n0) == ERROR) return (ERROR); if (n0 < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL) { ng_hci_remote_name_req_compl_ep *ep = (ng_hci_remote_name_req_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); fprintf(stdout, "Name: %s\n", ep->name); } else goto again; return (OK); } /* hci_remote_name_request */ /* Send Read_Remote_Supported_Features command to the unit */ static int hci_read_remote_supported_features(int s, int argc, char **argv) { int n; char b[512]; ng_hci_read_remote_features_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; char buffer[2048]; /* parse command parameters */ switch (argc) { case 1: /* connecton handle */ if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) return (USAGE); cp.con_handle = (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_READ_REMOTE_FEATURES), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_READ_REMOTE_FEATURES_COMPL) { ng_hci_read_remote_features_compl_ep *ep = (ng_hci_read_remote_features_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Features: "); for (n = 0; n < sizeof(ep->features); n++) fprintf(stdout, "%#02x ", ep->features[n]); fprintf(stdout, "\n%s\n", hci_features2str(ep->features, buffer, sizeof(buffer))); } else goto again; return (OK); } /* hci_read_remote_supported_features */ /* Send Read_Remote_Version_Information command to the unit */ static int hci_read_remote_version_information(int s, int argc, char **argv) { int n; char b[512]; ng_hci_read_remote_ver_info_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* parse command parameters */ switch (argc) { case 1: /* connecton handle */ if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) return (USAGE); cp.con_handle = (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_READ_REMOTE_VER_INFO), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL) { ng_hci_read_remote_ver_info_compl_ep *ep = (ng_hci_read_remote_ver_info_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } ep->manufacturer = le16toh(ep->manufacturer); fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "LMP version: %s [%#02x]\n", hci_lmpver2str(ep->lmp_version), ep->lmp_version); fprintf(stdout, "LMP sub-version: %#04x\n", le16toh(ep->lmp_subversion)); fprintf(stdout, "Manufacturer: %s [%#04x]\n", hci_manufacturer2str(ep->manufacturer), ep->manufacturer); } else goto again; return (OK); } /* hci_read_remote_version_information */ /* Send Read_Clock_Offset command to the unit */ static int hci_read_clock_offset(int s, int argc, char **argv) { int n; char b[512]; ng_hci_read_clock_offset_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* parse command parameters */ switch (argc) { case 1: /* connecton handle */ if (sscanf(argv[0], "%d", &n) != 1 || n < 0 || n > 0x0eff) return (USAGE); cp.con_handle = (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request and expect status response */ n = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_READ_CLOCK_OFFSET), (char const *) &cp, sizeof(cp), b, &n) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n = sizeof(b); if (hci_recv(s, b, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_READ_CLOCK_OFFSET_COMPL) { ng_hci_read_clock_offset_compl_ep *ep = (ng_hci_read_clock_offset_compl_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(ep->con_handle)); fprintf(stdout, "Clock offset: %#04x\n", le16toh(ep->clock_offset)); } else goto again; return (OK); } /* hci_read_clock_offset */ struct hci_command link_control_commands[] = { { "inquiry ", "\nThis command will cause the Bluetooth unit to enter Inquiry Mode.\n" \ "Inquiry Mode is used to discover other nearby Bluetooth units. The LAP\n" \ "input parameter contains the LAP from which the inquiry access code shall\n" \ "be derived when the inquiry procedure is made. The Inquiry_Length parameter\n"\ "specifies the total duration of the Inquiry Mode and, when this time\n" \ "expires, Inquiry will be halted. The Num_Responses parameter specifies the\n" \ "number of responses that can be received before the Inquiry is halted.\n\n" \ "\t - xx:xx:xx; 9e:8b:33 (GIAC), 93:8b:00 (LDIAC)\n" \ "\t - dd; total length == dd * 1.28 sec\n" \ "\t - dd", &hci_inquiry }, { "create_connection ", "" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name\n\n" \ "\t - xxxx; packet type\n" \ "" \ "\t\tACL packets\n" \ "\t\t-----------\n" \ "\t\t0x0008 DM1\n" \ "\t\t0x0010 DH1\n" \ "\t\t0x0400 DM3\n" \ "\t\t0x0800 DH3\n" \ "\t\t0x4000 DM5\n" \ "\t\t0x8000 DH5\n\n" \ "" \ "\trep_mode - d; page scan repetition mode\n" \ "" \ "\t\tPage scan repetition modes\n" \ "\t\t--------------------------\n" \ "\t\t0 Page scan repetition mode 0\n" \ "\t\t1 Page scan repetition mode 1\n" \ "\t\t2 Page scan repetition mode 2\n" \ "\n" \ "\tps_mode - d; Page scan mode\n" \ "" \ "\t\tPage scan modes\n" \ "\t\t---------------\n" \ "\t\t0 Mandatory page scan mode\n" \ "\t\t1 Optional page scan mode1\n" \ "\t\t2 Optional page scan mode2\n" \ "\t\t3 Optional page scan mode3\n" \ "\n" \ "\tclck_off - dddd; clock offset. Use 0 if unknown\n\n" \ "\trole_sw - d; allow (1) or deny role switch\n", &hci_create_connection }, { "disconnect ", "\nThe Disconnection command is used to terminate an existing connection.\n" \ "The connection handle command parameter indicates which connection is to\n" \ "be disconnected. The Reason command parameter indicates the reason for\n" \ "ending the connection.\n\n" \ "\t - dddd; connection handle\n" \ "\t - dd; reason; usually 19 (0x13) - user ended;\n" \ "\t also 0x05, 0x13-0x15, 0x1A, 0x29", &hci_disconnect }, { "add_sco_connection ", "This command will cause the link manager to create a SCO connection using\n" \ "the ACL connection specified by the connection handle command parameter.\n" \ "The Link Manager will determine how the new connection is established. This\n"\ "connection is determined by the current state of the device, its piconet,\n" \ "and the state of the device to be connected. The packet type command parameter\n" \ "specifies which packet types the Link Manager should use for the connection.\n"\ "The Link Manager must only use the packet type(s) specified by the packet\n" \ "type command parameter for sending HCI SCO data packets. Multiple packet\n" \ "types may be specified for the packet type command parameter by performing\n" \ "a bitwise OR operation of the different packet types. Note: An SCO connection\n" \ "can only be created when an ACL connection already exists and when it is\n" \ "not put in park mode.\n\n" \ "\t - dddd; ACL connection handle\n" \ "\t - xxxx; packet type\n" \ "" \ "\t\tSCO packets\n" \ "\t\t-----------\n" \ "\t\t0x0020 HV1\n" \ "\t\t0x0040 HV2\n" \ "\t\t0x0080 HV3\n", &hci_add_sco_connection }, { "change_connection_packet_type ", "The Change_Connection_Packet_Type command is used to change which packet\n" \ "types can be used for a connection that is currently established. This\n" \ "allows current connections to be dynamically modified to support different\n" \ "types of user data. The Packet_Type command parameter specifies which\n" \ "packet types the Link Manager can use for the connection. Multiple packet\n" \ "types may be specified for the Packet_Type command parameter by bitwise OR\n" \ "operation of the different packet types.\n\n" \ "\t - dddd; connection handle\n" \ "\t - xxxx; packet type mask\n" \ "" \ "\t\tACL packets\n" \ "\t\t-----------\n" \ "\t\t0x0008 DM1\n" \ "\t\t0x0010 DH1\n" \ "\t\t0x0400 DM3\n" \ "\t\t0x0800 DH3\n" \ "\t\t0x4000 DM5\n" \ "\t\t0x8000 DH5\n\n" \ "" \ "\t\tSCO packets\n" \ "\t\t-----------\n" \ "\t\t0x0020 HV1\n" \ "\t\t0x0040 HV2\n" \ "\t\t0x0080 HV3\n" \ "", &hci_change_connection_packet_type }, { "remote_name_request ", "\nThe Remote_Name_Request command is used to obtain the user-friendly\n" \ "name of another Bluetooth unit.\n\n" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name\n" \ "\t - dd; page scan repetition mode [0-2]\n" \ "\t - dd; page scan mode [0-3]\n" \ "\t - xxxx; clock offset [0 - 0xffff]", &hci_remote_name_request }, { "read_remote_supported_features ", "\nThis command requests a list of the supported features for the remote\n" \ "unit identified by the connection handle parameter. The connection handle\n" \ "must be a connection handle for an ACL connection.\n\n" \ "\t - dddd; connection handle", &hci_read_remote_supported_features }, { "read_remote_version_information ", "\nThis command will obtain the values for the version information for the\n" \ "remote Bluetooth unit identified by the connection handle parameter. The\n" \ "connection handle must be a connection handle for an ACL connection.\n\n" \ "\t - dddd; connection handle", &hci_read_remote_version_information }, { "read_clock_offset ", "\nThis command allows the Host to read the clock offset from the remote unit.\n" \ "\t - dddd; connection handle", &hci_read_clock_offset }, { NULL, }}; diff --git a/usr.sbin/bluetooth/hccontrol/link_policy.c b/usr.sbin/bluetooth/hccontrol/link_policy.c index b8a809d14a9f..b99ef2196eb8 100644 --- a/usr.sbin/bluetooth/hccontrol/link_policy.c +++ b/usr.sbin/bluetooth/hccontrol/link_policy.c @@ -1,308 +1,307 @@ /*- * link_policy.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: link_policy.c,v 1.3 2003/08/18 19:19:54 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "hccontrol.h" /* Send Role Discovery to the unit */ static int hci_role_discovery(int s, int argc, char **argv) { ng_hci_role_discovery_cp cp; ng_hci_role_discovery_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_POLICY, NG_HCI_OCF_ROLE_DISCOVERY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "Role: %s [%#x]\n", (rp.role == NG_HCI_ROLE_MASTER)? "Master" : "Slave", rp.role); return (OK); } /* hci_role_discovery */ /* Send Switch Role to the unit */ static int hci_switch_role(int s, int argc, char **argv) { int n0; char b[512]; ng_hci_switch_role_cp cp; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) b; /* parse command parameters */ switch (argc) { case 2: /* bdaddr */ if (!bt_aton(argv[0], &cp.bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(argv[0])) == NULL) return (USAGE); memcpy(&cp.bdaddr, he->h_addr, sizeof(cp.bdaddr)); } /* role */ if (sscanf(argv[1], "%d", &n0) != 1) return (USAGE); cp.role = n0? NG_HCI_ROLE_SLAVE : NG_HCI_ROLE_MASTER; break; default: return (USAGE); } /* send request and expect status response */ n0 = sizeof(b); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_POLICY, NG_HCI_OCF_SWITCH_ROLE), (char const *) &cp, sizeof(cp), b, &n0) == ERROR) return (ERROR); if (*b != 0x00) return (FAILED); /* wait for event */ again: n0 = sizeof(b); if (hci_recv(s, b, &n0) == ERROR) return (ERROR); if (n0 < sizeof(*e)) { errno = EIO; return (ERROR); } if (e->event == NG_HCI_EVENT_ROLE_CHANGE) { ng_hci_role_change_ep *ep = (ng_hci_role_change_ep *)(e + 1); if (ep->status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(ep->status), ep->status); return (FAILED); } fprintf(stdout, "BD_ADDR: %s\n", hci_bdaddr2str(&ep->bdaddr)); fprintf(stdout, "Role: %s [%#x]\n", (ep->role == NG_HCI_ROLE_MASTER)? "Master" : "Slave", ep->role); } else goto again; return (OK); } /* hci_switch_role */ /* Send Read_Link_Policy_Settings command to the unit */ static int hci_read_link_policy_settings(int s, int argc, char **argv) { ng_hci_read_link_policy_settings_cp cp; ng_hci_read_link_policy_settings_rp rp; int n; /* parse command parameters */ switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send request */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_POLICY, NG_HCI_OCF_READ_LINK_POLICY_SETTINGS), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "Link policy settings: %#x\n", le16toh(rp.settings)); return (OK); } /* hci_read_link_policy_settings */ /* Send Write_Link_Policy_Settings command to the unit */ static int hci_write_link_policy_settings(int s, int argc, char **argv) { ng_hci_write_link_policy_settings_cp cp; ng_hci_write_link_policy_settings_rp rp; int n; /* parse command parameters */ switch (argc) { case 2: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); /* link policy settings */ if (sscanf(argv[1], "%x", &n) != 1) return (USAGE); cp.settings = (uint16_t) (n & 0x0ffff); cp.settings = htole16(cp.settings); break; default: return (USAGE); } /* send request */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LINK_POLICY, NG_HCI_OCF_WRITE_LINK_POLICY_SETTINGS), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_write_link_policy_settings */ struct hci_command link_policy_commands[] = { { "role_discovery ", "\nThe Role_Discovery command is used for a Bluetooth device to determine\n" \ "which role the device is performing for a particular Connection Handle.\n" \ "The connection handle must be a connection handle for an ACL connection.\n\n" \ "\t - dddd; connection handle", &hci_role_discovery }, { "switch_role ", "\nThe Switch_Role command is used for a Bluetooth device to switch the\n" \ "current role the device is performing for a particular connection with\n" \ "another specified Bluetooth device. The BD_ADDR command parameter indicates\n"\ "for which connection the role switch is to be performed. The Role indicates\n"\ "the requested new role that the local device performs. Note: the BD_ADDR\n" \ "command parameter must specify a Bluetooth device for which a connection\n" "already exists.\n\n" \ "\t - xx:xx:xx:xx:xx:xx BD_ADDR or name\n" \ "\t - dd; role; 0 - Master, 1 - Slave", &hci_switch_role }, { "read_link_policy_settings ", "\nThis command will read the Link Policy setting for the specified connection\n"\ "handle. The link policy settings parameter determines the behavior of the\n" \ "local Link Manager when it receives a request from a remote device or it\n" \ "determines itself to change the master-slave role or to enter the hold,\n" \ "sniff, or park mode. The local Link Manager will automatically accept or\n" \ "reject such a request from the remote device, and may even autonomously\n" \ "request itself, depending on the value of the link policy settings parameter\n"\ "for the corresponding connection handle. The connection handle must be a\n" \ "connection handle for an ACL connection.\n\n" \ "\t - dddd; connection handle", &hci_read_link_policy_settings }, { "write_link_policy_settings ", "\nThis command will write the Link Policy setting for the specified connection\n"\ "handle. The link policy settings parameter determines the behavior of the\n" \ "local Link Manager when it receives a request from a remote device or it\n" \ "determines itself to change the master-slave role or to enter the hold,\n" \ "sniff, or park mode. The local Link Manager will automatically accept or\n" \ "reject such a request from the remote device, and may even autonomously\n" \ "request itself, depending on the value of the link policy settings parameter\n"\ "for the corresponding connection handle. The connection handle must be a\n" \ "connection handle for an ACL connection. Multiple Link Manager policies may\n"\ "be specified for the link policy settings parameter by performing a bitwise\n"\ "OR operation of the different activity types.\n\n" \ "\t - dddd; connection handle\n" \ "\t - xxxx; settings\n" \ "\t\t0x0000 - Disable All LM Modes (Default)\n" \ "\t\t0x0001 - Enable Master Slave Switch\n" \ "\t\t0x0002 - Enable Hold Mode\n" \ "\t\t0x0004 - Enable Sniff Mode\n" \ "\t\t0x0008 - Enable Park Mode\n", &hci_write_link_policy_settings }, { NULL, }}; diff --git a/usr.sbin/bluetooth/hccontrol/node.c b/usr.sbin/bluetooth/hccontrol/node.c index 8d8ee2059596..b100900f527d 100644 --- a/usr.sbin/bluetooth/hccontrol/node.c +++ b/usr.sbin/bluetooth/hccontrol/node.c @@ -1,620 +1,619 @@ /*- * node.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: node.c,v 1.6 2003/07/22 21:14:02 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include "hccontrol.h" /* Send Read_Node_State command to the node */ static int hci_read_node_state(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_state r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_STATE, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "State: %#x\n", r.state); return (OK); } /* hci_read_node_state */ /* Send Intitialize command to the node */ static int hci_node_initialize(int s, int argc, char **argv) { if (ioctl(s, SIOC_HCI_RAW_NODE_INIT) < 0) return (ERROR); return (OK); } /* hci_node_initialize */ /* Send Read_Debug_Level command to the node */ static int hci_read_debug_level(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_debug r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_DEBUG, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Debug level: %d\n", r.debug); return (OK); } /* hci_read_debug_level */ /* Send Write_Debug_Level command to the node */ static int hci_write_debug_level(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_debug r; memset(&r, 0, sizeof(r)); switch (argc) { case 1: r.debug = atoi(argv[0]); break; default: return (USAGE); } if (ioctl(s, SIOC_HCI_RAW_NODE_SET_DEBUG, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* hci_write_debug_level */ /* Send Read_Node_Buffer_Size command to the node */ static int hci_read_node_buffer_size(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_buffer r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_BUFFER, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Number of free command buffers: %d\n", r.buffer.cmd_free); fprintf(stdout, "Max. ACL packet size: %d\n", r.buffer.acl_size); fprintf(stdout, "Numbef of free ACL buffers: %d\n", r.buffer.acl_free); fprintf(stdout, "Total number of ACL buffers: %d\n", r.buffer.acl_pkts); fprintf(stdout, "Max. SCO packet size: %d\n", r.buffer.sco_size); fprintf(stdout, "Numbef of free SCO buffers: %d\n", r.buffer.sco_free); fprintf(stdout, "Total number of SCO buffers: %d\n", r.buffer.sco_pkts); return (OK); } /* hci_read_node_buffer_size */ /* Send Read_Node_BD_ADDR command to the node */ static int hci_read_node_bd_addr(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_bdaddr r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_BDADDR, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "BD_ADDR: %s\n", bt_ntoa(&r.bdaddr, NULL)); return (OK); } /* hci_read_node_bd_addr */ /* Send Read_Node_Features command to the node */ static int hci_read_node_features(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_features r; int n; char buffer[2048]; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_FEATURES, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Features: "); for (n = 0; n < sizeof(r.features)/sizeof(r.features[0]); n++) fprintf(stdout, "%#02x ", r.features[n]); fprintf(stdout, "\n%s\n", hci_features2str(r.features, buffer, sizeof(buffer))); return (OK); } /* hci_read_node_features */ /* Send Read_Node_Stat command to the node */ static int hci_read_node_stat(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_stat r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_STAT, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Commands sent: %d\n", r.stat.cmd_sent); fprintf(stdout, "Events received: %d\n", r.stat.evnt_recv); fprintf(stdout, "ACL packets received: %d\n", r.stat.acl_recv); fprintf(stdout, "ACL packets sent: %d\n", r.stat.acl_sent); fprintf(stdout, "SCO packets received: %d\n", r.stat.sco_recv); fprintf(stdout, "SCO packets sent: %d\n", r.stat.sco_sent); fprintf(stdout, "Bytes received: %d\n", r.stat.bytes_recv); fprintf(stdout, "Bytes sent: %d\n", r.stat.bytes_sent); return (OK); } /* hci_read_node_stat */ /* Send Reset_Node_Stat command to the node */ static int hci_reset_node_stat(int s, int argc, char **argv) { if (ioctl(s, SIOC_HCI_RAW_NODE_RESET_STAT) < 0) return (ERROR); return (OK); } /* hci_reset_node_stat */ /* Send Flush_Neighbor_Cache command to the node */ static int hci_flush_neighbor_cache(int s, int argc, char **argv) { if (ioctl(s, SIOC_HCI_RAW_NODE_FLUSH_NEIGHBOR_CACHE) < 0) return (ERROR); return (OK); } /* hci_flush_neighbor_cache */ /* Send Read_Neighbor_Cache command to the node */ static int hci_read_neighbor_cache(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_neighbor_cache r; int n, error = OK; const char *addrtype2str[] = {"B", "P", "R", "E"}; memset(&r, 0, sizeof(r)); r.num_entries = NG_HCI_MAX_NEIGHBOR_NUM; r.entries = calloc(NG_HCI_MAX_NEIGHBOR_NUM, sizeof(ng_hci_node_neighbor_cache_entry_ep)); if (r.entries == NULL) { errno = ENOMEM; return (ERROR); } if (ioctl(s, SIOC_HCI_RAW_NODE_GET_NEIGHBOR_CACHE, &r, sizeof(r)) < 0) { error = ERROR; goto out; } fprintf(stdout, "T " \ "BD_ADDR " \ "Features " \ "Clock offset " \ "Page scan " \ "Rep. scan\n"); for (n = 0; n < r.num_entries; n++) { uint8_t addrtype = r.entries[n].addrtype; if(addrtype >= sizeof(addrtype2str)/sizeof(addrtype2str[0])) addrtype = sizeof(addrtype2str)/sizeof(addrtype2str[0]) - 1; fprintf(stdout, "%1s %-17.17s " \ "%02x %02x %02x %02x %02x %02x %02x %02x " \ "%#12x " \ "%#9x " \ "%#9x\n", addrtype2str[addrtype], hci_bdaddr2str(&r.entries[n].bdaddr), r.entries[n].features[0], r.entries[n].features[1], r.entries[n].features[2], r.entries[n].features[3], r.entries[n].features[4], r.entries[n].features[5], r.entries[n].features[6], r.entries[n].features[7], r.entries[n].clock_offset, r.entries[n].page_scan_mode, r.entries[n].page_scan_rep_mode); print_adv_data(r.entries[n].extinq_size, r.entries[n].extinq_data); fprintf(stdout,"\n"); } out: free(r.entries); return (error); } /* hci_read_neightbor_cache */ /* Send Read_Connection_List command to the node */ static int hci_read_connection_list(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_con_list r; int n, error = OK; memset(&r, 0, sizeof(r)); r.num_connections = NG_HCI_MAX_CON_NUM; r.connections = calloc(NG_HCI_MAX_CON_NUM, sizeof(ng_hci_node_con_ep)); if (r.connections == NULL) { errno = ENOMEM; return (ERROR); } if (ioctl(s, SIOC_HCI_RAW_NODE_GET_CON_LIST, &r, sizeof(r)) < 0) { error = ERROR; goto out; } fprintf(stdout, "Remote BD_ADDR " \ "Handle " \ "Type " \ "Mode " \ "Role " \ "Encrypt " \ "Pending " \ "Queue " \ "State\n"); for (n = 0; n < r.num_connections; n++) { fprintf(stdout, "%-17.17s " \ "%6d " \ "%4.4s " \ "%4d " \ "%4.4s " \ "%7.7s " \ "%7d " \ "%5d " \ "%s\n", hci_bdaddr2str(&r.connections[n].bdaddr), r.connections[n].con_handle, (r.connections[n].link_type == NG_HCI_LINK_ACL)? "ACL" : "SCO", r.connections[n].mode, (r.connections[n].role == NG_HCI_ROLE_MASTER)? "MAST" : "SLAV", hci_encrypt2str(r.connections[n].encryption_mode, 1), r.connections[n].pending, r.connections[n].queue_len, hci_con_state2str(r.connections[n].state)); } out: free(r.connections); return (error); } /* hci_read_connection_list */ /* Send Read_Node_Link_Policy_Settings_Mask command to the node */ int hci_read_node_link_policy_settings_mask(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_link_policy_mask r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_LINK_POLICY_MASK, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Link Policy Settings mask: %#04x\n", r.policy_mask); return (OK); } /* hci_read_node_link_policy_settings_mask */ /* Send Write_Node_Link_Policy_Settings_Mask command to the node */ int hci_write_node_link_policy_settings_mask(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_link_policy_mask r; int m; memset(&r, 0, sizeof(r)); switch (argc) { case 1: if (sscanf(argv[0], "%x", &m) != 1) return (USAGE); r.policy_mask = (m & 0xffff); break; default: return (USAGE); } if (ioctl(s, SIOC_HCI_RAW_NODE_SET_LINK_POLICY_MASK, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* hci_write_node_link_policy_settings_mask */ /* Send Read_Node_Packet_Mask command to the node */ int hci_read_node_packet_mask(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_packet_mask r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_PACKET_MASK, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Packet mask: %#04x\n", r.packet_mask); return (OK); } /* hci_read_node_packet_mask */ /* Send Write_Node_Packet_Mask command to the node */ int hci_write_node_packet_mask(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_packet_mask r; int m; memset(&r, 0, sizeof(r)); switch (argc) { case 1: if (sscanf(argv[0], "%x", &m) != 1) return (USAGE); r.packet_mask = (m & 0xffff); break; default: return (USAGE); } if (ioctl(s, SIOC_HCI_RAW_NODE_SET_PACKET_MASK, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* hci_write_node_packet_mask */ /* Send Read_Node_Role_Switch command to the node */ int hci_read_node_role_switch(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_role_switch r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_HCI_RAW_NODE_GET_ROLE_SWITCH, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Role switch: %d\n", r.role_switch); return (OK); } /* hci_read_node_role_switch */ /* Send Write_Node_Role_Switch command to the node */ int hci_write_node_role_switch(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_role_switch r; int m; memset(&r, 0, sizeof(r)); switch (argc) { case 1: if (sscanf(argv[0], "%d", &m) != 1) return (USAGE); r.role_switch = m? 1 : 0; break; default: return (USAGE); } if (ioctl(s, SIOC_HCI_RAW_NODE_SET_ROLE_SWITCH, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* hci_write_node_role_switch */ /* Send Read_Node_List command to the node */ int hci_read_node_list(int s, int argc, char **argv) { struct ng_btsocket_hci_raw_node_list_names r; int i; r.num_names = MAX_NODE_NUM; r.names = (struct nodeinfo*)calloc(MAX_NODE_NUM, sizeof(struct nodeinfo)); if (r.names == NULL) return (ERROR); if (ioctl(s, SIOC_HCI_RAW_NODE_LIST_NAMES, &r, sizeof(r)) < 0) { free(r.names); return (ERROR); } fprintf(stdout, "Name ID Num hooks\n"); for (i = 0; i < r.num_names; ++i) fprintf(stdout, "%-15s %08x %9d\n", r.names[i].name, r.names[i].id, r.names[i].hooks); free(r.names); return (OK); } /* hci_read_node_list */ struct hci_command node_commands[] = { { "read_node_state", "Get the HCI node state", &hci_read_node_state }, { "initialize", "Initialize the HCI node", &hci_node_initialize }, { "read_debug_level", "Read the HCI node debug level", &hci_read_debug_level }, { "write_debug_level ", "Write the HCI node debug level", &hci_write_debug_level }, { "read_node_buffer_size", "Read the HCI node buffer information. This will return current state of the\n"\ "HCI buffer for the HCI node", &hci_read_node_buffer_size }, { "read_node_bd_addr", "Read the HCI node BD_ADDR. Returns device BD_ADDR as cached by the HCI node", &hci_read_node_bd_addr }, { "read_node_features", "Read the HCI node features. This will return list of supported features as\n" \ "cached by the HCI node", &hci_read_node_features }, { "read_node_stat", "Read packets and bytes counters for the HCI node", &hci_read_node_stat }, { "reset_node_stat", "Reset packets and bytes counters for the HCI node", &hci_reset_node_stat }, { "flush_neighbor_cache", "Flush content of the HCI node neighbor cache", &hci_flush_neighbor_cache }, { "read_neighbor_cache", "Read content of the HCI node neighbor cache", &hci_read_neighbor_cache }, { "read_connection_list", "Read the baseband connection descriptors list for the HCI node", &hci_read_connection_list }, { "read_node_link_policy_settings_mask", "Read the value of the Link Policy Settinngs mask for the HCI node", &hci_read_node_link_policy_settings_mask }, { "write_node_link_policy_settings_mask ", "Write the value of the Link Policy Settings mask for the HCI node. By default\n" \ "all supported Link Policy modes (as reported by the local device features) are\n"\ "enabled. The particular Link Policy mode is enabled if local device supports\n"\ "it and correspinding bit in the mask was set\n\n" \ "\t - xxxx; Link Policy mask\n" \ "\t\t0x0000 - Disable All LM Modes\n" \ "\t\t0x0001 - Enable Master Slave Switch\n" \ "\t\t0x0002 - Enable Hold Mode\n" \ "\t\t0x0004 - Enable Sniff Mode\n" \ "\t\t0x0008 - Enable Park Mode\n", &hci_write_node_link_policy_settings_mask }, { "read_node_packet_mask", "Read the value of the Packet mask for the HCI node", &hci_read_node_packet_mask }, { "write_node_packet_mask ", "Write the value of the Packet mask for the HCI node. By default all supported\n" \ "packet types (as reported by the local device features) are enabled. The\n" \ "particular packet type is enabled if local device supports it and corresponding\n" \ "bit in the mask was set\n\n" \ "\t - xxxx; packet type mask\n" \ "" \ "\t\tACL packets\n" \ "\t\t-----------\n" \ "\t\t0x0008 DM1\n" \ "\t\t0x0010 DH1\n" \ "\t\t0x0400 DM3\n" \ "\t\t0x0800 DH3\n" \ "\t\t0x4000 DM5\n" \ "\t\t0x8000 DH5\n" \ "\n" \ "\t\tSCO packets\n" \ "\t\t-----------\n" \ "\t\t0x0020 HV1\n" \ "\t\t0x0040 HV2\n" \ "\t\t0x0080 HV3\n", &hci_write_node_packet_mask }, { "read_node_role_switch", "Read the value of the Role Switch parameter for the HCI node", &hci_read_node_role_switch }, { "write_node_role_switch {0|1}", "Write the value of the Role Switch parameter for the HCI node. By default,\n" \ "if Role Switch is supported, local device will try to perform Role Switch\n" \ "and become Master on incoming connection. Some devices do not support Role\n" \ "Switch and thus incoming connections from such devices will fail. Setting\n" \ "this parameter to zero will prevent Role Switch and thus accepting device\n" \ "will remain Slave", &hci_write_node_role_switch }, { "read_node_list", "Get a list of HCI nodes, their Netgraph IDs and connected hooks.", &hci_read_node_list }, { NULL, }}; diff --git a/usr.sbin/bluetooth/hccontrol/send_recv.c b/usr.sbin/bluetooth/hccontrol/send_recv.c index 05ed1537ec31..4f9bb05aec48 100644 --- a/usr.sbin/bluetooth/hccontrol/send_recv.c +++ b/usr.sbin/bluetooth/hccontrol/send_recv.c @@ -1,186 +1,185 @@ /*- * send_recv.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: send_recv.c,v 1.2 2003/05/21 22:40:30 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include "hccontrol.h" /* Send HCI request to the unit */ int hci_request(int s, int opcode, char const *cp, int cp_size, char *rp, int *rp_size) { char buffer[512]; int n; ng_hci_cmd_pkt_t *c = (ng_hci_cmd_pkt_t *) buffer; ng_hci_event_pkt_t *e = (ng_hci_event_pkt_t *) buffer; assert(rp != NULL); assert(rp_size != NULL); assert(*rp_size > 0); c->type = NG_HCI_CMD_PKT; c->opcode = (uint16_t) opcode; c->opcode = htole16(c->opcode); if (cp != NULL) { assert(0 < cp_size && cp_size <= NG_HCI_CMD_PKT_SIZE); c->length = (uint8_t) cp_size; memcpy(buffer + sizeof(*c), cp, cp_size); } else c->length = 0; if (hci_send(s, buffer, sizeof(*c) + cp_size) == ERROR) return (ERROR); again: n = sizeof(buffer); if (hci_recv(s, buffer, &n) == ERROR) return (ERROR); if (n < sizeof(*e)) { errno = EMSGSIZE; return (ERROR); } if (e->type != NG_HCI_EVENT_PKT) { errno = EIO; return (ERROR); } switch (e->event) { case NG_HCI_EVENT_COMMAND_COMPL: { ng_hci_command_compl_ep *cc = (ng_hci_command_compl_ep *)(e + 1); cc->opcode = le16toh(cc->opcode); if (cc->opcode == 0x0000 || cc->opcode != opcode) goto again; n -= (sizeof(*e) + sizeof(*cc)); if (n < *rp_size) *rp_size = n; memcpy(rp, buffer + sizeof(*e) + sizeof(*cc), *rp_size); } break; case NG_HCI_EVENT_COMMAND_STATUS: { ng_hci_command_status_ep *cs = (ng_hci_command_status_ep *)(e + 1); cs->opcode = le16toh(cs->opcode); if (cs->opcode == 0x0000 || cs->opcode != opcode) goto again; *rp_size = 1; *rp = cs->status; } break; default: goto again; } return (OK); } /* hci_request */ /* Send simple HCI request - Just HCI command packet (no parameters) */ int hci_simple_request(int s, int opcode, char *rp, int *rp_size) { return (hci_request(s, opcode, NULL, 0, rp, rp_size)); } /* hci_simple_request */ /* Send HCI data to the unit */ int hci_send(int s, char const *buffer, int size) { assert(buffer != NULL); assert(size >= sizeof(ng_hci_cmd_pkt_t)); assert(size <= sizeof(ng_hci_cmd_pkt_t) + NG_HCI_CMD_PKT_SIZE); if (send(s, buffer, size, 0) < 0) return (ERROR); return (OK); } /* hci_send */ /* Receive HCI data from the unit */ int hci_recv(int s, char *buffer, int *size) { struct timeval tv; fd_set rfd; int n; assert(buffer != NULL); assert(size != NULL); assert(*size > sizeof(ng_hci_event_pkt_t)); again: FD_ZERO(&rfd); FD_SET(s, &rfd); tv.tv_sec = timeout; tv.tv_usec = 0; n = select(s + 1, &rfd, NULL, NULL, &tv); if (n <= 0) { if (n < 0) { if (errno == EINTR) goto again; } else errno = ETIMEDOUT; return (ERROR); } assert(FD_ISSET(s, &rfd)); n = recv(s, buffer, *size, 0); if (n < 0) return (ERROR); *size = n; return (OK); } /* hci_recv */ diff --git a/usr.sbin/bluetooth/hccontrol/status.c b/usr.sbin/bluetooth/hccontrol/status.c index 4e6ea48b58e3..9306c10fec85 100644 --- a/usr.sbin/bluetooth/hccontrol/status.c +++ b/usr.sbin/bluetooth/hccontrol/status.c @@ -1,247 +1,246 @@ /*- * status.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: status.c,v 1.2 2003/05/21 22:40:30 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include "hccontrol.h" /* Send Read_Failed_Contact_Counter command to the unit */ static int hci_read_failed_contact_counter(int s, int argc, char **argv) { ng_hci_read_failed_contact_cntr_cp cp; ng_hci_read_failed_contact_cntr_rp rp; int n; switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS, NG_HCI_OCF_READ_FAILED_CONTACT_CNTR), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "Failed contact counter: %d\n", le16toh(rp.counter)); return (OK); } /* hci_read_failed_contact_counter */ /* Send Reset_Failed_Contact_Counter command to the unit */ static int hci_reset_failed_contact_counter(int s, int argc, char **argv) { ng_hci_reset_failed_contact_cntr_cp cp; ng_hci_reset_failed_contact_cntr_rp rp; int n; switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS, NG_HCI_OCF_RESET_FAILED_CONTACT_CNTR), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } return (OK); } /* hci_reset_failed_contact_counter */ /* Sent Get_Link_Quality command to the unit */ static int hci_get_link_quality(int s, int argc, char **argv) { ng_hci_get_link_quality_cp cp; ng_hci_get_link_quality_rp rp; int n; switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS, NG_HCI_OCF_GET_LINK_QUALITY), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "Link quality: %d\n", le16toh(rp.quality)); return (OK); } /* hci_get_link_quality */ /* Send Read_RSSI command to the unit */ static int hci_read_rssi(int s, int argc, char **argv) { ng_hci_read_rssi_cp cp; ng_hci_read_rssi_rp rp; int n; switch (argc) { case 1: /* connection handle */ if (sscanf(argv[0], "%d", &n) != 1 || n <= 0 || n > 0x0eff) return (USAGE); cp.con_handle = (uint16_t) (n & 0x0fff); cp.con_handle = htole16(cp.con_handle); break; default: return (USAGE); } /* send command */ n = sizeof(rp); if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_STATUS, NG_HCI_OCF_READ_RSSI), (char const *) &cp, sizeof(cp), (char *) &rp, &n) == ERROR) return (ERROR); if (rp.status != 0x00) { fprintf(stdout, "Status: %s [%#02x]\n", hci_status2str(rp.status), rp.status); return (FAILED); } fprintf(stdout, "Connection handle: %d\n", le16toh(rp.con_handle)); fprintf(stdout, "RSSI: %d dB\n", (int) rp.rssi); return (OK); } /* hci_read_rssi */ struct hci_command status_commands[] = { { "read_failed_contact_counter ", "\nThis command will read the value for the Failed_Contact_Counter\n" \ "parameter for a particular ACL connection to another device.\n\n" \ "\t - dddd; ACL connection handle\n", &hci_read_failed_contact_counter }, { "reset_failed_contact_counter ", "\nThis command will reset the value for the Failed_Contact_Counter\n" \ "parameter for a particular ACL connection to another device.\n\n" \ "\t - dddd; ACL connection handle\n", &hci_reset_failed_contact_counter }, { "get_link_quality ", "\nThis command will return the value for the Link_Quality for the\n" \ "specified ACL connection handle. This command will return a Link_Quality\n" \ "value from 0-255, which represents the quality of the link between two\n" \ "Bluetooth devices. The higher the value, the better the link quality is.\n" \ "Each Bluetooth module vendor will determine how to measure the link quality." \ "\n\n" \ "\t - dddd; ACL connection handle\n", &hci_get_link_quality }, { "read_rssi ", "\nThis command will read the value for the difference between the\n" \ "measured Received Signal Strength Indication (RSSI) and the limits of\n" \ "the Golden Receive Power Range for a ACL connection handle to another\n" \ "Bluetooth device. Any positive RSSI value returned by the Host Controller\n" \ "indicates how many dB the RSSI is above the upper limit, any negative\n" \ "value indicates how many dB the RSSI is below the lower limit. The value\n" \ "zero indicates that the RSSI is inside the Golden Receive Power Range.\n\n" \ "\t - dddd; ACL connection handle\n", &hci_read_rssi }, { NULL, }}; diff --git a/usr.sbin/bluetooth/hccontrol/util.c b/usr.sbin/bluetooth/hccontrol/util.c index fd2f509bc387..029ced6e28fa 100644 --- a/usr.sbin/bluetooth/hccontrol/util.c +++ b/usr.sbin/bluetooth/hccontrol/util.c @@ -1,3367 +1,3366 @@ /*- * util.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: util.c,v 1.2 2003/05/19 17:29:29 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #define SIZE(x) (sizeof((x))/sizeof((x)[0])) char const * hci_link2str(int link_type) { static char const * const t[] = { /* NG_HCI_LINK_SCO */ "SCO", /* NG_HCI_LINK_ACL */ "ACL" }; return (link_type >= SIZE(t)? "?" : t[link_type]); } /* hci_link2str */ char const * hci_pin2str(int type) { static char const * const t[] = { /* 0x00 */ "Variable PIN", /* 0x01 */ "Fixed PIN" }; return (type >= SIZE(t)? "?" : t[type]); } /* hci_pin2str */ char const * hci_scan2str(int scan) { static char const * const t[] = { /* 0x00 */ "No Scan enabled", /* 0x01 */ "Inquiry Scan enabled. Page Scan disabled", /* 0x02 */ "Inquiry Scan disabled. Page Scan enabled", /* 0x03 */ "Inquiry Scan enabled. Page Scan enabled" }; return (scan >= SIZE(t)? "?" : t[scan]); } /* hci_scan2str */ char const * hci_encrypt2str(int encrypt, int brief) { static char const * const t[] = { /* 0x00 */ "Disabled", /* 0x01 */ "Only for point-to-point packets", /* 0x02 */ "Both point-to-point and broadcast packets" }; static char const * const t1[] = { /* NG_HCI_ENCRYPTION_MODE_NONE */ "NONE", /* NG_HCI_ENCRYPTION_MODE_P2P */ "P2P", /* NG_HCI_ENCRYPTION_MODE_ALL */ "ALL", }; if (brief) return (encrypt >= SIZE(t1)? "?" : t1[encrypt]); return (encrypt >= SIZE(t)? "?" : t[encrypt]); } /* hci_encrypt2str */ char const * hci_coding2str(int coding) { static char const * const t[] = { /* 0x00 */ "Linear", /* 0x01 */ "u-law", /* 0x02 */ "A-law", /* 0x03 */ "Reserved" }; return (coding >= SIZE(t)? "?" : t[coding]); } /* hci_coding2str */ char const * hci_vdata2str(int data) { static char const * const t[] = { /* 0x00 */ "1's complement", /* 0x01 */ "2's complement", /* 0x02 */ "Sign-Magnitude", /* 0x03 */ "Reserved" }; return (data >= SIZE(t)? "?" : t[data]); } /* hci_vdata2str */ char const * hci_hmode2str(int mode, char *buffer, int size) { static char const * const t[] = { /* 0x01 */ "Suspend Page Scan ", /* 0x02 */ "Suspend Inquiry Scan ", /* 0x04 */ "Suspend Periodic Inquiries " }; if (buffer != NULL && size > 0) { int n; memset(buffer, 0, size); size--; for (n = 0; n < SIZE(t); n++) { int len = strlen(buffer); if (len >= size) break; if (mode & (1 << n)) strncat(buffer, t[n], size - len); } } return (buffer); } /* hci_hmode2str */ char const * hci_ver2str(int ver) { static char const * const t[] = { /* 0x00 */ "Bluetooth HCI Specification 1.0B", /* 0x01 */ "Bluetooth HCI Specification 1.1", /* 0x02 */ "Bluetooth HCI Specification 1.2", /* 0x03 */ "Bluetooth HCI Specification 2.0", /* 0x04 */ "Bluetooth HCI Specification 2.1", /* 0x05 */ "Bluetooth HCI Specification 3.0", /* 0x06 */ "Bluetooth HCI Specification 4.0", /* 0x07 */ "Bluetooth HCI Specification 4.1", /* 0x08 */ "Bluetooth HCI Specification 4.2", /* 0x09 */ "Bluetooth HCI Specification 5.0", /* 0x0a */ "Bluetooth HCI Specification 5.1", /* 0x0b */ "Bluetooth HCI Specification 5.2" }; return (ver >= SIZE(t)? "?" : t[ver]); } /* hci_ver2str */ char const * hci_lmpver2str(int ver) { static char const * const t[] = { /* 0x00 */ "Bluetooth LMP 1.0", /* 0x01 */ "Bluetooth LMP 1.1", /* 0x02 */ "Bluetooth LMP 1.2", /* 0x03 */ "Bluetooth LMP 2.0", /* 0x04 */ "Bluetooth LMP 2.1", /* 0x05 */ "Bluetooth LMP 3.0", /* 0x06 */ "Bluetooth LMP 4.0", /* 0x07 */ "Bluetooth LMP 4.1", /* 0x08 */ "Bluetooth LMP 4.2", /* 0x09 */ "Bluetooth LMP 5.0", /* 0x0a */ "Bluetooth LMP 5.1", /* 0x0b */ "Bluetooth LMP 5.2" }; return (ver >= SIZE(t)? "?" : t[ver]); } /* hci_lmpver2str */ char const * hci_manufacturer2str(int m) { static char const * const t[] = { /* 0000 */ "Ericsson Technology Licensing", /* 0001 */ "Nokia Mobile Phones", /* 0002 */ "Intel Corp.", /* 0003 */ "IBM Corp.", /* 0004 */ "Toshiba Corp.", /* 0005 */ "3Com", /* 0006 */ "Microsoft", /* 0007 */ "Lucent", /* 0008 */ "Motorola", /* 0009 */ "Infineon Technologies AG", /* 0010 */ "Qualcomm Technologies International, Ltd. (QTIL)", /* 0011 */ "Silicon Wave", /* 0012 */ "Digianswer A/S", /* 0013 */ "Texas Instruments Inc.", /* 0014 */ "Parthus Technologies Inc.", /* 0015 */ "Broadcom Corporation", /* 0016 */ "Mitel Semiconductor", /* 0017 */ "Widcomm, Inc.", /* 0018 */ "Zeevo, Inc.", /* 0019 */ "Atmel Corporation", /* 0020 */ "Mitsubishi Electric Corporation", /* 0021 */ "RTX Telecom A/S", /* 0022 */ "KC Technology Inc.", /* 0023 */ "Newlogic", /* 0024 */ "Transilica, Inc.", /* 0025 */ "Rohde & Schwarz GmbH & Co. KG", /* 0026 */ "TTPCom Limited", /* 0027 */ "Signia Technologies, Inc.", /* 0028 */ "Conexant Systems Inc.", /* 0029 */ "Qualcomm", /* 0030 */ "Inventel", /* 0031 */ "AVM Berlin", /* 0032 */ "BandSpeed, Inc.", /* 0033 */ "Mansella Ltd", /* 0034 */ "NEC Corporation", /* 0035 */ "WavePlus Technology Co., Ltd.", /* 0036 */ "Alcatel", /* 0037 */ "NXP Semiconductors (formerly Philips Semiconductors)", /* 0038 */ "C Technologies", /* 0039 */ "Open Interface", /* 0040 */ "R F Micro Devices", /* 0041 */ "Hitachi Ltd", /* 0042 */ "Symbol Technologies, Inc.", /* 0043 */ "Tenovis", /* 0044 */ "Macronix International Co. Ltd.", /* 0045 */ "GCT Semiconductor", /* 0046 */ "Norwood Systems", /* 0047 */ "MewTel Technology Inc.", /* 0048 */ "ST Microelectronics", /* 0049 */ "Synopsys, Inc.", /* 0050 */ "Red-M (Communications) Ltd", /* 0051 */ "Commil Ltd", /* 0052 */ "Computer Access Technology Corporation (CATC)", /* 0053 */ "Eclipse (HQ Espana) S.L.", /* 0054 */ "Renesas Electronics Corporation", /* 0055 */ "Mobilian Corporation", /* 0056 */ "Syntronix Corporation", /* 0057 */ "Integrated System Solution Corp.", /* 0058 */ "Panasonic Corporation (formerly Matsushita Electric Industrial Co., Ltd.)", /* 0059 */ "Gennum Corporation", /* 0060 */ "BlackBerry Limited (formerly Research In Motion)", /* 0061 */ "IPextreme, Inc.", /* 0062 */ "Systems and Chips, Inc", /* 0063 */ "Bluetooth SIG, Inc", /* 0064 */ "Seiko Epson Corporation", /* 0065 */ "Integrated Silicon Solution Taiwan, Inc.", /* 0066 */ "CONWISE Technology Corporation Ltd", /* 0067 */ "PARROT AUTOMOTIVE SAS", /* 0068 */ "Socket Mobile", /* 0069 */ "Atheros Communications, Inc.", /* 0070 */ "MediaTek, Inc.", /* 0071 */ "Bluegiga", /* 0072 */ "Marvell Technology Group Ltd.", /* 0073 */ "3DSP Corporation", /* 0074 */ "Accel Semiconductor Ltd.", /* 0075 */ "Continental Automotive Systems", /* 0076 */ "Apple, Inc.", /* 0077 */ "Staccato Communications, Inc.", /* 0078 */ "Avago Technologies", /* 0079 */ "APT Ltd.", /* 0080 */ "SiRF Technology, Inc.", /* 0081 */ "Tzero Technologies, Inc.", /* 0082 */ "J&M Corporation", /* 0083 */ "Free2move AB", /* 0084 */ "3DiJoy Corporation", /* 0085 */ "Plantronics, Inc.", /* 0086 */ "Sony Ericsson Mobile Communications", /* 0087 */ "Harman International Industries, Inc.", /* 0088 */ "Vizio, Inc.", /* 0089 */ "Nordic Semiconductor ASA", /* 0090 */ "EM Microelectronic-Marin SA", /* 0091 */ "Ralink Technology Corporation", /* 0092 */ "Belkin International, Inc.", /* 0093 */ "Realtek Semiconductor Corporation", /* 0094 */ "Stonestreet One, LLC", /* 0095 */ "Wicentric, Inc.", /* 0096 */ "RivieraWaves S.A.S", /* 0097 */ "RDA Microelectronics", /* 0098 */ "Gibson Guitars", /* 0099 */ "MiCommand Inc.", /* 0100 */ "Band XI International, LLC", /* 0101 */ "Hewlett-Packard Company", /* 0102 */ "9Solutions Oy", /* 0103 */ "GN Netcom A/S", /* 0104 */ "General Motors", /* 0105 */ "A&D Engineering, Inc.", /* 0106 */ "MindTree Ltd.", /* 0107 */ "Polar Electro OY", /* 0108 */ "Beautiful Enterprise Co., Ltd.", /* 0109 */ "BriarTek, Inc", /* 0110 */ "Summit Data Communications, Inc.", /* 0111 */ "Sound ID", /* 0112 */ "Monster, LLC", /* 0113 */ "connectBlue AB", /* 0114 */ "ShangHai Super Smart Electronics Co. Ltd.", /* 0115 */ "Group Sense Ltd.", /* 0116 */ "Zomm, LLC", /* 0117 */ "Samsung Electronics Co. Ltd.", /* 0118 */ "Creative Technology Ltd.", /* 0119 */ "Laird Technologies", /* 0120 */ "Nike, Inc.", /* 0121 */ "lesswire AG", /* 0122 */ "MStar Semiconductor, Inc.", /* 0123 */ "Hanlynn Technologies", /* 0124 */ "A & R Cambridge", /* 0125 */ "Seers Technology Co., Ltd.", /* 0126 */ "Sports Tracking Technologies Ltd.", /* 0127 */ "Autonet Mobile", /* 0128 */ "DeLorme Publishing Company, Inc.", /* 0129 */ "WuXi Vimicro", /* 0130 */ "Sennheiser Communications A/S", /* 0131 */ "TimeKeeping Systems, Inc.", /* 0132 */ "Ludus Helsinki Ltd.", /* 0133 */ "BlueRadios, Inc.", /* 0134 */ "Equinux AG", /* 0135 */ "Garmin International, Inc.", /* 0136 */ "Ecotest", /* 0137 */ "GN ReSound A/S", /* 0138 */ "Jawbone", /* 0139 */ "Topcon Positioning Systems, LLC", /* 0140 */ "Gimbal Inc. (formerly Qualcomm Labs, Inc. and Qualcomm Retail Solutions, Inc.)", /* 0141 */ "Zscan Software", /* 0142 */ "Quintic Corp", /* 0143 */ "Telit Wireless Solutions GmbH (formerly Stollmann E+V GmbH)", /* 0144 */ "Funai Electric Co., Ltd.", /* 0145 */ "Advanced PANMOBIL systems GmbH & Co. KG", /* 0146 */ "ThinkOptics, Inc.", /* 0147 */ "Universal Electronics, Inc.", /* 0148 */ "Airoha Technology Corp.", /* 0149 */ "NEC Lighting, Ltd.", /* 0150 */ "ODM Technology, Inc.", /* 0151 */ "ConnecteDevice Ltd.", /* 0152 */ "zero1.tv GmbH", /* 0153 */ "i.Tech Dynamic Global Distribution Ltd.", /* 0154 */ "Alpwise", /* 0155 */ "Jiangsu Toppower Automotive Electronics Co., Ltd.", /* 0156 */ "Colorfy, Inc.", /* 0157 */ "Geoforce Inc.", /* 0158 */ "Bose Corporation", /* 0159 */ "Suunto Oy", /* 0160 */ "Kensington Computer Products Group", /* 0161 */ "SR-Medizinelektronik", /* 0162 */ "Vertu Corporation Limited", /* 0163 */ "Meta Watch Ltd.", /* 0164 */ "LINAK A/S", /* 0165 */ "OTL Dynamics LLC", /* 0166 */ "Panda Ocean Inc.", /* 0167 */ "Visteon Corporation", /* 0168 */ "ARP Devices Limited", /* 0169 */ "MARELLI EUROPE S.P.A. (formerly Magneti Marelli S.p.A.)", /* 0170 */ "CAEN RFID srl", /* 0171 */ "Ingenieur-Systemgruppe Zahn GmbH", /* 0172 */ "Green Throttle Games", /* 0173 */ "Peter Systemtechnik GmbH", /* 0174 */ "Omegawave Oy", /* 0175 */ "Cinetix", /* 0176 */ "Passif Semiconductor Corp", /* 0177 */ "Saris Cycling Group, Inc", /* 0178 */ "Bekey A/S", /* 0179 */ "Clarinox Technologies Pty. Ltd.", /* 0180 */ "BDE Technology Co., Ltd.", /* 0181 */ "Swirl Networks", /* 0182 */ "Meso international", /* 0183 */ "TreLab Ltd", /* 0184 */ "Qualcomm Innovation Center, Inc. (QuIC)", /* 0185 */ "Johnson Controls, Inc.", /* 0186 */ "Starkey Laboratories Inc.", /* 0187 */ "S-Power Electronics Limited", /* 0188 */ "Ace Sensor Inc", /* 0189 */ "Aplix Corporation", /* 0190 */ "AAMP of America", /* 0191 */ "Stalmart Technology Limited", /* 0192 */ "AMICCOM Electronics Corporation", /* 0193 */ "Shenzhen Excelsecu Data Technology Co.,Ltd", /* 0194 */ "Geneq Inc.", /* 0195 */ "adidas AG", /* 0196 */ "LG Electronics", /* 0197 */ "Onset Computer Corporation", /* 0198 */ "Selfly BV", /* 0199 */ "Quuppa Oy.", /* 0200 */ "GeLo Inc", /* 0201 */ "Evluma", /* 0202 */ "MC10", /* 0203 */ "Binauric SE", /* 0204 */ "Beats Electronics", /* 0205 */ "Microchip Technology Inc.", /* 0206 */ "Elgato Systems GmbH", /* 0207 */ "ARCHOS SA", /* 0208 */ "Dexcom, Inc.", /* 0209 */ "Polar Electro Europe B.V.", /* 0210 */ "Dialog Semiconductor B.V.", /* 0211 */ "Taixingbang Technology (HK) Co,. LTD.", /* 0212 */ "Kawantech", /* 0213 */ "Austco Communication Systems", /* 0214 */ "Timex Group USA, Inc.", /* 0215 */ "Qualcomm Technologies, Inc.", /* 0216 */ "Qualcomm Connected Experiences, Inc.", /* 0217 */ "Voyetra Turtle Beach", /* 0218 */ "txtr GmbH", /* 0219 */ "Biosentronics", /* 0220 */ "Procter & Gamble", /* 0221 */ "Hosiden Corporation", /* 0222 */ "Muzik LLC", /* 0223 */ "Misfit Wearables Corp", /* 0224 */ "Google", /* 0225 */ "Danlers Ltd", /* 0226 */ "Semilink Inc", /* 0227 */ "inMusic Brands, Inc", /* 0228 */ "L.S. Research Inc.", /* 0229 */ "Eden Software Consultants Ltd.", /* 0230 */ "Freshtemp", /* 0231 */ "KS Technologies", /* 0232 */ "ACTS Technologies", /* 0233 */ "Vtrack Systems", /* 0234 */ "Nielsen-Kellerman Company", /* 0235 */ "Server Technology Inc.", /* 0236 */ "BioResearch Associates", /* 0237 */ "Jolly Logic, LLC", /* 0238 */ "Above Average Outcomes, Inc.", /* 0239 */ "Bitsplitters GmbH", /* 0240 */ "PayPal, Inc.", /* 0241 */ "Witron Technology Limited", /* 0242 */ "Morse Project Inc.", /* 0243 */ "Kent Displays Inc.", /* 0244 */ "Nautilus Inc.", /* 0245 */ "Smartifier Oy", /* 0246 */ "Elcometer Limited", /* 0247 */ "VSN Technologies, Inc.", /* 0248 */ "AceUni Corp., Ltd.", /* 0249 */ "StickNFind", /* 0250 */ "Crystal Code AB", /* 0251 */ "KOUKAAM a.s.", /* 0252 */ "Delphi Corporation", /* 0253 */ "ValenceTech Limited", /* 0254 */ "Stanley Black and Decker", /* 0255 */ "Typo Products, LLC", /* 0256 */ "TomTom International BV", /* 0257 */ "Fugoo, Inc.", /* 0258 */ "Keiser Corporation", /* 0259 */ "Bang & Olufsen A/S", /* 0260 */ "PLUS Location Systems Pty Ltd", /* 0261 */ "Ubiquitous Computing Technology Corporation", /* 0262 */ "Innovative Yachtter Solutions", /* 0263 */ "William Demant Holding A/S", /* 0264 */ "Chicony Electronics Co., Ltd.", /* 0265 */ "Atus BV", /* 0266 */ "Codegate Ltd", /* 0267 */ "ERi, Inc", /* 0268 */ "Transducers Direct, LLC", /* 0269 */ "DENSO TEN LIMITED (formerly Fujitsu Ten LImited)", /* 0270 */ "Audi AG", /* 0271 */ "HiSilicon Technologies CO., LIMITED", /* 0272 */ "Nippon Seiki Co., Ltd.", /* 0273 */ "Steelseries ApS", /* 0274 */ "Visybl Inc.", /* 0275 */ "Openbrain Technologies, Co., Ltd.", /* 0276 */ "Xensr", /* 0277 */ "e.solutions", /* 0278 */ "10AK Technologies", /* 0279 */ "Wimoto Technologies Inc", /* 0280 */ "Radius Networks, Inc.", /* 0281 */ "Wize Technology Co., Ltd.", /* 0282 */ "Qualcomm Labs, Inc.", /* 0283 */ "Hewlett Packard Enterprise", /* 0284 */ "Baidu", /* 0285 */ "Arendi AG", /* 0286 */ "Skoda Auto a.s.", /* 0287 */ "Volkswagen AG", /* 0288 */ "Porsche AG", /* 0289 */ "Sino Wealth Electronic Ltd.", /* 0290 */ "AirTurn, Inc.", /* 0291 */ "Kinsa, Inc", /* 0292 */ "HID Global", /* 0293 */ "SEAT es", /* 0294 */ "Promethean Ltd.", /* 0295 */ "Salutica Allied Solutions", /* 0296 */ "GPSI Group Pty Ltd", /* 0297 */ "Nimble Devices Oy", /* 0298 */ "Changzhou Yongse Infotech Co., Ltd.", /* 0299 */ "SportIQ", /* 0300 */ "TEMEC Instruments B.V.", /* 0301 */ "Sony Corporation", /* 0302 */ "ASSA ABLOY", /* 0303 */ "Clarion Co. Inc.", /* 0304 */ "Warehouse Innovations", /* 0305 */ "Cypress Semiconductor", /* 0306 */ "MADS Inc", /* 0307 */ "Blue Maestro Limited", /* 0308 */ "Resolution Products, Ltd.", /* 0309 */ "Aireware LLC", /* 0310 */ "Silvair, Inc.", /* 0311 */ "Prestigio Plaza Ltd.", /* 0312 */ "NTEO Inc.", /* 0313 */ "Focus Systems Corporation", /* 0314 */ "Tencent Holdings Ltd.", /* 0315 */ "Allegion", /* 0316 */ "Murata Manufacturing Co., Ltd.", /* 0317 */ "WirelessWERX", /* 0318 */ "Nod, Inc.", /* 0319 */ "B&B Manufacturing Company", /* 0320 */ "Alpine Electronics (China) Co., Ltd", /* 0321 */ "FedEx Services", /* 0322 */ "Grape Systems Inc.", /* 0323 */ "Bkon Connect", /* 0324 */ "Lintech GmbH", /* 0325 */ "Novatel Wireless", /* 0326 */ "Ciright", /* 0327 */ "Mighty Cast, Inc.", /* 0328 */ "Ambimat Electronics", /* 0329 */ "Perytons Ltd.", /* 0330 */ "Tivoli Audio, LLC", /* 0331 */ "Master Lock", /* 0332 */ "Mesh-Net Ltd", /* 0333 */ "HUIZHOU DESAY SV AUTOMOTIVE CO., LTD.", /* 0334 */ "Tangerine, Inc.", /* 0335 */ "B&W Group Ltd.", /* 0336 */ "Pioneer Corporation", /* 0337 */ "OnBeep", /* 0338 */ "Vernier Software & Technology", /* 0339 */ "ROL Ergo", /* 0340 */ "Pebble Technology", /* 0341 */ "NETATMO", /* 0342 */ "Accumulate AB", /* 0343 */ "Anhui Huami Information Technology Co., Ltd.", /* 0344 */ "Inmite s.r.o.", /* 0345 */ "ChefSteps, Inc.", /* 0346 */ "micas AG", /* 0347 */ "Biomedical Research Ltd.", /* 0348 */ "Pitius Tec S.L.", /* 0349 */ "Estimote, Inc.", /* 0350 */ "Unikey Technologies, Inc.", /* 0351 */ "Timer Cap Co.", /* 0352 */ "AwoX", /* 0353 */ "yikes", /* 0354 */ "MADSGlobalNZ Ltd.", /* 0355 */ "PCH International", /* 0356 */ "Qingdao Yeelink Information Technology Co., Ltd.", /* 0357 */ "Milwaukee Tool (Formally Milwaukee Electric Tools)", /* 0358 */ "MISHIK Pte Ltd", /* 0359 */ "Ascensia Diabetes Care US Inc.", /* 0360 */ "Spicebox LLC", /* 0361 */ "emberlight", /* 0362 */ "Cooper-Atkins Corporation", /* 0363 */ "Qblinks", /* 0364 */ "MYSPHERA", /* 0365 */ "LifeScan Inc", /* 0366 */ "Volantic AB", /* 0367 */ "Podo Labs, Inc", /* 0368 */ "Roche Diabetes Care AG", /* 0369 */ "Amazon.com Services, LLC (formerly Amazon Fulfillment Service)", /* 0370 */ "Connovate Technology Private Limited", /* 0371 */ "Kocomojo, LLC", /* 0372 */ "Everykey Inc.", /* 0373 */ "Dynamic Controls", /* 0374 */ "SentriLock", /* 0375 */ "I-SYST inc.", /* 0376 */ "CASIO COMPUTER CO., LTD.", /* 0377 */ "LAPIS Semiconductor Co., Ltd.", /* 0378 */ "Telemonitor, Inc.", /* 0379 */ "taskit GmbH", /* 0380 */ "Daimler AG", /* 0381 */ "BatAndCat", /* 0382 */ "BluDotz Ltd", /* 0383 */ "XTel Wireless ApS", /* 0384 */ "Gigaset Communications GmbH", /* 0385 */ "Gecko Health Innovations, Inc.", /* 0386 */ "HOP Ubiquitous", /* 0387 */ "Walt Disney", /* 0388 */ "Nectar", /* 0389 */ "bel'apps LLC", /* 0390 */ "CORE Lighting Ltd", /* 0391 */ "Seraphim Sense Ltd", /* 0392 */ "Unico RBC", /* 0393 */ "Physical Enterprises Inc.", /* 0394 */ "Able Trend Technology Limited", /* 0395 */ "Konica Minolta, Inc.", /* 0396 */ "Wilo SE", /* 0397 */ "Extron Design Services", /* 0398 */ "Fitbit, Inc.", /* 0399 */ "Fireflies Systems", /* 0400 */ "Intelletto Technologies Inc.", /* 0401 */ "FDK CORPORATION", /* 0402 */ "Cloudleaf, Inc", /* 0403 */ "Maveric Automation LLC", /* 0404 */ "Acoustic Stream Corporation", /* 0405 */ "Zuli", /* 0406 */ "Paxton Access Ltd", /* 0407 */ "WiSilica Inc.", /* 0408 */ "VENGIT Korlatolt Felelossegu Tarsasag", /* 0409 */ "SALTO SYSTEMS S.L.", /* 0410 */ "TRON Forum (formerly T-Engine Forum)", /* 0411 */ "CUBETECH s.r.o.", /* 0412 */ "Cokiya Incorporated", /* 0413 */ "CVS Health", /* 0414 */ "Ceruus", /* 0415 */ "Strainstall Ltd", /* 0416 */ "Channel Enterprises (HK) Ltd.", /* 0417 */ "FIAMM", /* 0418 */ "GIGALANE.CO.,LTD", /* 0419 */ "EROAD", /* 0420 */ "Mine Safety Appliances", /* 0421 */ "Icon Health and Fitness", /* 0422 */ "Wille Engineering (formerly as Asandoo GmbH)", /* 0423 */ "ENERGOUS CORPORATION", /* 0424 */ "Taobao", /* 0425 */ "Canon Inc.", /* 0426 */ "Geophysical Technology Inc.", /* 0427 */ "Facebook, Inc.", /* 0428 */ "Trividia Health, Inc.", /* 0429 */ "FlightSafety International", /* 0430 */ "Earlens Corporation", /* 0431 */ "Sunrise Micro Devices, Inc.", /* 0432 */ "Star Micronics Co., Ltd.", /* 0433 */ "Netizens Sp. z o.o.", /* 0434 */ "Nymi Inc.", /* 0435 */ "Nytec, Inc.", /* 0436 */ "Trineo Sp. z o.o.", /* 0437 */ "Nest Labs Inc.", /* 0438 */ "LM Technologies Ltd", /* 0439 */ "General Electric Company", /* 0440 */ "i+D3 S.L.", /* 0441 */ "HANA Micron", /* 0442 */ "Stages Cycling LLC", /* 0443 */ "Cochlear Bone Anchored Solutions AB", /* 0444 */ "SenionLab AB", /* 0445 */ "Syszone Co., Ltd", /* 0446 */ "Pulsate Mobile Ltd.", /* 0447 */ "Hong Kong HunterSun Electronic Limited", /* 0448 */ "pironex GmbH", /* 0449 */ "BRADATECH Corp.", /* 0450 */ "Transenergooil AG", /* 0451 */ "Bunch", /* 0452 */ "DME Microelectronics", /* 0453 */ "Bitcraze AB", /* 0454 */ "HASWARE Inc.", /* 0455 */ "Abiogenix Inc.", /* 0456 */ "Poly-Control ApS", /* 0457 */ "Avi-on", /* 0458 */ "Laerdal Medical AS", /* 0459 */ "Fetch My Pet", /* 0460 */ "Sam Labs Ltd.", /* 0461 */ "Chengdu Synwing Technology Ltd", /* 0462 */ "HOUWA SYSTEM DESIGN, k.k.", /* 0463 */ "BSH", /* 0464 */ "Primus Inter Pares Ltd", /* 0465 */ "August Home, Inc", /* 0466 */ "Gill Electronics", /* 0467 */ "Sky Wave Design", /* 0468 */ "Newlab S.r.l.", /* 0469 */ "ELAD srl", /* 0470 */ "G-wearables inc.", /* 0471 */ "Squadrone Systems Inc.", /* 0472 */ "Code Corporation", /* 0473 */ "Savant Systems LLC", /* 0474 */ "Logitech International SA", /* 0475 */ "Innblue Consulting", /* 0476 */ "iParking Ltd.", /* 0477 */ "Koninklijke Philips Electronics N.V.", /* 0478 */ "Minelab Electronics Pty Limited", /* 0479 */ "Bison Group Ltd.", /* 0480 */ "Widex A/S", /* 0481 */ "Jolla Ltd", /* 0482 */ "Lectronix, Inc.", /* 0483 */ "Caterpillar Inc", /* 0484 */ "Freedom Innovations", /* 0485 */ "Dynamic Devices Ltd", /* 0486 */ "Technology Solutions (UK) Ltd", /* 0487 */ "IPS Group Inc.", /* 0488 */ "STIR", /* 0489 */ "Sano, Inc.", /* 0490 */ "Advanced Application Design, Inc.", /* 0491 */ "AutoMap LLC", /* 0492 */ "Spreadtrum Communications Shanghai Ltd", /* 0493 */ "CuteCircuit LTD", /* 0494 */ "Valeo Service", /* 0495 */ "Fullpower Technologies, Inc.", /* 0496 */ "KloudNation", /* 0497 */ "Zebra Technologies Corporation", /* 0498 */ "Itron, Inc.", /* 0499 */ "The University of Tokyo", /* 0500 */ "UTC Fire and Security", /* 0501 */ "Cool Webthings Limited", /* 0502 */ "DJO Global", /* 0503 */ "Gelliner Limited", /* 0504 */ "Anyka (Guangzhou) Microelectronics Technology Co, LTD", /* 0505 */ "Medtronic Inc.", /* 0506 */ "Gozio Inc.", /* 0507 */ "Form Lifting, LLC", /* 0508 */ "Wahoo Fitness, LLC", /* 0509 */ "Kontakt Micro-Location Sp. z o.o.", /* 0510 */ "Radio Systems Corporation", /* 0511 */ "Freescale Semiconductor, Inc.", /* 0512 */ "Verifone Systems Pte Ltd. Taiwan Branch", /* 0513 */ "AR Timing", /* 0514 */ "Rigado LLC", /* 0515 */ "Kemppi Oy", /* 0516 */ "Tapcentive Inc.", /* 0517 */ "Smartbotics Inc.", /* 0518 */ "Otter Products, LLC", /* 0519 */ "STEMP Inc.", /* 0520 */ "LumiGeek LLC", /* 0521 */ "InvisionHeart Inc.", /* 0522 */ "Macnica Inc.", /* 0523 */ "Jaguar Land Rover Limited", /* 0524 */ "CoroWare Technologies, Inc", /* 0525 */ "Simplo Technology Co., LTD", /* 0526 */ "Omron Healthcare Co., LTD", /* 0527 */ "Comodule GMBH", /* 0528 */ "ikeGPS", /* 0529 */ "Telink Semiconductor Co. Ltd", /* 0530 */ "Interplan Co., Ltd", /* 0531 */ "Wyler AG", /* 0532 */ "IK Multimedia Production srl", /* 0533 */ "Lukoton Experience Oy", /* 0534 */ "MTI Ltd", /* 0535 */ "Tech4home, Lda", /* 0536 */ "Hiotech AB", /* 0537 */ "DOTT Limited", /* 0538 */ "Blue Speck Labs, LLC", /* 0539 */ "Cisco Systems, Inc", /* 0540 */ "Mobicomm Inc", /* 0541 */ "Edamic", /* 0542 */ "Goodnet, Ltd", /* 0543 */ "Luster Leaf Products Inc", /* 0544 */ "Manus Machina BV", /* 0545 */ "Mobiquity Networks Inc", /* 0546 */ "Praxis Dynamics", /* 0547 */ "Philip Morris Products S.A.", /* 0548 */ "Comarch SA", /* 0549 */ "Nestlé Nespresso S.A.", /* 0550 */ "Merlinia A/S", /* 0551 */ "LifeBEAM Technologies", /* 0552 */ "Twocanoes Labs, LLC", /* 0553 */ "Muoverti Limited", /* 0554 */ "Stamer Musikanlagen GMBH", /* 0555 */ "Tesla Motors", /* 0556 */ "Pharynks Corporation", /* 0557 */ "Lupine", /* 0558 */ "Siemens AG", /* 0559 */ "Huami (Shanghai) Culture Communication CO., LTD", /* 0560 */ "Foster Electric Company, Ltd", /* 0561 */ "ETA SA", /* 0562 */ "x-Senso Solutions Kft", /* 0563 */ "Shenzhen SuLong Communication Ltd", /* 0564 */ "FengFan (BeiJing) Technology Co, Ltd", /* 0565 */ "Qrio Inc", /* 0566 */ "Pitpatpet Ltd", /* 0567 */ "MSHeli s.r.l.", /* 0568 */ "Trakm8 Ltd", /* 0569 */ "JIN CO, Ltd", /* 0570 */ "Alatech Tehnology", /* 0571 */ "Beijing CarePulse Electronic Technology Co, Ltd", /* 0572 */ "Awarepoint", /* 0573 */ "ViCentra B.V.", /* 0574 */ "Raven Industries", /* 0575 */ "WaveWare Technologies Inc.", /* 0576 */ "Argenox Technologies", /* 0577 */ "Bragi GmbH", /* 0578 */ "16Lab Inc", /* 0579 */ "Masimo Corp", /* 0580 */ "Iotera Inc", /* 0581 */ "Endress+Hauser", /* 0582 */ "ACKme Networks, Inc.", /* 0583 */ "FiftyThree Inc.", /* 0584 */ "Parker Hannifin Corp", /* 0585 */ "Transcranial Ltd", /* 0586 */ "Uwatec AG", /* 0587 */ "Orlan LLC", /* 0588 */ "Blue Clover Devices", /* 0589 */ "M-Way Solutions GmbH", /* 0590 */ "Microtronics Engineering GmbH", /* 0591 */ "Schneider Schreibgeräte GmbH", /* 0592 */ "Sapphire Circuits LLC", /* 0593 */ "Lumo Bodytech Inc.", /* 0594 */ "UKC Technosolution", /* 0595 */ "Xicato Inc.", /* 0596 */ "Playbrush", /* 0597 */ "Dai Nippon Printing Co., Ltd.", /* 0598 */ "G24 Power Limited", /* 0599 */ "AdBabble Local Commerce Inc.", /* 0600 */ "Devialet SA", /* 0601 */ "ALTYOR", /* 0602 */ "University of Applied Sciences Valais/Haute Ecole Valaisanne", /* 0603 */ "Five Interactive, LLC dba Zendo", /* 0604 */ "NetEase (Hangzhou) Network co.Ltd.", /* 0605 */ "Lexmark International Inc.", /* 0606 */ "Fluke Corporation", /* 0607 */ "Yardarm Technologies", /* 0608 */ "SensaRx", /* 0609 */ "SECVRE GmbH", /* 0610 */ "Glacial Ridge Technologies", /* 0611 */ "Identiv, Inc.", /* 0612 */ "DDS, Inc.", /* 0613 */ "SMK Corporation", /* 0614 */ "Schawbel Technologies LLC", /* 0615 */ "XMI Systems SA", /* 0616 */ "Cerevo", /* 0617 */ "Torrox GmbH & Co KG", /* 0618 */ "Gemalto", /* 0619 */ "DEKA Research & Development Corp.", /* 0620 */ "Domster Tadeusz Szydlowski", /* 0621 */ "Technogym SPA", /* 0622 */ "FLEURBAEY BVBA", /* 0623 */ "Aptcode Solutions", /* 0624 */ "LSI ADL Technology", /* 0625 */ "Animas Corp", /* 0626 */ "Alps Electric Co., Ltd.", /* 0627 */ "OCEASOFT", /* 0628 */ "Motsai Research", /* 0629 */ "Geotab", /* 0630 */ "E.G.O. Elektro-Geraetebau GmbH", /* 0631 */ "bewhere inc", /* 0632 */ "Johnson Outdoors Inc", /* 0633 */ "steute Schaltgerate GmbH & Co. KG", /* 0634 */ "Ekomini inc.", /* 0635 */ "DEFA AS", /* 0636 */ "Aseptika Ltd", /* 0637 */ "HUAWEI Technologies Co., Ltd.", /* 0638 */ "HabitAware, LLC", /* 0639 */ "ruwido austria gmbh", /* 0640 */ "ITEC corporation", /* 0641 */ "StoneL", /* 0642 */ "Sonova AG", /* 0643 */ "Maven Machines, Inc.", /* 0644 */ "Synapse Electronics", /* 0645 */ "Standard Innovation Inc.", /* 0646 */ "RF Code, Inc.", /* 0647 */ "Wally Ventures S.L.", /* 0648 */ "Willowbank Electronics Ltd", /* 0649 */ "SK Telecom", /* 0650 */ "Jetro AS", /* 0651 */ "Code Gears LTD", /* 0652 */ "NANOLINK APS", /* 0653 */ "IF, LLC", /* 0654 */ "RF Digital Corp", /* 0655 */ "Church & Dwight Co., Inc", /* 0656 */ "Multibit Oy", /* 0657 */ "CliniCloud Inc", /* 0658 */ "SwiftSensors", /* 0659 */ "Blue Bite", /* 0660 */ "ELIAS GmbH", /* 0661 */ "Sivantos GmbH", /* 0662 */ "Petzl", /* 0663 */ "storm power ltd", /* 0664 */ "EISST Ltd", /* 0665 */ "Inexess Technology Simma KG", /* 0666 */ "Currant, Inc.", /* 0667 */ "C2 Development, Inc.", /* 0668 */ "Blue Sky Scientific, LLC", /* 0669 */ "ALOTTAZS LABS, LLC", /* 0670 */ "Kupson spol. s r.o.", /* 0671 */ "Areus Engineering GmbH", /* 0672 */ "Impossible Camera GmbH", /* 0673 */ "InventureTrack Systems", /* 0674 */ "LockedUp", /* 0675 */ "Itude", /* 0676 */ "Pacific Lock Company", /* 0677 */ "Tendyron Corporation", /* 0678 */ "Robert Bosch GmbH", /* 0679 */ "Illuxtron international B.V.", /* 0680 */ "miSport Ltd.", /* 0681 */ "Chargelib", /* 0682 */ "Doppler Lab", /* 0683 */ "BBPOS Limited", /* 0684 */ "RTB Elektronik GmbH & Co. KG", /* 0685 */ "Rx Networks, Inc.", /* 0686 */ "WeatherFlow, Inc.", /* 0687 */ "Technicolor USA Inc.", /* 0688 */ "Bestechnic(Shanghai),Ltd", /* 0689 */ "Raden Inc", /* 0690 */ "JouZen Oy", /* 0691 */ "CLABER S.P.A.", /* 0692 */ "Hyginex, Inc.", /* 0693 */ "HANSHIN ELECTRIC RAILWAY CO.,LTD.", /* 0694 */ "Schneider Electric", /* 0695 */ "Oort Technologies LLC", /* 0696 */ "Chrono Therapeutics", /* 0697 */ "Rinnai Corporation", /* 0698 */ "Swissprime Technologies AG", /* 0699 */ "Koha.,Co.Ltd", /* 0700 */ "Genevac Ltd", /* 0701 */ "Chemtronics", /* 0702 */ "Seguro Technology Sp. z o.o.", /* 0703 */ "Redbird Flight Simulations", /* 0704 */ "Dash Robotics", /* 0705 */ "LINE Corporation", /* 0706 */ "Guillemot Corporation", /* 0707 */ "Techtronic Power Tools Technology Limited", /* 0708 */ "Wilson Sporting Goods", /* 0709 */ "Lenovo (Singapore) Pte Ltd.", /* 0710 */ "Ayatan Sensors", /* 0711 */ "Electronics Tomorrow Limited", /* 0712 */ "VASCO Data Security International, Inc.", /* 0713 */ "PayRange Inc.", /* 0714 */ "ABOV Semiconductor", /* 0715 */ "AINA-Wireless Inc.", /* 0716 */ "Eijkelkamp Soil & Water", /* 0717 */ "BMA ergonomics b.v.", /* 0718 */ "Teva Branded Pharmaceutical Products R&D, Inc.", /* 0719 */ "Anima", /* 0720 */ "3M", /* 0721 */ "Empatica Srl", /* 0722 */ "Afero, Inc.", /* 0723 */ "Powercast Corporation", /* 0724 */ "Secuyou ApS", /* 0725 */ "OMRON Corporation", /* 0726 */ "Send Solutions", /* 0727 */ "NIPPON SYSTEMWARE CO.,LTD.", /* 0728 */ "Neosfar", /* 0729 */ "Fliegl Agrartechnik GmbH", /* 0730 */ "Gilvader", /* 0731 */ "Digi International Inc (R)", /* 0732 */ "DeWalch Technologies, Inc.", /* 0733 */ "Flint Rehabilitation Devices, LLC", /* 0734 */ "Samsung SDS Co., Ltd.", /* 0735 */ "Blur Product Development", /* 0736 */ "University of Michigan", /* 0737 */ "Victron Energy BV", /* 0738 */ "NTT docomo", /* 0739 */ "Carmanah Technologies Corp.", /* 0740 */ "Bytestorm Ltd.", /* 0741 */ "Espressif Incorporated", /* 0742 */ "Unwire", /* 0743 */ "Connected Yard, Inc.", /* 0744 */ "American Music Environments", /* 0745 */ "Sensogram Technologies, Inc.", /* 0746 */ "Fujitsu Limited", /* 0747 */ "Ardic Technology", /* 0748 */ "Delta Systems, Inc", /* 0749 */ "HTC Corporation", /* 0750 */ "Citizen Holdings Co., Ltd.", /* 0751 */ "SMART-INNOVATION.inc", /* 0752 */ "Blackrat Software", /* 0753 */ "The Idea Cave, LLC", /* 0754 */ "GoPro, Inc.", /* 0755 */ "AuthAir, Inc", /* 0756 */ "Vensi, Inc.", /* 0757 */ "Indagem Tech LLC", /* 0758 */ "Intemo Technologies", /* 0759 */ "DreamVisions co., Ltd.", /* 0760 */ "Runteq Oy Ltd", /* 0761 */ "IMAGINATION TECHNOLOGIES LTD", /* 0762 */ "CoSTAR TEchnologies", /* 0763 */ "Clarius Mobile Health Corp.", /* 0764 */ "Shanghai Frequen Microelectronics Co., Ltd.", /* 0765 */ "Uwanna, Inc.", /* 0766 */ "Lierda Science & Technology Group Co., Ltd.", /* 0767 */ "Silicon Laboratories", /* 0768 */ "World Moto Inc.", /* 0769 */ "Giatec Scientific Inc.", /* 0770 */ "Loop Devices, Inc", /* 0771 */ "IACA electronique", /* 0772 */ "Proxy Technologies, Inc.", /* 0773 */ "Swipp ApS", /* 0774 */ "Life Laboratory Inc.", /* 0775 */ "FUJI INDUSTRIAL CO.,LTD.", /* 0776 */ "Surefire, LLC", /* 0777 */ "Dolby Labs", /* 0778 */ "Ellisys", /* 0779 */ "Magnitude Lighting Converters", /* 0780 */ "Hilti AG", /* 0781 */ "Devdata S.r.l.", /* 0782 */ "Deviceworx", /* 0783 */ "Shortcut Labs", /* 0784 */ "SGL Italia S.r.l.", /* 0785 */ "PEEQ DATA", /* 0786 */ "Ducere Technologies Pvt Ltd", /* 0787 */ "DiveNav, Inc.", /* 0788 */ "RIIG AI Sp. z o.o.", /* 0789 */ "Thermo Fisher Scientific", /* 0790 */ "AG Measurematics Pvt. Ltd.", /* 0791 */ "CHUO Electronics CO., LTD.", /* 0792 */ "Aspenta International", /* 0793 */ "Eugster Frismag AG", /* 0794 */ "Amber wireless GmbH", /* 0795 */ "HQ Inc", /* 0796 */ "Lab Sensor Solutions", /* 0797 */ "Enterlab ApS", /* 0798 */ "Eyefi, Inc.", /* 0799 */ "MetaSystem S.p.A.", /* 0800 */ "SONO ELECTRONICS. CO., LTD", /* 0801 */ "Jewelbots", /* 0802 */ "Compumedics Limited", /* 0803 */ "Rotor Bike Components", /* 0804 */ "Astro, Inc.", /* 0805 */ "Amotus Solutions", /* 0806 */ "Healthwear Technologies (Changzhou)Ltd", /* 0807 */ "Essex Electronics", /* 0808 */ "Grundfos A/S", /* 0809 */ "Eargo, Inc.", /* 0810 */ "Electronic Design Lab", /* 0811 */ "ESYLUX", /* 0812 */ "NIPPON SMT.CO.,Ltd", /* 0813 */ "BM innovations GmbH", /* 0814 */ "indoormap", /* 0815 */ "OttoQ Inc", /* 0816 */ "North Pole Engineering", /* 0817 */ "3flares Technologies Inc.", /* 0818 */ "Electrocompaniet A.S.", /* 0819 */ "Mul-T-Lock", /* 0820 */ "Corentium AS", /* 0821 */ "Enlighted Inc", /* 0822 */ "GISTIC", /* 0823 */ "AJP2 Holdings, LLC", /* 0824 */ "COBI GmbH", /* 0825 */ "Blue Sky Scientific, LLC", /* 0826 */ "Appception, Inc.", /* 0827 */ "Courtney Thorne Limited", /* 0828 */ "Virtuosys", /* 0829 */ "TPV Technology Limited", /* 0830 */ "Monitra SA", /* 0831 */ "Automation Components, Inc.", /* 0832 */ "Letsense s.r.l.", /* 0833 */ "Etesian Technologies LLC", /* 0834 */ "GERTEC BRASIL LTDA.", /* 0835 */ "Drekker Development Pty. Ltd.", /* 0836 */ "Whirl Inc", /* 0837 */ "Locus Positioning", /* 0838 */ "Acuity Brands Lighting, Inc", /* 0839 */ "Prevent Biometrics", /* 0840 */ "Arioneo", /* 0841 */ "VersaMe", /* 0842 */ "Vaddio", /* 0843 */ "Libratone A/S", /* 0844 */ "HM Electronics, Inc.", /* 0845 */ "TASER International, Inc.", /* 0846 */ "SafeTrust Inc.", /* 0847 */ "Heartland Payment Systems", /* 0848 */ "Bitstrata Systems Inc.", /* 0849 */ "Pieps GmbH", /* 0850 */ "iRiding(Xiamen)Technology Co.,Ltd.", /* 0851 */ "Alpha Audiotronics, Inc.", /* 0852 */ "TOPPAN FORMS CO.,LTD.", /* 0853 */ "Sigma Designs, Inc.", /* 0854 */ "Spectrum Brands, Inc.", /* 0855 */ "Polymap Wireless", /* 0856 */ "MagniWare Ltd.", /* 0857 */ "Novotec Medical GmbH", /* 0858 */ "Medicom Innovation Partner a/s", /* 0859 */ "Matrix Inc.", /* 0860 */ "Eaton Corporation", /* 0861 */ "KYS", /* 0862 */ "Naya Health, Inc.", /* 0863 */ "Acromag", /* 0864 */ "Insulet Corporation", /* 0865 */ "Wellinks Inc.", /* 0866 */ "ON Semiconductor", /* 0867 */ "FREELAP SA", /* 0868 */ "Favero Electronics Srl", /* 0869 */ "BioMech Sensor LLC", /* 0870 */ "BOLTT Sports technologies Private limited", /* 0871 */ "Saphe International", /* 0872 */ "Metormote AB", /* 0873 */ "littleBits", /* 0874 */ "SetPoint Medical", /* 0875 */ "BRControls Products BV", /* 0876 */ "Zipcar", /* 0877 */ "AirBolt Pty Ltd", /* 0878 */ "KeepTruckin Inc", /* 0879 */ "Motiv, Inc.", /* 0880 */ "Wazombi Labs OU", /* 0881 */ "ORBCOMM", /* 0882 */ "Nixie Labs, Inc.", /* 0883 */ "AppNearMe Ltd", /* 0884 */ "Holman Industries", /* 0885 */ "Expain AS", /* 0886 */ "Electronic Temperature Instruments Ltd", /* 0887 */ "Plejd AB", /* 0888 */ "Propeller Health", /* 0889 */ "Shenzhen iMCO Electronic Technology Co.,Ltd", /* 0890 */ "Algoria", /* 0891 */ "Apption Labs Inc.", /* 0892 */ "Cronologics Corporation", /* 0893 */ "MICRODIA Ltd.", /* 0894 */ "lulabytes S.L.", /* 0895 */ "Societe des Produits Nestle S.A. (formerly Nestec S.A.)", /* 0896 */ "LLC \"MEGA-F service\"", /* 0897 */ "Sharp Corporation", /* 0898 */ "Precision Outcomes Ltd", /* 0899 */ "Kronos Incorporated", /* 0900 */ "OCOSMOS Co., Ltd.", /* 0901 */ "Embedded Electronic Solutions Ltd. dba e2Solutions", /* 0902 */ "Aterica Inc.", /* 0903 */ "BluStor PMC, Inc.", /* 0904 */ "Kapsch TrafficCom AB", /* 0905 */ "ActiveBlu Corporation", /* 0906 */ "Kohler Mira Limited", /* 0907 */ "Noke", /* 0908 */ "Appion Inc.", /* 0909 */ "Resmed Ltd", /* 0910 */ "Crownstone B.V.", /* 0911 */ "Xiaomi Inc.", /* 0912 */ "INFOTECH s.r.o.", /* 0913 */ "Thingsquare AB", /* 0914 */ "T&D", /* 0915 */ "LAVAZZA S.p.A.", /* 0916 */ "Netclearance Systems, Inc.", /* 0917 */ "SDATAWAY", /* 0918 */ "BLOKS GmbH", /* 0919 */ "LEGO System A/S", /* 0920 */ "Thetatronics Ltd", /* 0921 */ "Nikon Corporation", /* 0922 */ "NeST", /* 0923 */ "South Silicon Valley Microelectronics", /* 0924 */ "ALE International", /* 0925 */ "CareView Communications, Inc.", /* 0926 */ "SchoolBoard Limited", /* 0927 */ "Molex Corporation", /* 0928 */ "IVT Wireless Limited", /* 0929 */ "Alpine Labs LLC", /* 0930 */ "Candura Instruments", /* 0931 */ "SmartMovt Technology Co., Ltd", /* 0932 */ "Token Zero Ltd", /* 0933 */ "ACE CAD Enterprise Co., Ltd. (ACECAD)", /* 0934 */ "Medela, Inc", /* 0935 */ "AeroScout", /* 0936 */ "Esrille Inc.", /* 0937 */ "THINKERLY SRL", /* 0938 */ "Exon Sp. z o.o.", /* 0939 */ "Meizu Technology Co., Ltd.", /* 0940 */ "Smablo LTD", /* 0941 */ "XiQ", /* 0942 */ "Allswell Inc.", /* 0943 */ "Comm-N-Sense Corp DBA Verigo", /* 0944 */ "VIBRADORM GmbH", /* 0945 */ "Otodata Wireless Network Inc.", /* 0946 */ "Propagation Systems Limited", /* 0947 */ "Midwest Instruments & Controls", /* 0948 */ "Alpha Nodus, inc.", /* 0949 */ "petPOMM, Inc", /* 0950 */ "Mattel", /* 0951 */ "Airbly Inc.", /* 0952 */ "A-Safe Limited", /* 0953 */ "FREDERIQUE CONSTANT SA", /* 0954 */ "Maxscend Microelectronics Company Limited", /* 0955 */ "Abbott", /* 0956 */ "ASB Bank Ltd", /* 0957 */ "amadas", /* 0958 */ "Applied Science, Inc.", /* 0959 */ "iLumi Solutions Inc.", /* 0960 */ "Arch Systems Inc.", /* 0961 */ "Ember Technologies, Inc.", /* 0962 */ "Snapchat Inc", /* 0963 */ "Casambi Technologies Oy", /* 0964 */ "Pico Technology Inc.", /* 0965 */ "St. Jude Medical, Inc.", /* 0966 */ "Intricon", /* 0967 */ "Structural Health Systems, Inc.", /* 0968 */ "Avvel International", /* 0969 */ "Gallagher Group", /* 0970 */ "In2things Automation Pvt. Ltd.", /* 0971 */ "SYSDEV Srl", /* 0972 */ "Vonkil Technologies Ltd", /* 0973 */ "Wynd Technologies, Inc.", /* 0974 */ "CONTRINEX S.A.", /* 0975 */ "MIRA, Inc.", /* 0976 */ "Watteam Ltd", /* 0977 */ "Density Inc.", /* 0978 */ "IOT Pot India Private Limited", /* 0979 */ "Sigma Connectivity AB", /* 0980 */ "PEG PEREGO SPA", /* 0981 */ "Wyzelink Systems Inc.", /* 0982 */ "Yota Devices LTD", /* 0983 */ "FINSECUR", /* 0984 */ "Zen-Me Labs Ltd", /* 0985 */ "3IWare Co., Ltd.", /* 0986 */ "EnOcean GmbH", /* 0987 */ "Instabeat, Inc", /* 0988 */ "Nima Labs", /* 0989 */ "Andreas Stihl AG & Co. KG", /* 0990 */ "Nathan Rhoades LLC", /* 0991 */ "Grob Technologies, LLC", /* 0992 */ "Actions (Zhuhai) Technology Co., Limited", /* 0993 */ "SPD Development Company Ltd", /* 0994 */ "Sensoan Oy", /* 0995 */ "Qualcomm Life Inc", /* 0996 */ "Chip-ing AG", /* 0997 */ "ffly4u", /* 0998 */ "IoT Instruments Oy", /* 0999 */ "TRUE Fitness Technology", /* 1000 */ "Reiner Kartengeraete GmbH & Co. KG.", /* 1001 */ "SHENZHEN LEMONJOY TECHNOLOGY CO., LTD.", /* 1002 */ "Hello Inc.", /* 1003 */ "Evollve Inc.", /* 1004 */ "Jigowatts Inc.", /* 1005 */ "BASIC MICRO.COM,INC.", /* 1006 */ "CUBE TECHNOLOGIES", /* 1007 */ "foolography GmbH", /* 1008 */ "CLINK", /* 1009 */ "Hestan Smart Cooking Inc.", /* 1010 */ "WindowMaster A/S", /* 1011 */ "Flowscape AB", /* 1012 */ "PAL Technologies Ltd", /* 1013 */ "WHERE, Inc.", /* 1014 */ "Iton Technology Corp.", /* 1015 */ "Owl Labs Inc.", /* 1016 */ "Rockford Corp.", /* 1017 */ "Becon Technologies Co.,Ltd.", /* 1018 */ "Vyassoft Technologies Inc", /* 1019 */ "Nox Medical", /* 1020 */ "Kimberly-Clark", /* 1021 */ "Trimble Navigation Ltd.", /* 1022 */ "Littelfuse", /* 1023 */ "Withings", /* 1024 */ "i-developer IT Beratung UG", /* 1025 */ "Relations Inc.", /* 1026 */ "Sears Holdings Corporation", /* 1027 */ "Gantner Electronic GmbH", /* 1028 */ "Authomate Inc", /* 1029 */ "Vertex International, Inc.", /* 1030 */ "Airtago", /* 1031 */ "Swiss Audio SA", /* 1032 */ "ToGetHome Inc.", /* 1033 */ "AXIS", /* 1034 */ "Openmatics", /* 1035 */ "Jana Care Inc.", /* 1036 */ "Senix Corporation", /* 1037 */ "NorthStar Battery Company, LLC", /* 1038 */ "SKF (U.K.) Limited", /* 1039 */ "CO-AX Technology, Inc.", /* 1040 */ "Fender Musical Instruments", /* 1041 */ "Luidia Inc", /* 1042 */ "SEFAM", /* 1043 */ "Wireless Cables Inc", /* 1044 */ "Lightning Protection International Pty Ltd", /* 1045 */ "Uber Technologies Inc", /* 1046 */ "SODA GmbH", /* 1047 */ "Fatigue Science", /* 1048 */ "Alpine Electronics Inc.", /* 1049 */ "Novalogy LTD", /* 1050 */ "Friday Labs Limited", /* 1051 */ "OrthoAccel Technologies", /* 1052 */ "WaterGuru, Inc.", /* 1053 */ "Benning Elektrotechnik und Elektronik GmbH & Co. KG", /* 1054 */ "Dell Computer Corporation", /* 1055 */ "Kopin Corporation", /* 1056 */ "TecBakery GmbH", /* 1057 */ "Backbone Labs, Inc.", /* 1058 */ "DELSEY SA", /* 1059 */ "Chargifi Limited", /* 1060 */ "Trainesense Ltd.", /* 1061 */ "Unify Software and Solutions GmbH & Co. KG", /* 1062 */ "Husqvarna AB", /* 1063 */ "Focus fleet and fuel management inc", /* 1064 */ "SmallLoop, LLC", /* 1065 */ "Prolon Inc.", /* 1066 */ "BD Medical", /* 1067 */ "iMicroMed Incorporated", /* 1068 */ "Ticto N.V.", /* 1069 */ "Meshtech AS", /* 1070 */ "MemCachier Inc.", /* 1071 */ "Danfoss A/S", /* 1072 */ "SnapStyk Inc.", /* 1073 */ "Amway Corporation", /* 1074 */ "Silk Labs, Inc.", /* 1075 */ "Pillsy Inc.", /* 1076 */ "Hatch Baby, Inc.", /* 1077 */ "Blocks Wearables Ltd.", /* 1078 */ "Drayson Technologies (Europe) Limited", /* 1079 */ "eBest IOT Inc.", /* 1080 */ "Helvar Ltd", /* 1081 */ "Radiance Technologies", /* 1082 */ "Nuheara Limited", /* 1083 */ "Appside co., ltd.", /* 1084 */ "DeLaval", /* 1085 */ "Coiler Corporation", /* 1086 */ "Thermomedics, Inc.", /* 1087 */ "Tentacle Sync GmbH", /* 1088 */ "Valencell, Inc.", /* 1089 */ "iProtoXi Oy", /* 1090 */ "SECOM CO., LTD.", /* 1091 */ "Tucker International LLC", /* 1092 */ "Metanate Limited", /* 1093 */ "Kobian Canada Inc.", /* 1094 */ "NETGEAR, Inc.", /* 1095 */ "Fabtronics Australia Pty Ltd", /* 1096 */ "Grand Centrix GmbH", /* 1097 */ "1UP USA.com llc", /* 1098 */ "SHIMANO INC.", /* 1099 */ "Nain Inc.", /* 1100 */ "LifeStyle Lock, LLC", /* 1101 */ "VEGA Grieshaber KG", /* 1102 */ "Xtrava Inc.", /* 1103 */ "TTS Tooltechnic Systems AG & Co. KG", /* 1104 */ "Teenage Engineering AB", /* 1105 */ "Tunstall Nordic AB", /* 1106 */ "Svep Design Center AB", /* 1107 */ "GreenPeak Technologies BV", /* 1108 */ "Sphinx Electronics GmbH & Co KG", /* 1109 */ "Atomation", /* 1110 */ "Nemik Consulting Inc", /* 1111 */ "RF INNOVATION", /* 1112 */ "Mini Solution Co., Ltd.", /* 1113 */ "Lumenetix, Inc", /* 1114 */ "2048450 Ontario Inc", /* 1115 */ "SPACEEK LTD", /* 1116 */ "Delta T Corporation", /* 1117 */ "Boston Scientific Corporation", /* 1118 */ "Nuviz, Inc.", /* 1119 */ "Real Time Automation, Inc.", /* 1120 */ "Kolibree", /* 1121 */ "vhf elektronik GmbH", /* 1122 */ "Bonsai Systems GmbH", /* 1123 */ "Fathom Systems Inc.", /* 1124 */ "Bellman & Symfon", /* 1125 */ "International Forte Group LLC", /* 1126 */ "CycleLabs Solutions inc.", /* 1127 */ "Codenex Oy", /* 1128 */ "Kynesim Ltd", /* 1129 */ "Palago AB", /* 1130 */ "INSIGMA INC.", /* 1131 */ "PMD Solutions", /* 1132 */ "Qingdao Realtime Technology Co., Ltd.", /* 1133 */ "BEGA Gantenbrink-Leuchten KG", /* 1134 */ "Pambor Ltd.", /* 1135 */ "Develco Products A/S", /* 1136 */ "iDesign s.r.l.", /* 1137 */ "TiVo Corp", /* 1138 */ "Control-J Pty Ltd", /* 1139 */ "Steelcase, Inc.", /* 1140 */ "iApartment co., ltd.", /* 1141 */ "Icom inc.", /* 1142 */ "Oxstren Wearable Technologies Private Limited", /* 1143 */ "Blue Spark Technologies", /* 1144 */ "FarSite Communications Limited", /* 1145 */ "mywerk system GmbH", /* 1146 */ "Sinosun Technology Co., Ltd.", /* 1147 */ "MIYOSHI ELECTRONICS CORPORATION", /* 1148 */ "POWERMAT LTD", /* 1149 */ "Occly LLC", /* 1150 */ "OurHub Dev IvS", /* 1151 */ "Pro-Mark, Inc.", /* 1152 */ "Dynometrics Inc.", /* 1153 */ "Quintrax Limited", /* 1154 */ "POS Tuning Udo Vosshenrich GmbH & Co. KG", /* 1155 */ "Multi Care Systems B.V.", /* 1156 */ "Revol Technologies Inc", /* 1157 */ "SKIDATA AG", /* 1158 */ "DEV TECNOLOGIA INDUSTRIA, COMERCIO E MANUTENCAO DE EQUIPAMENTOS LTDA. - ME", /* 1159 */ "Centrica Connected Home", /* 1160 */ "Automotive Data Solutions Inc", /* 1161 */ "Igarashi Engineering", /* 1162 */ "Taelek Oy", /* 1163 */ "CP Electronics Limited", /* 1164 */ "Vectronix AG", /* 1165 */ "S-Labs Sp. z o.o.", /* 1166 */ "Companion Medical, Inc.", /* 1167 */ "BlueKitchen GmbH", /* 1168 */ "Matting AB", /* 1169 */ "SOREX - Wireless Solutions GmbH", /* 1170 */ "ADC Technology, Inc.", /* 1171 */ "Lynxemi Pte Ltd", /* 1172 */ "SENNHEISER electronic GmbH & Co. KG", /* 1173 */ "LMT Mercer Group, Inc", /* 1174 */ "Polymorphic Labs LLC", /* 1175 */ "Cochlear Limited", /* 1176 */ "METER Group, Inc. USA", /* 1177 */ "Ruuvi Innovations Ltd.", /* 1178 */ "Situne AS", /* 1179 */ "nVisti, LLC", /* 1180 */ "DyOcean", /* 1181 */ "Uhlmann & Zacher GmbH", /* 1182 */ "AND!XOR LLC", /* 1183 */ "tictote AB", /* 1184 */ "Vypin, LLC", /* 1185 */ "PNI Sensor Corporation", /* 1186 */ "ovrEngineered, LLC", /* 1187 */ "GT-tronics HK Ltd", /* 1188 */ "Herbert Waldmann GmbH & Co. KG", /* 1189 */ "Guangzhou FiiO Electronics Technology Co.,Ltd", /* 1190 */ "Vinetech Co., Ltd", /* 1191 */ "Dallas Logic Corporation", /* 1192 */ "BioTex, Inc.", /* 1193 */ "DISCOVERY SOUND TECHNOLOGY, LLC", /* 1194 */ "LINKIO SAS", /* 1195 */ "Harbortronics, Inc.", /* 1196 */ "Undagrid B.V.", /* 1197 */ "Shure Inc", /* 1198 */ "ERM Electronic Systems LTD", /* 1199 */ "BIOROWER Handelsagentur GmbH", /* 1200 */ "Weba Sport und Med. Artikel GmbH", /* 1201 */ "Kartographers Technologies Pvt. Ltd.", /* 1202 */ "The Shadow on the Moon", /* 1203 */ "mobike (Hong Kong) Limited", /* 1204 */ "Inuheat Group AB", /* 1205 */ "Swiftronix AB", /* 1206 */ "Diagnoptics Technologies", /* 1207 */ "Analog Devices, Inc.", /* 1208 */ "Soraa Inc.", /* 1209 */ "CSR Building Products Limited", /* 1210 */ "Crestron Electronics, Inc.", /* 1211 */ "Neatebox Ltd", /* 1212 */ "Draegerwerk AG & Co. KGaA", /* 1213 */ "AlbynMedical", /* 1214 */ "Averos FZCO", /* 1215 */ "VIT Initiative, LLC", /* 1216 */ "Statsports International", /* 1217 */ "Sospitas, s.r.o.", /* 1218 */ "Dmet Products Corp.", /* 1219 */ "Mantracourt Electronics Limited", /* 1220 */ "TeAM Hutchins AB", /* 1221 */ "Seibert Williams Glass, LLC", /* 1222 */ "Insta GmbH", /* 1223 */ "Svantek Sp. z o.o.", /* 1224 */ "Shanghai Flyco Electrical Appliance Co., Ltd.", /* 1225 */ "Thornwave Labs Inc", /* 1226 */ "Steiner-Optik GmbH", /* 1227 */ "Novo Nordisk A/S", /* 1228 */ "Enflux Inc.", /* 1229 */ "Safetech Products LLC", /* 1230 */ "GOOOLED S.R.L.", /* 1231 */ "DOM Sicherheitstechnik GmbH & Co. KG", /* 1232 */ "Olympus Corporation", /* 1233 */ "KTS GmbH", /* 1234 */ "Anloq Technologies Inc.", /* 1235 */ "Queercon, Inc", /* 1236 */ "5th Element Ltd", /* 1237 */ "Gooee Limited", /* 1238 */ "LUGLOC LLC", /* 1239 */ "Blincam, Inc.", /* 1240 */ "FUJIFILM Corporation", /* 1241 */ "RandMcNally", /* 1242 */ "Franceschi Marina snc", /* 1243 */ "Engineered Audio, LLC.", /* 1244 */ "IOTTIVE (OPC) PRIVATE LIMITED", /* 1245 */ "4MOD Technology", /* 1246 */ "Lutron Electronics Co., Inc.", /* 1247 */ "Emerson", /* 1248 */ "Guardtec, Inc.", /* 1249 */ "REACTEC LIMITED", /* 1250 */ "EllieGrid", /* 1251 */ "Under Armour", /* 1252 */ "Woodenshark", /* 1253 */ "Avack Oy", /* 1254 */ "Smart Solution Technology, Inc.", /* 1255 */ "REHABTRONICS INC.", /* 1256 */ "STABILO International", /* 1257 */ "Busch Jaeger Elektro GmbH", /* 1258 */ "Pacific Bioscience Laboratories, Inc", /* 1259 */ "Bird Home Automation GmbH", /* 1260 */ "Motorola Solutions", /* 1261 */ "R9 Technology, Inc.", /* 1262 */ "Auxivia", /* 1263 */ "DaisyWorks, Inc", /* 1264 */ "Kosi Limited", /* 1265 */ "Theben AG", /* 1266 */ "InDreamer Techsol Private Limited", /* 1267 */ "Cerevast Medical", /* 1268 */ "ZanCompute Inc.", /* 1269 */ "Pirelli Tyre S.P.A.", /* 1270 */ "McLear Limited", /* 1271 */ "Shenzhen Huiding Technology Co.,Ltd.", /* 1272 */ "Convergence Systems Limited", /* 1273 */ "Interactio", /* 1274 */ "Androtec GmbH", /* 1275 */ "Benchmark Drives GmbH & Co. KG", /* 1276 */ "SwingLync L. L. C.", /* 1277 */ "Tapkey GmbH", /* 1278 */ "Woosim Systems Inc.", /* 1279 */ "Microsemi Corporation", /* 1280 */ "Wiliot LTD.", /* 1281 */ "Polaris IND", /* 1282 */ "Specifi-Kali LLC", /* 1283 */ "Locoroll, Inc", /* 1284 */ "PHYPLUS Inc", /* 1285 */ "Inplay Technologies LLC", /* 1286 */ "Hager", /* 1287 */ "Yellowcog", /* 1288 */ "Axes System sp. z o. o.", /* 1289 */ "myLIFTER Inc.", /* 1290 */ "Shake-on B.V.", /* 1291 */ "Vibrissa Inc.", /* 1292 */ "OSRAM GmbH", /* 1293 */ "TRSystems GmbH", /* 1294 */ "Yichip Microelectronics (Hangzhou) Co.,Ltd.", /* 1295 */ "Foundation Engineering LLC", /* 1296 */ "UNI-ELECTRONICS, INC.", /* 1297 */ "Brookfield Equinox LLC", /* 1298 */ "Soprod SA", /* 1299 */ "9974091 Canada Inc.", /* 1300 */ "FIBRO GmbH", /* 1301 */ "RB Controls Co., Ltd.", /* 1302 */ "Footmarks", /* 1303 */ "Amtronic Sverige AB (formerly Amcore AB)", /* 1304 */ "MAMORIO.inc", /* 1305 */ "Tyto Life LLC", /* 1306 */ "Leica Camera AG", /* 1307 */ "Angee Technologies Ltd.", /* 1308 */ "EDPS", /* 1309 */ "OFF Line Co., Ltd.", /* 1310 */ "Detect Blue Limited", /* 1311 */ "Setec Pty Ltd", /* 1312 */ "Target Corporation", /* 1313 */ "IAI Corporation", /* 1314 */ "NS Tech, Inc.", /* 1315 */ "MTG Co., Ltd.", /* 1316 */ "Hangzhou iMagic Technology Co., Ltd", /* 1317 */ "HONGKONG NANO IC TECHNOLOGIES CO., LIMITED", /* 1318 */ "Honeywell International Inc.", /* 1319 */ "Albrecht JUNG", /* 1320 */ "Lunera Lighting Inc.", /* 1321 */ "Lumen UAB", /* 1322 */ "Keynes Controls Ltd", /* 1323 */ "Novartis AG", /* 1324 */ "Geosatis SA", /* 1325 */ "EXFO, Inc.", /* 1326 */ "LEDVANCE GmbH", /* 1327 */ "Center ID Corp.", /* 1328 */ "Adolene, Inc.", /* 1329 */ "D&M Holdings Inc.", /* 1330 */ "CRESCO Wireless, Inc.", /* 1331 */ "Nura Operations Pty Ltd", /* 1332 */ "Frontiergadget, Inc.", /* 1333 */ "Smart Component Technologies Limited", /* 1334 */ "ZTR Control Systems LLC", /* 1335 */ "MetaLogics Corporation", /* 1336 */ "Medela AG", /* 1337 */ "OPPLE Lighting Co., Ltd", /* 1338 */ "Savitech Corp.,", /* 1339 */ "prodigy", /* 1340 */ "Screenovate Technologies Ltd", /* 1341 */ "TESA SA", /* 1342 */ "CLIM8 LIMITED", /* 1343 */ "Silergy Corp", /* 1344 */ "SilverPlus, Inc", /* 1345 */ "Sharknet srl", /* 1346 */ "Mist Systems, Inc.", /* 1347 */ "MIWA LOCK CO.,Ltd", /* 1348 */ "OrthoSensor, Inc.", /* 1349 */ "Candy Hoover Group s.r.l", /* 1350 */ "Apexar Technologies S.A.", /* 1351 */ "LOGICDATA d.o.o.", /* 1352 */ "Knick Elektronische Messgeraete GmbH & Co. KG", /* 1353 */ "Smart Technologies and Investment Limited", /* 1354 */ "Linough Inc.", /* 1355 */ "Advanced Electronic Designs, Inc.", /* 1356 */ "Carefree Scott Fetzer Co Inc", /* 1357 */ "Sensome", /* 1358 */ "FORTRONIK storitve d.o.o.", /* 1359 */ "Sinnoz", /* 1360 */ "Versa Networks, Inc.", /* 1361 */ "Sylero", /* 1362 */ "Avempace SARL", /* 1363 */ "Nintendo Co., Ltd.", /* 1364 */ "National Instruments", /* 1365 */ "KROHNE Messtechnik GmbH", /* 1366 */ "Otodynamics Ltd", /* 1367 */ "Arwin Technology Limited", /* 1368 */ "benegear, inc.", /* 1369 */ "Newcon Optik", /* 1370 */ "CANDY HOUSE, Inc.", /* 1371 */ "FRANKLIN TECHNOLOGY INC", /* 1372 */ "Lely", /* 1373 */ "Valve Corporation", /* 1374 */ "Hekatron Vertriebs GmbH", /* 1375 */ "PROTECH S.A.S. DI GIRARDI ANDREA & C.", /* 1376 */ "Sarita CareTech APS (formerly Sarita CareTech IVS)", /* 1377 */ "Finder S.p.A.", /* 1378 */ "Thalmic Labs Inc.", /* 1379 */ "Steinel Vertrieb GmbH", /* 1380 */ "Beghelli Spa", /* 1381 */ "Beijing Smartspace Technologies Inc.", /* 1382 */ "CORE TRANSPORT TECHNOLOGIES NZ LIMITED", /* 1383 */ "Xiamen Everesports Goods Co., Ltd", /* 1384 */ "Bodyport Inc.", /* 1385 */ "Audionics System, INC.", /* 1386 */ "Flipnavi Co.,Ltd.", /* 1387 */ "Rion Co., Ltd.", /* 1388 */ "Long Range Systems, LLC", /* 1389 */ "Redmond Industrial Group LLC", /* 1390 */ "VIZPIN INC.", /* 1391 */ "BikeFinder AS", /* 1392 */ "Consumer Sleep Solutions LLC", /* 1393 */ "PSIKICK, INC.", /* 1394 */ "AntTail.com", /* 1395 */ "Lighting Science Group Corp.", /* 1396 */ "AFFORDABLE ELECTRONICS INC", /* 1397 */ "Integral Memory Plc", /* 1398 */ "Globalstar, Inc.", /* 1399 */ "True Wearables, Inc.", /* 1400 */ "Wellington Drive Technologies Ltd", /* 1401 */ "Ensemble Tech Private Limited", /* 1402 */ "OMNI Remotes", /* 1403 */ "Duracell U.S. Operations Inc.", /* 1404 */ "Toor Technologies LLC", /* 1405 */ "Instinct Performance", /* 1406 */ "Beco, Inc", /* 1407 */ "Scuf Gaming International, LLC", /* 1408 */ "ARANZ Medical Limited", /* 1409 */ "LYS TECHNOLOGIES LTD", /* 1410 */ "Breakwall Analytics, LLC", /* 1411 */ "Code Blue Communications", /* 1412 */ "Gira Giersiepen GmbH & Co. KG", /* 1413 */ "Hearing Lab Technology", /* 1414 */ "LEGRAND", /* 1415 */ "Derichs GmbH", /* 1416 */ "ALT-TEKNIK LLC", /* 1417 */ "Star Technologies", /* 1418 */ "START TODAY CO.,LTD.", /* 1419 */ "Maxim Integrated Products", /* 1420 */ "MERCK Kommanditgesellschaft auf Aktien", /* 1421 */ "Jungheinrich Aktiengesellschaft", /* 1422 */ "Oculus VR, LLC", /* 1423 */ "HENDON SEMICONDUCTORS PTY LTD", /* 1424 */ "Pur3 Ltd", /* 1425 */ "Viasat Group S.p.A.", /* 1426 */ "IZITHERM", /* 1427 */ "Spaulding Clinical Research", /* 1428 */ "Kohler Company", /* 1429 */ "Inor Process AB", /* 1430 */ "My Smart Blinds", /* 1431 */ "RadioPulse Inc", /* 1432 */ "rapitag GmbH", /* 1433 */ "Lazlo326, LLC.", /* 1434 */ "Teledyne Lecroy, Inc.", /* 1435 */ "Dataflow Systems Limited", /* 1436 */ "Macrogiga Electronics", /* 1437 */ "Tandem Diabetes Care", /* 1438 */ "Polycom, Inc.", /* 1439 */ "Fisher & Paykel Healthcare", /* 1440 */ "RCP Software Oy", /* 1441 */ "Shanghai Xiaoyi Technology Co.,Ltd.", /* 1442 */ "ADHERIUM(NZ) LIMITED", /* 1443 */ "Axiomware Systems Incorporated", /* 1444 */ "O. E. M. Controls, Inc.", /* 1445 */ "Kiiroo BV", /* 1446 */ "Telecon Mobile Limited", /* 1447 */ "Sonos Inc", /* 1448 */ "Tom Allebrandi Consulting", /* 1449 */ "Monidor", /* 1450 */ "Tramex Limited", /* 1451 */ "Nofence AS", /* 1452 */ "GoerTek Dynaudio Co., Ltd.", /* 1453 */ "INIA", /* 1454 */ "CARMATE MFG.CO.,LTD", /* 1455 */ "ONvocal", /* 1456 */ "NewTec GmbH", /* 1457 */ "Medallion Instrumentation Systems", /* 1458 */ "CAREL INDUSTRIES S.P.A.", /* 1459 */ "Parabit Systems, Inc.", /* 1460 */ "White Horse Scientific ltd", /* 1461 */ "verisilicon", /* 1462 */ "Elecs Industry Co.,Ltd.", /* 1463 */ "Beijing Pinecone Electronics Co.,Ltd.", /* 1464 */ "Ambystoma Labs Inc.", /* 1465 */ "Suzhou Pairlink Network Technology", /* 1466 */ "igloohome", /* 1467 */ "Oxford Metrics plc", /* 1468 */ "Leviton Mfg. Co., Inc.", /* 1469 */ "ULC Robotics Inc.", /* 1470 */ "RFID Global by Softwork SrL", /* 1471 */ "Real-World-Systems Corporation", /* 1472 */ "Nalu Medical, Inc.", /* 1473 */ "P.I.Engineering", /* 1474 */ "Grote Industries", /* 1475 */ "Runtime, Inc.", /* 1476 */ "Codecoup sp. z o.o. sp. k.", /* 1477 */ "SELVE GmbH & Co. KG", /* 1478 */ "Smart Animal Training Systems, LLC", /* 1479 */ "Lippert Components, INC", /* 1480 */ "SOMFY SAS", /* 1481 */ "TBS Electronics B.V.", /* 1482 */ "MHL Custom Inc", /* 1483 */ "LucentWear LLC", /* 1484 */ "WATTS ELECTRONICS", /* 1485 */ "RJ Brands LLC", /* 1486 */ "V-ZUG Ltd", /* 1487 */ "Biowatch SA", /* 1488 */ "Anova Applied Electronics", /* 1489 */ "Lindab AB", /* 1490 */ "frogblue TECHNOLOGY GmbH", /* 1491 */ "Acurable Limited", /* 1492 */ "LAMPLIGHT Co., Ltd.", /* 1493 */ "TEGAM, Inc.", /* 1494 */ "Zhuhai Jieli technology Co.,Ltd", /* 1495 */ "modum.io AG", /* 1496 */ "Farm Jenny LLC", /* 1497 */ "Toyo Electronics Corporation", /* 1498 */ "Applied Neural Research Corp", /* 1499 */ "Avid Identification Systems, Inc.", /* 1500 */ "Petronics Inc.", /* 1501 */ "essentim GmbH", /* 1502 */ "QT Medical INC.", /* 1503 */ "VIRTUALCLINIC.DIRECT LIMITED", /* 1504 */ "Viper Design LLC", /* 1505 */ "Human, Incorporated", /* 1506 */ "stAPPtronics GmbH", /* 1507 */ "Elemental Machines, Inc.", /* 1508 */ "Taiyo Yuden Co., Ltd", /* 1509 */ "INEO ENERGY& SYSTEMS", /* 1510 */ "Motion Instruments Inc.", /* 1511 */ "PressurePro", /* 1512 */ "COWBOY", /* 1513 */ "iconmobile GmbH", /* 1514 */ "ACS-Control-System GmbH", /* 1515 */ "Bayerische Motoren Werke AG", /* 1516 */ "Gycom Svenska AB", /* 1517 */ "Fuji Xerox Co., Ltd", /* 1518 */ "Glide Inc.", /* 1519 */ "SIKOM AS", /* 1520 */ "beken", /* 1521 */ "The Linux Foundation", /* 1522 */ "Try and E CO.,LTD.", /* 1523 */ "SeeScan", /* 1524 */ "Clearity, LLC", /* 1525 */ "GS TAG", /* 1526 */ "DPTechnics", /* 1527 */ "TRACMO, INC.", /* 1528 */ "Anki Inc.", /* 1529 */ "Hagleitner Hygiene International GmbH", /* 1530 */ "Konami Sports Life Co., Ltd.", /* 1531 */ "Arblet Inc.", /* 1532 */ "Masbando GmbH", /* 1533 */ "Innoseis", /* 1534 */ "Niko nv", /* 1535 */ "Wellnomics Ltd", /* 1536 */ "iRobot Corporation", /* 1537 */ "Schrader Electronics", /* 1538 */ "Geberit International AG", /* 1539 */ "Fourth Evolution Inc", /* 1540 */ "Cell2Jack LLC", /* 1541 */ "FMW electronic Futterer u. Maier-Wolf OHG", /* 1542 */ "John Deere", /* 1543 */ "Rookery Technology Ltd", /* 1544 */ "KeySafe-Cloud", /* 1545 */ "BUCHI Labortechnik AG", /* 1546 */ "IQAir AG", /* 1547 */ "Triax Technologies Inc", /* 1548 */ "Vuzix Corporation", /* 1549 */ "TDK Corporation", /* 1550 */ "Blueair AB", /* 1551 */ "Signify Netherlands", /* 1552 */ "ADH GUARDIAN USA LLC", /* 1553 */ "Beurer GmbH", /* 1554 */ "Playfinity AS", /* 1555 */ "Hans Dinslage GmbH", /* 1556 */ "OnAsset Intelligence, Inc.", /* 1557 */ "INTER ACTION Corporation", /* 1558 */ "OS42 UG (haftungsbeschraenkt)", /* 1559 */ "WIZCONNECTED COMPANY LIMITED", /* 1560 */ "Audio-Technica Corporation", /* 1561 */ "Six Guys Labs, s.r.o.", /* 1562 */ "R.W. Beckett Corporation", /* 1563 */ "silex technology, inc.", /* 1564 */ "Univations Limited", /* 1565 */ "SENS Innovation ApS", /* 1566 */ "Diamond Kinetics, Inc.", /* 1567 */ "Phrame Inc.", /* 1568 */ "Forciot Oy", /* 1569 */ "Noordung d.o.o.", /* 1570 */ "Beam Labs, LLC", /* 1571 */ "Philadelphia Scientific (U.K.) Limited", /* 1572 */ "Biovotion AG", /* 1573 */ "Square Panda, Inc.", /* 1574 */ "Amplifico", /* 1575 */ "WEG S.A.", /* 1576 */ "Ensto Oy", /* 1577 */ "PHONEPE PVT LTD", /* 1578 */ "Lunatico Astronomia SL", /* 1579 */ "MinebeaMitsumi Inc.", /* 1580 */ "ASPion GmbH", /* 1581 */ "Vossloh-Schwabe Deutschland GmbH", /* 1582 */ "Procept", /* 1583 */ "ONKYO Corporation", /* 1584 */ "Asthrea D.O.O.", /* 1585 */ "Fortiori Design LLC", /* 1586 */ "Hugo Muller GmbH & Co KG", /* 1587 */ "Wangi Lai PLT", /* 1588 */ "Fanstel Corp", /* 1589 */ "Crookwood", /* 1590 */ "ELECTRONICA INTEGRAL DE SONIDO S.A.", /* 1591 */ "GiP Innovation Tools GmbH", /* 1592 */ "LX SOLUTIONS PTY LIMITED", /* 1593 */ "Shenzhen Minew Technologies Co., Ltd.", /* 1594 */ "Prolojik Limited", /* 1595 */ "Kromek Group Plc", /* 1596 */ "Contec Medical Systems Co., Ltd.", /* 1597 */ "Xradio Technology Co.,Ltd.", /* 1598 */ "The Indoor Lab, LLC", /* 1599 */ "LDL TECHNOLOGY", /* 1600 */ "Parkifi", /* 1601 */ "Revenue Collection Systems FRANCE SAS", /* 1602 */ "Bluetrum Technology Co.,Ltd", /* 1603 */ "makita corporation", /* 1604 */ "Apogee Instruments", /* 1605 */ "BM3", /* 1606 */ "SGV Group Holding GmbH & Co. KG", /* 1607 */ "MED-EL", /* 1608 */ "Ultune Technologies", /* 1609 */ "Ryeex Technology Co.,Ltd.", /* 1610 */ "Open Research Institute, Inc.", /* 1611 */ "Scale-Tec, Ltd", /* 1612 */ "Zumtobel Group AG", /* 1613 */ "iLOQ Oy", /* 1614 */ "KRUXWorks Technologies Private Limited", /* 1615 */ "Digital Matter Pty Ltd", /* 1616 */ "Coravin, Inc.", /* 1617 */ "Stasis Labs, Inc.", /* 1618 */ "ITZ Innovations- und Technologiezentrum GmbH", /* 1619 */ "Meggitt SA", /* 1620 */ "Ledlenser GmbH & Co. KG", /* 1621 */ "Renishaw PLC", /* 1622 */ "ZhuHai AdvanPro Technology Company Limited", /* 1623 */ "Meshtronix Limited", /* 1624 */ "Payex Norge AS", /* 1625 */ "UnSeen Technologies Oy", /* 1626 */ "Zound Industries International AB", /* 1627 */ "Sesam Solutions BV", /* 1628 */ "PixArt Imaging Inc.", /* 1629 */ "Panduit Corp.", /* 1630 */ "Alo AB", /* 1631 */ "Ricoh Company Ltd", /* 1632 */ "RTC Industries, Inc.", /* 1633 */ "Mode Lighting Limited", /* 1634 */ "Particle Industries, Inc.", /* 1635 */ "Advanced Telemetry Systems, Inc.", /* 1636 */ "RHA TECHNOLOGIES LTD", /* 1637 */ "Pure International Limited", /* 1638 */ "WTO Werkzeug-Einrichtungen GmbH", /* 1639 */ "Spark Technology Labs Inc.", /* 1640 */ "Bleb Technology srl", /* 1641 */ "Livanova USA, Inc.", /* 1642 */ "Brady Worldwide Inc.", /* 1643 */ "DewertOkin GmbH", /* 1644 */ "Ztove ApS", /* 1645 */ "Venso EcoSolutions AB", /* 1646 */ "Eurotronik Kranj d.o.o.", /* 1647 */ "Hug Technology Ltd", /* 1648 */ "Gema Switzerland GmbH", /* 1649 */ "Buzz Products Ltd.", /* 1650 */ "Kopi", /* 1651 */ "Innova Ideas Limited", /* 1652 */ "BeSpoon", /* 1653 */ "Deco Enterprises, Inc.", /* 1654 */ "Expai Solutions Private Limited", /* 1655 */ "Innovation First, Inc.", /* 1656 */ "SABIK Offshore GmbH", /* 1657 */ "4iiii Innovations Inc.", /* 1658 */ "The Energy Conservatory, Inc.", /* 1659 */ "I.FARM, INC.", /* 1660 */ "Tile, Inc.", /* 1661 */ "Form Athletica Inc.", /* 1662 */ "MbientLab Inc", /* 1663 */ "NETGRID S.N.C. DI BISSOLI MATTEO, CAMPOREALE SIMONE, TOGNETTI FEDERICO", /* 1664 */ "Mannkind Corporation", /* 1665 */ "Trade FIDES a.s.", /* 1666 */ "Photron Limited", /* 1667 */ "Eltako GmbH", /* 1668 */ "Dermalapps, LLC", /* 1669 */ "Greenwald Industries", /* 1670 */ "inQs Co., Ltd.", /* 1671 */ "Cherry GmbH", /* 1672 */ "Amsted Digital Solutions Inc.", /* 1673 */ "Tacx b.v.", /* 1674 */ "Raytac Corporation", /* 1675 */ "Jiangsu Teranovo Tech Co., Ltd.", /* 1676 */ "Changzhou Sound Dragon Electronics and Acoustics Co., Ltd", /* 1677 */ "JetBeep Inc.", /* 1678 */ "Razer Inc.", /* 1679 */ "JRM Group Limited", /* 1680 */ "Eccrine Systems, Inc.", /* 1681 */ "Curie Point AB", /* 1682 */ "Georg Fischer AG", /* 1683 */ "Hach - Danaher", /* 1684 */ "T&A Laboratories LLC", /* 1685 */ "Koki Holdings Co., Ltd.", /* 1686 */ "Gunakar Private Limited", /* 1687 */ "Stemco Products Inc", /* 1688 */ "Wood IT Security, LLC", /* 1689 */ "RandomLab SAS", /* 1690 */ "Adero, Inc. (formerly as TrackR, Inc.)", /* 1691 */ "Dragonchip Limited", /* 1692 */ "Noomi AB", /* 1693 */ "Vakaros LLC", /* 1694 */ "Delta Electronics, Inc.", /* 1695 */ "FlowMotion Technologies AS", /* 1696 */ "OBIQ Location Technology Inc.", /* 1697 */ "Cardo Systems, Ltd", /* 1698 */ "Globalworx GmbH", /* 1699 */ "Nymbus, LLC", /* 1700 */ "Sanyo Techno Solutions Tottori Co., Ltd.", /* 1701 */ "TEKZITEL PTY LTD", /* 1702 */ "Roambee Corporation", /* 1703 */ "Chipsea Technologies (ShenZhen) Corp.", /* 1704 */ "GD Midea Air-Conditioning Equipment Co., Ltd.", /* 1705 */ "Soundmax Electronics Limited", /* 1706 */ "Produal Oy", /* 1707 */ "HMS Industrial Networks AB", /* 1708 */ "Ingchips Technology Co., Ltd.", /* 1709 */ "InnovaSea Systems Inc.", /* 1710 */ "SenseQ Inc.", /* 1711 */ "Shoof Technologies", /* 1712 */ "BRK Brands, Inc.", /* 1713 */ "SimpliSafe, Inc.", /* 1714 */ "Tussock Innovation 2013 Limited", /* 1715 */ "The Hablab ApS", /* 1716 */ "Sencilion Oy", /* 1717 */ "Wabilogic Ltd.", /* 1718 */ "Sociometric Solutions, Inc.", /* 1719 */ "iCOGNIZE GmbH", /* 1720 */ "ShadeCraft, Inc", /* 1721 */ "Beflex Inc.", /* 1722 */ "Beaconzone Ltd", /* 1723 */ "Leaftronix Analogic Solutions Private Limited", /* 1724 */ "TWS Srl", /* 1725 */ "ABB Oy", /* 1726 */ "HitSeed Oy", /* 1727 */ "Delcom Products Inc.", /* 1728 */ "CAME S.p.A.", /* 1729 */ "Alarm.com Holdings, Inc", /* 1730 */ "Measurlogic Inc.", /* 1731 */ "King I Electronics.Co.,Ltd", /* 1732 */ "Dream Labs GmbH", /* 1733 */ "Urban Compass, Inc", /* 1734 */ "Simm Tronic Limited", /* 1735 */ "Somatix Inc", /* 1736 */ "Storz & Bickel GmbH & Co. KG", /* 1737 */ "MYLAPS B.V.", /* 1738 */ "Shenzhen Zhongguang Infotech Technology Development Co., Ltd", /* 1739 */ "Dyeware, LLC", /* 1740 */ "Dongguan SmartAction Technology Co.,Ltd.", /* 1741 */ "DIG Corporation", /* 1742 */ "FIOR & GENTZ", /* 1743 */ "Belparts N.V.", /* 1744 */ "Etekcity Corporation", /* 1745 */ "Meyer Sound Laboratories, Incorporated", /* 1746 */ "CeoTronics AG", /* 1747 */ "TriTeq Lock and Security, LLC", /* 1748 */ "DYNAKODE TECHNOLOGY PRIVATE LIMITED", /* 1749 */ "Sensirion AG", /* 1750 */ "JCT Healthcare Pty Ltd", /* 1751 */ "FUBA Automotive Electronics GmbH", /* 1752 */ "AW Company", /* 1753 */ "Shanghai Mountain View Silicon Co.,Ltd.", /* 1754 */ "Zliide Technologies ApS", /* 1755 */ "Automatic Labs, Inc.", /* 1756 */ "Industrial Network Controls, LLC", /* 1757 */ "Intellithings Ltd.", /* 1758 */ "Navcast, Inc.", /* 1759 */ "Hubbell Lighting, Inc.", /* 1760 */ "Avaya", /* 1761 */ "Milestone AV Technologies LLC", /* 1762 */ "Alango Technologies Ltd", /* 1763 */ "Spinlock Ltd", /* 1764 */ "Aluna", /* 1765 */ "OPTEX CO.,LTD.", /* 1766 */ "NIHON DENGYO KOUSAKU", /* 1767 */ "VELUX A/S", /* 1768 */ "Almendo Technologies GmbH", /* 1769 */ "Zmartfun Electronics, Inc.", /* 1770 */ "SafeLine Sweden AB", /* 1771 */ "Houston Radar LLC", /* 1772 */ "Sigur", /* 1773 */ "J Neades Ltd", /* 1774 */ "Avantis Systems Limited", /* 1775 */ "ALCARE Co., Ltd.", /* 1776 */ "Chargy Technologies, SL", /* 1777 */ "Shibutani Co., Ltd.", /* 1778 */ "Trapper Data AB", /* 1779 */ "Alfred International Inc.", /* 1780 */ "Near Field Solutions Ltd", /* 1781 */ "Vigil Technologies Inc.", /* 1782 */ "Vitulo Plus BV", /* 1783 */ "WILKA Schliesstechnik GmbH", /* 1784 */ "BodyPlus Technology Co.,Ltd", /* 1785 */ "happybrush GmbH", /* 1786 */ "Enequi AB", /* 1787 */ "Sartorius AG", /* 1788 */ "Tom Communication Industrial Co.,Ltd.", /* 1789 */ "ESS Embedded System Solutions Inc.", /* 1790 */ "Mahr GmbH", /* 1791 */ "Redpine Signals Inc", /* 1792 */ "TraqFreq LLC", /* 1793 */ "PAFERS TECH", /* 1794 */ "Akciju sabiedriba \"SAF TEHNIKA\"", /* 1795 */ "Beijing Jingdong Century Trading Co., Ltd.", /* 1796 */ "JBX Designs Inc.", /* 1797 */ "AB Electrolux", /* 1798 */ "Wernher von Braun Center for ASdvanced Research", /* 1799 */ "Essity Hygiene and Health Aktiebolag", /* 1800 */ "Be Interactive Co., Ltd", /* 1801 */ "Carewear Corp.", /* 1802 */ "Huf Hülsbeck & Fürst GmbH & Co. KG", /* 1803 */ "Element Products, Inc.", /* 1804 */ "Beijing Winner Microelectronics Co.,Ltd", /* 1805 */ "SmartSnugg Pty Ltd", /* 1806 */ "FiveCo Sarl", /* 1807 */ "California Things Inc.", /* 1808 */ "Audiodo AB", /* 1809 */ "ABAX AS", /* 1810 */ "Bull Group Company Limited", /* 1811 */ "Respiri Limited", /* 1812 */ "MindPeace Safety LLC", /* 1813 */ "Vgyan Solutions", /* 1814 */ "Altonics", /* 1815 */ "iQsquare BV", /* 1816 */ "IDIBAIX enginneering", /* 1817 */ "ECSG", /* 1818 */ "REVSMART WEARABLE HK CO LTD", /* 1819 */ "Precor", /* 1820 */ "F5 Sports, Inc", /* 1821 */ "exoTIC Systems", /* 1822 */ "DONGGUAN HELE ELECTRONICS CO., LTD", /* 1823 */ "Dongguan Liesheng Electronic Co.Ltd", /* 1824 */ "Oculeve, Inc.", /* 1825 */ "Clover Network, Inc.", /* 1826 */ "Xiamen Eholder Electronics Co.Ltd", /* 1827 */ "Ford Motor Company", /* 1828 */ "Guangzhou SuperSound Information Technology Co.,Ltd", /* 1829 */ "Tedee Sp. z o.o.", /* 1830 */ "PHC Corporation", /* 1831 */ "STALKIT AS", /* 1832 */ "Eli Lilly and Company", /* 1833 */ "SwaraLink Technologies", /* 1834 */ "JMR embedded systems GmbH", /* 1835 */ "Bitkey Inc.", /* 1836 */ "GWA Hygiene GmbH", /* 1837 */ "Safera Oy", /* 1838 */ "Open Platform Systems LLC", /* 1839 */ "OnePlus Electronics (Shenzhen) Co., Ltd.", /* 1840 */ "Wildlife Acoustics, Inc.", /* 1841 */ "ABLIC Inc.", /* 1842 */ "Dairy Tech, Inc.", /* 1843 */ "Iguanavation, Inc.", /* 1844 */ "DiUS Computing Pty Ltd", /* 1845 */ "UpRight Technologies LTD", /* 1846 */ "FrancisFund, LLC", /* 1847 */ "LLC Navitek", /* 1848 */ "Glass Security Pte Ltd", /* 1849 */ "Jiangsu Qinheng Co., Ltd.", /* 1850 */ "Chandler Systems Inc.", /* 1851 */ "Fantini Cosmi s.p.a.", /* 1852 */ "Acubit ApS", /* 1853 */ "Beijing Hao Heng Tian Tech Co., Ltd.", /* 1854 */ "Bluepack S.R.L.", /* 1855 */ "Beijing Unisoc Technologies Co., Ltd.", /* 1856 */ "HITIQ LIMITED", /* 1857 */ "MAC SRL", /* 1858 */ "DML LLC", /* 1859 */ "Sanofi", /* 1860 */ "SOCOMEC", /* 1861 */ "WIZNOVA, Inc.", /* 1862 */ "Seitec Elektronik GmbH", /* 1863 */ "OR Technologies Pty Ltd", /* 1864 */ "GuangZhou KuGou Computer Technology Co.Ltd", /* 1865 */ "DIAODIAO (Beijing) Technology Co., Ltd.", /* 1866 */ "Illusory Studios LLC", /* 1867 */ "Sarvavid Software Solutions LLP", /* 1868 */ "iopool s.a.", /* 1869 */ "Amtech Systems, LLC", /* 1870 */ "EAGLE DETECTION SA", /* 1871 */ "MEDIATECH S.R.L.", /* 1872 */ "Hamilton Professional Services of Canada Incorporated", /* 1873 */ "Changsha JEMO IC Design Co.,Ltd", /* 1874 */ "Elatec GmbH", /* 1875 */ "JLG Industries, Inc.", /* 1876 */ "Michael Parkin", /* 1877 */ "Brother Industries, Ltd", /* 1878 */ "Lumens For Less, Inc", /* 1879 */ "ELA Innovation", /* 1880 */ "umanSense AB", /* 1881 */ "Shanghai InGeek Cyber Security Co., Ltd.", /* 1882 */ "HARMAN CO.,LTD.", /* 1883 */ "Smart Sensor Devices AB", /* 1884 */ "Antitronics Inc.", /* 1885 */ "RHOMBUS SYSTEMS, INC.", /* 1886 */ "Katerra Inc.", /* 1887 */ "Remote Solution Co., LTD.", /* 1888 */ "Vimar SpA", /* 1889 */ "Mantis Tech LLC", /* 1890 */ "TerOpta Ltd", /* 1891 */ "PIKOLIN S.L.", /* 1892 */ "WWZN Information Technology Company Limited", /* 1893 */ "Voxx International", /* 1894 */ "ART AND PROGRAM, INC.", /* 1895 */ "NITTO DENKO ASIA TECHNICAL CENTRE PTE. LTD.", /* 1896 */ "Peloton Interactive Inc.", /* 1897 */ "Force Impact Technologies", /* 1898 */ "Dmac Mobile Developments, LLC", /* 1899 */ "Engineered Medical Technologies", /* 1900 */ "Noodle Technology inc", /* 1901 */ "Graesslin GmbH", /* 1902 */ "WuQi technologies, Inc.", /* 1903 */ "Successful Endeavours Pty Ltd", /* 1904 */ "InnoCon Medical ApS", /* 1905 */ "Corvex Connected Safety", /* 1906 */ "Thirdwayv Inc.", /* 1907 */ "Echoflex Solutions Inc.", /* 1908 */ "C-MAX Asia Limited", /* 1909 */ "4eBusiness GmbH", /* 1910 */ "Cyber Transport Control GmbH", /* 1911 */ "Cue", /* 1912 */ "KOAMTAC INC.", /* 1913 */ "Loopshore Oy", /* 1914 */ "Niruha Systems Private Limited", /* 1915 */ "AmaterZ, Inc.", /* 1916 */ "radius co., ltd.", /* 1917 */ "Sensority, s.r.o.", /* 1918 */ "Sparkage Inc.", /* 1919 */ "Glenview Software Corporation", /* 1920 */ "Finch Technologies Ltd.", /* 1921 */ "Qingping Technology (Beijing) Co., Ltd.", /* 1922 */ "DeviceDrive AS", /* 1923 */ "ESEMBER LIMITED LIABILITY COMPANY", /* 1924 */ "audifon GmbH & Co. KG", /* 1925 */ "O2 Micro, Inc.", /* 1926 */ "HLP Controls Pty Limited", /* 1927 */ "Pangaea Solution", /* 1928 */ "BubblyNet, LLC", /* 1930 */ "The Wildflower Foundation", /* 1931 */ "Optikam Tech Inc.", /* 1932 */ "MINIBREW HOLDING B.V", /* 1933 */ "Cybex GmbH", /* 1934 */ "FUJIMIC NIIGATA, INC.", /* 1935 */ "Hanna Instruments, Inc.", /* 1936 */ "KOMPAN A/S", /* 1937 */ "Scosche Industries, Inc.", /* 1938 */ "Provo Craft", /* 1939 */ "AEV spol. s r.o.", /* 1940 */ "The Coca-Cola Company", /* 1941 */ "GASTEC CORPORATION", /* 1942 */ "StarLeaf Ltd", /* 1943 */ "Water-i.d. GmbH", /* 1944 */ "HoloKit, Inc.", /* 1945 */ "PlantChoir Inc.", /* 1946 */ "GuangDong Oppo Mobile Telecommunications Corp., Ltd.", /* 1947 */ "CST ELECTRONICS (PROPRIETARY) LIMITED", /* 1948 */ "Sky UK Limited", /* 1949 */ "Digibale Pty Ltd", /* 1950 */ "Smartloxx GmbH", /* 1951 */ "Pune Scientific LLP", /* 1952 */ "Regent Beleuchtungskorper AG", /* 1953 */ "Apollo Neuroscience, Inc.", /* 1954 */ "Roku, Inc.", /* 1955 */ "Comcast Cable", /* 1956 */ "Xiamen Mage Information Technology Co., Ltd.", /* 1957 */ "RAB Lighting, Inc.", /* 1958 */ "Musen Connect, Inc.", /* 1959 */ "Zume, Inc.", /* 1960 */ "conbee GmbH", /* 1961 */ "Bruel & Kjaer Sound & Vibration", /* 1962 */ "The Kroger Co.", /* 1963 */ "Granite River Solutions, Inc.", /* 1964 */ "LoupeDeck Oy", /* 1965 */ "New H3C Technologies Co.,Ltd", /* 1966 */ "Aurea Solucoes Tecnologicas Ltda.", /* 1967 */ "Hong Kong Bouffalo Lab Limited", /* 1968 */ "GV Concepts Inc.", /* 1969 */ "Thomas Dynamics, LLC", /* 1970 */ "Moeco IOT Inc.", /* 1971 */ "2N TELEKOMUNIKACE a.s.", /* 1972 */ "Hormann KG Antriebstechnik", /* 1973 */ "CRONO CHIP, S.L.", /* 1974 */ "Soundbrenner Limited", /* 1975 */ "ETABLISSEMENTS GEORGES RENAULT", /* 1976 */ "iSwip", /* 1977 */ "Epona Biotec Limited", /* 1978 */ "Battery-Biz Inc.", /* 1979 */ "EPIC S.R.L.", /* 1980 */ "KD CIRCUITS LLC", /* 1981 */ "Genedrive Diagnostics Ltd", /* 1982 */ "Axentia Technologies AB", /* 1983 */ "REGULA Ltd.", /* 1984 */ "Biral AG", /* 1985 */ "A.W. Chesterton Company", /* 1986 */ "Radinn AB", /* 1987 */ "CIMTechniques, Inc.", /* 1988 */ "Johnson Health Tech NA", /* 1989 */ "June Life, Inc.", /* 1990 */ "Bluenetics GmbH", /* 1991 */ "iaconicDesign Inc.", /* 1992 */ "WRLDS Creations AB", /* 1993 */ "Skullcandy, Inc.", /* 1994 */ "Modul-System HH AB", /* 1995 */ "West Pharmaceutical Services, Inc.", /* 1996 */ "Barnacle Systems Inc.", /* 1997 */ "Smart Wave Technologies Canada Inc", /* 1998 */ "Shanghai Top-Chip Microelectronics Tech. Co., LTD", /* 1999 */ "NeoSensory, Inc.", /* 2000 */ "Hangzhou Tuya Information Technology Co., Ltd", /* 2001 */ "Shanghai Panchip Microelectronics Co., Ltd", /* 2002 */ "React Accessibility Limited", /* 2003 */ "LIVNEX Co.,Ltd.", /* 2004 */ "Kano Computing Limited", /* 2005 */ "hoots classic GmbH", /* 2006 */ "ecobee Inc.", /* 2007 */ "Nanjing Qinheng Microelectronics Co., Ltd", /* 2008 */ "SOLUTIONS AMBRA INC.", /* 2009 */ "Micro-Design, Inc.", /* 2010 */ "STARLITE Co., Ltd.", /* 2011 */ "Remedee Labs", /* 2012 */ "ThingOS GmbH", /* 2013 */ "Linear Circuits", /* 2014 */ "Unlimited Engineering SL", /* 2015 */ "Snap-on Incorporated", /* 2016 */ "Edifier International Limited", /* 2017 */ "Lucie Labs", /* 2018 */ "Alfred Kaercher SE & Co. KG", /* 2019 */ "Audiowise Technology Inc.", /* 2020 */ "Geeksme S.L.", /* 2021 */ "Minut, Inc.", /* 2022 */ "Autogrow Systems Limited", /* 2023 */ "Komfort IQ, Inc.", /* 2024 */ "Packetcraft, Inc.", /* 2025 */ "Häfele GmbH & Co KG", /* 2026 */ "ShapeLog, Inc.", /* 2027 */ "NOVABASE S.R.L.", /* 2028 */ "Frecce LLC", /* 2029 */ "Joule IQ, INC.", /* 2030 */ "KidzTek LLC", /* 2031 */ "Aktiebolaget Sandvik Coromant", /* 2032 */ "e-moola.com Pty Ltd", /* 2033 */ "GSM Innovations Pty Ltd", /* 2034 */ "SERENE GROUP, INC", /* 2035 */ "DIGISINE ENERGYTECH CO. LTD.", /* 2036 */ "MEDIRLAB Orvosbiologiai Fejleszto Korlatolt Felelossegu Tarsasag", /* 2037 */ "Byton North America Corporation", /* 2038 */ "Shenzhen TonliScience and Technology Development Co.,Ltd", /* 2039 */ "Cesar Systems Ltd.", /* 2040 */ "quip NYC Inc.", /* 2041 */ "Direct Communication Solutions, Inc.", /* 2042 */ "Klipsch Group, Inc.", /* 2043 */ "Access Co., Ltd", /* 2044 */ "Renault SA", /* 2045 */ "JSK CO., LTD.", /* 2046 */ "BIROTA", /* 2047 */ "maxon motor ltd.", /* 2048 */ "Optek", /* 2049 */ "CRONUS ELECTRONICS LTD", /* 2050 */ "NantSound, Inc.", /* 2051 */ "Domintell s.a.", /* 2052 */ "Andon Health Co.,Ltd", /* 2053 */ "Urbanminded Ltd", /* 2054 */ "TYRI Sweden AB", /* 2055 */ "ECD Electronic Components GmbH Dresden", /* 2056 */ "SISTEMAS KERN, SOCIEDAD ANÓMINA", /* 2057 */ "Trulli Audio", /* 2058 */ "Altaneos", /* 2059 */ "Nanoleaf Canada Limited", /* 2060 */ "Ingy B.V.", /* 2061 */ "Azbil Co.", /* 2062 */ "TATTCOM LLC", /* 2063 */ "Paradox Engineering SA", /* 2064 */ "LECO Corporation", /* 2065 */ "Becker Antriebe GmbH", /* 2066 */ "Mstream Technologies., Inc.", /* 2067 */ "Flextronics International USA Inc.", /* 2068 */ "Ossur hf.", /* 2069 */ "SKC Inc", /* 2070 */ "SPICA SYSTEMS LLC", /* 2071 */ "Wangs Alliance Corporation", /* 2072 */ "tatwah SA", /* 2073 */ "Hunter Douglas Inc", /* 2074 */ "Shenzhen Conex", /* 2075 */ "DIM3", /* 2076 */ "Bobrick Washroom Equipment, Inc.", /* 2077 */ "Potrykus Holdings and Development LLC", /* 2078 */ "iNFORM Technology GmbH", /* 2079 */ "eSenseLab LTD", /* 2080 */ "Brilliant Home Technology, Inc.", /* 2081 */ "INOVA Geophysical, Inc.", /* 2082 */ "adafruit industries", /* 2083 */ "Nexite Ltd", /* 2084 */ "8Power Limited", /* 2085 */ "CME PTE. LTD.", /* 2086 */ "Hyundai Motor Company", /* 2087 */ "Kickmaker", /* 2088 */ "Shanghai Suisheng Information Technology Co., Ltd.", /* 2089 */ "HEXAGON", /* 2090 */ "Mitutoyo Corporation", /* 2091 */ "shenzhen fitcare electronics Co.,Ltd", /* 2092 */ "INGICS TECHNOLOGY CO., LTD.", /* 2093 */ "INCUS PERFORMANCE LTD.", /* 2094 */ "ABB S.p.A.", /* 2095 */ "Blippit AB", /* 2096 */ "Core Health and Fitness LLC", /* 2097 */ "Foxble, LLC", /* 2098 */ "Intermotive,Inc.", /* 2099 */ "Conneqtech B.V.", /* 2100 */ "RIKEN KEIKI CO., LTD.,", /* 2101 */ "Canopy Growth Corporation", /* 2102 */ "Bitwards Oy", /* 2103 */ "vivo Mobile Communication Co., Ltd.", /* 2104 */ "Etymotic Research, Inc.", /* 2105 */ "A puissance 3", /* 2106 */ "BPW Bergische Achsen Kommanditgesellschaft", /* 2107 */ "Piaggio Fast Forward", /* 2108 */ "BeerTech LTD", /* 2109 */ "Tokenize, Inc.", /* 2110 */ "Zorachka LTD", /* 2111 */ "D-Link Corp.", /* 2112 */ "Down Range Systems LLC", /* 2113 */ "General Luminaire (Shanghai) Co., Ltd.", /* 2114 */ "Tangshan HongJia electronic technology co., LTD.", /* 2115 */ "FRAGRANCE DELIVERY TECHNOLOGIES LTD", /* 2116 */ "Pepperl + Fuchs GmbH", /* 2117 */ "Dometic Corporation", /* 2118 */ "USound GmbH", /* 2119 */ "DNANUDGE LIMITED", /* 2120 */ "JUJU JOINTS CANADA CORP.", /* 2121 */ "Dopple Technologies B.V.", /* 2122 */ "ARCOM", /* 2123 */ "Biotechware SRL", /* 2124 */ "ORSO Inc.", /* 2125 */ "SafePort", /* 2126 */ "Carol Cole Company", /* 2127 */ "Embedded Fitness B.V.", /* 2128 */ "Yealink (Xiamen) Network Technology Co.,LTD", /* 2129 */ "Subeca, Inc.", /* 2130 */ "Cognosos, Inc.", /* 2131 */ "Pektron Group Limited", /* 2132 */ "Tap Sound System", /* 2133 */ "Helios Hockey, Inc.", /* 2134 */ "Canopy Growth Corporation", /* 2135 */ "Parsyl Inc", /* 2136 */ "SOUNDBOKS", /* 2137 */ "BlueUp", /* 2138 */ "DAKATECH", /* 2139 */ "RICOH ELECTRONIC DEVICES CO., LTD.", /* 2140 */ "ACOS CO.,LTD.", /* 2141 */ "Guilin Zhishen Information Technology Co.,Ltd.", /* 2142 */ "Krog Systems LLC", /* 2143 */ "COMPEGPS TEAM,SOCIEDAD LIMITADA", /* 2144 */ "Alflex Products B.V.", /* 2145 */ "SmartSensor Labs Ltd", /* 2146 */ "SmartDrive Inc.", /* 2147 */ "Yo-tronics Technology Co., Ltd.", /* 2148 */ "Rafaelmicro", /* 2149 */ "Emergency Lighting Products Limited", /* 2150 */ "LAONZ Co.,Ltd", /* 2151 */ "Western Digital Techologies, Inc.", /* 2152 */ "WIOsense GmbH & Co. KG", /* 2153 */ "EVVA Sicherheitstechnologie GmbH", /* 2154 */ "Odic Incorporated", /* 2155 */ "Pacific Track, LLC", /* 2156 */ "Revvo Technologies, Inc.", /* 2157 */ "Biometrika d.o.o.", /* 2158 */ "Vorwerk Elektrowerke GmbH & Co. KG", /* 2159 */ "Trackunit A/S", /* 2160 */ "Wyze Labs, Inc", /* 2161 */ "Dension Elektronikai Kft. (formerly: Dension Audio Systems Ltd.)", /* 2162 */ "11 Health & Technologies Limited", /* 2163 */ "Innophase Incorporated", /* 2164 */ "Treegreen Limited", /* 2165 */ "Berner International LLC", /* 2166 */ "SmartResQ ApS", /* 2167 */ "Tome, Inc.", /* 2168 */ "The Chamberlain Group, Inc.", /* 2169 */ "MIZUNO Corporation", /* 2170 */ "ZRF, LLC", /* 2171 */ "BYSTAMP", /* 2172 */ "Crosscan GmbH", /* 2173 */ "Konftel AB", /* 2174 */ "1bar.net Limited", /* 2175 */ "Phillips Connect Technologies LLC", /* 2176 */ "imagiLabs AB", /* 2177 */ "Optalert", /* 2178 */ "PSYONIC, Inc.", /* 2179 */ "Wintersteiger AG", /* 2180 */ "Controlid Industria, Comercio de Hardware e Servicos de Tecnologia Ltda", /* 2181 */ "LEVOLOR, INC.", /* 2182 */ "Xsens Technologies B.V.", /* 2183 */ "Hydro-Gear Limited Partnership", /* 2184 */ "EnPointe Fencing Pty Ltd", /* 2185 */ "XANTHIO", /* 2186 */ "sclak s.r.l.", /* 2187 */ "Tricorder Arraay Technologies LLC", /* 2188 */ "GB Solution co.,Ltd", /* 2189 */ "Soliton Systems K.K.", /* 2190 */ "GIGA-TMS INC", /* 2191 */ "Tait International Limited", /* 2192 */ "NICHIEI INTEC CO., LTD.", /* 2193 */ "SmartWireless GmbH & Co. KG", /* 2194 */ "Ingenieurbuero Birnfeld UG (haftungsbeschraenkt)", /* 2195 */ "Maytronics Ltd", /* 2196 */ "EPIFIT", /* 2197 */ "Gimer medical", /* 2198 */ "Nokian Renkaat Oyj", /* 2199 */ "Current Lighting Solutions LLC", /* 2200 */ "Sensibo, Inc.", /* 2201 */ "SFS unimarket AG", /* 2202 */ "Private limited company \"Teltonika\"", /* 2203 */ "Saucon Technologies", /* 2204 */ "Embedded Devices Co. Company", /* 2205 */ "J-J.A.D.E. Enterprise LLC", /* 2206 */ "i-SENS, inc.", /* 2207 */ "Witschi Electronic Ltd", /* 2208 */ "Aclara Technologies LLC", /* 2209 */ "EXEO TECH CORPORATION", /* 2210 */ "Epic Systems Co., Ltd.", /* 2211 */ "Hoffmann SE", /* 2212 */ "Realme Chongqing Mobile Telecommunications Corp., Ltd.", /* 2213 */ "UMEHEAL Ltd", /* 2214 */ "Intelligenceworks Inc.", /* 2215 */ "TGR 1.618 Limited", /* 2216 */ "Shanghai Kfcube Inc", /* 2217 */ "Fraunhofer IIS", /* 2218 */ "SZ DJI TECHNOLOGY CO.,LTD", /* 2219 */ "Coburn Technology, LLC", /* 2220 */ "Topre Corporation", /* 2221 */ "Kayamatics Limited", /* 2222 */ "Moticon ReGo AG", /* 2223 */ "Polidea Sp. z o.o.", /* 2224 */ "Trivedi Advanced Technologies LLC", /* 2225 */ "CORE|vision BV", /* 2226 */ "PF SCHWEISSTECHNOLOGIE GMBH", /* 2227 */ "IONIQ Skincare GmbH & Co. KG", /* 2228 */ "Sengled Co., Ltd.", /* 2229 */ "TransferFi", /* 2230 */ "Boehringer Ingelheim Vetmedica GmbH" }; return (m >= SIZE(t)? "?" : t[m]); } /* hci_manufacturer2str */ char const * hci_commands2str(uint8_t *commands, char *buffer, int size) { static char const * const t[][8] = { { /* byte 0 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 1 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 2 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 3 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 4 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 5 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 6 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 7 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 8 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 9 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 10 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 11 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 12 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 13 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 14 */ /* 0 */ " ", /* 1 */ "", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 15 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 16 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 17 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 18 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 19 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 20 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 21 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 22 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 23 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 24 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 25 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 26 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 27 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 28 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 29 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 30 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 31 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 32 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 33 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 34 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 35 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 36 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 37 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 38 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 39 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 40 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 41 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 42 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 43 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 44 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 45 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }}; if (buffer != NULL && size > 0) { int n, i, len0, len1; memset(buffer, 0, size); size--; for (n = 0; n < SIZE(t); n++) { for (i = 0; i < SIZE(t[n]); i++) { len0 = strlen(buffer); if (len0 >= size) goto done; if (commands[n] & (1 << i)) { if (len1 + strlen(t[n][i]) > 60) { len1 = 0; buffer[len0 - 1] = '\n'; } len1 += strlen(t[n][i]); strncat(buffer, t[n][i], size - len0); } } } } done: return (buffer); } /* hci_commands2str */ char const * hci_features2str(uint8_t *features, char *buffer, int size) { static char const * const t[][8] = { { /* byte 0 */ /* 0 */ "<3-Slot> ", /* 1 */ "<5-Slot> ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 1 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 2 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 3 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 4 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ "
", /* 6 */ " ", /* 7 */ "<3-Slot EDR ACL packets> " }, { /* byte 5 */ /* 0 */ "<5-Slot EDR ACL packets> ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ "<3-Slot EDR eSCO packets> " }, { /* byte 6 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 7 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }}; if (buffer != NULL && size > 0) { int n, i, len0, len1; memset(buffer, 0, size); len1 = 0; size--; for (n = 0; n < SIZE(t); n++) { for (i = 0; i < SIZE(t[n]); i++) { len0 = strlen(buffer); if (len0 >= size) goto done; if (features[n] & (1 << i)) { if (len1 + strlen(t[n][i]) > 60) { len1 = 0; buffer[len0 - 1] = '\n'; } len1 += strlen(t[n][i]); strncat(buffer, t[n][i], size - len0); } } } } done: return (buffer); } /* hci_features2str */ char const * hci_le_features2str(uint8_t *features, char *buffer, int size) { static char const * const t[][8] = { { /* byte 0 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 1 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 2 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 3 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 4 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 5 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 6 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }, { /* byte 7 */ /* 0 */ " ", /* 1 */ " ", /* 2 */ " ", /* 3 */ " ", /* 4 */ " ", /* 5 */ " ", /* 6 */ " ", /* 7 */ " " }}; if (buffer != NULL && size > 0) { int n, i, len0, len1; memset(buffer, 0, size); len1 = 0; size--; for (n = 0; n < SIZE(t); n++) { for (i = 0; i < SIZE(t[n]); i++) { len0 = strlen(buffer); if (len0 >= size) goto done; if (features[n] & (1 << i)) { if (len1 + strlen(t[n][i]) > 60) { len1 = 0; buffer[len0 - 1] = '\n'; } len1 += strlen(t[n][i]); strncat(buffer, t[n][i], size - len0); } } } } done: return (buffer); } char const * hci_cc2str(int cc) { static char const * const t[] = { /* 0x00 */ "North America, Europe, Japan", /* 0x01 */ "France" }; return (cc >= SIZE(t)? "?" : t[cc]); } /* hci_cc2str */ char const * hci_con_state2str(int state) { static char const * const t[] = { /* NG_HCI_CON_CLOSED */ "CLOSED", /* NG_HCI_CON_W4_LP_CON_RSP */ "W4_LP_CON_RSP", /* NG_HCI_CON_W4_CONN_COMPLETE */ "W4_CONN_COMPLETE", /* NG_HCI_CON_OPEN */ "OPEN" }; return (state >= SIZE(t)? "UNKNOWN" : t[state]); } /* hci_con_state2str */ char const * hci_status2str(int status) { static char const * const t[] = { /* 0x00 */ "No error", /* 0x01 */ "Unknown HCI command", /* 0x02 */ "No connection", /* 0x03 */ "Hardware failure", /* 0x04 */ "Page timeout", /* 0x05 */ "Authentication failure", /* 0x06 */ "Key missing", /* 0x07 */ "Memory full", /* 0x08 */ "Connection timeout", /* 0x09 */ "Max number of connections", /* 0x0a */ "Max number of SCO connections to a unit", /* 0x0b */ "ACL connection already exists", /* 0x0c */ "Command disallowed", /* 0x0d */ "Host rejected due to limited resources", /* 0x0e */ "Host rejected due to security reasons", /* 0x0f */ "Host rejected due to remote unit is a personal unit", /* 0x10 */ "Host timeout", /* 0x11 */ "Unsupported feature or parameter value", /* 0x12 */ "Invalid HCI command parameter", /* 0x13 */ "Other end terminated connection: User ended connection", /* 0x14 */ "Other end terminated connection: Low resources", /* 0x15 */ "Other end terminated connection: About to power off", /* 0x16 */ "Connection terminated by local host", /* 0x17 */ "Repeated attempts", /* 0x18 */ "Pairing not allowed", /* 0x19 */ "Unknown LMP PDU", /* 0x1a */ "Unsupported remote feature", /* 0x1b */ "SCO offset rejected", /* 0x1c */ "SCO interval rejected", /* 0x1d */ "SCO air mode rejected", /* 0x1e */ "Invalid LMP parameters", /* 0x1f */ "Unspecified error", /* 0x20 */ "Unsupported LMP parameter value", /* 0x21 */ "Role change not allowed", /* 0x22 */ "LMP response timeout", /* 0x23 */ "LMP error transaction collision", /* 0x24 */ "LMP PSU not allowed", /* 0x25 */ "Encryption mode not acceptable", /* 0x26 */ "Unit key used", /* 0x27 */ "QoS is not supported", /* 0x28 */ "Instant passed", /* 0x29 */ "Pairing with unit key not supported", /* 0x2a */ "Different Transaction Collision", /* 0x2b */ "Unknown error (Reserved for future use)", /* 0x2c */ "QoS Unacceptable Parameter", /* 0x2d */ "QoS Rejected", /* 0x2e */ "Channel Classification Not Supported", /* 0x2f */ "Insufficient Security", /* 0x30 */ "Parameter Out Of Mandatory Range", /* 0x31 */ "Unknown error (Reserved for future use)", /* 0x32 */ "Role Switch Pending", /* 0x33 */ "Unknown error (Reserved for future use)", /* 0x34 */ "Reserved Slot Violation", /* 0x35 */ "Role Switch Failed", /* 0x36 */ "Extended Inquiry Response Too Large", /* 0x37 */ "Secure Simple Pairing Not Supported By Host", /* 0x38 */ "Host Busy - Pairing", /* 0x39 */ "Connection Rejected due to No Suitable Channel Found", /* 0x3a */ "Controller Busy", /* 0x3b */ "Unacceptable Connection Parameters", /* 0x3c */ "Advertising Timeout", /* 0x3d */ "Connection Terminated due to MIC Failure", /* 0x3e */ "Connection Failed to be Established / Synchronization Timeout", /* 0x3f */ "MAC Connection Failed", /* 0x40 */ "Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging", /* 0x41 */ "Type0 Submap Not Defined", /* 0x42 */ "Unknown Advertising Identifier", /* 0x43 */ "Limit Reached", /* 0x44 */ "Operation Cancelled by Host", /* 0x45 */ "Packet Too Long" }; return (status >= SIZE(t)? "Unknown error" : t[status]); } /* hci_status2str */ char const * hci_bdaddr2str(bdaddr_t const *ba) { extern int numeric_bdaddr; static char buffer[MAXHOSTNAMELEN]; struct hostent *he = NULL; if (memcmp(ba, NG_HCI_BDADDR_ANY, sizeof(*ba)) == 0) { buffer[0] = '*'; buffer[1] = 0; return (buffer); } if (!numeric_bdaddr && (he = bt_gethostbyaddr((char *)ba, sizeof(*ba), AF_BLUETOOTH)) != NULL) { strlcpy(buffer, he->h_name, sizeof(buffer)); return (buffer); } bt_ntoa(ba, buffer); return (buffer); } /* hci_bdaddr2str */ char const * hci_addrtype2str(int type) { static char const * const t[] = { /* 0x00 */ "Public Device Address", /* 0x01 */ "Random Device Address", /* 0x02 */ "Public Identity Address", /* 0x03 */ "Random (static) Identity Address" }; return (type >= SIZE(t)? "?" : t[type]); } /* hci_addrtype2str */ char const * hci_role2str(int role) { static char const * const roles[] = { /* 0x00 */ "Master", /* 0x01 */ "Slave", }; return (role >= SIZE(roles)? "Unknown role" : roles[role]); } /* hci_role2str */ char const * hci_mc_accuracy2str(int accuracy) { static char const * const acc[] = { /* 0x00 */ "500 ppm", /* 0x01 */ "250 ppm", /* 0x02 */ "150 ppm", /* 0x03 */ "100 ppm", /* 0x04 */ "75 ppm", /* 0x05 */ "50 ppm", /* 0x06 */ "30 ppm", /* 0x07 */ "20 ppm", }; return (accuracy >= SIZE(acc)? "Unknown accuracy" : acc[accuracy]); } /* hci_mc_accuracy2str */ char const * hci_le_chanmap2str(uint8_t *map, char *buffer, int size) { char chantxt[4]; if (buffer != NULL && size > 0) { int n, i, len0, len1; memset(buffer, 0, size); len1 = 0; size--; for (n = 0; n < 5; n++) { fprintf(stdout, "%02x ", map[n]); for (i = 0; i < 8; i++) { len0 = strlen(buffer); if (len0 >= size) goto done; if (map[n] & (1 << i)) { if (len1 + 3 > 60) { len1 = 0; buffer[len0 - 1] = '\n'; } len1 += 3; snprintf( chantxt, sizeof(chantxt), "%02d ", (n * 8 + i)); strncat( buffer, chantxt, size - len0); } } } fprintf(stdout, "\n"); } done: return (buffer); } diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.c b/usr.sbin/bluetooth/hcsecd/hcsecd.c index 43db3e6f6a39..824b0ba6971b 100644 --- a/usr.sbin/bluetooth/hcsecd/hcsecd.c +++ b/usr.sbin/bluetooth/hcsecd/hcsecd.c @@ -1,449 +1,448 @@ /*- * hcsecd.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hcsecd.c,v 1.6 2003/08/18 19:19:55 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include "hcsecd.h" static int done = 0; static int process_pin_code_request_event (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); static int process_link_key_request_event (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); static int send_pin_code_reply (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, char const *pin); static int send_link_key_reply (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, uint8_t *key); static int process_link_key_notification_event (int sock, struct sockaddr_hci *addr, ng_hci_link_key_notification_ep *ep); static void sighup (int s); static void sigint (int s); static void usage (void); /* Main */ int main(int argc, char *argv[]) { int n, detach, sock; socklen_t size; struct sigaction sa; struct sockaddr_hci addr; struct ng_btsocket_hci_raw_filter filter; char buffer[HCSECD_BUFFER_SIZE]; ng_hci_event_pkt_t *event = NULL; detach = 1; while ((n = getopt(argc, argv, "df:h")) != -1) { switch (n) { case 'd': detach = 0; break; case 'f': config_file = optarg; break; case 'h': default: usage(); /* NOT REACHED */ } } if (config_file == NULL) usage(); /* NOT REACHED */ if (getuid() != 0) errx(1, "** ERROR: You should run %s as privileged user!", HCSECD_IDENT); /* Set signal handlers */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sigint; sa.sa_flags = SA_NOCLDWAIT; if (sigaction(SIGINT, &sa, NULL) < 0) err(1, "Could not sigaction(SIGINT)"); if (sigaction(SIGTERM, &sa, NULL) < 0) err(1, "Could not sigaction(SIGINT)"); memset(&sa, 0, sizeof(sa)); sa.sa_handler = sighup; if (sigaction(SIGHUP, &sa, NULL) < 0) err(1, "Could not sigaction(SIGHUP)"); /* Open socket and set filter */ sock = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); if (sock < 0) err(1, "Could not create HCI socket"); memset(&filter, 0, sizeof(filter)); bit_set(filter.event_mask, NG_HCI_EVENT_PIN_CODE_REQ - 1); bit_set(filter.event_mask, NG_HCI_EVENT_LINK_KEY_REQ - 1); bit_set(filter.event_mask, NG_HCI_EVENT_LINK_KEY_NOTIFICATION - 1); if (setsockopt(sock, SOL_HCI_RAW, SO_HCI_RAW_FILTER, (void * const) &filter, sizeof(filter)) < 0) err(1, "Could not set HCI socket filter"); if (detach && daemon(0, 0) < 0) err(1, "Could not daemon()ize"); openlog(HCSECD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); read_config_file(); read_keys_file(); if (detach) { FILE *pid = NULL; if ((pid = fopen(HCSECD_PIDFILE, "w")) == NULL) { syslog(LOG_ERR, "Could not create PID file %s. %s (%d)", HCSECD_PIDFILE, strerror(errno), errno); exit(1); } fprintf(pid, "%d", getpid()); fclose(pid); } event = (ng_hci_event_pkt_t *) buffer; while (!done) { size = sizeof(addr); n = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr *) &addr, &size); if (n < 0) { if (errno == EINTR) continue; syslog(LOG_ERR, "Could not receive from HCI socket. " \ "%s (%d)", strerror(errno), errno); exit(1); } if (event->type != NG_HCI_EVENT_PKT) { syslog(LOG_ERR, "Received unexpected HCI packet, " \ "type=%#x", event->type); continue; } switch (event->event) { case NG_HCI_EVENT_PIN_CODE_REQ: process_pin_code_request_event(sock, &addr, (bdaddr_p)(event + 1)); break; case NG_HCI_EVENT_LINK_KEY_REQ: process_link_key_request_event(sock, &addr, (bdaddr_p)(event + 1)); break; case NG_HCI_EVENT_LINK_KEY_NOTIFICATION: process_link_key_notification_event(sock, &addr, (ng_hci_link_key_notification_ep *)(event + 1)); break; default: syslog(LOG_ERR, "Received unexpected HCI event, " \ "event=%#x", event->event); break; } } if (detach) if (remove(HCSECD_PIDFILE) < 0) syslog(LOG_ERR, "Could not remove PID file %s. %s (%d)", HCSECD_PIDFILE, strerror(errno), errno); dump_keys_file(); clean_config(); closelog(); close(sock); return (0); } /* Process PIN_Code_Request event */ static int process_pin_code_request_event(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr) { link_key_p key = NULL; syslog(LOG_DEBUG, "Got PIN_Code_Request event from '%s', " \ "remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); if ((key = get_key(bdaddr, 0)) != NULL) { syslog(LOG_DEBUG, "Found matching entry, " \ "remote bdaddr %s, name '%s', PIN code %s", bt_ntoa(&key->bdaddr, NULL), (key->name != NULL)? key->name : "No name", (key->pin != NULL)? "exists" : "doesn't exist"); return (send_pin_code_reply(sock, addr, bdaddr, key->pin)); } syslog(LOG_DEBUG, "Could not PIN code for remote bdaddr %s", bt_ntoa(bdaddr, NULL)); return (send_pin_code_reply(sock, addr, bdaddr, NULL)); } /* Process Link_Key_Request event */ static int process_link_key_request_event(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr) { link_key_p key = NULL; syslog(LOG_DEBUG, "Got Link_Key_Request event from '%s', " \ "remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); if ((key = get_key(bdaddr, 0)) != NULL) { syslog(LOG_DEBUG, "Found matching entry, " \ "remote bdaddr %s, name '%s', link key %s", bt_ntoa(&key->bdaddr, NULL), (key->name != NULL)? key->name : "No name", (key->key != NULL)? "exists" : "doesn't exist"); return (send_link_key_reply(sock, addr, bdaddr, key->key)); } syslog(LOG_DEBUG, "Could not find link key for remote bdaddr %s", bt_ntoa(bdaddr, NULL)); return (send_link_key_reply(sock, addr, bdaddr, NULL)); } /* Send PIN_Code_[Negative]_Reply */ static int send_pin_code_reply(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, char const *pin) { uint8_t buffer[HCSECD_BUFFER_SIZE]; ng_hci_cmd_pkt_t *cmd = NULL; memset(buffer, 0, sizeof(buffer)); cmd = (ng_hci_cmd_pkt_t *) buffer; cmd->type = NG_HCI_CMD_PKT; if (pin != NULL) { ng_hci_pin_code_rep_cp *cp = NULL; cmd->opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_PIN_CODE_REP)); cmd->length = sizeof(*cp); cp = (ng_hci_pin_code_rep_cp *)(cmd + 1); memcpy(&cp->bdaddr, bdaddr, sizeof(cp->bdaddr)); strncpy((char *) cp->pin, pin, sizeof(cp->pin)); cp->pin_size = strlen((char const *) cp->pin); syslog(LOG_DEBUG, "Sending PIN_Code_Reply to '%s' " \ "for remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); } else { ng_hci_pin_code_neg_rep_cp *cp = NULL; cmd->opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_PIN_CODE_NEG_REP)); cmd->length = sizeof(*cp); cp = (ng_hci_pin_code_neg_rep_cp *)(cmd + 1); memcpy(&cp->bdaddr, bdaddr, sizeof(cp->bdaddr)); syslog(LOG_DEBUG, "Sending PIN_Code_Negative_Reply to '%s' " \ "for remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); } again: if (sendto(sock, buffer, sizeof(*cmd) + cmd->length, 0, (struct sockaddr *) addr, sizeof(*addr)) < 0) { if (errno == EINTR) goto again; syslog(LOG_ERR, "Could not send PIN code reply to '%s' " \ "for remote bdaddr %s. %s (%d)", addr->hci_node, bt_ntoa(bdaddr, NULL), strerror(errno), errno); return (-1); } return (0); } /* Send Link_Key_[Negative]_Reply */ static int send_link_key_reply(int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, uint8_t *key) { uint8_t buffer[HCSECD_BUFFER_SIZE]; ng_hci_cmd_pkt_t *cmd = NULL; memset(buffer, 0, sizeof(buffer)); cmd = (ng_hci_cmd_pkt_t *) buffer; cmd->type = NG_HCI_CMD_PKT; if (key != NULL) { ng_hci_link_key_rep_cp *cp = NULL; cmd->opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_LINK_KEY_REP)); cmd->length = sizeof(*cp); cp = (ng_hci_link_key_rep_cp *)(cmd + 1); memcpy(&cp->bdaddr, bdaddr, sizeof(cp->bdaddr)); memcpy(&cp->key, key, sizeof(cp->key)); syslog(LOG_DEBUG, "Sending Link_Key_Reply to '%s' " \ "for remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); } else { ng_hci_link_key_neg_rep_cp *cp = NULL; cmd->opcode = htole16(NG_HCI_OPCODE(NG_HCI_OGF_LINK_CONTROL, NG_HCI_OCF_LINK_KEY_NEG_REP)); cmd->length = sizeof(*cp); cp = (ng_hci_link_key_neg_rep_cp *)(cmd + 1); memcpy(&cp->bdaddr, bdaddr, sizeof(cp->bdaddr)); syslog(LOG_DEBUG, "Sending Link_Key_Negative_Reply to '%s' " \ "for remote bdaddr %s", addr->hci_node, bt_ntoa(bdaddr, NULL)); } again: if (sendto(sock, buffer, sizeof(*cmd) + cmd->length, 0, (struct sockaddr *) addr, sizeof(*addr)) < 0) { if (errno == EINTR) goto again; syslog(LOG_ERR, "Could not send link key reply to '%s' " \ "for remote bdaddr %s. %s (%d)", addr->hci_node, bt_ntoa(bdaddr, NULL), strerror(errno), errno); return (-1); } return (0); } /* Process Link_Key_Notification event */ static int process_link_key_notification_event(int sock, struct sockaddr_hci *addr, ng_hci_link_key_notification_ep *ep) { link_key_p key = NULL; syslog(LOG_DEBUG, "Got Link_Key_Notification event from '%s', " \ "remote bdaddr %s", addr->hci_node, bt_ntoa(&ep->bdaddr, NULL)); if ((key = get_key(&ep->bdaddr, 1)) == NULL) { syslog(LOG_ERR, "Could not find entry for remote bdaddr %s", bt_ntoa(&ep->bdaddr, NULL)); return (-1); } syslog(LOG_DEBUG, "Updating link key for the entry, " \ "remote bdaddr %s, name '%s', link key %s", bt_ntoa(&key->bdaddr, NULL), (key->name != NULL)? key->name : "No name", (key->key != NULL)? "exists" : "doesn't exist"); if (key->key == NULL) { key->key = (uint8_t *) malloc(NG_HCI_KEY_SIZE); if (key->key == NULL) { syslog(LOG_ERR, "Could not allocate link key"); exit(1); } } memcpy(key->key, &ep->key, NG_HCI_KEY_SIZE); return (0); } /* Signal handlers */ static void sighup(int s) { syslog(LOG_DEBUG, "Got SIGHUP (%d)", s); dump_keys_file(); read_config_file(); read_keys_file(); } static void sigint(int s) { syslog(LOG_DEBUG, "Got signal %d, total number of signals %d", s, ++ done); } /* Display usage and exit */ static void usage(void) { fprintf(stderr, "Usage: %s [-d] -f config_file [-h]\n" \ "Where:\n" \ "\t-d do not detach from terminal\n" \ "\t-f config_file use \n" \ "\t-h display this message\n", HCSECD_IDENT); exit(255); } diff --git a/usr.sbin/bluetooth/hcsecd/hcsecd.h b/usr.sbin/bluetooth/hcsecd/hcsecd.h index a1cbcac792fe..e13139e7cf1a 100644 --- a/usr.sbin/bluetooth/hcsecd/hcsecd.h +++ b/usr.sbin/bluetooth/hcsecd/hcsecd.h @@ -1,67 +1,66 @@ /*- * hcsecd.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: hcsecd.h,v 1.3 2003/09/08 18:54:21 max Exp $ - * $FreeBSD$ */ #ifndef _HCSECD_H_ #define _HCSECD_H_ 1 #define HCSECD_BUFFER_SIZE 512 #define HCSECD_IDENT "hcsecd" #define HCSECD_PIDFILE "/var/run/" HCSECD_IDENT ".pid" #define HCSECD_KEYSFILE "/var/db/" HCSECD_IDENT ".keys" struct link_key { bdaddr_t bdaddr; /* remote device BDADDR */ char *name; /* remote device name */ uint8_t *key; /* link key (or NULL if no key) */ char *pin; /* pin (or NULL if no pin) */ LIST_ENTRY(link_key) next; /* link to the next */ }; typedef struct link_key link_key_t; typedef struct link_key * link_key_p; extern char *config_file; #if __config_debug__ void dump_config (void); #endif void read_config_file(void); void clean_config (void); link_key_p get_key (bdaddr_p bdaddr, int exact_match); int read_keys_file (void); int dump_keys_file (void); #endif /* ndef _HCSECD_H_ */ diff --git a/usr.sbin/bluetooth/hcsecd/lexer.l b/usr.sbin/bluetooth/hcsecd/lexer.l index 801bbc8ea18b..71bfd7d5c7b1 100644 --- a/usr.sbin/bluetooth/hcsecd/lexer.l +++ b/usr.sbin/bluetooth/hcsecd/lexer.l @@ -1,97 +1,96 @@ %{ /*- * lexer.l * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: lexer.l,v 1.1 2002/11/24 20:22:39 max Exp $ - * $FreeBSD$ */ #include #include "parser.h" %} %option yylineno noyywrap nounput noinput delim [ \t\n] ws {delim}+ empty {delim}* comment \#.* hexdigit [0-9a-fA-F] hexbyte {hexdigit}{hexdigit} device_word device bdaddr_word bdaddr name_word name key_word key nokey_word nokey pin_word pin nopin_word nopin bdaddrstring {hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte}:{hexbyte} hexstring 0x{hexbyte}+ string \".+\" %% \; return (';'); \: return (':'); \{ return ('{'); \} return ('}'); {ws} ; {empty} ; {comment} ; {device_word} return (T_DEVICE); {bdaddr_word} return (T_BDADDR); {name_word} return (T_NAME); {key_word} return (T_KEY); {nokey_word} return (T_NOKEY); {pin_word} return (T_PIN); {nopin_word} return (T_NOPIN); {bdaddrstring} { yylval.string = yytext; return (T_BDADDRSTRING); } {hexstring} { yylval.string = &yytext[2]; return (T_HEXSTRING); } {string} { yytext[strlen(yytext) - 1] = 0; yylval.string = &yytext[1]; return (T_STRING); } %% diff --git a/usr.sbin/bluetooth/hcsecd/parser.y b/usr.sbin/bluetooth/hcsecd/parser.y index 86138a71ac57..bf8d33f565bc 100644 --- a/usr.sbin/bluetooth/hcsecd/parser.y +++ b/usr.sbin/bluetooth/hcsecd/parser.y @@ -1,437 +1,436 @@ %{ /*- * parser.y * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: parser.y,v 1.5 2003/06/07 21:22:30 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include "hcsecd.h" int yyparse (void); int yylex (void); static void free_key (link_key_p key); static int hexa2int4(char *a); static int hexa2int8(char *a); extern int yylineno; static LIST_HEAD(, link_key) link_keys; char *config_file = "/etc/bluetooth/hcsecd.conf"; static link_key_p key = NULL; %} %union { char *string; } %token T_BDADDRSTRING T_HEXSTRING T_STRING %token T_DEVICE T_BDADDR T_NAME T_KEY T_PIN T_NOKEY T_NOPIN T_JUNK %% config: line | config line ; line: T_DEVICE { key = (link_key_p) malloc(sizeof(*key)); if (key == NULL) { syslog(LOG_ERR, "Could not allocate new " \ "config entry"); exit(1); } memset(key, 0, sizeof(*key)); } '{' options '}' { if (get_key(&key->bdaddr, 1) != NULL) { syslog(LOG_ERR, "Ignoring duplicated entry " \ "for bdaddr %s", bt_ntoa(&key->bdaddr, NULL)); free_key(key); } else LIST_INSERT_HEAD(&link_keys, key, next); key = NULL; } ; options: option ';' | options option ';' ; option: bdaddr | name | key | pin ; bdaddr: T_BDADDR T_BDADDRSTRING { if (!bt_aton($2, &key->bdaddr)) { syslog(LOG_ERR, "Cound not parse BD_ADDR " \ "'%s'", $2); exit(1); } } ; name: T_NAME T_STRING { if (key->name != NULL) free(key->name); key->name = strdup($2); if (key->name == NULL) { syslog(LOG_ERR, "Could not allocate new " \ "device name"); exit(1); } } ; key: T_KEY T_HEXSTRING { int i, len; if (key->key != NULL) free(key->key); key->key = (uint8_t *) malloc(NG_HCI_KEY_SIZE); if (key->key == NULL) { syslog(LOG_ERR, "Could not allocate new " \ "link key"); exit(1); } memset(key->key, 0, NG_HCI_KEY_SIZE); len = strlen($2) / 2; if (len > NG_HCI_KEY_SIZE) len = NG_HCI_KEY_SIZE; for (i = 0; i < len; i ++) key->key[i] = hexa2int8((char *)($2) + 2*i); } | T_KEY T_NOKEY { if (key->key != NULL) free(key->key); key->key = NULL; } ; pin: T_PIN T_STRING { if (key->pin != NULL) free(key->pin); key->pin = strdup($2); if (key->pin == NULL) { syslog(LOG_ERR, "Could not allocate new " \ "PIN code"); exit(1); } } | T_PIN T_NOPIN { if (key->pin != NULL) free(key->pin); key->pin = NULL; } ; %% /* Display parser error message */ void yyerror(char const *message) { syslog(LOG_ERR, "%s in line %d", message, yylineno); } /* Re-read config file */ void read_config_file(void) { extern FILE *yyin; if (config_file == NULL) { syslog(LOG_ERR, "Unknown config file name!"); exit(1); } if ((yyin = fopen(config_file, "r")) == NULL) { syslog(LOG_ERR, "Could not open config file '%s'. %s (%d)", config_file, strerror(errno), errno); exit(1); } clean_config(); if (yyparse() < 0) { syslog(LOG_ERR, "Could not parse config file '%s'",config_file); exit(1); } fclose(yyin); yyin = NULL; #if __config_debug__ dump_config(); #endif } /* Clean config */ void clean_config(void) { link_key_p key = NULL; while ((key = LIST_FIRST(&link_keys)) != NULL) { LIST_REMOVE(key, next); free_key(key); } } /* Find link key entry in the list. Return exact or default match */ link_key_p get_key(bdaddr_p bdaddr, int exact_match) { link_key_p key = NULL, defkey = NULL; LIST_FOREACH(key, &link_keys, next) { if (memcmp(bdaddr, &key->bdaddr, sizeof(key->bdaddr)) == 0) break; if (!exact_match) if (memcmp(NG_HCI_BDADDR_ANY, &key->bdaddr, sizeof(key->bdaddr)) == 0) defkey = key; } return ((key != NULL)? key : defkey); } #if __config_debug__ /* Dump config */ void dump_config(void) { link_key_p key = NULL; char buffer[64]; LIST_FOREACH(key, &link_keys, next) { if (key->key != NULL) snprintf(buffer, sizeof(buffer), "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", key->key[0], key->key[1], key->key[2], key->key[3], key->key[4], key->key[5], key->key[6], key->key[7], key->key[8], key->key[9], key->key[10], key->key[11], key->key[12], key->key[13], key->key[14], key->key[15]); syslog(LOG_DEBUG, "device %s " \ "bdaddr %s " \ "pin %s " \ "key %s", (key->name != NULL)? key->name : "noname", bt_ntoa(&key->bdaddr, NULL), (key->pin != NULL)? key->pin : "nopin", (key->key != NULL)? buffer : "nokey"); } } #endif /* Read keys file */ int read_keys_file(void) { FILE *f = NULL; link_key_t *key = NULL; char buf[HCSECD_BUFFER_SIZE], *p = NULL, *cp = NULL; bdaddr_t bdaddr; int i, len; if ((f = fopen(HCSECD_KEYSFILE, "r")) == NULL) { if (errno == ENOENT) return (0); syslog(LOG_ERR, "Could not open keys file %s. %s (%d)\n", HCSECD_KEYSFILE, strerror(errno), errno); return (-1); } while ((p = fgets(buf, sizeof(buf), f)) != NULL) { if (*p == '#') continue; if ((cp = strpbrk(p, " ")) == NULL) continue; *cp++ = '\0'; if (!bt_aton(p, &bdaddr)) continue; if ((key = get_key(&bdaddr, 1)) == NULL) continue; if (key->key == NULL) { key->key = (uint8_t *) malloc(NG_HCI_KEY_SIZE); if (key->key == NULL) { syslog(LOG_ERR, "Could not allocate link key"); exit(1); } } memset(key->key, 0, NG_HCI_KEY_SIZE); len = strlen(cp) / 2; if (len > NG_HCI_KEY_SIZE) len = NG_HCI_KEY_SIZE; for (i = 0; i < len; i ++) key->key[i] = hexa2int8(cp + 2*i); syslog(LOG_DEBUG, "Restored link key for the entry, " \ "remote bdaddr %s, name '%s'", bt_ntoa(&key->bdaddr, NULL), (key->name != NULL)? key->name : "No name"); } fclose(f); return (0); } /* Dump keys file */ int dump_keys_file(void) { link_key_p key = NULL; char tmp[PATH_MAX], buf[HCSECD_BUFFER_SIZE]; int f; snprintf(tmp, sizeof(tmp), "%s.tmp", HCSECD_KEYSFILE); if ((f = open(tmp, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600)) < 0) { syslog(LOG_ERR, "Could not create temp keys file %s. %s (%d)\n", tmp, strerror(errno), errno); return (-1); } LIST_FOREACH(key, &link_keys, next) { if (key->key == NULL) continue; snprintf(buf, sizeof(buf), "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", bt_ntoa(&key->bdaddr, NULL), key->key[0], key->key[1], key->key[2], key->key[3], key->key[4], key->key[5], key->key[6], key->key[7], key->key[8], key->key[9], key->key[10], key->key[11], key->key[12], key->key[13], key->key[14], key->key[15]); if (write(f, buf, strlen(buf)) < 0) { syslog(LOG_ERR, "Could not write temp keys file. " \ "%s (%d)\n", strerror(errno), errno); break; } } close(f); if (rename(tmp, HCSECD_KEYSFILE) < 0) { syslog(LOG_ERR, "Could not rename(%s, %s). %s (%d)\n", tmp, HCSECD_KEYSFILE, strerror(errno), errno); unlink(tmp); return (-1); } return (0); } /* Free key entry */ static void free_key(link_key_p key) { if (key->name != NULL) free(key->name); if (key->key != NULL) free(key->key); if (key->pin != NULL) free(key->pin); memset(key, 0, sizeof(*key)); free(key); } /* Convert hex ASCII to int4 */ static int hexa2int4(char *a) { if ('0' <= *a && *a <= '9') return (*a - '0'); if ('A' <= *a && *a <= 'F') return (*a - 'A' + 0xa); if ('a' <= *a && *a <= 'f') return (*a - 'a' + 0xa); syslog(LOG_ERR, "Invalid hex character: '%c' (%#x)", *a, *a); exit(1); } /* Convert hex ASCII to int8 */ static int hexa2int8(char *a) { return ((hexa2int4(a) << 4) | hexa2int4(a + 1)); } diff --git a/usr.sbin/bluetooth/l2control/l2cap.c b/usr.sbin/bluetooth/l2control/l2cap.c index f459c492749d..0f410d3c6a85 100644 --- a/usr.sbin/bluetooth/l2control/l2cap.c +++ b/usr.sbin/bluetooth/l2control/l2cap.c @@ -1,316 +1,315 @@ /*- * l2cap.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: l2cap.c,v 1.5 2003/05/16 19:52:37 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include "l2control.h" #define SIZE(x) (sizeof((x))/sizeof((x)[0])) /* Print BDADDR */ static char * bdaddrpr(bdaddr_t const *ba) { extern int numeric_bdaddr; static char str[24]; struct hostent *he = NULL; if (memcmp(ba, NG_HCI_BDADDR_ANY, sizeof(*ba)) == 0) { str[0] = '*'; str[1] = 0; return (str); } if (!numeric_bdaddr && (he = bt_gethostbyaddr((char *)ba, sizeof(*ba), AF_BLUETOOTH)) != NULL) { strlcpy(str, he->h_name, sizeof(str)); return (str); } bt_ntoa(ba, str); return (str); } /* bdaddrpr */ /* Send read_node_flags command to the node */ static int l2cap_read_node_flags(int s, int argc, char **argv) { struct ng_btsocket_l2cap_raw_node_flags r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_L2CAP_NODE_GET_FLAGS, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Connectionless traffic flags:\n"); fprintf(stdout, "\tSDP: %s\n", (r.flags & NG_L2CAP_CLT_SDP_DISABLED)? "disabled" : "enabled"); fprintf(stdout, "\tRFCOMM: %s\n", (r.flags & NG_L2CAP_CLT_RFCOMM_DISABLED)? "disabled":"enabled"); fprintf(stdout, "\tTCP: %s\n", (r.flags & NG_L2CAP_CLT_TCP_DISABLED)? "disabled" : "enabled"); return (OK); } /* l2cap_read_node_flags */ /* Send read_debug_level command to the node */ static int l2cap_read_debug_level(int s, int argc, char **argv) { struct ng_btsocket_l2cap_raw_node_debug r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_L2CAP_NODE_GET_DEBUG, &r, sizeof(r)) < 0) return (ERROR); fprintf(stdout, "Debug level: %d\n", r.debug); return (OK); } /* l2cap_read_debug_level */ /* Send write_debug_level command to the node */ static int l2cap_write_debug_level(int s, int argc, char **argv) { struct ng_btsocket_l2cap_raw_node_debug r; memset(&r, 0, sizeof(r)); switch (argc) { case 1: r.debug = atoi(argv[0]); break; default: return (USAGE); } if (ioctl(s, SIOC_L2CAP_NODE_SET_DEBUG, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* l2cap_write_debug_level */ /* Send read_connection_list command to the node */ static int l2cap_read_connection_list(int s, int argc, char **argv) { static char const * const state[] = { /* NG_L2CAP_CON_CLOSED */ "CLOSED", /* NG_L2CAP_W4_LP_CON_CFM */ "W4_LP_CON_CFM", /* NG_L2CAP_CON_OPEN */ "OPEN" }; #define con_state2str(x) ((x) >= SIZE(state)? "UNKNOWN" : state[(x)]) struct ng_btsocket_l2cap_raw_con_list r; int n, error = OK; memset(&r, 0, sizeof(r)); r.num_connections = NG_L2CAP_MAX_CON_NUM; r.connections = calloc(NG_L2CAP_MAX_CON_NUM, sizeof(ng_l2cap_node_con_ep)); if (r.connections == NULL) { errno = ENOMEM; return (ERROR); } if (ioctl(s, SIOC_L2CAP_NODE_GET_CON_LIST, &r, sizeof(r)) < 0) { error = ERROR; goto out; } fprintf(stdout, "L2CAP connections:\n"); fprintf(stdout, "Remote BD_ADDR Handle Flags Pending State\n"); for (n = 0; n < r.num_connections; n++) { fprintf(stdout, "%-17.17s " \ "%6d " \ "%c%c%c%c%c " \ "%7d " \ "%s\n", bdaddrpr(&r.connections[n].remote), r.connections[n].con_handle, ((r.connections[n].flags & NG_L2CAP_CON_OUTGOING)? 'O' : 'I'), ((r.connections[n].flags & NG_L2CAP_CON_LP_TIMO)? 'L' : ' '), ((r.connections[n].flags & NG_L2CAP_CON_AUTO_DISCON_TIMO)? 'D' : ' '), ((r.connections[n].flags & NG_L2CAP_CON_TX)? 'T' : ' '), ((r.connections[n].flags & NG_L2CAP_CON_RX)? 'R' : ' '), r.connections[n].pending, con_state2str(r.connections[n].state)); } out: free(r.connections); return (error); } /* l2cap_read_connection_list */ /* Send read_channel_list command to the node */ static int l2cap_read_channel_list(int s, int argc, char **argv) { static char const * const state[] = { /* NG_L2CAP_CLOSED */ "CLOSED", /* NG_L2CAP_W4_L2CAP_CON_RSP */ "W4_L2CAP_CON_RSP", /* NG_L2CAP_W4_L2CA_CON_RSP */ "W4_L2CA_CON_RSP", /* NG_L2CAP_CONFIG */ "CONFIG", /* NG_L2CAP_OPEN */ "OPEN", /* NG_L2CAP_W4_L2CAP_DISCON_RSP */ "W4_L2CAP_DISCON_RSP", /* NG_L2CAP_W4_L2CA_DISCON_RSP */ "W4_L2CA_DISCON_RSP" }; #define ch_state2str(x) ((x) >= SIZE(state)? "UNKNOWN" : state[(x)]) struct ng_btsocket_l2cap_raw_chan_list r; int n, error = OK; memset(&r, 0, sizeof(r)); r.num_channels = NG_L2CAP_MAX_CHAN_NUM; r.channels = calloc(NG_L2CAP_MAX_CHAN_NUM, sizeof(ng_l2cap_node_chan_ep)); if (r.channels == NULL) { errno = ENOMEM; return (ERROR); } if (ioctl(s, SIOC_L2CAP_NODE_GET_CHAN_LIST, &r, sizeof(r)) < 0) { error = ERROR; goto out; } fprintf(stdout, "L2CAP channels:\n"); fprintf(stdout, "Remote BD_ADDR SCID/ DCID PSM IMTU/ OMTU State\n"); for (n = 0; n < r.num_channels; n++) { fprintf(stdout, "%-17.17s " \ "%5d/%5d %5d " \ "%5d/%5d " \ "%s\n", bdaddrpr(&r.channels[n].remote), r.channels[n].scid, r.channels[n].dcid, r.channels[n].psm, r.channels[n].imtu, r.channels[n].omtu, ch_state2str(r.channels[n].state)); } out: free(r.channels); return (error); } /* l2cap_read_channel_list */ /* Send read_auto_disconnect_timeout command to the node */ static int l2cap_read_auto_disconnect_timeout(int s, int argc, char **argv) { struct ng_btsocket_l2cap_raw_auto_discon_timo r; memset(&r, 0, sizeof(r)); if (ioctl(s, SIOC_L2CAP_NODE_GET_AUTO_DISCON_TIMO, &r, sizeof(r)) < 0) return (ERROR); if (r.timeout != 0) fprintf(stdout, "Auto disconnect timeout: %d sec\n", r.timeout); else fprintf(stdout, "Auto disconnect disabled\n"); return (OK); } /* l2cap_read_auto_disconnect_timeout */ /* Send write_auto_disconnect_timeout command to the node */ static int l2cap_write_auto_disconnect_timeout(int s, int argc, char **argv) { struct ng_btsocket_l2cap_raw_auto_discon_timo r; memset(&r, 0, sizeof(r)); switch (argc) { case 1: r.timeout = atoi(argv[0]); break; default: return (USAGE); } if (ioctl(s, SIOC_L2CAP_NODE_SET_AUTO_DISCON_TIMO, &r, sizeof(r)) < 0) return (ERROR); return (OK); } /* l2cap_write_auto_disconnect_timeout */ struct l2cap_command l2cap_commands[] = { { "read_node_flags", "Get L2CAP node flags", &l2cap_read_node_flags }, { "read_debug_level", "Get L2CAP node debug level", &l2cap_read_debug_level }, { "write_debug_level ", "Set L2CAP node debug level", &l2cap_write_debug_level }, { "read_connection_list", "Read list of the L2CAP connections", &l2cap_read_connection_list }, { "read_channel_list", "Read list of the L2CAP channels", &l2cap_read_channel_list }, { "read_auto_disconnect_timeout", "Get L2CAP node auto disconnect timeout (in sec)", &l2cap_read_auto_disconnect_timeout }, { "write_auto_disconnect_timeout ", "Set L2CAP node auto disconnect timeout (in sec)", &l2cap_write_auto_disconnect_timeout }, { NULL, }}; diff --git a/usr.sbin/bluetooth/l2control/l2control.c b/usr.sbin/bluetooth/l2control/l2control.c index 54429a368aab..7312371345ec 100644 --- a/usr.sbin/bluetooth/l2control/l2control.c +++ b/usr.sbin/bluetooth/l2control/l2control.c @@ -1,223 +1,222 @@ /*- * l2control.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: l2control.c,v 1.6 2003/09/05 00:38:25 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include "l2control.h" /* Prototypes */ static int do_l2cap_command (bdaddr_p, int, char **); static struct l2cap_command * find_l2cap_command (char const *, struct l2cap_command *); static void print_l2cap_command (struct l2cap_command *); static void usage (void); /* Main */ int numeric_bdaddr = 0; int main(int argc, char *argv[]) { int n; bdaddr_t bdaddr; memset(&bdaddr, 0, sizeof(bdaddr)); /* Process command line arguments */ while ((n = getopt(argc, argv, "a:nh")) != -1) { switch (n) { case 'a': if (!bt_aton(optarg, &bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&bdaddr, he->h_addr, sizeof(bdaddr)); } break; case 'n': numeric_bdaddr = 1; break; case 'h': default: usage(); break; } } argc -= optind; argv += optind; if (*argv == NULL) usage(); return (do_l2cap_command(&bdaddr, argc, argv)); } /* main */ /* Execute commands */ static int do_l2cap_command(bdaddr_p bdaddr, int argc, char **argv) { char *cmd = argv[0]; struct l2cap_command *c = NULL; struct sockaddr_l2cap sa; int s, e, help; help = 0; if (strcasecmp(cmd, "help") == 0) { argc --; argv ++; if (argc <= 0) { fprintf(stdout, "Supported commands:\n"); print_l2cap_command(l2cap_commands); fprintf(stdout, "\nFor more information use " \ "'help command'\n"); return (OK); } help = 1; cmd = argv[0]; } c = find_l2cap_command(cmd, l2cap_commands); if (c == NULL) { fprintf(stdout, "Unknown command: \"%s\"\n", cmd); return (ERROR); } if (!help) { if (memcmp(bdaddr, NG_HCI_BDADDR_ANY, sizeof(*bdaddr)) == 0) usage(); memset(&sa, 0, sizeof(sa)); sa.l2cap_len = sizeof(sa); sa.l2cap_family = AF_BLUETOOTH; memcpy(&sa.l2cap_bdaddr, bdaddr, sizeof(sa.l2cap_bdaddr)); s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_L2CAP); if (s < 0) err(1, "Could not create socket"); if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) err(2, "Could not bind socket, bdaddr=%s", bt_ntoa(&sa.l2cap_bdaddr, NULL)); e = 0x0ffff; if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, &e, sizeof(e)) < 0) err(3, "Could not setsockopt(RCVBUF, %d)", e); e = (c->handler)(s, -- argc, ++ argv); close(s); } else e = USAGE; switch (e) { case OK: case FAILED: break; case ERROR: fprintf(stdout, "Could not execute command \"%s\". %s\n", cmd, strerror(errno)); break; case USAGE: fprintf(stdout, "Usage: %s\n%s\n", c->command, c->description); break; default: assert(0); break; } return (e); } /* do_l2cap_command */ /* Try to find command in specified category */ static struct l2cap_command * find_l2cap_command(char const *command, struct l2cap_command *category) { struct l2cap_command *c = NULL; for (c = category; c->command != NULL; c++) { char *c_end = strchr(c->command, ' '); if (c_end != NULL) { int len = c_end - c->command; if (strncasecmp(command, c->command, len) == 0) return (c); } else if (strcasecmp(command, c->command) == 0) return (c); } return (NULL); } /* find_l2cap_command */ /* Print commands in specified category */ static void print_l2cap_command(struct l2cap_command *category) { struct l2cap_command *c = NULL; for (c = category; c->command != NULL; c++) fprintf(stdout, "\t%s\n", c->command); } /* print_l2cap_command */ /* Usage */ static void usage(void) { fprintf(stderr, "Usage: l2control [-hn] -a local cmd [params ..]\n"); fprintf(stderr, "Where:\n"); fprintf(stderr, " -a local Specify local device to connect to\n"); fprintf(stderr, " -h Display this message\n"); fprintf(stderr, " -n Show addresses as numbers\n"); fprintf(stderr, " cmd Supported command " \ "(see l2control help)\n"); fprintf(stderr, " params Optional command parameters\n"); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/l2control/l2control.h b/usr.sbin/bluetooth/l2control/l2control.h index af86f7a953e7..e18691d84ca3 100644 --- a/usr.sbin/bluetooth/l2control/l2control.h +++ b/usr.sbin/bluetooth/l2control/l2control.h @@ -1,51 +1,50 @@ /*- * l2control.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: l2control.h,v 1.1 2002/11/24 20:22:41 max Exp $ - * $FreeBSD$ */ #ifndef _L2CONTROL_H_ #define _L2CONTROL_H_ #define OK 0 /* everything was OK */ #define ERROR 1 /* could not execute command */ #define FAILED 2 /* error was reported */ #define USAGE 3 /* invalid parameters */ struct l2cap_command { char const *command; char const *description; int (*handler)(int, int, char **); }; extern struct l2cap_command l2cap_commands[]; #endif /* _L2CONTROL_H_ */ diff --git a/usr.sbin/bluetooth/l2ping/l2ping.c b/usr.sbin/bluetooth/l2ping/l2ping.c index 93c606bcae58..25ddf06e8532 100644 --- a/usr.sbin/bluetooth/l2ping/l2ping.c +++ b/usr.sbin/bluetooth/l2ping/l2ping.c @@ -1,295 +1,294 @@ /*- * l2ping.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2002 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: l2ping.c,v 1.5 2003/05/16 19:54:40 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include static void usage (void); static void tv_sub (struct timeval *, struct timeval const *); static double tv2msec (struct timeval const *); #undef min #define min(x, y) (((x) > (y))? (y) : (x)) static char const pattern[] = "1234567890-"; #define PATTERN_SIZE (sizeof(pattern) - 1) /* * Main */ int main(int argc, char *argv[]) { bdaddr_t src, dst; struct hostent *he; uint8_t *echo_data; struct sockaddr_l2cap sa; int32_t n, s, count, wait, flood, echo_size, numeric; char *endp, *rname; /* Set defaults */ memcpy(&src, NG_HCI_BDADDR_ANY, sizeof(src)); memcpy(&dst, NG_HCI_BDADDR_ANY, sizeof(dst)); echo_data = (uint8_t *) calloc(NG_L2CAP_MAX_ECHO_SIZE, sizeof(uint8_t)); if (echo_data == NULL) { fprintf(stderr, "Failed to allocate echo data buffer"); exit(1); } /* * Set default echo size to the NG_L2CAP_MTU_MINIMUM minus * the size of the L2CAP signalling command header. */ echo_size = NG_L2CAP_MTU_MINIMUM - sizeof(ng_l2cap_cmd_hdr_t); count = -1; /* unimited */ wait = 1; /* sec */ flood = 0; numeric = 0; /* Parse command line arguments */ while ((n = getopt(argc, argv, "a:c:fi:nS:s:h")) != -1) { switch (n) { case 'a': if (!bt_aton(optarg, &dst)) { if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&dst, he->h_addr, sizeof(dst)); } break; case 'c': count = strtol(optarg, &endp, 10); if (count <= 0 || *endp != '\0') usage(); break; case 'f': flood = 1; break; case 'i': wait = strtol(optarg, &endp, 10); if (wait <= 0 || *endp != '\0') usage(); break; case 'n': numeric = 1; break; case 'S': if (!bt_aton(optarg, &src)) { if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&src, he->h_addr, sizeof(src)); } break; case 's': echo_size = strtol(optarg, &endp, 10); if (echo_size < sizeof(int32_t) || echo_size > NG_L2CAP_MAX_ECHO_SIZE || *endp != '\0') usage(); break; case 'h': default: usage(); break; } } if (memcmp(&dst, NG_HCI_BDADDR_ANY, sizeof(dst)) == 0) usage(); he = bt_gethostbyaddr((const char *)&dst, sizeof(dst), AF_BLUETOOTH); if (he == NULL || he->h_name == NULL || he->h_name[0] == '\0' || numeric) asprintf(&rname, "%s", bt_ntoa(&dst, NULL)); else rname = strdup(he->h_name); if (rname == NULL) errx(1, "Failed to create remote hostname"); s = socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_L2CAP); if (s < 0) err(2, "Could not create socket"); memset(&sa, 0, sizeof(sa)); sa.l2cap_len = sizeof(sa); sa.l2cap_family = AF_BLUETOOTH; memcpy(&sa.l2cap_bdaddr, &src, sizeof(sa.l2cap_bdaddr)); if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) err(3, "Could not bind socket, src bdaddr=%s", bt_ntoa(&sa.l2cap_bdaddr, NULL)); memset(&sa, 0, sizeof(sa)); sa.l2cap_len = sizeof(sa); sa.l2cap_family = AF_BLUETOOTH; memcpy(&sa.l2cap_bdaddr, &dst, sizeof(sa.l2cap_bdaddr)); if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) err(4, "Could not connect socket, dst bdaddr=%s", bt_ntoa(&sa.l2cap_bdaddr, NULL)); /* Fill pattern */ for (n = 0; n < echo_size; ) { int32_t avail = min(echo_size - n, PATTERN_SIZE); memcpy(echo_data + n, pattern, avail); n += avail; } /* Start ping'ing */ for (n = 0; count == -1 || count > 0; n ++) { struct ng_btsocket_l2cap_raw_ping r; struct timeval a, b; int32_t fail; if (gettimeofday(&a, NULL) < 0) err(5, "Could not gettimeofday(a)"); fail = 0; *((int32_t *) echo_data) = htonl(n); r.result = 0; r.echo_size = echo_size; r.echo_data = echo_data; if (ioctl(s, SIOC_L2CAP_L2CA_PING, &r, sizeof(r)) < 0) { r.result = errno; fail = 1; /* warn("Could not ping, dst bdaddr=%s", bt_ntoa(&r.echo_dst, NULL)); */ } if (gettimeofday(&b, NULL) < 0) err(7, "Could not gettimeofday(b)"); tv_sub(&b, &a); fprintf(stdout, "%d bytes from %s seq_no=%d time=%.3f ms result=%#x %s\n", r.echo_size, rname, ntohl(*((int32_t *)(r.echo_data))), tv2msec(&b), r.result, ((fail == 0)? "" : strerror(errno))); if (!flood) { /* Wait */ a.tv_sec = wait; a.tv_usec = 0; select(0, NULL, NULL, NULL, &a); } if (count != -1) count --; } free(rname); free(echo_data); close(s); return (0); } /* main */ /* * a -= b, for timevals */ static void tv_sub(struct timeval *a, struct timeval const *b) { if (a->tv_usec < b->tv_usec) { a->tv_usec += 1000000; a->tv_sec -= 1; } a->tv_usec -= b->tv_usec; a->tv_sec -= b->tv_sec; } /* tv_sub */ /* * convert tv to msec */ static double tv2msec(struct timeval const *tvp) { return(((double)tvp->tv_usec)/1000.0 + ((double)tvp->tv_sec)*1000.0); } /* tv2msec */ /* * Usage */ static void usage(void) { fprintf(stderr, "Usage: l2ping [-fhn] -a remote " \ "[-c count] [-i wait] [-S source] [-s size]\n"); fprintf(stderr, "Where:\n"); fprintf(stderr, " -a remote Specify remote device to ping\n"); fprintf(stderr, " -c count Number of packets to send\n"); fprintf(stderr, " -f No delay between packets\n"); fprintf(stderr, " -h Display this message\n"); fprintf(stderr, " -i wait Delay between packets (sec)\n"); fprintf(stderr, " -n Numeric output only\n"); fprintf(stderr, " -S source Specify source device\n"); fprintf(stderr, " -s size Packet size (bytes), " \ "between %zd and %zd\n", sizeof(int32_t), NG_L2CAP_MAX_ECHO_SIZE); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c index 5623dd1d494e..439b4157f59e 100644 --- a/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c +++ b/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c @@ -1,473 +1,472 @@ /* * rfcomm_pppd.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2008 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: rfcomm_pppd.c,v 1.5 2003/09/07 18:32:11 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include #include #include #define RFCOMM_PPPD "rfcomm_pppd" int rfcomm_channel_lookup (bdaddr_t const *local, bdaddr_t const *remote, int service, int *channel, int *error); static void exec_ppp (int s, char *unit, char *label); static void sighandler (int s); static void usage (void); static int done; /* Main */ int main(int argc, char *argv[]) { struct sockaddr_rfcomm sock_addr; char *label = NULL, *unit = NULL, *ep = NULL; bdaddr_t addr; int s, channel, detach, server, service, regdun, regsp; pid_t pid; memcpy(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)); channel = 0; detach = 1; server = 0; service = 0; regdun = 0; regsp = 0; /* Parse command line arguments */ while ((s = getopt(argc, argv, "a:cC:dDhl:sSu:")) != -1) { switch (s) { case 'a': /* BDADDR */ if (!bt_aton(optarg, &addr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&addr, he->h_addr, sizeof(addr)); } break; case 'c': /* client */ server = 0; break; case 'C': /* RFCOMM channel */ channel = strtoul(optarg, &ep, 10); if (*ep != '\0') { channel = 0; switch (tolower(optarg[0])) { case 'd': /* DialUp Networking */ service = SDP_SERVICE_CLASS_DIALUP_NETWORKING; break; case 'l': /* LAN Access Using PPP */ service = SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP; break; } } break; case 'd': /* do not detach */ detach = 0; break; case 'D': /* Register DUN service as well as LAN service */ regdun = 1; break; case 'l': /* PPP label */ label = optarg; break; case 's': /* server */ server = 1; break; case 'S': /* Register SP service as well as LAN service */ regsp = 1; break; case 'u': /* PPP -unit option */ strtoul(optarg, &ep, 10); if (*ep != '\0') usage(); /* NOT REACHED */ unit = optarg; break; case 'h': default: usage(); /* NOT REACHED */ } } /* Check if we got everything we wanted */ if (label == NULL) errx(1, "Must specify PPP label"); if (!server) { if (memcmp(&addr, NG_HCI_BDADDR_ANY, sizeof(addr)) == 0) errx(1, "Must specify server BD_ADDR"); /* Check channel, if was not set then obtain it via SDP */ if (channel == 0 && service != 0) if (rfcomm_channel_lookup(NULL, &addr, service, &channel, &s) != 0) errc(1, s, "Could not obtain RFCOMM channel"); } if (channel <= 0 || channel > 30) errx(1, "Invalid RFCOMM channel number %d", channel); openlog(RFCOMM_PPPD, LOG_PID | LOG_PERROR | LOG_NDELAY, LOG_USER); if (detach && daemon(0, 0) < 0) { syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", strerror(errno), errno); exit(1); } s = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM); if (s < 0) { syslog(LOG_ERR, "Could not create socket. %s (%d)", strerror(errno), errno); exit(1); } if (server) { struct sigaction sa; void *ss = NULL; sdp_lan_profile_t lan; /* Install signal handler */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sighandler; if (sigaction(SIGTERM, &sa, NULL) < 0) { syslog(LOG_ERR, "Could not sigaction(SIGTERM). %s (%d)", strerror(errno), errno); exit(1); } if (sigaction(SIGHUP, &sa, NULL) < 0) { syslog(LOG_ERR, "Could not sigaction(SIGHUP). %s (%d)", strerror(errno), errno); exit(1); } if (sigaction(SIGINT, &sa, NULL) < 0) { syslog(LOG_ERR, "Could not sigaction(SIGINT). %s (%d)", strerror(errno), errno); exit(1); } sa.sa_handler = SIG_IGN; sa.sa_flags = SA_NOCLDWAIT; if (sigaction(SIGCHLD, &sa, NULL) < 0) { syslog(LOG_ERR, "Could not sigaction(SIGCHLD). %s (%d)", strerror(errno), errno); exit(1); } /* bind socket and listen for incoming connections */ sock_addr.rfcomm_len = sizeof(sock_addr); sock_addr.rfcomm_family = AF_BLUETOOTH; memcpy(&sock_addr.rfcomm_bdaddr, &addr, sizeof(sock_addr.rfcomm_bdaddr)); sock_addr.rfcomm_channel = channel; if (bind(s, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0) { syslog(LOG_ERR, "Could not bind socket. %s (%d)", strerror(errno), errno); exit(1); } if (listen(s, 10) < 0) { syslog(LOG_ERR, "Could not listen on socket. %s (%d)", strerror(errno), errno); exit(1); } ss = sdp_open_local(NULL); if (ss == NULL) { syslog(LOG_ERR, "Unable to create local SDP session"); exit(1); } if (sdp_error(ss) != 0) { syslog(LOG_ERR, "Unable to open local SDP session. " \ "%s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); exit(1); } memset(&lan, 0, sizeof(lan)); lan.server_channel = channel; if (sdp_register_service(ss, SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP, &addr, (void *) &lan, sizeof(lan), NULL) != 0) { syslog(LOG_ERR, "Unable to register LAN service with " \ "local SDP daemon. %s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); exit(1); } /* * Register DUN (Dial-Up Networking) service on the same * RFCOMM channel if requested. There is really no good reason * to not to support this. AT-command exchange can be faked * with chat script in ppp.conf */ if (regdun) { sdp_dun_profile_t dun; memset(&dun, 0, sizeof(dun)); dun.server_channel = channel; if (sdp_register_service(ss, SDP_SERVICE_CLASS_DIALUP_NETWORKING, &addr, (void *) &dun, sizeof(dun), NULL) != 0) { syslog(LOG_ERR, "Unable to register DUN " \ "service with local SDP daemon. " \ "%s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); exit(1); } } /* * Register SP (Serial Port) service on the same RFCOMM channel * if requested. It appears that some cell phones are using so * called "callback mechanism". In this scenario user is trying * to connect his cell phone to the Internet, and, user's host * computer is acting as the gateway server. It seems that it * is not possible to tell the phone to just connect and start * using the LAN service. Instead the user's host computer must * "jump start" the phone by connecting to the phone's SP * service. What happens next is the phone kills the existing * connection and opens another connection back to the user's * host computer. The phone really wants to use LAN service, * but for whatever reason it looks for SP service on the * user's host computer. This brain damaged behavior was * reported for Nokia 6600 and Sony/Ericsson P900. Both phones * are Symbian-based phones. Perhaps this is a Symbian problem? */ if (regsp) { sdp_sp_profile_t sp; memset(&sp, 0, sizeof(sp)); sp.server_channel = channel; if (sdp_register_service(ss, SDP_SERVICE_CLASS_SERIAL_PORT, &addr, (void *) &sp, sizeof(sp), NULL) != 0) { syslog(LOG_ERR, "Unable to register SP " \ "service with local SDP daemon. " \ "%s (%d)", strerror(sdp_error(ss)), sdp_error(ss)); exit(1); } } for (done = 0; !done; ) { socklen_t len = sizeof(sock_addr); int s1 = accept(s, (struct sockaddr *) &sock_addr, &len); if (s1 < 0) { syslog(LOG_ERR, "Could not accept connection " \ "on socket. %s (%d)", strerror(errno), errno); exit(1); } pid = fork(); if (pid == (pid_t) -1) { syslog(LOG_ERR, "Could not fork(). %s (%d)", strerror(errno), errno); exit(1); } if (pid == 0) { sdp_close(ss); close(s); /* Reset signal handler */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_DFL; sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); sigaction(SIGINT, &sa, NULL); sigaction(SIGCHLD, &sa, NULL); /* Become daemon */ daemon(0, 0); /* * XXX Make sure user does not shoot himself * in the foot. Do not pass unit option to the * PPP when operating in the server mode. */ exec_ppp(s1, NULL, label); } else close(s1); } } else { sock_addr.rfcomm_len = sizeof(sock_addr); sock_addr.rfcomm_family = AF_BLUETOOTH; memcpy(&sock_addr.rfcomm_bdaddr, NG_HCI_BDADDR_ANY, sizeof(sock_addr.rfcomm_bdaddr)); sock_addr.rfcomm_channel = 0; if (bind(s, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0) { syslog(LOG_ERR, "Could not bind socket. %s (%d)", strerror(errno), errno); exit(1); } memcpy(&sock_addr.rfcomm_bdaddr, &addr, sizeof(sock_addr.rfcomm_bdaddr)); sock_addr.rfcomm_channel = channel; if (connect(s, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) < 0) { syslog(LOG_ERR, "Could not connect socket. %s (%d)", strerror(errno), errno); exit(1); } exec_ppp(s, unit, label); } exit(0); } /* main */ /* * Redirects stdin/stdout to s, stderr to /dev/null and exec * 'ppp -direct -quiet [-unit N] label'. Never returns. */ static void exec_ppp(int s, char *unit, char *label) { char ppp[] = "/usr/sbin/ppp"; char *ppp_args[] = { ppp, "-direct", "-quiet", NULL, NULL, NULL, NULL }; close(0); if (dup(s) < 0) { syslog(LOG_ERR, "Could not dup(0). %s (%d)", strerror(errno), errno); exit(1); } close(1); if (dup(s) < 0) { syslog(LOG_ERR, "Could not dup(1). %s (%d)", strerror(errno), errno); exit(1); } close(2); open("/dev/null", O_RDWR); if (unit != NULL) { ppp_args[3] = "-unit"; ppp_args[4] = unit; ppp_args[5] = label; } else ppp_args[3] = label; if (execv(ppp, ppp_args) < 0) { syslog(LOG_ERR, "Could not exec(%s -direct -quiet%s%s %s). " \ "%s (%d)", ppp, (unit != NULL)? " -unit " : "", (unit != NULL)? unit : "", label, strerror(errno), errno); exit(1); } } /* run_ppp */ /* Signal handler */ static void sighandler(int s) { done = 1; } /* sighandler */ /* Display usage and exit */ static void usage(void) { fprintf(stdout, "Usage: %s options\n" \ "Where options are:\n" \ "\t-a address Address to listen on or connect to (required for client)\n" \ "\t-c Act as a clinet (default)\n" \ "\t-C channel RFCOMM channel to listen on or connect to (required)\n" \ "\t-d Run in foreground\n" \ "\t-D Register Dial-Up Networking service (server mode only)\n" \ "\t-l label Use PPP label (required)\n" \ "\t-s Act as a server\n" \ "\t-S Register Serial Port service (server mode only)\n" \ "\t-u N Tell PPP to operate on /dev/tunN (client mode only)\n" \ "\t-h Display this message\n", RFCOMM_PPPD); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c index 2c36d7536e1b..890e6e3cfdba 100644 --- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c +++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.c @@ -1,222 +1,221 @@ /*- * sdpcontrol.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sdpcontrol.c,v 1.1 2003/09/08 02:27:27 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include "sdpcontrol.h" /* Prototypes */ static int do_sdp_command (bdaddr_p, char const *, int, int, char **); static struct sdp_command * find_sdp_command (char const *, struct sdp_command *); static void print_sdp_command (struct sdp_command *); static void usage (void); /* Main */ int main(int argc, char *argv[]) { char const *control = SDP_LOCAL_PATH; int n, local; bdaddr_t bdaddr; memset(&bdaddr, 0, sizeof(bdaddr)); local = 0; /* Process command line arguments */ while ((n = getopt(argc, argv, "a:c:lh")) != -1) { switch (n) { case 'a': /* bdaddr */ if (!bt_aton(optarg, &bdaddr)) { struct hostent *he = NULL; if ((he = bt_gethostbyname(optarg)) == NULL) errx(1, "%s: %s", optarg, hstrerror(h_errno)); memcpy(&bdaddr, he->h_addr, sizeof(bdaddr)); } break; case 'c': /* control socket */ control = optarg; break; case 'l': /* local sdpd */ local = 1; break; case 'h': default: usage(); /* NOT REACHED */ } } argc -= optind; argv += optind; if (*argv == NULL) usage(); return (do_sdp_command(&bdaddr, control, local, argc, argv)); } /* Execute commands */ static int do_sdp_command(bdaddr_p bdaddr, char const *control, int local, int argc, char **argv) { char *cmd = argv[0]; struct sdp_command *c = NULL; void *xs = NULL; int e, help; help = 0; if (strcasecmp(cmd, "help") == 0) { argc --; argv ++; if (argc <= 0) { fprintf(stdout, "Supported commands:\n"); print_sdp_command(sdp_commands); fprintf(stdout, "\nFor more information use " \ "'help command'\n"); return (OK); } help = 1; cmd = argv[0]; } c = find_sdp_command(cmd, sdp_commands); if (c == NULL) { fprintf(stdout, "Unknown command: \"%s\"\n", cmd); return (ERROR); } if (!help) { if (!local) { if (memcmp(bdaddr, NG_HCI_BDADDR_ANY, sizeof(*bdaddr)) == 0) usage(); xs = sdp_open(NG_HCI_BDADDR_ANY, bdaddr); } else xs = sdp_open_local(control); if (xs == NULL) errx(1, "Could not create SDP session object"); if (sdp_error(xs) == 0) e = (c->handler)(xs, -- argc, ++ argv); else e = ERROR; } else e = USAGE; switch (e) { case OK: case FAILED: break; case ERROR: fprintf(stdout, "Could not execute command \"%s\". %s\n", cmd, strerror(sdp_error(xs))); break; case USAGE: fprintf(stdout, "Usage: %s\n%s\n", c->command, c->description); break; default: assert(0); break; } sdp_close(xs); return (e); } /* do_sdp_command */ /* Try to find command in specified category */ static struct sdp_command * find_sdp_command(char const *command, struct sdp_command *category) { struct sdp_command *c = NULL; for (c = category; c->command != NULL; c++) { char *c_end = strchr(c->command, ' '); if (c_end != NULL) { int len = c_end - c->command; if (strncasecmp(command, c->command, len) == 0) return (c); } else if (strcasecmp(command, c->command) == 0) return (c); } return (NULL); } /* find_sdp_command */ /* Print commands in specified category */ static void print_sdp_command(struct sdp_command *category) { struct sdp_command *c = NULL; for (c = category; c->command != NULL; c++) fprintf(stdout, "\t%s\n", c->command); } /* print_sdp_command */ /* Usage */ static void usage(void) { fprintf(stderr, "Usage: sdpcontrol options command\n" \ "Where options are:\n" " -a address address to connect to\n" \ " -c path path to the control socket (default is %s)\n" \ " -h display usage and quit\n" \ " -l connect to the local SDP server via control socket\n" \ " command one of the supported commands\n", SDP_LOCAL_PATH); exit(255); } /* usage */ diff --git a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h index afbb210753c3..818005ee34ce 100644 --- a/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h +++ b/usr.sbin/bluetooth/sdpcontrol/sdpcontrol.h @@ -1,51 +1,50 @@ /*- * sdpcontrol.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sdpcontrol.h,v 1.1 2003/09/08 02:27:27 max Exp $ - * $FreeBSD$ */ #ifndef __SDPCONTROL_H__ #define __SDPCONTROL_H__ #define OK 0 /* everything was OK */ #define ERROR 1 /* could not execute command */ #define FAILED 2 /* error was reported */ #define USAGE 3 /* invalid parameters */ struct sdp_command { char const *command; char const *description; int (*handler)(void *, int, char **); }; extern struct sdp_command sdp_commands[]; #endif /* __SDPCONTROL_H__ */ diff --git a/usr.sbin/bluetooth/sdpcontrol/search.c b/usr.sbin/bluetooth/sdpcontrol/search.c index ccb9ed365ea3..94c34828a949 100644 --- a/usr.sbin/bluetooth/sdpcontrol/search.c +++ b/usr.sbin/bluetooth/sdpcontrol/search.c @@ -1,750 +1,749 @@ /*- * search.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2001-2003 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: search.c,v 1.2 2003/09/08 17:35:15 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include "sdpcontrol.h" /* List of the attributes we are looking for */ static uint32_t attrs[] = { SDP_ATTR_RANGE( SDP_ATTR_SERVICE_RECORD_HANDLE, SDP_ATTR_SERVICE_RECORD_HANDLE), SDP_ATTR_RANGE( SDP_ATTR_SERVICE_CLASS_ID_LIST, SDP_ATTR_SERVICE_CLASS_ID_LIST), SDP_ATTR_RANGE( SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST), SDP_ATTR_RANGE( SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST) }; #define attrs_len (sizeof(attrs)/sizeof(attrs[0])) /* Buffer for the attributes */ #define NRECS 25 /* request this much records from the SDP server */ #define BSIZE 256 /* one attribute buffer size */ static uint8_t buffer[NRECS * attrs_len][BSIZE]; /* SDP attributes */ static sdp_attr_t values[NRECS * attrs_len]; #define values_len (sizeof(values)/sizeof(values[0])) /* * Print Service Class ID List * * The ServiceClassIDList attribute consists of a data element sequence in * which each data element is a UUID representing the service classes that * a given service record conforms to. The UUIDs are listed in order from * the most specific class to the most general class. The ServiceClassIDList * must contain at least one service class UUID. */ static void print_service_class_id_list(uint8_t const *start, uint8_t const *end) { uint32_t type, len, value; if (end - start < 2) { fprintf(stderr, "Invalid Service Class ID List. " \ "Too short, len=%zd\n", end - start); return; } SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: fprintf(stderr, "Invalid Service Class ID List. " \ "Not a sequence, type=%#x\n", type); return; /* NOT REACHED */ } if (len > (end - start)) { fprintf(stderr, "Invalid Service Class ID List. " \ "Too long len=%d\n", len); return; } while (start < end) { SDP_GET8(type, start); switch (type) { case SDP_DATA_UUID16: SDP_GET16(value, start); fprintf(stdout, "\t%s (%#4.4x)\n", sdp_uuid2desc(value), value); break; case SDP_DATA_UUID32: SDP_GET32(value, start); fprintf(stdout, "\t%#8.8x\n", value); break; case SDP_DATA_UUID128: { int128_t uuid; SDP_GET_UUID128(&uuid, start); fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n", ntohl(*(uint32_t *)&uuid.b[0]), ntohs(*(uint16_t *)&uuid.b[4]), ntohs(*(uint16_t *)&uuid.b[6]), ntohs(*(uint16_t *)&uuid.b[8]), ntohs(*(uint16_t *)&uuid.b[10]), ntohl(*(uint32_t *)&uuid.b[12])); } break; default: fprintf(stderr, "Invalid Service Class ID List. " \ "Not a UUID, type=%#x\n", type); return; /* NOT REACHED */ } } } /* print_service_class_id_list */ /* * Print Protocol Descriptor List * * If the ProtocolDescriptorList describes a single stack, it takes the form * of a data element sequence in which each element of the sequence is a * protocol descriptor. Each protocol descriptor is, in turn, a data element * sequence whose first element is a UUID identifying the protocol and whose * successive elements are protocol-specific parameters. The protocol * descriptors are listed in order from the lowest layer protocol to the * highest layer protocol used to gain access to the service. If it is possible * for more than one kind of protocol stack to be used to gain access to the * service, the ProtocolDescriptorList takes the form of a data element * alternative where each member is a data element sequence as described above. */ static void print_protocol_descriptor(uint8_t const *start, uint8_t const *end) { union { uint8_t uint8; uint16_t uint16; uint32_t uint32; uint64_t uint64; int128_t int128; } value; uint32_t type, len, param; /* Get Protocol UUID */ SDP_GET8(type, start); switch (type) { case SDP_DATA_UUID16: SDP_GET16(value.uint16, start); fprintf(stdout, "\t%s (%#4.4x)\n", sdp_uuid2desc(value.uint16), value.uint16); break; case SDP_DATA_UUID32: SDP_GET32(value.uint32, start); fprintf(stdout, "\t%#8.8x\n", value.uint32); break; case SDP_DATA_UUID128: SDP_GET_UUID128(&value.int128, start); fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n", ntohl(*(uint32_t *)&value.int128.b[0]), ntohs(*(uint16_t *)&value.int128.b[4]), ntohs(*(uint16_t *)&value.int128.b[6]), ntohs(*(uint16_t *)&value.int128.b[8]), ntohs(*(uint16_t *)&value.int128.b[10]), ntohl(*(uint32_t *)&value.int128.b[12])); break; default: fprintf(stderr, "Invalid Protocol Descriptor. " \ "Not a UUID, type=%#x\n", type); return; /* NOT REACHED */ } /* Protocol specific parameters */ for (param = 1; start < end; param ++) { fprintf(stdout, "\t\tProtocol specific parameter #%d: ", param); SDP_GET8(type, start); switch (type) { case SDP_DATA_NIL: fprintf(stdout, "nil\n"); break; case SDP_DATA_UINT8: case SDP_DATA_INT8: case SDP_DATA_BOOL: SDP_GET8(value.uint8, start); fprintf(stdout, "u/int8/bool %u\n", value.uint8); break; case SDP_DATA_UINT16: case SDP_DATA_INT16: case SDP_DATA_UUID16: SDP_GET16(value.uint16, start); fprintf(stdout, "u/int/uuid16 %u\n", value.uint16); break; case SDP_DATA_UINT32: case SDP_DATA_INT32: case SDP_DATA_UUID32: SDP_GET32(value.uint32, start); fprintf(stdout, "u/int/uuid32 %u\n", value.uint32); break; case SDP_DATA_UINT64: case SDP_DATA_INT64: SDP_GET64(value.uint64, start); fprintf(stdout, "u/int64 %ju\n", value.uint64); break; case SDP_DATA_UINT128: case SDP_DATA_INT128: SDP_GET128(&value.int128, start); fprintf(stdout, "u/int128 %#8.8x%8.8x%8.8x%8.8x\n", *(uint32_t *)&value.int128.b[0], *(uint32_t *)&value.int128.b[4], *(uint32_t *)&value.int128.b[8], *(uint32_t *)&value.int128.b[12]); break; case SDP_DATA_UUID128: SDP_GET_UUID128(&value.int128, start); fprintf(stdout, "uuid128 %#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x\n", ntohl(*(uint32_t *)&value.int128.b[0]), ntohs(*(uint16_t *)&value.int128.b[4]), ntohs(*(uint16_t *)&value.int128.b[6]), ntohs(*(uint16_t *)&value.int128.b[8]), ntohs(*(uint16_t *)&value.int128.b[10]), ntohl(*(uint32_t *)&value.int128.b[12])); break; case SDP_DATA_STR8: case SDP_DATA_URL8: SDP_GET8(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%c", *start); fprintf(stdout, "\n"); break; case SDP_DATA_STR16: case SDP_DATA_URL16: SDP_GET16(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%c", *start); fprintf(stdout, "\n"); break; case SDP_DATA_STR32: case SDP_DATA_URL32: SDP_GET32(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%c", *start); fprintf(stdout, "\n"); break; case SDP_DATA_SEQ8: case SDP_DATA_ALT8: SDP_GET8(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%#2.2x ", *start); fprintf(stdout, "\n"); break; case SDP_DATA_SEQ16: case SDP_DATA_ALT16: SDP_GET16(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%#2.2x ", *start); fprintf(stdout, "\n"); break; case SDP_DATA_SEQ32: case SDP_DATA_ALT32: SDP_GET32(len, start); for (; start < end && len > 0; start ++, len --) fprintf(stdout, "%#2.2x ", *start); fprintf(stdout, "\n"); break; default: fprintf(stderr, "Invalid Protocol Descriptor. " \ "Unknown data type: %#02x\n", type); return; /* NOT REACHED */ } } } /* print_protocol_descriptor */ static void print_protocol_descriptor_list(uint8_t const *start, uint8_t const *end) { uint32_t type, len; if (end - start < 2) { fprintf(stderr, "Invalid Protocol Descriptor List. " \ "Too short, len=%zd\n", end - start); return; } SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: fprintf(stderr, "Invalid Protocol Descriptor List. " \ "Not a sequence, type=%#x\n", type); return; /* NOT REACHED */ } if (len > (end - start)) { fprintf(stderr, "Invalid Protocol Descriptor List. " \ "Too long, len=%d\n", len); return; } while (start < end) { SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: fprintf(stderr, "Invalid Protocol Descriptor List. " \ "Not a sequence, type=%#x\n", type); return; /* NOT REACHED */ } if (len > (end - start)) { fprintf(stderr, "Invalid Protocol Descriptor List. " \ "Too long, len=%d\n", len); return; } print_protocol_descriptor(start, start + len); start += len; } } /* print_protocol_descriptor_list */ /* * Print Bluetooth Profile Descriptor List * * The BluetoothProfileDescriptorList attribute consists of a data element * sequence in which each element is a profile descriptor that contains * information about a Bluetooth profile to which the service represented by * this service record conforms. Each profile descriptor is a data element * sequence whose first element is the UUID assigned to the profile and whose * second element is a 16-bit profile version number. Each version of a profile * is assigned a 16-bit unsigned integer profile version number, which consists * of two 8-bit fields. The higher-order 8 bits contain the major version * number field and the lower-order 8 bits contain the minor version number * field. */ static void print_bluetooth_profile_descriptor_list(uint8_t const *start, uint8_t const *end) { uint32_t type, len, value; if (end - start < 2) { fprintf(stderr, "Invalid Bluetooth Profile Descriptor List. " \ "Too short, len=%zd\n", end - start); return; } SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: fprintf(stderr, "Invalid Bluetooth Profile Descriptor List. " \ "Not a sequence, type=%#x\n", type); return; /* NOT REACHED */ } if (len > (end - start)) { fprintf(stderr, "Invalid Bluetooth Profile Descriptor List. " \ "Too long, len=%d\n", len); return; } while (start < end) { SDP_GET8(type, start); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(len, start); break; case SDP_DATA_SEQ16: SDP_GET16(len, start); break; case SDP_DATA_SEQ32: SDP_GET32(len, start); break; default: fprintf(stderr, "Invalid Bluetooth Profile " \ "Descriptor List. " \ "Not a sequence, type=%#x\n", type); return; /* NOT REACHED */ } if (len > (end - start)) { fprintf(stderr, "Invalid Bluetooth Profile " \ "Descriptor List. " \ "Too long, len=%d\n", len); return; } /* Get UUID */ SDP_GET8(type, start); switch (type) { case SDP_DATA_UUID16: SDP_GET16(value, start); fprintf(stdout, "\t%s (%#4.4x) ", sdp_uuid2desc(value), value); break; case SDP_DATA_UUID32: SDP_GET32(value, start); fprintf(stdout, "\t%#8.8x ", value); break; case SDP_DATA_UUID128: { int128_t uuid; SDP_GET_UUID128(&uuid, start); fprintf(stdout, "\t%#8.8x-%4.4x-%4.4x-%4.4x-%4.4x%8.8x ", ntohl(*(uint32_t *)&uuid.b[0]), ntohs(*(uint16_t *)&uuid.b[4]), ntohs(*(uint16_t *)&uuid.b[6]), ntohs(*(uint16_t *)&uuid.b[8]), ntohs(*(uint16_t *)&uuid.b[10]), ntohl(*(uint32_t *)&uuid.b[12])); } break; default: fprintf(stderr, "Invalid Bluetooth Profile " \ "Descriptor List. " \ "Not a UUID, type=%#x\n", type); return; /* NOT REACHED */ } /* Get version */ SDP_GET8(type, start); if (type != SDP_DATA_UINT16) { fprintf(stderr, "Invalid Bluetooth Profile " \ "Descriptor List. " \ "Invalid version type=%#x\n", type); return; } SDP_GET16(value, start); fprintf(stdout, "ver. %d.%d\n", (value >> 8) & 0xff, value & 0xff); } } /* print_bluetooth_profile_descriptor_list */ /* Perform SDP search command */ static int do_sdp_search(void *xs, int argc, char **argv) { char *ep = NULL; int32_t n, type, value; uint16_t service; /* Parse command line arguments */ switch (argc) { case 1: n = strtoul(argv[0], &ep, 16); if (*ep != 0) { switch (tolower(argv[0][0])) { case 'c': /* CIP/CTP */ switch (tolower(argv[0][1])) { case 'i': service = SDP_SERVICE_CLASS_COMMON_ISDN_ACCESS; break; case 't': service = SDP_SERVICE_CLASS_CORDLESS_TELEPHONY; break; default: return (USAGE); /* NOT REACHED */ } break; case 'd': /* DialUp Networking */ service = SDP_SERVICE_CLASS_DIALUP_NETWORKING; break; case 'f': /* Fax/OBEX File Transfer */ switch (tolower(argv[0][1])) { case 'a': service = SDP_SERVICE_CLASS_FAX; break; case 't': service = SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER; break; default: return (USAGE); /* NOT REACHED */ } break; case 'g': /* GN */ service = SDP_SERVICE_CLASS_GN; break; case 'h': /* Headset/HID */ switch (tolower(argv[0][1])) { case 'i': service = SDP_SERVICE_CLASS_HUMAN_INTERFACE_DEVICE; break; case 's': service = SDP_SERVICE_CLASS_HEADSET; break; default: return (USAGE); /* NOT REACHED */ } break; case 'l': /* LAN Access Using PPP */ service = SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP; break; case 'n': /* NAP */ service = SDP_SERVICE_CLASS_NAP; break; case 'o': /* OBEX Object Push */ service = SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH; break; case 's': /* Serial Port */ service = SDP_SERVICE_CLASS_SERIAL_PORT; break; default: return (USAGE); /* NOT REACHED */ } } else service = (uint16_t) n; break; default: return (USAGE); } /* Initialize attribute values array */ for (n = 0; n < values_len; n ++) { values[n].flags = SDP_ATTR_INVALID; values[n].attr = 0; values[n].vlen = BSIZE; values[n].value = buffer[n]; } /* Do SDP Service Search Attribute Request */ n = sdp_search(xs, 1, &service, attrs_len, attrs, values_len, values); if (n != 0) return (ERROR); /* Print attributes values */ for (n = 0; n < values_len; n ++) { if (values[n].flags != SDP_ATTR_OK) break; switch (values[n].attr) { case SDP_ATTR_SERVICE_RECORD_HANDLE: fprintf(stdout, "\n"); if (values[n].vlen == 5) { SDP_GET8(type, values[n].value); if (type == SDP_DATA_UINT32) { SDP_GET32(value, values[n].value); fprintf(stdout, "Record Handle: " \ "%#8.8x\n", value); } else fprintf(stderr, "Invalid type=%#x " \ "Record Handle " \ "attribute!\n", type); } else fprintf(stderr, "Invalid size=%d for Record " \ "Handle attribute\n", values[n].vlen); break; case SDP_ATTR_SERVICE_CLASS_ID_LIST: fprintf(stdout, "Service Class ID List:\n"); print_service_class_id_list(values[n].value, values[n].value + values[n].vlen); break; case SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST: fprintf(stdout, "Protocol Descriptor List:\n"); print_protocol_descriptor_list(values[n].value, values[n].value + values[n].vlen); break; case SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST: fprintf(stdout, "Bluetooth Profile Descriptor List:\n"); print_bluetooth_profile_descriptor_list(values[n].value, values[n].value + values[n].vlen); break; default: fprintf(stderr, "Unexpected attribute ID=%#4.4x\n", values[n].attr); break; } } return (OK); } /* do_sdp_search */ /* Perform SDP browse command */ static int do_sdp_browse(void *xs, int argc, char **argv) { #undef _STR #undef STR #define _STR(x) #x #define STR(x) _STR(x) static char const * const av[] = { STR(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP), NULL }; switch (argc) { case 0: argc = 1; argv = (char **) av; /* FALL THROUGH */ case 1: return (do_sdp_search(xs, argc, argv)); } return (USAGE); } /* do_sdp_browse */ /* List of SDP commands */ struct sdp_command sdp_commands[] = { { "Browse []", "Browse for services. The parameter is a 16-bit UUID of the group\n" \ "to browse. If omitted is set to Public Browse Group.\n\n" \ "\t - xxxx; 16-bit UUID of the group to browse\n", do_sdp_browse }, { "Search ", "Search for the . The parameter is a 16-bit UUID of the\n" \ "service to search for. For some services it is possible to use service name\n"\ "instead of service UUID\n\n" \ "\t - xxxx; 16-bit UUID of the service to search for\n\n" \ "\tKnown service names\n" \ "\t===================\n" \ "\tCIP - Common ISDN Access\n" \ "\tCTP - Cordless Telephony\n" \ "\tDUN - DialUp Networking\n" \ "\tFAX - Fax\n" \ "\tFTRN - OBEX File Transfer\n" \ "\tGN - GN\n" \ "\tHID - Human Interface Device\n" \ "\tHSET - Headset\n" \ "\tLAN - LAN Access Using PPP\n" \ "\tNAP - Network Access Point\n" \ "\tOPUSH - OBEX Object Push\n" \ "\tSP - Serial Port\n", do_sdp_search }, { NULL, NULL, NULL } }; diff --git a/usr.sbin/bluetooth/sdpd/bgd.c b/usr.sbin/bluetooth/sdpd/bgd.c index 0345d7b9b625..628389efc8e1 100644 --- a/usr.sbin/bluetooth/sdpd/bgd.c +++ b/usr.sbin/bluetooth/sdpd/bgd.c @@ -1,104 +1,103 @@ /*- * bgd.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: bgd.c,v 1.4 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" static int32_t bgd_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t bgd_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Public Browse Group Root"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t bgd_profile_create_group_id( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 3 > eob) return (-1); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP, buf); return (3); } static attr_t bgd_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, bgd_profile_create_service_class_id_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, bgd_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, bgd_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_PROVIDER_NAME_OFFSET, common_profile_create_service_provider_name }, { SDP_ATTR_GROUP_ID, bgd_profile_create_group_id }, { 0, NULL } /* end entry */ }; profile_t bgd_profile_descriptor = { SDP_SERVICE_CLASS_BROWSE_GROUP_DESCRIPTOR, 0, (profile_data_valid_p) NULL, (attr_t const * const) &bgd_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/dun.c b/usr.sbin/bluetooth/sdpd/dun.c index 50ec3685f667..3f4159926275 100644 --- a/usr.sbin/bluetooth/sdpd/dun.c +++ b/usr.sbin/bluetooth/sdpd/dun.c @@ -1,139 +1,138 @@ /*- * dun.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: dun.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t dun_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_DIALUP_NETWORKING }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t dun_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_DIALUP_NETWORKING, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t dun_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "DialUp networking"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t dun_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_dun_profile_p dun = (sdp_dun_profile_p) provider->data; return (rfcomm_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &dun->server_channel, 1)); } static int32_t dun_profile_create_audio_feedback_support( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_dun_profile_p dun = (sdp_dun_profile_p) provider->data; if (buf + 2 > eob) return (-1); SDP_PUT8(SDP_DATA_BOOL, buf); SDP_PUT8(dun->audio_feedback_support, buf); return (2); } static attr_t dun_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, dun_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, dun_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, dun_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, dun_profile_create_protocol_descriptor_list }, { SDP_ATTR_AUDIO_FEEDBACK_SUPPORT, dun_profile_create_audio_feedback_support }, { 0, NULL } /* end entry */ }; profile_t dun_profile_descriptor = { SDP_SERVICE_CLASS_DIALUP_NETWORKING, sizeof(sdp_dun_profile_t), common_profile_server_channel_valid, (attr_t const * const) &dun_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/ftrn.c b/usr.sbin/bluetooth/sdpd/ftrn.c index a3a0e2cde665..32b4912f25ed 100644 --- a/usr.sbin/bluetooth/sdpd/ftrn.c +++ b/usr.sbin/bluetooth/sdpd/ftrn.c @@ -1,120 +1,119 @@ /*- * ftrn.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: ftrn.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t ftrn_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t ftrn_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t ftrn_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "OBEX File Transfer"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t ftrn_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_ftrn_profile_p ftrn = (sdp_ftrn_profile_p) provider->data; return (obex_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &ftrn->server_channel, 1)); } static attr_t ftrn_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, ftrn_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, ftrn_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, ftrn_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, ftrn_profile_create_protocol_descriptor_list }, { 0, NULL } /* end entry */ }; profile_t ftrn_profile_descriptor = { SDP_SERVICE_CLASS_OBEX_FILE_TRANSFER, sizeof(sdp_ftrn_profile_t), common_profile_server_channel_valid, (attr_t const * const) &ftrn_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/gn.c b/usr.sbin/bluetooth/sdpd/gn.c index cecb93a38a67..17879c4fb193 100644 --- a/usr.sbin/bluetooth/sdpd/gn.c +++ b/usr.sbin/bluetooth/sdpd/gn.c @@ -1,175 +1,174 @@ /* * gn.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: gn.c,v 1.1 2008/03/11 00:02:42 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t gn_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_GN }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t gn_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_GN, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t gn_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Group Ad-hoc Network"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t gn_profile_create_service_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_descr[] = "Personal Group Ad-hoc Network Service"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_descr, strlen(service_descr))); } static int32_t gn_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_gn_profile_p gn = (sdp_gn_profile_p) provider->data; return (bnep_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &gn->psm, sizeof(gn->psm))); } static int32_t gn_profile_create_security_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_gn_profile_p gn = (sdp_gn_profile_p) provider->data; return (bnep_profile_create_security_description(buf, eob, (uint8_t const *) &gn->security_description, sizeof(gn->security_description))); } static int32_t gn_profile_create_service_availability( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_gn_profile_p gn = (sdp_gn_profile_p) provider->data; return (common_profile_create_service_availability(buf, eob, &gn->load_factor, 1)); } static int32_t gn_profile_data_valid(uint8_t const *data, uint32_t datalen) { sdp_gn_profile_p gn = (sdp_gn_profile_p) data; return ((gn->psm == 0)? 0 : 1); } static attr_t gn_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, gn_profile_create_service_class_id_list }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, gn_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_SERVICE_AVAILABILITY, gn_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, gn_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, gn_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, gn_profile_create_service_description }, { SDP_ATTR_SECURITY_DESCRIPTION, gn_profile_create_security_description }, { 0, NULL } /* end entry */ }; profile_t gn_profile_descriptor = { SDP_SERVICE_CLASS_GN, sizeof(sdp_gn_profile_t), gn_profile_data_valid, (attr_t const * const) &gn_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/irmc.c b/usr.sbin/bluetooth/sdpd/irmc.c index 9de370c70aea..90155e065492 100644 --- a/usr.sbin/bluetooth/sdpd/irmc.c +++ b/usr.sbin/bluetooth/sdpd/irmc.c @@ -1,136 +1,135 @@ /*- * irmc.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: irmc.c,v 1.6 2004/01/13 19:31:54 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t irmc_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_IR_MC_SYNC }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t irmc_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_IR_MC_SYNC, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t irmc_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "IrMC Synchronization"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t irmc_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_irmc_profile_p irmc = (sdp_irmc_profile_p) provider->data; return (obex_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &irmc->server_channel, 1)); } static int32_t irmc_profile_create_supported_formats_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_irmc_profile_p irmc = (sdp_irmc_profile_p) provider->data; return (obex_profile_create_supported_formats_list( buf, eob, (uint8_t const *) irmc->supported_formats, irmc->supported_formats_size)); } static attr_t irmc_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, irmc_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, irmc_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, irmc_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, irmc_profile_create_protocol_descriptor_list }, { SDP_ATTR_SUPPORTED_FORMATS_LIST, irmc_profile_create_supported_formats_list }, { 0, NULL } /* end entry */ }; profile_t irmc_profile_descriptor = { SDP_SERVICE_CLASS_IR_MC_SYNC, sizeof(sdp_irmc_profile_t), obex_profile_data_valid, (attr_t const * const) &irmc_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/irmc_command.c b/usr.sbin/bluetooth/sdpd/irmc_command.c index 0280016856b2..e8d0723fa8a4 100644 --- a/usr.sbin/bluetooth/sdpd/irmc_command.c +++ b/usr.sbin/bluetooth/sdpd/irmc_command.c @@ -1,120 +1,119 @@ /*- * irmc_command_command_command.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: irmc_command.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t irmc_command_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t irmc_command_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t irmc_command_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Sync Command Service"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t irmc_command_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_irmc_command_profile_p irmc_command = (sdp_irmc_command_profile_p) provider->data; return (obex_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &irmc_command->server_channel, 1)); } static attr_t irmc_command_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, irmc_command_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, irmc_command_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, irmc_command_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, irmc_command_profile_create_protocol_descriptor_list }, { 0, NULL } /* end entry */ }; profile_t irmc_command_profile_descriptor = { SDP_SERVICE_CLASS_IR_MC_SYNC_COMMAND, sizeof(sdp_irmc_command_profile_t), common_profile_server_channel_valid, (attr_t const * const) &irmc_command_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/lan.c b/usr.sbin/bluetooth/sdpd/lan.c index 0fc22df94d6f..66a71754ef48 100644 --- a/usr.sbin/bluetooth/sdpd/lan.c +++ b/usr.sbin/bluetooth/sdpd/lan.c @@ -1,175 +1,174 @@ /*- * lan.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: lan.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "profile.h" #include "provider.h" static int32_t lan_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t lan_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t lan_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "LAN Access using PPP"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t lan_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_lan_profile_p lan = (sdp_lan_profile_p) provider->data; return (rfcomm_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &lan->server_channel, 1)); } static int32_t lan_profile_create_service_availability( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_lan_profile_p lan = (sdp_lan_profile_p) provider->data; return (common_profile_create_service_availability(buf, eob, &lan->load_factor, 1)); } static int32_t lan_profile_create_ip_subnet( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_lan_profile_p lan = (sdp_lan_profile_p) provider->data; char net[32]; int32_t len; len = snprintf(net, sizeof(net), "%s/%d", inet_ntoa(* (struct in_addr *) &lan->ip_subnet), lan->ip_subnet_radius); if (len < 0 || buf + 2 + len > eob) return (-1); SDP_PUT8(SDP_DATA_STR8, buf); SDP_PUT8(len, buf); memcpy(buf, net, len); return (2 + len); } static int32_t lan_profile_data_valid(uint8_t const *data, uint32_t datalen) { sdp_lan_profile_p lan = (sdp_lan_profile_p) data; if (lan->server_channel < 1 || lan->server_channel > 30 || lan->ip_subnet_radius > 32) return (0); return (1); } static attr_t lan_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, lan_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, lan_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, lan_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, lan_profile_create_protocol_descriptor_list }, { SDP_ATTR_SERVICE_AVAILABILITY, lan_profile_create_service_availability }, { SDP_ATTR_IP_SUBNET, lan_profile_create_ip_subnet }, { 0, NULL } /* end entry */ }; profile_t lan_profile_descriptor = { SDP_SERVICE_CLASS_LAN_ACCESS_USING_PPP, sizeof(sdp_lan_profile_t), lan_profile_data_valid, (attr_t const * const) &lan_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/log.c b/usr.sbin/bluetooth/sdpd/log.c index 57394c89b159..f7d4fa350c65 100644 --- a/usr.sbin/bluetooth/sdpd/log.c +++ b/usr.sbin/bluetooth/sdpd/log.c @@ -1,129 +1,128 @@ /*- * log.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: log.c,v 1.1 2004/01/07 23:15:00 max Exp $ - * $FreeBSD$ */ #include #include #include void log_open(char const *prog, int32_t log2stderr) { openlog(prog, LOG_PID|LOG_NDELAY|(log2stderr? LOG_PERROR:0), LOG_USER); } void log_close(void) { closelog(); } void log_emerg(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_EMERG, message, ap); va_end(ap); } void log_alert(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_ALERT, message, ap); va_end(ap); } void log_crit(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_CRIT, message, ap); va_end(ap); } void log_err(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_ERR, message, ap); va_end(ap); } void log_warning(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_WARNING, message, ap); va_end(ap); } void log_notice(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_NOTICE, message, ap); va_end(ap); } void log_info(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_INFO, message, ap); va_end(ap); } void log_debug(char const *message, ...) { va_list ap; va_start(ap, message); vsyslog(LOG_DEBUG, message, ap); va_end(ap); } diff --git a/usr.sbin/bluetooth/sdpd/log.h b/usr.sbin/bluetooth/sdpd/log.h index fcc53a02c64c..e00ed4d8c838 100644 --- a/usr.sbin/bluetooth/sdpd/log.h +++ b/usr.sbin/bluetooth/sdpd/log.h @@ -1,49 +1,48 @@ /*- * log.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: log.h,v 1.1 2004/01/07 23:15:00 max Exp $ - * $FreeBSD$ */ #ifndef _LOG_H_ #define _LOG_H_ void log_open (char const *prog, int32_t log2stderr); void log_close (void); void log_emerg (char const *message, ...); void log_alert (char const *message, ...); void log_crit (char const *message, ...); void log_err (char const *message, ...); void log_warning (char const *message, ...); void log_notice (char const *message, ...); void log_info (char const *message, ...); void log_debug (char const *message, ...); #endif /* ndef _LOG_H_ */ diff --git a/usr.sbin/bluetooth/sdpd/main.c b/usr.sbin/bluetooth/sdpd/main.c index e438d5b9e000..cc21b314f486 100644 --- a/usr.sbin/bluetooth/sdpd/main.c +++ b/usr.sbin/bluetooth/sdpd/main.c @@ -1,238 +1,237 @@ /*- * main.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: main.c,v 1.8 2004/01/13 19:31:54 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include #include #include "log.h" #include "server.h" #include #include #include #include "profile.h" #include "provider.h" #define SDPD "sdpd" static int32_t drop_root (char const *user, char const *group); static void sighandler (int32_t s); static void usage (void); static int32_t done; /* * Bluetooth Service Discovery Procotol (SDP) daemon */ int main(int argc, char *argv[]) { server_t server; char const *control = SDP_LOCAL_PATH; char const *user = "nobody", *group = "nobody"; int32_t detach = 1, opt; struct sigaction sa; while ((opt = getopt(argc, argv, "c:dg:hu:")) != -1) { switch (opt) { case 'c': /* control */ control = optarg; break; case 'd': /* do not detach */ detach = 0; break; case 'g': /* group */ group = optarg; break; case 'u': /* user */ user = optarg; break; case 'h': default: usage(); /* NOT REACHED */ } } log_open(SDPD, !detach); /* Become daemon if required */ if (detach && daemon(0, 0) < 0) { log_crit("Could not become daemon. %s (%d)", strerror(errno), errno); exit(1); } /* Set signal handlers */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = sighandler; if (sigaction(SIGTERM, &sa, NULL) < 0 || sigaction(SIGHUP, &sa, NULL) < 0 || sigaction(SIGINT, &sa, NULL) < 0) { log_crit("Could not install signal handlers. %s (%d)", strerror(errno), errno); exit(1); } sa.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sa, NULL) < 0) { log_crit("Could not install signal handlers. %s (%d)", strerror(errno), errno); exit(1); } /* Initialize server */ if (server_init(&server, control) < 0) exit(1); if ((user != NULL || group != NULL) && drop_root(user, group) < 0) exit(1); for (done = 0; !done; ) { if (server_do(&server) != 0) done ++; } server_shutdown(&server); log_close(); return (0); } /* * Drop root */ static int32_t drop_root(char const *user, char const *group) { int uid, gid; char *ep; if ((uid = getuid()) != 0) { log_notice("Cannot set uid/gid. Not a superuser"); return (0); /* dont do anything unless root */ } gid = getgid(); if (user != NULL) { uid = strtol(user, &ep, 10); if (*ep != '\0') { struct passwd *pwd = getpwnam(user); if (pwd == NULL) { log_err("Could not find passwd entry for " \ "user %s", user); return (-1); } uid = pwd->pw_uid; } } if (group != NULL) { gid = strtol(group, &ep, 10); if (*ep != '\0') { struct group *grp = getgrnam(group); if (grp == NULL) { log_err("Could not find group entry for " \ "group %s", group); return (-1); } gid = grp->gr_gid; } } if (setgid(gid) < 0) { log_err("Could not setgid(%s). %s (%d)", group, strerror(errno), errno); return (-1); } if (setuid(uid) < 0) { log_err("Could not setuid(%s). %s (%d)", user, strerror(errno), errno); return (-1); } return (0); } /* * Signal handler */ static void sighandler(int32_t s) { log_notice("Got signal %d. Total number of signals received %d", s, ++ done); } /* * Display usage information and quit */ static void usage(void) { fprintf(stderr, "Usage: %s [options]\n" \ "Where options are:\n" \ " -c specify control socket name (default %s)\n" \ " -d do not detach (run in foreground)\n" \ " -g grp specify group\n" \ " -h display usage and exit\n" \ " -u usr specify user\n", SDPD, SDP_LOCAL_PATH); exit(255); } diff --git a/usr.sbin/bluetooth/sdpd/nap.c b/usr.sbin/bluetooth/sdpd/nap.c index 529bfd528372..229600b9c950 100644 --- a/usr.sbin/bluetooth/sdpd/nap.c +++ b/usr.sbin/bluetooth/sdpd/nap.c @@ -1,212 +1,211 @@ /* * nap.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: nap.c,v 1.1 2008/03/11 00:02:42 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t nap_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_NAP }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t nap_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_NAP, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t nap_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Network Access Point"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t nap_profile_create_service_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_descr[] = "Personal Ad-hoc Network Service"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_descr, strlen(service_descr))); } static int32_t nap_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; return (bnep_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &nap->psm, sizeof(nap->psm))); } static int32_t nap_profile_create_security_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; return (bnep_profile_create_security_description(buf, eob, (uint8_t const *) &nap->security_description, sizeof(nap->security_description))); } static int32_t nap_profile_create_net_access_type( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; if (buf + 3 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(nap->net_access_type, buf); return (3); } static int32_t nap_profile_create_max_net_access_rate( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; if (buf + 3 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(nap->max_net_access_rate, buf); return (3); } static int32_t nap_profile_create_service_availability( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_nap_profile_p nap = (sdp_nap_profile_p) provider->data; return (common_profile_create_service_availability(buf, eob, &nap->load_factor, 1)); } static int32_t nap_profile_data_valid(uint8_t const *data, uint32_t datalen) { sdp_nap_profile_p nap = (sdp_nap_profile_p) data; return ((nap->psm == 0)? 0 : 1); } static attr_t nap_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, nap_profile_create_service_class_id_list }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, nap_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_SERVICE_AVAILABILITY, nap_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, nap_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, nap_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, nap_profile_create_service_description }, { SDP_ATTR_SECURITY_DESCRIPTION, nap_profile_create_security_description }, { SDP_ATTR_NET_ACCESS_TYPE, nap_profile_create_net_access_type }, { SDP_ATTR_MAX_NET_ACCESS_RATE, nap_profile_create_max_net_access_rate }, { 0, NULL } /* end entry */ }; profile_t nap_profile_descriptor = { SDP_SERVICE_CLASS_NAP, sizeof(sdp_nap_profile_t), nap_profile_data_valid, (attr_t const * const) &nap_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/opush.c b/usr.sbin/bluetooth/sdpd/opush.c index b2a7255c5da4..6f2464191292 100644 --- a/usr.sbin/bluetooth/sdpd/opush.c +++ b/usr.sbin/bluetooth/sdpd/opush.c @@ -1,136 +1,135 @@ /*- * opush.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: opush.c,v 1.6 2004/01/13 19:31:54 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t opush_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t opush_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t opush_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "OBEX Object Push"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t opush_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_opush_profile_p opush = (sdp_opush_profile_p) provider->data; return (obex_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &opush->server_channel, 1)); } static int32_t opush_profile_create_supported_formats_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_opush_profile_p opush = (sdp_opush_profile_p) provider->data; return (obex_profile_create_supported_formats_list( buf, eob, (uint8_t const *) opush->supported_formats, opush->supported_formats_size)); } static attr_t opush_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, opush_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, opush_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, opush_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, opush_profile_create_protocol_descriptor_list }, { SDP_ATTR_SUPPORTED_FORMATS_LIST, opush_profile_create_supported_formats_list }, { 0, NULL } /* end entry */ }; profile_t opush_profile_descriptor = { SDP_SERVICE_CLASS_OBEX_OBJECT_PUSH, sizeof(sdp_opush_profile_t), obex_profile_data_valid, (attr_t const * const) &opush_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/panu.c b/usr.sbin/bluetooth/sdpd/panu.c index e0498e89a185..bba1dbd45d1d 100644 --- a/usr.sbin/bluetooth/sdpd/panu.c +++ b/usr.sbin/bluetooth/sdpd/panu.c @@ -1,175 +1,174 @@ /* * panu.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2008 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: panu.c,v 1.1 2008/03/11 00:02:42 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t panu_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_PANU }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t panu_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_PANU, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t panu_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Personal Ad-hoc User Service"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t panu_profile_create_service_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_descr[] = "Personal Ad-hoc User Service"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_descr, strlen(service_descr))); } static int32_t panu_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_panu_profile_p panu = (sdp_panu_profile_p) provider->data; return (bnep_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &panu->psm, sizeof(panu->psm))); } static int32_t panu_profile_data_valid(uint8_t const *data, uint32_t datalen) { sdp_panu_profile_p panu = (sdp_panu_profile_p) data; return ((panu->psm == 0)? 0 : 1); } static int32_t panu_profile_create_service_availability( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_panu_profile_p panu = (sdp_panu_profile_p) provider->data; return (common_profile_create_service_availability( buf, eob, &panu->load_factor, 1)); } static int32_t panu_profile_create_security_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_panu_profile_p panu = (sdp_panu_profile_p) provider->data; return (bnep_profile_create_security_description(buf, eob, (uint8_t const *) &panu->security_description, sizeof(panu->security_description))); } static attr_t panu_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, panu_profile_create_service_class_id_list }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, panu_profile_create_protocol_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_SERVICE_AVAILABILITY, panu_profile_create_service_availability }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, panu_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, panu_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, panu_profile_create_service_description }, { SDP_ATTR_SECURITY_DESCRIPTION, panu_profile_create_security_description }, { 0, NULL } /* end entry */ }; profile_t panu_profile_descriptor = { SDP_SERVICE_CLASS_PANU, sizeof(sdp_panu_profile_t), panu_profile_data_valid, (attr_t const * const) &panu_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/profile.c b/usr.sbin/bluetooth/sdpd/profile.c index 1b576e44d91e..3c6ada6871c7 100644 --- a/usr.sbin/bluetooth/sdpd/profile.c +++ b/usr.sbin/bluetooth/sdpd/profile.c @@ -1,504 +1,503 @@ /* * profile.c */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: profile.c,v 1.6 2004/01/13 19:31:54 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" /* * Lookup profile descriptor */ profile_p profile_get_descriptor(uint16_t uuid) { extern profile_t audio_sink_profile_descriptor; extern profile_t audio_source_profile_descriptor; extern profile_t dun_profile_descriptor; extern profile_t ftrn_profile_descriptor; extern profile_t irmc_profile_descriptor; extern profile_t irmc_command_profile_descriptor; extern profile_t lan_profile_descriptor; extern profile_t opush_profile_descriptor; extern profile_t sp_profile_descriptor; extern profile_t nap_profile_descriptor; extern profile_t gn_profile_descriptor; extern profile_t panu_profile_descriptor; static const profile_p profiles[] = { &audio_sink_profile_descriptor, &audio_source_profile_descriptor, &dun_profile_descriptor, &ftrn_profile_descriptor, &irmc_profile_descriptor, &irmc_command_profile_descriptor, &lan_profile_descriptor, &opush_profile_descriptor, &sp_profile_descriptor, &nap_profile_descriptor, &gn_profile_descriptor, &panu_profile_descriptor }; int32_t i; for (i = 0; i < sizeof(profiles)/sizeof(profiles[0]); i++) if (profiles[i]->uuid == uuid) return (profiles[i]); return (NULL); } /* * Look attribute in the profile descripror */ profile_attr_create_p profile_get_attr(const profile_p profile, uint16_t attr) { attr_p ad = (attr_p) profile->attrs; for (; ad->create != NULL; ad ++) if (ad->attr == attr) return (ad->create); return (NULL); } /* * uint32 value32 - 5 bytes */ int32_t common_profile_create_service_record_handle( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 5 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT32, buf); SDP_PUT32(((provider_p) data)->handle, buf); return (5); } /* * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes * [ uuid16 value ] */ int32_t common_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { int32_t len = 3 * (datalen >>= 1); if (len <= 0 || len > 0xff || buf + 2 + len > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(len, buf); for (; datalen > 0; datalen --) { SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(*((uint16_t const *)data), buf); data += sizeof(uint16_t); } return (2 + len); } /* * seq8 len8 - 2 bytes * seq 8 len8 - 2 bytes * uuid16 value16 - 3 bytes * uint16 value16 - 3 bytes * [ seq 8 len8 * uuid16 value16 * uint16 value16 ] */ int32_t common_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { int32_t len = 8 * (datalen >>= 2); if (len <= 0 || len > 0xff || buf + 2 + len > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(len, buf); for (; datalen > 0; datalen --) { SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(6, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(*((uint16_t const *)data), buf); data += sizeof(uint16_t); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(*((uint16_t const *)data), buf); data += sizeof(uint16_t); } return (2 + len); } /* * seq8 len8 - 2 bytes * uint16 value16 - 3 bytes * uint16 value16 - 3 bytes * uint16 value16 - 3 bytes */ int32_t common_profile_create_language_base_attribute_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 11 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(9, buf); /* * Language code per ISO 639:1988. Use "en". */ SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(((0x65 << 8) | 0x6e), buf); /* * Encoding. Recommended is UTF-8. ISO639 UTF-8 MIBenum is 106 * (http://www.iana.org/assignments/character-sets) */ SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(106, buf); /* * Offset (Primary Language Base is 0x100) */ SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID, buf); return (11); } /* * Common provider name is "FreeBSD" */ int32_t common_profile_create_service_provider_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { char provider_name[] = "FreeBSD"; return (common_profile_create_string8(buf, eob, (uint8_t const *) provider_name, strlen(provider_name))); } /* * str8 len8 string */ int32_t common_profile_create_string8( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (datalen == 0 || datalen > 0xff || buf + 2 + datalen > eob) return (-1); SDP_PUT8(SDP_DATA_STR8, buf); SDP_PUT8(datalen, buf); memcpy(buf, data, datalen); return (2 + datalen); } /* * Service Availability */ int32_t common_profile_create_service_availability( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (datalen != 1 || buf + 2 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT8, buf); SDP_PUT8(data[0], buf); return (2); } /* * seq8 len8 - 2 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes * uint8 value8 - 2 bytes */ int32_t rfcomm_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (datalen != 1 || buf + 14 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(12, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(5, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_RFCOMM, buf); SDP_PUT8(SDP_DATA_UINT8, buf); SDP_PUT8(*data, buf); return (14); } /* * seq8 len8 - 2 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes * uint8 value8 - 2 bytes * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes */ int32_t obex_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (datalen != 1 || buf + 19 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(17, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(5, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_RFCOMM, buf); SDP_PUT8(SDP_DATA_UINT8, buf); SDP_PUT8(*data, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_OBEX, buf); return (19); } /* * seq8 len8 * uint8 value8 - bytes * [ uint8 value 8 ] */ int32_t obex_profile_create_supported_formats_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { int32_t len = 2 * datalen; if (len <= 0 || len > 0xff || buf + 2 + len > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(len, buf); for (; datalen > 0; datalen --) { SDP_PUT8(SDP_DATA_UINT8, buf); SDP_PUT8(*data++, buf); } return (2 + len); } /* * do not check anything */ int32_t common_profile_always_valid(uint8_t const *data, uint32_t datalen) { return (1); } /* * verify server channel number (the first byte in the data) */ int32_t common_profile_server_channel_valid(uint8_t const *data, uint32_t datalen) { if (data[0] < 1 || data[0] > 30) return (0); return (1); } /* * verify server channel number and supported_formats_size * sdp_opush_profile and sdp_irmc_profile */ int32_t obex_profile_data_valid(uint8_t const *data, uint32_t datalen) { sdp_opush_profile_p opush = (sdp_opush_profile_p) data; if (opush->server_channel < 1 || opush->server_channel > 30 || opush->supported_formats_size == 0 || opush->supported_formats_size > sizeof(opush->supported_formats)) return (0); return (1); } /* * BNEP protocol descriptor */ int32_t bnep_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { /* supported protocol types */ uint16_t ptype[] = { 0x0800, /* IPv4 */ 0x0806, /* ARP */ #ifdef INET6 0x86dd, /* IPv6 */ #endif }; uint16_t i, psm, version = 0x0100, nptypes = sizeof(ptype)/sizeof(ptype[0]), nptypes_size = nptypes * 3; if (datalen != 2 || 18 + nptypes_size > 255 || buf + 20 + nptypes_size > eob) return (-1); memcpy(&psm, data, sizeof(psm)); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(18 + nptypes_size, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(6, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(psm, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(8 + nptypes_size, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_BNEP, buf); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(version, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(nptypes_size, buf); for (i = 0; i < nptypes; i ++) { SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(ptype[i], buf); } return (20 + nptypes_size); } /* * BNEP security description */ int32_t bnep_profile_create_security_description( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { uint16_t security_descr; if (datalen != 2 || buf + 3 > eob) return (-1); memcpy(&security_descr, data, sizeof(security_descr)); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(security_descr, buf); return (3); } diff --git a/usr.sbin/bluetooth/sdpd/profile.h b/usr.sbin/bluetooth/sdpd/profile.h index b8c5cda7d6a9..7184c0fd742e 100644 --- a/usr.sbin/bluetooth/sdpd/profile.h +++ b/usr.sbin/bluetooth/sdpd/profile.h @@ -1,98 +1,97 @@ /* * profile.h */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: profile.h,v 1.6 2004/01/13 19:31:54 max Exp $ - * $FreeBSD$ */ #ifndef _PROFILE_H_ #define _PROFILE_H_ /* * Attribute descriptor */ typedef int32_t (profile_attr_create_t)( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen); typedef profile_attr_create_t * profile_attr_create_p; typedef int32_t (profile_data_valid_t)( uint8_t const *data, uint32_t datalen); typedef profile_data_valid_t * profile_data_valid_p; struct attr { uint16_t attr; /* attribute id */ profile_attr_create_p create; /* create attr value */ }; typedef struct attr attr_t; typedef struct attr * attr_p; /* * Profile descriptor */ struct profile { uint16_t uuid; /* profile uuid */ uint16_t dsize; /* profile data size */ profile_data_valid_p valid; /* profile data validator */ attr_t const * const attrs; /* supported attributes */ }; typedef struct profile profile_t; typedef struct profile *profile_p; profile_p profile_get_descriptor(uint16_t uuid); profile_attr_create_p profile_get_attr(const profile_p profile, uint16_t attr); profile_attr_create_t common_profile_create_service_record_handle; profile_attr_create_t common_profile_create_service_class_id_list; profile_attr_create_t common_profile_create_bluetooth_profile_descriptor_list; profile_attr_create_t common_profile_create_language_base_attribute_id_list; profile_attr_create_t common_profile_create_service_provider_name; profile_attr_create_t common_profile_create_string8; profile_attr_create_t common_profile_create_service_availability; profile_attr_create_t rfcomm_profile_create_protocol_descriptor_list; profile_attr_create_t obex_profile_create_protocol_descriptor_list; profile_attr_create_t obex_profile_create_supported_formats_list; profile_attr_create_t bnep_profile_create_protocol_descriptor_list; profile_attr_create_t bnep_profile_create_security_description; profile_data_valid_t common_profile_always_valid; profile_data_valid_t common_profile_server_channel_valid; profile_data_valid_t obex_profile_data_valid; #endif /* ndef _PROFILE_H_ */ diff --git a/usr.sbin/bluetooth/sdpd/provider.c b/usr.sbin/bluetooth/sdpd/provider.c index 2f7ed67f1851..7ac800a85006 100644 --- a/usr.sbin/bluetooth/sdpd/provider.c +++ b/usr.sbin/bluetooth/sdpd/provider.c @@ -1,199 +1,198 @@ /*- * provider.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: provider.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static TAILQ_HEAD(, provider) providers = TAILQ_HEAD_INITIALIZER(providers); static uint32_t change_state = 0; static uint32_t handle = 0; /* * Register Service Discovery provider. * Should not be called more the once. */ int32_t provider_register_sd(int32_t fd) { extern profile_t sd_profile_descriptor; extern profile_t bgd_profile_descriptor; provider_p sd = calloc(1, sizeof(*sd)); provider_p bgd = calloc(1, sizeof(*bgd)); if (sd == NULL || bgd == NULL) { if (sd != NULL) free(sd); if (bgd != NULL) free(bgd); return (-1); } sd->profile = &sd_profile_descriptor; bgd->handle = 0; sd->fd = fd; TAILQ_INSERT_HEAD(&providers, sd, provider_next); bgd->profile = &bgd_profile_descriptor; bgd->handle = 1; sd->fd = fd; TAILQ_INSERT_AFTER(&providers, sd, bgd, provider_next); change_state ++; return (0); } /* * Register new provider for a given profile, bdaddr and session. */ provider_p provider_register(profile_p const profile, bdaddr_p const bdaddr, int32_t fd, uint8_t const *data, uint32_t datalen) { provider_p provider = calloc(1, sizeof(*provider)); if (provider != NULL) { provider->data = malloc(datalen); if (provider->data != NULL) { provider->profile = profile; memcpy(provider->data, data, datalen); /* * Record handles 0x0 and 0x1 are reserved * for SDP itself */ if (++ handle <= 1) handle = 2; provider->handle = handle; memcpy(&provider->bdaddr, bdaddr, sizeof(provider->bdaddr)); provider->fd = fd; TAILQ_INSERT_TAIL(&providers, provider, provider_next); change_state ++; } else { free(provider); provider = NULL; } } return (provider); } /* * Unregister provider */ void provider_unregister(provider_p provider) { TAILQ_REMOVE(&providers, provider, provider_next); if (provider->data != NULL) free(provider->data); free(provider); change_state ++; } /* * Update provider data */ int32_t provider_update(provider_p provider, uint8_t const *data, uint32_t datalen) { uint8_t *new_data = (uint8_t *) realloc(provider->data, datalen); if (new_data == NULL) return (-1); memcpy(new_data, data, datalen); provider->data = new_data; return (0); } /* * Get a provider for given record handle */ provider_p provider_by_handle(uint32_t handle) { provider_p provider = NULL; TAILQ_FOREACH(provider, &providers, provider_next) if (provider->handle == handle) break; return (provider); } /* * Cursor access */ provider_p provider_get_first(void) { return (TAILQ_FIRST(&providers)); } provider_p provider_get_next(provider_p provider) { return (TAILQ_NEXT(provider, provider_next)); } /* * Return change state */ uint32_t provider_get_change_state(void) { return (change_state); } diff --git a/usr.sbin/bluetooth/sdpd/provider.h b/usr.sbin/bluetooth/sdpd/provider.h index eeb63ef1ba88..b4f3bb0a46d0 100644 --- a/usr.sbin/bluetooth/sdpd/provider.h +++ b/usr.sbin/bluetooth/sdpd/provider.h @@ -1,77 +1,76 @@ /*- * provider.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: provider.h,v 1.6 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #ifndef _PROVIDER_H_ #define _PROVIDER_H_ /* * Provider of service */ struct profile; struct provider { struct profile *profile; /* profile */ void *data; /* profile data */ uint32_t handle; /* record handle */ bdaddr_t bdaddr; /* provider's BDADDR */ int32_t fd; /* session descriptor */ TAILQ_ENTRY(provider) provider_next; /* all providers */ }; typedef struct provider provider_t; typedef struct provider * provider_p; #define provider_match_bdaddr(p, b) \ (memcmp(b, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \ memcmp(&(p)->bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \ memcmp(&(p)->bdaddr, b, sizeof(bdaddr_t)) == 0) int32_t provider_register_sd (int32_t fd); provider_p provider_register (profile_p const profile, bdaddr_p const bdaddr, int32_t fd, uint8_t const *data, uint32_t datalen); void provider_unregister (provider_p provider); int32_t provider_update (provider_p provider, uint8_t const *data, uint32_t datalen); provider_p provider_by_handle (uint32_t handle); provider_p provider_get_first (void); provider_p provider_get_next (provider_p provider); uint32_t provider_get_change_state (void); #endif /* ndef _PROVIDER_H_ */ diff --git a/usr.sbin/bluetooth/sdpd/sar.c b/usr.sbin/bluetooth/sdpd/sar.c index 99d63e4e7fff..0470109ebc07 100644 --- a/usr.sbin/bluetooth/sdpd/sar.c +++ b/usr.sbin/bluetooth/sdpd/sar.c @@ -1,320 +1,319 @@ /*- * sar.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sar.c,v 1.2 2004/01/08 23:46:51 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include /* for NULL */ #include "profile.h" #include "provider.h" #include "server.h" /* * Prepare SDP attr/value pair. Check if profile implements the attribute * and if so call the attribute value function. * * uint16 value16 - 3 bytes (attribute) * value - N bytes (value) */ static int32_t server_prepare_attr_value_pair( provider_p const provider, uint16_t attr, uint8_t *buf, uint8_t const * const eob) { profile_attr_create_p cf = profile_get_attr(provider->profile, attr); int32_t len; if (cf == NULL) return (0); /* no attribute */ if (buf + 3 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(attr, buf); len = cf(buf, eob, (uint8_t const *) provider, sizeof(*provider)); if (len < 0) return (-1); return (3 + len); } /* * seq16 value16 - 3 bytes * attr value - 3+ bytes * [ attr value ] */ int32_t server_prepare_attr_list(provider_p const provider, uint8_t const *req, uint8_t const * const req_end, uint8_t *rsp, uint8_t const * const rsp_end) { uint8_t *ptr = rsp + 3; int32_t type, hi, lo, len; if (ptr > rsp_end) return (-1); while (req < req_end) { SDP_GET8(type, req); switch (type) { case SDP_DATA_UINT16: if (req + 2 > req_end) return (-1); SDP_GET16(lo, req); hi = lo; break; case SDP_DATA_UINT32: if (req + 4 > req_end) return (-1); SDP_GET16(lo, req); SDP_GET16(hi, req); break; default: return (-1); /* NOT REACHED */ } for (; lo <= hi; lo ++) { len = server_prepare_attr_value_pair(provider, lo, ptr, rsp_end); if (len < 0) return (-1); ptr += len; } } len = ptr - rsp; /* we put this much bytes in rsp */ /* Fix SEQ16 header for the rsp */ SDP_PUT8(SDP_DATA_SEQ16, rsp); SDP_PUT16(len - 3, rsp); return (len); } /* * Prepare SDP Service Attribute Response */ int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; uint8_t const *rsp_end = rsp + NG_L2CAP_MTU_MAXIMUM; uint8_t *ptr = NULL; provider_t *provider = NULL; uint32_t handle; int32_t type, rsp_limit, aidlen, cslen, cs; /* * Minimal Service Attribute Request request * * value32 - 4 bytes ServiceRecordHandle * value16 - 2 bytes MaximumAttributeByteCount * seq8 len8 - 2 bytes * uint16 value16 - 3 bytes AttributeIDList * value8 - 1 byte ContinuationState */ if (req_end - req < 12) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get ServiceRecordHandle and MaximumAttributeByteCount */ SDP_GET32(handle, req); SDP_GET16(rsp_limit, req); if (rsp_limit <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get size of AttributeIDList */ aidlen = 0; SDP_GET8(type, req); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(aidlen, req); break; case SDP_DATA_SEQ16: SDP_GET16(aidlen, req); break; case SDP_DATA_SEQ32: SDP_GET32(aidlen, req); break; } if (aidlen <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); ptr = (uint8_t *) req + aidlen; /* Get ContinuationState */ if (ptr + 1 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET8(cslen, ptr); if (cslen != 0) { if (cslen != 2 || req_end - ptr != 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(cs, ptr); } else cs = 0; /* Process the request. First, check continuation state */ if (srv->fdidx[fd].rsp_cs != cs) return (SDP_ERROR_CODE_INVALID_CONTINUATION_STATE); if (srv->fdidx[fd].rsp_size > 0) return (0); /* Lookup record handle */ if ((provider = provider_by_handle(handle)) == NULL) return (SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE); /* * Service Attribute Response format * * value16 - 2 bytes AttributeListByteCount (not incl.) * seq8 len16 - 3 bytes * attr value - 3+ bytes AttributeList * [ attr value ] */ cs = server_prepare_attr_list(provider, req, req+aidlen, rsp, rsp_end); if (cs < 0) return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); /* Set reply size (not counting PDU header and continuation state) */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 2; if (srv->fdidx[fd].rsp_limit > rsp_limit) srv->fdidx[fd].rsp_limit = rsp_limit; srv->fdidx[fd].rsp_size = cs; srv->fdidx[fd].rsp_cs = 0; return (0); } /* * Send SDP Service [Search] Attribute Response */ int32_t server_send_service_attribute_response(server_p srv, int32_t fd) { uint8_t *rsp = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_cs; uint8_t *rsp_end = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_size; struct iovec iov[4]; sdp_pdu_t pdu; uint16_t bcount; uint8_t cs[3]; int32_t size; /* First update continuation state (assume we will send all data) */ size = rsp_end - rsp; srv->fdidx[fd].rsp_cs += size; if (size + 1 > srv->fdidx[fd].rsp_limit) { /* * We need to split out response. Add 3 more bytes for the * continuation state and move rsp_end and rsp_cs backwards. */ while ((rsp_end - rsp) + 3 > srv->fdidx[fd].rsp_limit) { rsp_end --; srv->fdidx[fd].rsp_cs --; } cs[0] = 2; cs[1] = srv->fdidx[fd].rsp_cs >> 8; cs[2] = srv->fdidx[fd].rsp_cs & 0xff; } else cs[0] = 0; assert(rsp_end >= rsp); bcount = rsp_end - rsp; if (((sdp_pdu_p)(srv->req))->pid == SDP_PDU_SERVICE_ATTRIBUTE_REQUEST) pdu.pid = SDP_PDU_SERVICE_ATTRIBUTE_RESPONSE; else pdu.pid = SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_RESPONSE; pdu.tid = ((sdp_pdu_p)(srv->req))->tid; pdu.len = htons(sizeof(bcount) + bcount + 1 + cs[0]); bcount = htons(bcount); iov[0].iov_base = &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = &bcount; iov[1].iov_len = sizeof(bcount); iov[2].iov_base = rsp; iov[2].iov_len = rsp_end - rsp; iov[3].iov_base = cs; iov[3].iov_len = 1 + cs[0]; do { size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); } while (size < 0 && errno == EINTR); /* Check if we have sent (or failed to sent) last response chunk */ if (srv->fdidx[fd].rsp_cs == srv->fdidx[fd].rsp_size) { srv->fdidx[fd].rsp_cs = 0; srv->fdidx[fd].rsp_size = 0; srv->fdidx[fd].rsp_limit = 0; } return ((size < 0)? errno : 0); } diff --git a/usr.sbin/bluetooth/sdpd/scr.c b/usr.sbin/bluetooth/sdpd/scr.c index 3f2b7882044e..a5bced947f8e 100644 --- a/usr.sbin/bluetooth/sdpd/scr.c +++ b/usr.sbin/bluetooth/sdpd/scr.c @@ -1,95 +1,94 @@ /*- * scr.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: scr.c,v 1.1 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "profile.h" #include "provider.h" #include "server.h" /* * Prepare Service Change response */ int32_t server_prepare_service_change_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; provider_t *provider = NULL; uint32_t handle; /* * Minimal Service Change Request * * value32 - handle 4 bytes */ if (!srv->fdidx[fd].control || !srv->fdidx[fd].priv || req_end - req < 4) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get handle */ SDP_GET32(handle, req); /* Lookup provider */ provider = provider_by_handle(handle); if (provider == NULL || provider->fd != fd) return (SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE); /* Validate user data */ if (req_end - req < provider->profile->dsize || provider->profile->valid == NULL || (provider->profile->valid)(req, req_end - req) == 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Update provider */ if (provider_update(provider, req, req_end - req) < 0) return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); SDP_PUT16(0, rsp); /* Set reply size */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t); srv->fdidx[fd].rsp_size = rsp - srv->fdidx[fd].rsp; srv->fdidx[fd].rsp_cs = 0; return (0); } diff --git a/usr.sbin/bluetooth/sdpd/sd.c b/usr.sbin/bluetooth/sdpd/sd.c index 2ee22084f8c4..cd4f7fa3364b 100644 --- a/usr.sbin/bluetooth/sdpd/sd.c +++ b/usr.sbin/bluetooth/sdpd/sd.c @@ -1,231 +1,230 @@ /*- * sd.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sd.c,v 1.4 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t sd_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t sd_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t sd_profile_create_service_id( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 3 > eob) return (-1); /* * The ServiceID is a UUID that universally and uniquely identifies * the service instance described by the service record. This service * attribute is particularly useful if the same service is described * by service records in more than one SDP server */ SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_SDP, buf); /* XXX ??? */ return (3); } static int32_t sd_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Bluetooth service discovery"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t sd_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 12 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(10, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_L2CAP, buf); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_UUID_PROTOCOL_SDP, buf); return (12); } static int32_t sd_profile_create_browse_group_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 5 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); /* * The top-level browse group ID, called PublicBrowseRoot and * representing the root of the browsing hierarchy, has the value * 00001002-0000-1000-8000-00805F9B34FB (UUID16: 0x1002) from the * Bluetooth Assigned Numbers document */ SDP_PUT8(SDP_DATA_UUID16, buf); SDP_PUT16(SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP, buf); return (5); } static int32_t sd_profile_create_version_number_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { if (buf + 5 > eob) return (-1); SDP_PUT8(SDP_DATA_SEQ8, buf); SDP_PUT8(3, buf); /* * The VersionNumberList is a data element sequence in which each * element of the sequence is a version number supported by the SDP * server. A version number is a 16-bit unsigned integer consisting * of two fields. The higher-order 8 bits contain the major version * number field and the low-order 8 bits contain the minor version * number field. The initial version of SDP has a major version of * 1 and a minor version of 0 */ SDP_PUT8(SDP_DATA_UINT16, buf); SDP_PUT16(0x0100, buf); return (5); } static int32_t sd_profile_create_service_database_state( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { uint32_t change_state = provider_get_change_state(); if (buf + 5 > eob) return (-1); SDP_PUT8(SDP_DATA_UINT32, buf); SDP_PUT32(change_state, buf); return (5); } static attr_t sd_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, sd_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, sd_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_SERVICE_ID, sd_profile_create_service_id }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, sd_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_DESCRIPTION_OFFSET, sd_profile_create_service_name }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_PROVIDER_NAME_OFFSET, common_profile_create_service_provider_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, sd_profile_create_protocol_descriptor_list }, { SDP_ATTR_BROWSE_GROUP_LIST, sd_profile_create_browse_group_list }, { SDP_ATTR_VERSION_NUMBER_LIST, sd_profile_create_version_number_list }, { SDP_ATTR_SERVICE_DATABASE_STATE, sd_profile_create_service_database_state }, { 0, NULL } /* end entry */ }; profile_t sd_profile_descriptor = { SDP_SERVICE_CLASS_SERVICE_DISCOVERY_SERVER, 0, (profile_data_valid_p) NULL, (attr_t const * const) &sd_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/server.c b/usr.sbin/bluetooth/sdpd/server.c index dcca8d15b838..ab398cd9339f 100644 --- a/usr.sbin/bluetooth/sdpd/server.c +++ b/usr.sbin/bluetooth/sdpd/server.c @@ -1,592 +1,591 @@ /*- * server.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: server.c,v 1.6 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include #include #include #include #include "log.h" #include "profile.h" #include "provider.h" #include "server.h" static void server_accept_client (server_p srv, int32_t fd); static int32_t server_process_request (server_p srv, int32_t fd); static int32_t server_send_error_response (server_p srv, int32_t fd, uint16_t error); static void server_close_fd (server_p srv, int32_t fd); /* * Initialize server */ int32_t server_init(server_p srv, char const *control) { struct sockaddr_un un; struct sockaddr_l2cap l2; int32_t unsock, l2sock; socklen_t size; uint16_t imtu; assert(srv != NULL); assert(control != NULL); memset(srv, 0, sizeof(*srv)); /* Open control socket */ if (unlink(control) < 0 && errno != ENOENT) { log_crit("Could not unlink(%s). %s (%d)", control, strerror(errno), errno); return (-1); } unsock = socket(PF_LOCAL, SOCK_STREAM, 0); if (unsock < 0) { log_crit("Could not create control socket. %s (%d)", strerror(errno), errno); return (-1); } memset(&un, 0, sizeof(un)); un.sun_len = sizeof(un); un.sun_family = AF_LOCAL; strlcpy(un.sun_path, control, sizeof(un.sun_path)); if (bind(unsock, (struct sockaddr *) &un, sizeof(un)) < 0) { log_crit("Could not bind control socket. %s (%d)", strerror(errno), errno); close(unsock); return (-1); } if (chmod(control, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) < 0) { log_crit("Could not change permissions on control socket. " \ "%s (%d)", strerror(errno), errno); close(unsock); return (-1); } if (listen(unsock, 10) < 0) { log_crit("Could not listen on control socket. %s (%d)", strerror(errno), errno); close(unsock); return (-1); } /* Open L2CAP socket */ l2sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BLUETOOTH_PROTO_L2CAP); if (l2sock < 0) { log_crit("Could not create L2CAP socket. %s (%d)", strerror(errno), errno); close(unsock); return (-1); } size = sizeof(imtu); if (getsockopt(l2sock, SOL_L2CAP, SO_L2CAP_IMTU, &imtu, &size) < 0) { log_crit("Could not get L2CAP IMTU. %s (%d)", strerror(errno), errno); close(unsock); close(l2sock); return (-1); } memset(&l2, 0, sizeof(l2)); l2.l2cap_len = sizeof(l2); l2.l2cap_family = AF_BLUETOOTH; memcpy(&l2.l2cap_bdaddr, NG_HCI_BDADDR_ANY, sizeof(l2.l2cap_bdaddr)); l2.l2cap_psm = htole16(NG_L2CAP_PSM_SDP); if (bind(l2sock, (struct sockaddr *) &l2, sizeof(l2)) < 0) { log_crit("Could not bind L2CAP socket. %s (%d)", strerror(errno), errno); close(unsock); close(l2sock); return (-1); } if (listen(l2sock, 10) < 0) { log_crit("Could not listen on L2CAP socket. %s (%d)", strerror(errno), errno); close(unsock); close(l2sock); return (-1); } /* Allocate incoming buffer */ srv->imtu = (imtu > SDP_LOCAL_MTU)? imtu : SDP_LOCAL_MTU; srv->req = (uint8_t *) calloc(srv->imtu, sizeof(srv->req[0])); if (srv->req == NULL) { log_crit("Could not allocate request buffer"); close(unsock); close(l2sock); return (-1); } /* Allocate memory for descriptor index */ srv->fdidx = (fd_idx_p) calloc(FD_SETSIZE, sizeof(srv->fdidx[0])); if (srv->fdidx == NULL) { log_crit("Could not allocate fd index"); free(srv->req); close(unsock); close(l2sock); return (-1); } /* Register Service Discovery profile (attach it to control socket) */ if (provider_register_sd(unsock) < 0) { log_crit("Could not register Service Discovery profile"); free(srv->fdidx); free(srv->req); close(unsock); close(l2sock); return (-1); } /* * If we got here then everything is fine. Add both control sockets * to the index. */ FD_ZERO(&srv->fdset); srv->maxfd = (unsock > l2sock)? unsock : l2sock; FD_SET(unsock, &srv->fdset); srv->fdidx[unsock].valid = 1; srv->fdidx[unsock].server = 1; srv->fdidx[unsock].control = 1; srv->fdidx[unsock].priv = 0; srv->fdidx[unsock].rsp_cs = 0; srv->fdidx[unsock].rsp_size = 0; srv->fdidx[unsock].rsp_limit = 0; srv->fdidx[unsock].omtu = SDP_LOCAL_MTU; srv->fdidx[unsock].rsp = NULL; FD_SET(l2sock, &srv->fdset); srv->fdidx[l2sock].valid = 1; srv->fdidx[l2sock].server = 1; srv->fdidx[l2sock].control = 0; srv->fdidx[l2sock].priv = 0; srv->fdidx[l2sock].rsp_cs = 0; srv->fdidx[l2sock].rsp_size = 0; srv->fdidx[l2sock].rsp_limit = 0; srv->fdidx[l2sock].omtu = 0; /* unknown */ srv->fdidx[l2sock].rsp = NULL; return (0); } /* * Shutdown server */ void server_shutdown(server_p srv) { int fd; assert(srv != NULL); for (fd = 0; fd < srv->maxfd + 1; fd ++) if (srv->fdidx[fd].valid) server_close_fd(srv, fd); free(srv->req); free(srv->fdidx); memset(srv, 0, sizeof(*srv)); } /* * Do one server iteration */ int32_t server_do(server_p srv) { fd_set fdset; int32_t n, fd; assert(srv != NULL); /* Copy cached version of the fd set and call select */ memcpy(&fdset, &srv->fdset, sizeof(fdset)); n = select(srv->maxfd + 1, &fdset, NULL, NULL, NULL); if (n < 0) { if (errno == EINTR) return (0); log_err("Could not select(%d, %p). %s (%d)", srv->maxfd + 1, &fdset, strerror(errno), errno); return (-1); } /* Process descriptors */ for (fd = 0; fd < srv->maxfd + 1 && n > 0; fd ++) { if (!FD_ISSET(fd, &fdset)) continue; assert(srv->fdidx[fd].valid); n --; if (srv->fdidx[fd].server) server_accept_client(srv, fd); else if (server_process_request(srv, fd) != 0) server_close_fd(srv, fd); } return (0); } /* * Accept new client connection and register it with index */ static void server_accept_client(server_p srv, int32_t fd) { uint8_t *rsp = NULL; int32_t cfd, priv; uint16_t omtu; socklen_t size; do { cfd = accept(fd, NULL, NULL); } while (cfd < 0 && errno == EINTR); if (cfd < 0) { log_err("Could not accept connection on %s socket. %s (%d)", srv->fdidx[fd].control? "control" : "L2CAP", strerror(errno), errno); return; } assert(!FD_ISSET(cfd, &srv->fdset)); assert(!srv->fdidx[cfd].valid); priv = 0; if (!srv->fdidx[fd].control) { /* Get local BD_ADDR */ size = sizeof(srv->req_sa); if (getsockname(cfd,(struct sockaddr*)&srv->req_sa,&size) < 0) { log_err("Could not get local BD_ADDR. %s (%d)", strerror(errno), errno); close(cfd); return; } /* Get outgoing MTU */ size = sizeof(omtu); if (getsockopt(cfd,SOL_L2CAP,SO_L2CAP_OMTU,&omtu,&size) < 0) { log_err("Could not get L2CAP OMTU. %s (%d)", strerror(errno), errno); close(cfd); return; } /* * The maximum size of the L2CAP packet is 65536 bytes. * The minimum L2CAP MTU is 43 bytes. That means we need * 65536 / 43 = ~1524 chunks to transfer maximum packet * size with minimum MTU. The "rsp_cs" field in fd_idx_t * is 11 bits wide, which gives us up to 2048 chunks. */ if (omtu < NG_L2CAP_MTU_MINIMUM) { log_err("L2CAP OMTU is too small (%d bytes)", omtu); close(cfd); return; } } else { struct xucred cr; struct passwd *pw; /* Get peer's credentials */ memset(&cr, 0, sizeof(cr)); size = sizeof(cr); if (getsockopt(cfd, 0, LOCAL_PEERCRED, &cr, &size) < 0) { log_err("Could not get peer's credentials. %s (%d)", strerror(errno), errno); close(cfd); return; } /* Check credentials */ pw = getpwuid(cr.cr_uid); if (pw != NULL) priv = (strcmp(pw->pw_name, "root") == 0); else log_warning("Could not verify credentials for uid %d", cr.cr_uid); memcpy(&srv->req_sa.l2cap_bdaddr, NG_HCI_BDADDR_ANY, sizeof(srv->req_sa.l2cap_bdaddr)); omtu = srv->fdidx[fd].omtu; } /* * Allocate buffer. This is an overkill, but we can not know how * big our reply is going to be. */ rsp = (uint8_t *) calloc(NG_L2CAP_MTU_MAXIMUM, sizeof(rsp[0])); if (rsp == NULL) { log_crit("Could not allocate response buffer"); close(cfd); return; } /* Add client descriptor to the index */ FD_SET(cfd, &srv->fdset); if (srv->maxfd < cfd) srv->maxfd = cfd; srv->fdidx[cfd].valid = 1; srv->fdidx[cfd].server = 0; srv->fdidx[cfd].control = srv->fdidx[fd].control; srv->fdidx[cfd].priv = priv; srv->fdidx[cfd].rsp_cs = 0; srv->fdidx[cfd].rsp_size = 0; srv->fdidx[cfd].rsp_limit = 0; srv->fdidx[cfd].omtu = omtu; srv->fdidx[cfd].rsp = rsp; } /* * Process request from the client */ static int32_t server_process_request(server_p srv, int32_t fd) { sdp_pdu_p pdu = (sdp_pdu_p) srv->req; int32_t len, error; assert(srv->imtu > 0); assert(srv->req != NULL); assert(FD_ISSET(fd, &srv->fdset)); assert(srv->fdidx[fd].valid); assert(!srv->fdidx[fd].server); assert(srv->fdidx[fd].rsp != NULL); assert(srv->fdidx[fd].omtu >= NG_L2CAP_MTU_MINIMUM); do { len = read(fd, srv->req, srv->imtu); } while (len < 0 && errno == EINTR); if (len < 0) { log_err("Could not receive SDP request from %s socket. %s (%d)", srv->fdidx[fd].control? "control" : "L2CAP", strerror(errno), errno); return (-1); } if (len == 0) { log_info("Client on %s socket has disconnected", srv->fdidx[fd].control? "control" : "L2CAP"); return (-1); } if (len >= sizeof(*pdu) && sizeof(*pdu) + (pdu->len = ntohs(pdu->len)) == len) { switch (pdu->pid) { case SDP_PDU_SERVICE_SEARCH_REQUEST: error = server_prepare_service_search_response(srv, fd); break; case SDP_PDU_SERVICE_ATTRIBUTE_REQUEST: error = server_prepare_service_attribute_response(srv, fd); break; case SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST: error = server_prepare_service_search_attribute_response(srv, fd); break; case SDP_PDU_SERVICE_REGISTER_REQUEST: error = server_prepare_service_register_response(srv, fd); break; case SDP_PDU_SERVICE_UNREGISTER_REQUEST: error = server_prepare_service_unregister_response(srv, fd); break; case SDP_PDU_SERVICE_CHANGE_REQUEST: error = server_prepare_service_change_response(srv, fd); break; default: error = SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX; break; } } else error = SDP_ERROR_CODE_INVALID_PDU_SIZE; if (error == 0) { switch (pdu->pid) { case SDP_PDU_SERVICE_SEARCH_REQUEST: error = server_send_service_search_response(srv, fd); break; case SDP_PDU_SERVICE_ATTRIBUTE_REQUEST: error = server_send_service_attribute_response(srv, fd); break; case SDP_PDU_SERVICE_SEARCH_ATTRIBUTE_REQUEST: error = server_send_service_search_attribute_response(srv, fd); break; case SDP_PDU_SERVICE_REGISTER_REQUEST: error = server_send_service_register_response(srv, fd); break; case SDP_PDU_SERVICE_UNREGISTER_REQUEST: error = server_send_service_unregister_response(srv, fd); break; case SDP_PDU_SERVICE_CHANGE_REQUEST: error = server_send_service_change_response(srv, fd); break; default: error = SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX; break; } if (error != 0) log_err("Could not send SDP response to %s socket, " \ "pdu->pid=%d, pdu->tid=%d, error=%d", srv->fdidx[fd].control? "control" : "L2CAP", pdu->pid, ntohs(pdu->tid), error); } else { log_err("Could not process SDP request from %s socket, " \ "pdu->pid=%d, pdu->tid=%d, pdu->len=%d, len=%d, " \ "error=%d", srv->fdidx[fd].control? "control" : "L2CAP", pdu->pid, ntohs(pdu->tid), pdu->len, len, error); error = server_send_error_response(srv, fd, error); if (error != 0) log_err("Could not send SDP error response to %s " \ "socket, pdu->pid=%d, pdu->tid=%d, error=%d", srv->fdidx[fd].control? "control" : "L2CAP", pdu->pid, ntohs(pdu->tid), error); } /* On error forget response (if any) */ if (error != 0) { srv->fdidx[fd].rsp_cs = 0; srv->fdidx[fd].rsp_size = 0; srv->fdidx[fd].rsp_limit = 0; } return (error); } /* * Send SDP_Error_Response PDU */ static int32_t server_send_error_response(server_p srv, int32_t fd, uint16_t error) { int32_t size; struct { sdp_pdu_t pdu; uint16_t error; } __attribute__ ((packed)) rsp; /* Prepare and send SDP error response */ rsp.pdu.pid = SDP_PDU_ERROR_RESPONSE; rsp.pdu.tid = ((sdp_pdu_p)(srv->req))->tid; rsp.pdu.len = htons(sizeof(rsp.error)); rsp.error = htons(error); do { size = write(fd, &rsp, sizeof(rsp)); } while (size < 0 && errno == EINTR); return ((size < 0)? errno : 0); } /* * Close descriptor and remove it from index */ static void server_close_fd(server_p srv, int32_t fd) { provider_p provider = NULL, provider_next = NULL; assert(FD_ISSET(fd, &srv->fdset)); assert(srv->fdidx[fd].valid); close(fd); FD_CLR(fd, &srv->fdset); if (fd == srv->maxfd) srv->maxfd --; if (srv->fdidx[fd].rsp != NULL) free(srv->fdidx[fd].rsp); memset(&srv->fdidx[fd], 0, sizeof(srv->fdidx[fd])); for (provider = provider_get_first(); provider != NULL; provider = provider_next) { provider_next = provider_get_next(provider); if (provider->fd == fd) provider_unregister(provider); } } diff --git a/usr.sbin/bluetooth/sdpd/server.h b/usr.sbin/bluetooth/sdpd/server.h index 3fd8e59bcf21..9a1cb86eb3da 100644 --- a/usr.sbin/bluetooth/sdpd/server.h +++ b/usr.sbin/bluetooth/sdpd/server.h @@ -1,104 +1,103 @@ /*- * server.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #ifndef _SERVER_H_ #define _SERVER_H_ /* * File descriptor index entry */ struct fd_idx { unsigned valid : 1; /* descriptor is valid */ unsigned server : 1; /* descriptor is listening */ unsigned control : 1; /* descriptor is a control socket */ unsigned priv : 1; /* descriptor is privileged */ unsigned reserved : 1; unsigned rsp_cs : 11; /* response continuation state */ uint16_t rsp_size; /* response size */ uint16_t rsp_limit; /* response limit */ uint16_t omtu; /* outgoing MTU */ uint8_t *rsp; /* outgoing buffer */ }; typedef struct fd_idx fd_idx_t; typedef struct fd_idx * fd_idx_p; /* * SDP server */ struct server { uint32_t imtu; /* incoming MTU */ uint8_t *req; /* incoming buffer */ int32_t maxfd; /* max. descriptor is the set */ fd_set fdset; /* current descriptor set */ fd_idx_p fdidx; /* descriptor index */ struct sockaddr_l2cap req_sa; /* local address */ }; typedef struct server server_t; typedef struct server * server_p; /* * External API */ int32_t server_init(server_p srv, const char *control); void server_shutdown(server_p srv); int32_t server_do(server_p srv); int32_t server_prepare_service_search_response(server_p srv, int32_t fd); int32_t server_send_service_search_response(server_p srv, int32_t fd); int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd); int32_t server_send_service_attribute_response(server_p srv, int32_t fd); int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd); #define server_send_service_search_attribute_response \ server_send_service_attribute_response int32_t server_prepare_service_register_response(server_p srv, int32_t fd); int32_t server_send_service_register_response(server_p srv, int32_t fd); int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd); #define server_send_service_unregister_response \ server_send_service_register_response int32_t server_prepare_service_change_response(server_p srv, int32_t fd); #define server_send_service_change_response \ server_send_service_register_response #endif /* ndef _SERVER_H_ */ diff --git a/usr.sbin/bluetooth/sdpd/sp.c b/usr.sbin/bluetooth/sdpd/sp.c index ed911e7d6e56..3c79dd93965d 100644 --- a/usr.sbin/bluetooth/sdpd/sp.c +++ b/usr.sbin/bluetooth/sdpd/sp.c @@ -1,120 +1,119 @@ /*- * sp.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sp.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" static int32_t sp_profile_create_service_class_id_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t service_classes[] = { SDP_SERVICE_CLASS_SERIAL_PORT }; return (common_profile_create_service_class_id_list( buf, eob, (uint8_t const *) service_classes, sizeof(service_classes))); } static int32_t sp_profile_create_bluetooth_profile_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static uint16_t profile_descriptor_list[] = { SDP_SERVICE_CLASS_SERIAL_PORT, 0x0100 }; return (common_profile_create_bluetooth_profile_descriptor_list( buf, eob, (uint8_t const *) profile_descriptor_list, sizeof(profile_descriptor_list))); } static int32_t sp_profile_create_service_name( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { static char service_name[] = "Serial Port"; return (common_profile_create_string8( buf, eob, (uint8_t const *) service_name, strlen(service_name))); } static int32_t sp_profile_create_protocol_descriptor_list( uint8_t *buf, uint8_t const * const eob, uint8_t const *data, uint32_t datalen) { provider_p provider = (provider_p) data; sdp_sp_profile_p sp = (sdp_sp_profile_p) provider->data; return (rfcomm_profile_create_protocol_descriptor_list( buf, eob, (uint8_t const *) &sp->server_channel, 1)); } static attr_t sp_profile_attrs[] = { { SDP_ATTR_SERVICE_RECORD_HANDLE, common_profile_create_service_record_handle }, { SDP_ATTR_SERVICE_CLASS_ID_LIST, sp_profile_create_service_class_id_list }, { SDP_ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST, sp_profile_create_bluetooth_profile_descriptor_list }, { SDP_ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST, common_profile_create_language_base_attribute_id_list }, { SDP_ATTR_PRIMARY_LANGUAGE_BASE_ID + SDP_ATTR_SERVICE_NAME_OFFSET, sp_profile_create_service_name }, { SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST, sp_profile_create_protocol_descriptor_list }, { 0, NULL } /* end entry */ }; profile_t sp_profile_descriptor = { SDP_SERVICE_CLASS_SERIAL_PORT, sizeof(sdp_sp_profile_t), common_profile_server_channel_valid, (attr_t const * const) &sp_profile_attrs }; diff --git a/usr.sbin/bluetooth/sdpd/srr.c b/usr.sbin/bluetooth/sdpd/srr.c index 01ec2bdf1c99..8e887a4841de 100644 --- a/usr.sbin/bluetooth/sdpd/srr.c +++ b/usr.sbin/bluetooth/sdpd/srr.c @@ -1,142 +1,141 @@ /*- * srr.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: srr.c,v 1.1 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "profile.h" #include "provider.h" #include "server.h" /* * Prepare Service Register response */ int32_t server_prepare_service_register_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; profile_t *profile = NULL; provider_t *provider = NULL; bdaddr_t *bdaddr = NULL; int32_t uuid; /* * Minimal Service Register Request * * value16 - uuid 2 bytes * bdaddr - BD_ADDR 6 bytes */ if (!srv->fdidx[fd].control || !srv->fdidx[fd].priv || req_end - req < 8) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get ServiceClass UUID */ SDP_GET16(uuid, req); /* Get BD_ADDR */ bdaddr = (bdaddr_p) req; req += sizeof(*bdaddr); /* Lookup profile descriptror */ profile = profile_get_descriptor(uuid); if (profile == NULL) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Validate user data */ if (req_end - req < profile->dsize || profile->valid == NULL || (profile->valid)(req, req_end - req) == 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Register provider */ provider = provider_register(profile, bdaddr, fd, req, req_end - req); if (provider == NULL) return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); SDP_PUT16(0, rsp); SDP_PUT32(provider->handle, rsp); /* Set reply size */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t); srv->fdidx[fd].rsp_size = rsp - srv->fdidx[fd].rsp; srv->fdidx[fd].rsp_cs = 0; return (0); } /* * Send Service Register Response */ int32_t server_send_service_register_response(server_p srv, int32_t fd) { struct iovec iov[2]; sdp_pdu_t pdu; int32_t size; assert(srv->fdidx[fd].rsp_size < srv->fdidx[fd].rsp_limit); pdu.pid = SDP_PDU_ERROR_RESPONSE; pdu.tid = ((sdp_pdu_p)(srv->req))->tid; pdu.len = htons(srv->fdidx[fd].rsp_size); iov[0].iov_base = &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = srv->fdidx[fd].rsp; iov[1].iov_len = srv->fdidx[fd].rsp_size; do { size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); } while (size < 0 && errno == EINTR); srv->fdidx[fd].rsp_cs = 0; srv->fdidx[fd].rsp_size = 0; srv->fdidx[fd].rsp_limit = 0; return ((size < 0)? errno : 0); } diff --git a/usr.sbin/bluetooth/sdpd/ssar.c b/usr.sbin/bluetooth/sdpd/ssar.c index 594c410c9f46..fad498c2b34a 100644 --- a/usr.sbin/bluetooth/sdpd/ssar.c +++ b/usr.sbin/bluetooth/sdpd/ssar.c @@ -1,381 +1,380 @@ /*- * ssar.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: ssar.c,v 1.4 2004/01/12 22:54:31 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include "profile.h" #include "provider.h" #include "server.h" #include "uuid-private.h" /* from sar.c */ int32_t server_prepare_attr_list(provider_p const provider, uint8_t const *req, uint8_t const * const req_end, uint8_t *rsp, uint8_t const * const rsp_end); /* * Scan an attribute for matching UUID. */ static int server_search_uuid_sub(uint8_t *buf, uint8_t const * const eob, const uint128_t *uuid) { int128_t duuid; uint32_t value; uint8_t type; while (buf < eob) { SDP_GET8(type, buf); switch (type) { case SDP_DATA_UUID16: if (buf + 2 > eob) continue; SDP_GET16(value, buf); memcpy(&duuid, &uuid_base, sizeof(duuid)); duuid.b[2] = value >> 8 & 0xff; duuid.b[3] = value & 0xff; if (memcmp(&duuid, uuid, sizeof(duuid)) == 0) return (0); break; case SDP_DATA_UUID32: if (buf + 4 > eob) continue; SDP_GET32(value, buf); memcpy(&duuid, &uuid_base, sizeof(duuid)); duuid.b[0] = value >> 24 & 0xff; duuid.b[1] = value >> 16 & 0xff; duuid.b[2] = value >> 8 & 0xff; duuid.b[3] = value & 0xff; if (memcmp(&duuid, uuid, sizeof(duuid)) == 0) return (0); break; case SDP_DATA_UUID128: if (buf + 16 > eob) continue; SDP_GET_UUID128(&duuid, buf); if (memcmp(&duuid, uuid, sizeof(duuid)) == 0) return (0); break; case SDP_DATA_UINT8: case SDP_DATA_INT8: case SDP_DATA_SEQ8: buf++; break; case SDP_DATA_UINT16: case SDP_DATA_INT16: case SDP_DATA_SEQ16: buf += 2; break; case SDP_DATA_UINT32: case SDP_DATA_INT32: case SDP_DATA_SEQ32: buf += 4; break; case SDP_DATA_UINT64: case SDP_DATA_INT64: buf += 8; break; case SDP_DATA_UINT128: case SDP_DATA_INT128: buf += 16; break; case SDP_DATA_STR8: if (buf + 1 > eob) continue; SDP_GET8(value, buf); buf += value; break; case SDP_DATA_STR16: if (buf + 2 > eob) continue; SDP_GET16(value, buf); if (value > (eob - buf)) return (1); buf += value; break; case SDP_DATA_STR32: if (buf + 4 > eob) continue; SDP_GET32(value, buf); if (value > (eob - buf)) return (1); buf += value; break; case SDP_DATA_BOOL: buf += 1; break; default: return (1); } } return (1); } /* * Search a provider for matching UUID in its attributes. */ static int server_search_uuid(provider_p const provider, const uint128_t *uuid) { uint8_t buffer[256]; const attr_t *attr; int len; for (attr = provider->profile->attrs; attr->create != NULL; attr++) { len = attr->create(buffer, buffer + sizeof(buffer), (const uint8_t *)provider->profile, sizeof(*provider->profile)); if (len < 0) continue; if (server_search_uuid_sub(buffer, buffer + len, uuid) == 0) return (0); } return (1); } /* * Prepare SDP Service Search Attribute Response */ int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; uint8_t const *rsp_end = rsp + NG_L2CAP_MTU_MAXIMUM; uint8_t const *sspptr = NULL, *aidptr = NULL; uint8_t *ptr = NULL; provider_t *provider = NULL; int32_t type, rsp_limit, ssplen, aidlen, cslen, cs; uint128_t uuid, puuid; /* * Minimal Service Search Attribute Request request * * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes ServiceSearchPattern * value16 - 2 bytes MaximumAttributeByteCount * seq8 len8 - 2 bytes * uint16 value16 - 3 bytes AttributeIDList * value8 - 1 byte ContinuationState */ if (req_end - req < 13) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get size of ServiceSearchPattern */ ssplen = 0; SDP_GET8(type, req); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(ssplen, req); break; case SDP_DATA_SEQ16: SDP_GET16(ssplen, req); break; case SDP_DATA_SEQ32: SDP_GET32(ssplen, req); break; } if (ssplen <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); sspptr = req; req += ssplen; /* Get MaximumAttributeByteCount */ if (req + 2 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(rsp_limit, req); if (rsp_limit <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get size of AttributeIDList */ if (req + 1 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); aidlen = 0; SDP_GET8(type, req); switch (type) { case SDP_DATA_SEQ8: if (req + 1 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET8(aidlen, req); break; case SDP_DATA_SEQ16: if (req + 2 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(aidlen, req); break; case SDP_DATA_SEQ32: if (req + 4 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET32(aidlen, req); break; } if (aidlen <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); aidptr = req; req += aidlen; /* Get ContinuationState */ if (req + 1 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET8(cslen, req); if (cslen != 0) { if (cslen != 2 || req_end - req != 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(cs, req); } else cs = 0; /* Process the request. First, check continuation state */ if (srv->fdidx[fd].rsp_cs != cs) return (SDP_ERROR_CODE_INVALID_CONTINUATION_STATE); if (srv->fdidx[fd].rsp_size > 0) return (0); /* * Service Search Attribute Response format * * value16 - 2 bytes AttributeListByteCount (not incl.) * seq8 len16 - 3 bytes * attr list - 3+ bytes AttributeLists * [ attr list ] */ ptr = rsp + 3; while (ssplen > 0) { SDP_GET8(type, sspptr); ssplen --; switch (type) { case SDP_DATA_UUID16: if (ssplen < 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(&uuid, &uuid_base, sizeof(uuid)); uuid.b[2] = *sspptr ++; uuid.b[3] = *sspptr ++; ssplen -= 2; break; case SDP_DATA_UUID32: if (ssplen < 4) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(&uuid, &uuid_base, sizeof(uuid)); uuid.b[0] = *sspptr ++; uuid.b[1] = *sspptr ++; uuid.b[2] = *sspptr ++; uuid.b[3] = *sspptr ++; ssplen -= 4; break; case SDP_DATA_UUID128: if (ssplen < 16) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(uuid.b, sspptr, 16); sspptr += 16; ssplen -= 16; break; default: return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* NOT REACHED */ } for (provider = provider_get_first(); provider != NULL; provider = provider_get_next(provider)) { if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) continue; memcpy(&puuid, &uuid_base, sizeof(puuid)); puuid.b[2] = provider->profile->uuid >> 8; puuid.b[3] = provider->profile->uuid; if (memcmp(&uuid, &puuid, sizeof(uuid)) != 0 && memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) != 0 && server_search_uuid(provider, &uuid) != 0) continue; cs = server_prepare_attr_list(provider, aidptr, aidptr + aidlen, ptr, rsp_end); if (cs < 0) return (SDP_ERROR_CODE_INSUFFICIENT_RESOURCES); ptr += cs; } } /* Set reply size (not counting PDU header and continuation state) */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 2; if (srv->fdidx[fd].rsp_limit > rsp_limit) srv->fdidx[fd].rsp_limit = rsp_limit; srv->fdidx[fd].rsp_size = ptr - rsp; srv->fdidx[fd].rsp_cs = 0; /* Fix AttributeLists sequence header */ ptr = rsp; SDP_PUT8(SDP_DATA_SEQ16, ptr); SDP_PUT16(srv->fdidx[fd].rsp_size - 3, ptr); return (0); } diff --git a/usr.sbin/bluetooth/sdpd/ssr.c b/usr.sbin/bluetooth/sdpd/ssr.c index f176ec77d8b4..c6b3a1f65fe1 100644 --- a/usr.sbin/bluetooth/sdpd/ssr.c +++ b/usr.sbin/bluetooth/sdpd/ssr.c @@ -1,285 +1,284 @@ /*- * ssr.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: ssr.c,v 1.5 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #include #include #include #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "profile.h" #include "provider.h" #include "server.h" #include "uuid-private.h" /* * Prepare SDP Service Search Response */ int32_t server_prepare_service_search_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; uint8_t const *rsp_end = rsp + NG_L2CAP_MTU_MAXIMUM; uint8_t *ptr = NULL; provider_t *provider = NULL; int32_t type, ssplen, rsp_limit, rcount, cslen, cs; uint128_t uuid, puuid; /* * Minimal SDP Service Search Request * * seq8 len8 - 2 bytes * uuid16 value16 - 3 bytes ServiceSearchPattern * value16 - 2 bytes MaximumServiceRecordCount * value8 - 1 byte ContinuationState */ if (req_end - req < 8) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get size of ServiceSearchPattern */ ssplen = 0; SDP_GET8(type, req); switch (type) { case SDP_DATA_SEQ8: SDP_GET8(ssplen, req); break; case SDP_DATA_SEQ16: SDP_GET16(ssplen, req); break; case SDP_DATA_SEQ32: SDP_GET32(ssplen, req); break; } if (ssplen <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); ptr = (uint8_t *) req + ssplen; /* Get MaximumServiceRecordCount */ if (ptr + 2 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(rsp_limit, ptr); if (rsp_limit <= 0) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get ContinuationState */ if (ptr + 1 > req_end) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET8(cslen, ptr); if (cslen != 0) { if (cslen != 2 || req_end - ptr != 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); SDP_GET16(cs, ptr); } else cs = 0; /* Process the request. First, check continuation state */ if (srv->fdidx[fd].rsp_cs != cs) return (SDP_ERROR_CODE_INVALID_CONTINUATION_STATE); if (srv->fdidx[fd].rsp_size > 0) return (0); /* * Service Search Response format * * value16 - 2 bytes TotalServiceRecordCount (not incl.) * value16 - 2 bytes CurrentServiceRecordCount (not incl.) * value32 - 4 bytes handle * [ value32 ] * * Calculate how many record handles we can fit * in our reply buffer and adjust rlimit. */ ptr = rsp; rcount = (rsp_end - ptr) / 4; if (rcount < rsp_limit) rsp_limit = rcount; /* Look for the record handles */ for (rcount = 0; ssplen > 0 && rcount < rsp_limit; ) { SDP_GET8(type, req); ssplen --; switch (type) { case SDP_DATA_UUID16: if (ssplen < 2) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(&uuid, &uuid_base, sizeof(uuid)); uuid.b[2] = *req ++; uuid.b[3] = *req ++; ssplen -= 2; break; case SDP_DATA_UUID32: if (ssplen < 4) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(&uuid, &uuid_base, sizeof(uuid)); uuid.b[0] = *req ++; uuid.b[1] = *req ++; uuid.b[2] = *req ++; uuid.b[3] = *req ++; ssplen -= 4; break; case SDP_DATA_UUID128: if (ssplen < 16) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); memcpy(uuid.b, req, 16); req += 16; ssplen -= 16; break; default: return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* NOT REACHED */ } for (provider = provider_get_first(); provider != NULL && rcount < rsp_limit; provider = provider_get_next(provider)) { if (!provider_match_bdaddr(provider, &srv->req_sa.l2cap_bdaddr)) continue; memcpy(&puuid, &uuid_base, sizeof(puuid)); puuid.b[2] = provider->profile->uuid >> 8; puuid.b[3] = provider->profile->uuid; if (memcmp(&uuid, &puuid, sizeof(uuid)) == 0 || memcmp(&uuid, &uuid_public_browse_group, sizeof(uuid)) == 0) { SDP_PUT32(provider->handle, ptr); rcount ++; } } } /* Set reply size (not counting PDU header and continuation state) */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t) - 4; srv->fdidx[fd].rsp_size = ptr - rsp; srv->fdidx[fd].rsp_cs = 0; return (0); } /* * Send SDP Service Search Response */ int32_t server_send_service_search_response(server_p srv, int32_t fd) { uint8_t *rsp = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_cs; uint8_t *rsp_end = srv->fdidx[fd].rsp + srv->fdidx[fd].rsp_size; struct iovec iov[4]; sdp_pdu_t pdu; uint16_t rcounts[2]; uint8_t cs[3]; int32_t size; /* First update continuation state (assume we will send all data) */ size = rsp_end - rsp; srv->fdidx[fd].rsp_cs += size; if (size + 1 > srv->fdidx[fd].rsp_limit) { /* * We need to split out response. Add 3 more bytes for the * continuation state and move rsp_end and rsp_cs backwards. */ while ((rsp_end - rsp) + 3 > srv->fdidx[fd].rsp_limit) { rsp_end -= 4; srv->fdidx[fd].rsp_cs -= 4; } cs[0] = 2; cs[1] = srv->fdidx[fd].rsp_cs >> 8; cs[2] = srv->fdidx[fd].rsp_cs & 0xff; } else cs[0] = 0; assert(rsp_end >= rsp); rcounts[0] = srv->fdidx[fd].rsp_size / 4; /* TotalServiceRecordCount */ rcounts[1] = (rsp_end - rsp) / 4; /* CurrentServiceRecordCount */ pdu.pid = SDP_PDU_SERVICE_SEARCH_RESPONSE; pdu.tid = ((sdp_pdu_p)(srv->req))->tid; pdu.len = htons(sizeof(rcounts) + rcounts[1] * 4 + 1 + cs[0]); rcounts[0] = htons(rcounts[0]); rcounts[1] = htons(rcounts[1]); iov[0].iov_base = &pdu; iov[0].iov_len = sizeof(pdu); iov[1].iov_base = rcounts; iov[1].iov_len = sizeof(rcounts); iov[2].iov_base = rsp; iov[2].iov_len = rsp_end - rsp; iov[3].iov_base = cs; iov[3].iov_len = 1 + cs[0]; do { size = writev(fd, (struct iovec const *) &iov, sizeof(iov)/sizeof(iov[0])); } while (size < 0 && errno == EINTR); /* Check if we have sent (or failed to sent) last response chunk */ if (srv->fdidx[fd].rsp_cs == srv->fdidx[fd].rsp_size) { srv->fdidx[fd].rsp_cs = 0; srv->fdidx[fd].rsp_size = 0; srv->fdidx[fd].rsp_limit = 0; } return ((size < 0)? errno : 0); } diff --git a/usr.sbin/bluetooth/sdpd/sur.c b/usr.sbin/bluetooth/sdpd/sur.c index 8348240fa938..43581be0bbf1 100644 --- a/usr.sbin/bluetooth/sdpd/sur.c +++ b/usr.sbin/bluetooth/sdpd/sur.c @@ -1,86 +1,85 @@ /*- * sur.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: sur.c,v 1.1 2004/01/13 01:54:39 max Exp $ - * $FreeBSD$ */ #include #define L2CAP_SOCKET_CHECKED #include #include #include #include #include "profile.h" #include "provider.h" #include "server.h" /* * Prepare Service Unregister response */ int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd) { uint8_t const *req = srv->req + sizeof(sdp_pdu_t); uint8_t const *req_end = req + ((sdp_pdu_p)(srv->req))->len; uint8_t *rsp = srv->fdidx[fd].rsp; provider_t *provider = NULL; uint32_t handle; /* * Minimal Service Unregister Request * * value32 - uuid 4 bytes */ if (!srv->fdidx[fd].control || !srv->fdidx[fd].priv || req_end - req < 4) return (SDP_ERROR_CODE_INVALID_REQUEST_SYNTAX); /* Get handle */ SDP_GET32(handle, req); /* Lookup provider */ provider = provider_by_handle(handle); if (provider == NULL || provider->fd != fd) return (SDP_ERROR_CODE_INVALID_SERVICE_RECORD_HANDLE); provider_unregister(provider); SDP_PUT16(0, rsp); /* Set reply size */ srv->fdidx[fd].rsp_limit = srv->fdidx[fd].omtu - sizeof(sdp_pdu_t); srv->fdidx[fd].rsp_size = rsp - srv->fdidx[fd].rsp; srv->fdidx[fd].rsp_cs = 0; return (0); } diff --git a/usr.sbin/bluetooth/sdpd/uuid-private.h b/usr.sbin/bluetooth/sdpd/uuid-private.h index 7a8f96f049df..8a3f9bb1c62b 100644 --- a/usr.sbin/bluetooth/sdpd/uuid-private.h +++ b/usr.sbin/bluetooth/sdpd/uuid-private.h @@ -1,41 +1,40 @@ /*- * uuid-private.h * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: uuid-private.h,v 1.1 2004/12/09 18:20:26 max Exp $ - * $FreeBSD$ */ #ifndef _UUID_PRIVATE_H_ #define _UUID_PRIVATE_H_ extern uint128_t uuid_base; extern uint128_t uuid_public_browse_group; #endif /* ndef _UUID_PRIVATE_H_ */ diff --git a/usr.sbin/bluetooth/sdpd/uuid.c b/usr.sbin/bluetooth/sdpd/uuid.c index e3adba047e48..90a6d5b17322 100644 --- a/usr.sbin/bluetooth/sdpd/uuid.c +++ b/usr.sbin/bluetooth/sdpd/uuid.c @@ -1,58 +1,57 @@ /*- * uuid.c * * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Maksim Yevmenkin * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: uuid.c,v 1.1 2004/12/09 18:20:26 max Exp $ - * $FreeBSD$ */ #define L2CAP_SOCKET_CHECKED #include #include #include #include "uuid-private.h" uint128_t uuid_base = { .b = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb } }; uint128_t uuid_public_browse_group = { .b = { 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb } }; diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 8555bf000d0f..df0428b59073 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -1,279 +1,278 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)config.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * Config. */ #include #include #include #include #include #ifdef __cplusplus #include class configword { private: std::string cw_word; bool cw_eof; bool cw_eol; public: configword() : cw_word(""), cw_eof(false), cw_eol(false) {} configword(std::string &&word) : cw_word(word), cw_eof(false), cw_eol(false) {} bool eof() const { return (cw_eof); } bool eol() const { return (cw_eol); } configword &eof(bool eof) { cw_eof = eof; return (*this); } configword &eol(bool eol) { cw_eol = eol; return (*this); } char operator[](int idx) { return (cw_word[idx]); } operator const char*() const { return (cw_word.c_str()); } const std::string &operator*() const { return (cw_word); } const std::string *operator->() const { return (&cw_word); } }; /* * Is it ugly to limit these to C++ files? Yes. */ configword get_word(FILE *); configword get_quoted_word(FILE *); #endif __BEGIN_DECLS struct cfgfile { STAILQ_ENTRY(cfgfile) cfg_next; char *cfg_path; }; extern STAILQ_HEAD(cfgfile_head, cfgfile) cfgfiles; struct file_list { STAILQ_ENTRY(file_list) f_next; char *f_fn; /* the name */ int f_type; /* type */ u_char f_flags; /* see below */ char *f_compilewith; /* special make rule if present */ char *f_depends; /* additional dependencies */ char *f_clean; /* File list to add to clean rule */ char *f_warn; /* warning message */ const char *f_objprefix; /* prefix string for object name */ const char *f_srcprefix; /* source prefix such as $S/ */ }; struct files_name { char *f_name; STAILQ_ENTRY(files_name) f_next; }; /* * Types. */ #define NORMAL 1 #define NODEPEND 4 #define LOCAL 5 #define DEVDONE 0x80000000 #define TYPEMASK 0x7fffffff /* * Attributes (flags). */ #define NO_IMPLCT_RULE 1 #define NO_OBJ 2 #define BEFORE_DEPEND 4 #define NOWERROR 16 #define NO_CTFCONVERT 32 struct device { int d_done; /* processed */ char *d_name; /* name of device (e.g. rk11) */ char *yyfile; /* name of the file that first include the device */ #define UNKNOWN -2 /* -2 means not set yet */ STAILQ_ENTRY(device) d_next; /* Next one in list */ }; struct config { char *s_sysname; }; /* * Config has a global notion of which machine type is * being used. It uses the name of the machine in choosing * files and directories. Thus if the name of the machine is ``i386'', * it will build from ``Makefile.i386'' and use ``../i386/inline'' * in the makerules, etc. machinearch is the global notion of the * MACHINE_ARCH for this MACHINE. */ extern char *machinename; extern char *machinearch; /* * For each machine, a set of CPU's may be specified as supported. * These and the options (below) are put in the C flags in the makefile. */ struct cputype { char *cpu_name; SLIST_ENTRY(cputype) cpu_next; }; extern SLIST_HEAD(cputype_head, cputype) cputype; /* * A set of options may also be specified which are like CPU types, * but which may also specify values for the options. * A separate set of options may be defined for make-style options. */ struct opt { char *op_name; char *op_value; int op_ownfile; /* true = own file, false = makefile */ char *yyfile; /* name of the file that first include the option */ SLIST_ENTRY(opt) op_next; SLIST_ENTRY(opt) op_append; }; extern SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts; struct opt_list { char *o_name; char *o_file; int o_flags; #define OL_ALIAS 1 SLIST_ENTRY(opt_list) o_next; }; extern SLIST_HEAD(opt_list_head, opt_list) otab; struct envvar { char *env_str; bool env_is_file; STAILQ_ENTRY(envvar) envvar_next; }; extern STAILQ_HEAD(envvar_head, envvar) envvars; struct hint { char *hint_name; STAILQ_ENTRY(hint) hint_next; }; extern STAILQ_HEAD(hint_head, hint) hints; struct includepath { char *path; SLIST_ENTRY(includepath) path_next; }; extern SLIST_HEAD(includepath_head, includepath) includepath; /* * Tag present in the kernconf.tmpl template file. It's mandatory for those * two strings to be the same. Otherwise you'll get into trouble. */ #define KERNCONFTAG "%%KERNCONFFILE%%" /* * Faked option to note, that the configuration file has been taken from the * kernel file and inclusion of DEFAULTS etc.. isn't nessesery, because we * already have a list of all required devices. */ #define OPT_AUTOGEN "CONFIG_AUTOGENERATED" extern char *ident; extern char kernconfstr[]; extern int do_trace; extern int incignore; char *path(const char *); char *raisestr(char *); void remember(const char *); void moveifchanged(const char *, const char *); int yylex(void); int yyparse(void); void options(void); void makefile(void); void makeenv(void); void makehints(void); void headers(void); void cfgfile_add(const char *); void cfgfile_removeall(void); FILE *open_makefile_template(void); extern STAILQ_HEAD(device_head, device) dtab; extern char errbuf[80]; extern int yyline; extern const char *yyfile; extern STAILQ_HEAD(file_list_head, file_list) ftab; extern STAILQ_HEAD(files_name_head, files_name) fntab; extern int debugging; extern int found_defaults; extern int maxusers; extern int versreq; extern char *PREFIX; /* Config file name - for error messages */ extern char srcdir[]; /* root of the kernel source tree */ __END_DECLS; #define eq(a,b) (!strcmp(a,b)) #define ns(s) strdup(s) diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index c4a3522ebbcf..c475f15f56e4 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -1,484 +1,483 @@ %union { char *str; int val; struct file_list *file; } %token ARCH %token COMMA %token CONFIG %token CPU %token NOCPU %token DEVICE %token NODEVICE %token ENV %token ENVVAR %token EQUALS %token PLUSEQUALS %token HINTS %token IDENT %token MAXUSERS %token OPTIONS %token NOOPTION %token MAKEOPTIONS %token NOMAKEOPTION %token SEMICOLON %token INCLUDE %token FILES %token ENVLINE %token ID %token NUMBER %type Save_id %type Opt_value %type Dev %token PATH %{ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)config.y 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include #include #include #include "config.h" struct device_head dtab; char *ident; char *env; int yyline; const char *yyfile; struct file_list_head ftab; struct files_name_head fntab; char errbuf[80]; int maxusers; #define ns(s) strdup(s) int include(const char *, int); void yyerror(const char *s); int yywrap(void); static void newdev(char *name); static void newfile(char *name); static void newenvvar(char *name, bool is_file); static void rmdev_schedule(struct device_head *dh, char *name); static void newopt(struct opt_head *list, char *name, char *value, int append, int dupe); static void rmopt_schedule(struct opt_head *list, char *name); static char * devopt(char *dev) { char *ret = malloc(strlen(dev) + 5); sprintf(ret, "DEV_%s", dev); raisestr(ret); return ret; } %} %% Configuration: Many_specs ; Many_specs: Many_specs Spec | /* lambda */ ; Spec: Device_spec SEMICOLON | Config_spec SEMICOLON | INCLUDE PATH SEMICOLON { if (incignore == 0) include($2, 0); }; | INCLUDE ID SEMICOLON { if (incignore == 0) include($2, 0); }; | FILES ID SEMICOLON { newfile($2); }; | SEMICOLON | error SEMICOLON ; Config_spec: ARCH Save_id { if (machinename != NULL && !eq($2, machinename)) errx(1, "%s:%d: only one machine directive is allowed", yyfile, yyline); machinename = $2; machinearch = $2; } | ARCH Save_id Save_id { /* * Allow the machinearch to change with a second machine directive, * but still enforce no changes to the machinename. */ if (machinename != NULL && !eq($2, machinename)) errx(1, "%s:%d: only one machine directive is allowed", yyfile, yyline); machinename = $2; machinearch = $3; } | CPU Save_id { struct cputype *cp = (struct cputype *)calloc(1, sizeof (struct cputype)); if (cp == NULL) err(EXIT_FAILURE, "calloc"); cp->cpu_name = $2; SLIST_INSERT_HEAD(&cputype, cp, cpu_next); } | NOCPU Save_id { struct cputype *cp, *cp2; SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) { if (eq(cp->cpu_name, $2)) { SLIST_REMOVE(&cputype, cp, cputype, cpu_next); free(cp); } } } | OPTIONS Opt_list | NOOPTION NoOpt_list | MAKEOPTIONS Mkopt_list | NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } | IDENT ID { ident = $2; } | MAXUSERS NUMBER { maxusers = $2; } | ENV ID { newenvvar($2, true); } | ENVVAR ENVLINE { newenvvar($2, false); } | HINTS ID { struct hint *hint; hint = (struct hint *)calloc(1, sizeof (struct hint)); if (hint == NULL) err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; STAILQ_INSERT_HEAD(&hints, hint, hint_next); } System_id: Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0, 0); }; System_parameter_list: System_parameter_list ID | ID ; Opt_list: Opt_list COMMA Option | Option ; NoOpt_list: NoOpt_list COMMA NoOption | NoOption ; Option: Save_id { newopt(&opt, $1, NULL, 0, 1); if (strchr($1, '=') != NULL) errx(1, "%s:%d: The `=' in options should not be " "quoted", yyfile, yyline); } | Save_id EQUALS Opt_value { newopt(&opt, $1, $3, 0, 1); } ; NoOption: Save_id { rmopt_schedule(&opt, $1); }; Opt_value: ID { $$ = $1; } | NUMBER { char buf[80]; (void) snprintf(buf, sizeof(buf), "%d", $1); $$ = ns(buf); } ; Save_id: ID { $$ = $1; } ; Mkopt_list: Mkopt_list COMMA Mkoption | Mkoption ; Mkoption: Save_id { newopt(&mkopt, $1, ns(""), 0, 0); } | Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0, 0); } | Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0, 0); } | Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1, 0); } ; Dev: ID { $$ = $1; } ; Device_spec: DEVICE Dev_list | NODEVICE NoDev_list ; Dev_list: Dev_list COMMA Device | Device ; NoDev_list: NoDev_list COMMA NoDevice | NoDevice ; Device: Dev { newopt(&opt, devopt($1), ns("1"), 0, 0); /* and the device part */ newdev($1); } NoDevice: Dev { char *s = devopt($1); rmopt_schedule(&opt, s); free(s); /* and the device part */ rmdev_schedule(&dtab, $1); } ; %% void yyerror(const char *s) { errx(1, "%s:%d: %s", yyfile, yyline + 1, s); } int yywrap(void) { if (found_defaults) { if (freopen(PREFIX, "r", stdin) == NULL) err(2, "%s", PREFIX); yyfile = PREFIX; yyline = 0; found_defaults = 0; return 0; } return 1; } /* * Add a new file to the list of files. */ static void newfile(char *name) { struct files_name *nl; nl = (struct files_name *) calloc(1, sizeof *nl); if (nl == NULL) err(EXIT_FAILURE, "calloc"); nl->f_name = name; STAILQ_INSERT_TAIL(&fntab, nl, f_next); } static void newenvvar(char *name, bool is_file) { struct envvar *envvar; envvar = (struct envvar *)calloc(1, sizeof (struct envvar)); if (envvar == NULL) err(EXIT_FAILURE, "calloc"); envvar->env_str = name; envvar->env_is_file = is_file; STAILQ_INSERT_HEAD(&envvars, envvar, envvar_next); } /* * Find a device in the list of devices. */ static struct device * finddev(struct device_head *dlist, char *name) { struct device *dp; STAILQ_FOREACH(dp, dlist, d_next) if (eq(dp->d_name, name)) return (dp); return (NULL); } /* * Add a device to the list of devices. */ static void newdev(char *name) { struct device *np, *dp; if ((dp = finddev(&dtab, name)) != NULL) { if (strcmp(dp->yyfile, yyfile) == 0) fprintf(stderr, "WARNING: duplicate device `%s' encountered in %s\n", name, yyfile); return; } np = (struct device *) calloc(1, sizeof *np); if (np == NULL) err(EXIT_FAILURE, "calloc"); np->d_name = name; np->yyfile = strdup(yyfile); STAILQ_INSERT_TAIL(&dtab, np, d_next); } /* * Schedule a device to removal. */ static void rmdev_schedule(struct device_head *dh, char *name) { struct device *dp; dp = finddev(dh, name); if (dp != NULL) { STAILQ_REMOVE(dh, dp, device, d_next); free(dp->yyfile); free(dp->d_name); free(dp); } } /* * Find an option in the list of options. */ static struct opt * findopt(struct opt_head *list, char *name) { struct opt *op; SLIST_FOREACH(op, list, op_next) if (eq(op->op_name, name)) return (op); return (NULL); } /* * Add an option to the list of options. */ static void newopt(struct opt_head *list, char *name, char *value, int append, int dupe) { struct opt *op, *op2; /* * Ignore inclusions listed explicitly for configuration files. */ if (eq(name, OPT_AUTOGEN)) { incignore = 1; return; } op2 = findopt(list, name); if (op2 != NULL && !append && !dupe) { if (strcmp(op2->yyfile, yyfile) == 0) fprintf(stderr, "WARNING: duplicate option `%s' encountered.\n", name); return; } op = (struct opt *)calloc(1, sizeof (struct opt)); if (op == NULL) err(EXIT_FAILURE, "calloc"); op->op_name = name; op->op_ownfile = 0; op->op_value = value; op->yyfile = strdup(yyfile); if (op2 != NULL) { if (append) { while (SLIST_NEXT(op2, op_append) != NULL) op2 = SLIST_NEXT(op2, op_append); SLIST_NEXT(op2, op_append) = op; } else { while (SLIST_NEXT(op2, op_next) != NULL) op2 = SLIST_NEXT(op2, op_next); SLIST_NEXT(op2, op_next) = op; } } else SLIST_INSERT_HEAD(list, op, op_next); } /* * Remove an option from the list of options. */ static void rmopt_schedule(struct opt_head *list, char *name) { struct opt *op; while ((op = findopt(list, name)) != NULL) { SLIST_REMOVE(list, op, opt, op_next); free(op->yyfile); free(op->op_name); free(op); } } diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 243b66666d0e..e3315b028df2 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -1,338 +1,337 @@ %{ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)lang.l 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #include #include #include #include #include "y.tab.h" #include "config.h" /* * Data for returning to previous files from include files. */ struct incl { struct incl *in_prev; /* previous includes in effect, if any */ YY_BUFFER_STATE in_buf; /* previous lex state */ const char *in_fname; /* previous file name */ int in_lineno; /* previous line number */ int in_ateof; /* token to insert at EOF */ }; static struct incl *inclp; static const char *lastfile; /* * Key word table */ struct kt { const char *kt_name; int kt_val; } key_words[] = { { "cpu", CPU }, { "nocpu", NOCPU }, { "device", DEVICE }, { "devices", DEVICE }, { "nodevice", NODEVICE }, { "nodevices", NODEVICE }, { "env", ENV }, { "envvar", ENVVAR }, { "hints", HINTS }, { "ident", IDENT }, { "machine", ARCH }, /* MACHINE is defined in /sys/param.h */ { "makeoption", MAKEOPTIONS }, { "makeoptions", MAKEOPTIONS }, { "nomakeoption", NOMAKEOPTION }, { "nomakeoptions", NOMAKEOPTION }, { "maxusers", MAXUSERS }, { "option", OPTIONS }, { "options", OPTIONS }, { "nooption", NOOPTION }, { "nooptions", NOOPTION }, { "include", INCLUDE }, { "files", FILES }, { 0, 0 }, }; static int endinclude(void); int include(const char *, int); int kw_lookup(char *); unsigned int octal(const char *); unsigned int hex(const char *); int yyerror(const char *); #define YY_DECL int yylex(void) %} %option nounput %option noinput ID [A-Za-z_][-A-Za-z_0-9]* PATH [./][-/.%^A-Za-z_0-9]+ %START TOEOL %START ENVC %% [^#\n]* { BEGIN 0; yylval.str = strdup(yytext); return ENVLINE; } {ID} { int i; BEGIN 0; if ((i = kw_lookup(yytext)) == -1) { yylval.str = strdup(yytext); return ID; } /* We'll glom onto the rest of an envvar line */ if (i == ENVVAR) BEGIN ENVC; return i; } \\\"[^"]*\\\" { BEGIN 0; yytext[yyleng-2] = '"'; yytext[yyleng-1] = '\0'; yylval.str = strdup(yytext + 1); return ID; } \"[^"]+\" { BEGIN 0; yytext[yyleng-1] = '\0'; yylval.str = strdup(yytext + 1); return ID; } [^# \t\n]* { BEGIN 0; yylval.str = strdup(yytext); return ID; } 0[0-7]* { yylval.val = octal(yytext); return NUMBER; } 0x[0-9a-fA-F]+ { yylval.val = hex(yytext); return NUMBER; } -?[1-9][0-9]* { yylval.val = atoi(yytext); return NUMBER; } "?" { yylval.val = -1; return NUMBER; } \n/[ \t] { yyline++; } \n { yyline++; return SEMICOLON; } #.* { /* Ignored (comment) */; } [ \t\f]* { /* Ignored (white space) */; } ";" { return SEMICOLON; } "," { return COMMA; } "=" { BEGIN TOEOL; return EQUALS; } "+=" { BEGIN TOEOL; return PLUSEQUALS; } <> { int tok; if (inclp == NULL) return YY_NULL; tok = endinclude(); if (tok != 0) return tok; /* otherwise continue scanning */ } {PATH} { BEGIN 0; yylval.str = strdup(yytext); return PATH; } . { return yytext[0]; } %% /* * kw_lookup * Look up a string in the keyword table. Returns a -1 if the * string is not a keyword otherwise it returns the keyword number */ int kw_lookup(char *word) { struct kt *kp; for (kp = key_words; kp->kt_name != 0; kp++) if (eq(word, kp->kt_name)) return kp->kt_val; return -1; } /* * Number conversion routines */ unsigned int octal(const char *str) { unsigned int num; (void) sscanf(str, "%o", &num); return num; } unsigned int hex(const char *str) { unsigned int num; (void) sscanf(str+2, "%x", &num); return num; } void cfgfile_add(const char *fname) { struct cfgfile *cf; cf = calloc(1, sizeof(*cf)); if (cf == NULL) err(EXIT_FAILURE, "calloc"); assert(cf != NULL); asprintf(&cf->cfg_path, "%s", fname); STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next); } void cfgfile_removeall(void) { struct cfgfile *cf; while (!STAILQ_EMPTY(&cfgfiles)) { cf = STAILQ_FIRST(&cfgfiles); STAILQ_REMOVE_HEAD(&cfgfiles, cfg_next); if (cf->cfg_path != NULL) free(cf->cfg_path); free(cf); } } /* * Open the named file for inclusion at the current point. Returns 0 on * success (file opened and previous state pushed), nonzero on failure * (fopen failed, complaint made). The `ateof' parameter controls the * token to be inserted at the end of the include file. If ateof == 0, * then nothing is inserted. */ int include(const char *fname, int ateof) { FILE *fp; struct incl *in; struct includepath* ipath; char *fnamebuf; fnamebuf = NULL; fp = fopen(fname, "r"); if (fp == NULL && fname[0] != '.' && fname[0] != '/') { asprintf(&fnamebuf, "../../conf/%s", fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); if (fp == NULL) free(fnamebuf); } } if (fp == NULL) { SLIST_FOREACH(ipath, &includepath, path_next) { asprintf(&fnamebuf, "%s/%s", ipath->path, fname); if (fnamebuf != NULL) { fp = fopen(fnamebuf, "r"); } if (fp != NULL) break; free(fnamebuf); } } if (fp == NULL) { yyerror("cannot open included file"); return (-1); } cfgfile_add(fnamebuf == NULL ? fname : fnamebuf); free(fnamebuf); in = malloc(sizeof(*in)); assert(in != NULL); in->in_prev = inclp; in->in_buf = YY_CURRENT_BUFFER; in->in_fname = yyfile; in->in_lineno = yyline; in->in_ateof = ateof; inclp = in; yy_switch_to_buffer(yy_create_buffer(fp, YY_BUF_SIZE)); yyfile = fname; yyline = 0; return (0); } /* * Terminate the most recent inclusion. */ static int endinclude(void) { struct incl *in; int ateof; in = inclp; assert(in != NULL); inclp = in->in_prev; lastfile = yyfile; yy_delete_buffer(YY_CURRENT_BUFFER); (void)fclose(yyin); yy_switch_to_buffer(in->in_buf); yyfile = in->in_fname; yyline = in->in_lineno; ateof = in->in_ateof; free(in); return (ateof); } diff --git a/usr.sbin/dconschat/dconschat.c b/usr.sbin/dconschat/dconschat.c index 0896280d515f..72d1aa276bd3 100644 --- a/usr.sbin/dconschat/dconschat.c +++ b/usr.sbin/dconschat/dconschat.c @@ -1,1149 +1,1148 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (C) 2003 * Hidetoshi Shimokawa. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * * This product includes software developed by Hidetoshi Shimokawa. * * 4. Neither the name of the author 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: dconschat.c,v 1.76 2003/10/23 06:21:13 simokawa Exp $ - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define DCONS_POLL_HZ 100 #define DCONS_POLL_OFFLINE 2 /* sec */ #define RETRY 3 #ifdef CSRVAL_VENDOR_PRIVATE #define USE_CROM 1 #else #define USE_CROM 0 #endif int verbose = 0; int tc_set = 0; int poll_hz = DCONS_POLL_HZ; static u_char abreak[3] = {13 /* CR */, 126 /* ~ */, 2 /* ^B */}; #define IS_CONSOLE(p) ((p)->port == DCONS_CON) #define IS_GDB(p) ((p)->port == DCONS_GDB) static struct dcons_state { int fd; kvm_t *kd; int kq; off_t paddr; off_t reset; #define F_READY (1 << 1) #define F_RD_ONLY (1 << 2) #define F_ALT_BREAK (1 << 3) #define F_TELNET (1 << 4) #define F_USE_CROM (1 << 5) #define F_ONE_SHOT (1 << 6) #define F_REPLAY (1 << 7) int flags; enum { TYPE_KVM, TYPE_FW } type; int escape_state; struct dcons_port { int port; int sport; struct dcons_ch o; struct dcons_ch i; u_int32_t optr; u_int32_t iptr; int s; int infd; int outfd; struct addrinfo *res; int skip_read; } port[DCONS_NPORT]; struct timespec to; struct timespec zero; struct termios tsave; struct termios traw; char escape; } sc; static int dconschat_write_dcons(struct dcons_state *, int, char *, int); static int dread(struct dcons_state *dc, void *buf, size_t n, off_t offset) { switch (dc->type) { case TYPE_FW: return (pread(dc->fd, buf, n, offset)); case TYPE_KVM: return (kvm_read(dc->kd, offset, buf, n)); } return (-1); } static int dwrite(struct dcons_state *dc, void *buf, size_t n, off_t offset) { if ((dc->flags & F_RD_ONLY) != 0) return (n); switch (dc->type) { case TYPE_FW: return (pwrite(dc->fd, buf, n, offset)); case TYPE_KVM: return (kvm_write(dc->kd, offset, buf, n)); } return (-1); } static void dconschat_reset_target(struct dcons_state *dc, struct dcons_port *p) { char buf[PAGE_SIZE]; if (dc->reset == 0) return; snprintf(buf, PAGE_SIZE, "\r\n[dconschat reset target(addr=0x%jx)...]\r\n", (intmax_t)dc->reset); write(p->outfd, buf, strlen(buf)); bzero(&buf[0], PAGE_SIZE); dwrite(dc, (void *)buf, PAGE_SIZE, dc->reset); } static void dconschat_suspend(struct dcons_state *dc, struct dcons_port *p) { if (p->sport != 0) return; if (tc_set) tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->tsave); printf("\n[dconschat suspend]\n"); kill(getpid(), SIGTSTP); if (tc_set) tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->traw); } static void dconschat_sigchld(int s) { struct kevent kev; struct dcons_port *p; char buf[256]; p = &sc.port[DCONS_CON]; snprintf(buf, 256, "\r\n[child exit]\r\n"); write(p->outfd, buf, strlen(buf)); if (tc_set) tcsetattr(STDIN_FILENO, TCSADRAIN, &sc.traw); EV_SET(&kev, p->infd, EVFILT_READ, EV_ADD, NOTE_LOWAT, 1, (void *)p); kevent(sc.kq, &kev, 1, NULL, 0, &sc.zero); } static void dconschat_fork_gdb(struct dcons_state *dc, struct dcons_port *p) { pid_t pid; char buf[256], com[256]; struct kevent kev; pid = fork(); if (pid < 0) { snprintf(buf, 256, "\r\n[%s: fork failed]\r\n", __FUNCTION__); write(p->outfd, buf, strlen(buf)); } if (pid == 0) { /* child */ if (tc_set) tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->tsave); snprintf(com, sizeof(buf), "kgdb -r :%d kernel", dc->port[DCONS_GDB].sport); snprintf(buf, 256, "\n[fork %s]\n", com); write(p->outfd, buf, strlen(buf)); execl("/bin/sh", "/bin/sh", "-c", com, NULL); snprintf(buf, 256, "\n[fork failed]\n"); write(p->outfd, buf, strlen(buf)); if (tc_set) tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->traw); exit(0); } else { signal(SIGCHLD, dconschat_sigchld); EV_SET(&kev, p->infd, EVFILT_READ, EV_DELETE, 0, 0, NULL); kevent(sc.kq, &kev, 1, NULL, 0, &sc.zero); } } static void dconschat_cleanup(int sig) { struct dcons_state *dc; int status; dc = ≻ if (tc_set != 0) tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->tsave); if (sig > 0) printf("\n[dconschat exiting with signal %d ...]\n", sig); else printf("\n[dconschat exiting...]\n"); wait(&status); exit(0); } #if USE_CROM static int dconschat_get_crom(struct dcons_state *dc) { off_t addr; int i, state = 0; u_int32_t buf, hi = 0, lo = 0, reset_hi = 0, reset_lo = 0; struct csrreg *reg; reg = (struct csrreg *)&buf; addr = 0xffff; addr = (addr << 32) | 0xf0000400; for (i = 20; i < 0x400; i += 4) { if (dread(dc, &buf, 4, addr + i) < 0) { if (verbose) warn("crom read failed"); goto out; } buf = ntohl(buf); if (verbose) printf("%d %02x %06x\n", state, reg->key, reg->val); switch (state) { case 0: if (reg->key == CSRKEY_SPEC && reg->val == CSRVAL_VENDOR_PRIVATE) state = 1; break; case 1: if (reg->key == CSRKEY_VER && reg->val == DCONS_CSR_VAL_VER) state = 2; break; case 2: switch (reg->key) { case DCONS_CSR_KEY_HI: hi = reg->val; break; case DCONS_CSR_KEY_LO: lo = reg->val; break; case DCONS_CSR_KEY_RESET_HI: reset_hi = reg->val; break; case DCONS_CSR_KEY_RESET_LO: reset_lo = reg->val; goto out; break; case 0x81: break; default: state = 0; } break; } } out: if (verbose) printf("addr: %06x %06x\n", hi, lo); dc->paddr = ((off_t)hi << 24) | lo; dc->reset = ((off_t)reset_hi << 24) | reset_lo; if (dc->paddr == 0) return (-1); return (0); } #endif static void dconschat_ready(struct dcons_state *dc, int ready, char *reason) { static char oldreason[64] = ""; int old; old = (dc->flags & F_READY) ? 1 : 0; if (ready) { dc->flags |= F_READY; if (ready != old) printf("[dcons connected]\r\n"); oldreason[0] = 0; } else { dc->flags &= ~F_READY; if (strncmp(oldreason, reason, sizeof(oldreason)) != 0) { printf("[dcons disconnected (%s)]\r\n", reason); strlcpy(oldreason, reason, sizeof(oldreason)); } } } static int dconschat_fetch_header(struct dcons_state *dc) { char ebuf[64]; struct dcons_buf dbuf; int j; #if USE_CROM if (dc->paddr == 0 && (dc->flags & F_USE_CROM) != 0) { if (dconschat_get_crom(dc)) { dconschat_ready(dc, 0, "get crom failed"); return (-1); } } #endif if (dread(dc, &dbuf, DCONS_HEADER_SIZE, dc->paddr) < 0) { dconschat_ready(dc, 0, "read header failed"); return (-1); } if (dbuf.magic != htonl(DCONS_MAGIC)) { if ((dc->flags & F_USE_CROM) !=0) dc->paddr = 0; snprintf(ebuf, sizeof(ebuf), "wrong magic 0x%08x", dbuf.magic); dconschat_ready(dc, 0, ebuf); return (-1); } if (ntohl(dbuf.version) != DCONS_VERSION) { snprintf(ebuf, sizeof(ebuf), "wrong version %d,%d", ntohl(dbuf.version), DCONS_VERSION); /* XXX exit? */ dconschat_ready(dc, 0, ebuf); return (-1); } for (j = 0; j < DCONS_NPORT; j++) { struct dcons_ch *o, *i; off_t newbuf; int new = 0; o = &dc->port[j].o; newbuf = dc->paddr + ntohl(dbuf.ooffset[j]); o->size = ntohl(dbuf.osize[j]); if (newbuf != o->buf) { /* buffer address has changes */ new = 1; o->gen = ntohl(dbuf.optr[j]) >> DCONS_GEN_SHIFT; o->pos = ntohl(dbuf.optr[j]) & DCONS_POS_MASK; o->buf = newbuf; } i = &dc->port[j].i; i->size = ntohl(dbuf.isize[j]); i->gen = ntohl(dbuf.iptr[j]) >> DCONS_GEN_SHIFT; i->pos = ntohl(dbuf.iptr[j]) & DCONS_POS_MASK; i->buf = dc->paddr + ntohl(dbuf.ioffset[j]); if (verbose) { printf("port %d size offset gen pos\n", j); printf("output: %5d %6d %5d %5d\n" "input : %5d %6d %5d %5d\n", o->size, ntohl(dbuf.ooffset[j]), o->gen, o->pos, i->size, ntohl(dbuf.ioffset[j]), i->gen, i->pos); } if (IS_CONSOLE(&dc->port[j]) && new && (dc->flags & F_REPLAY) !=0) { if (o->gen > 0) o->gen --; else o->pos = 0; } } dconschat_ready(dc, 1, NULL); return(0); } static int dconschat_get_ptr (struct dcons_state *dc) { int dlen, i; u_int32_t ptr[DCONS_NPORT*2+1]; static int retry = RETRY; char ebuf[64]; again: dlen = dread(dc, &ptr, sizeof(ptr), dc->paddr + __offsetof(struct dcons_buf, magic)); if (dlen < 0) { if (errno == ETIMEDOUT) if (retry -- > 0) goto again; dconschat_ready(dc, 0, "get ptr failed"); return(-1); } if (ptr[0] != htonl(DCONS_MAGIC)) { if ((dc->flags & F_USE_CROM) !=0) dc->paddr = 0; snprintf(ebuf, sizeof(ebuf), "wrong magic 0x%08x", ptr[0]); dconschat_ready(dc, 0, ebuf); return(-1); } retry = RETRY; for (i = 0; i < DCONS_NPORT; i ++) { dc->port[i].optr = ntohl(ptr[i + 1]); dc->port[i].iptr = ntohl(ptr[DCONS_NPORT + i + 1]); } return(0); } #define MAX_XFER 2048 static int dconschat_read_dcons(struct dcons_state *dc, int port, char *buf, int len) { struct dcons_ch *ch; u_int32_t ptr, pos, gen, next_gen; int rlen, dlen, lost; int retry = RETRY; ch = &dc->port[port].o; ptr = dc->port[port].optr; gen = ptr >> DCONS_GEN_SHIFT; pos = ptr & DCONS_POS_MASK; if (gen == ch->gen && pos == ch->pos) return (-1); next_gen = DCONS_NEXT_GEN(ch->gen); /* XXX sanity check */ if (gen == ch->gen) { if (pos > ch->pos) goto ok; lost = ch->size * DCONS_GEN_MASK - ch->pos; ch->pos = 0; } else if (gen == next_gen) { if (pos <= ch->pos) goto ok; lost = pos - ch->pos; ch->pos = pos; } else { lost = gen - ch->gen; if (lost < 0) lost += DCONS_GEN_MASK; if (verbose) printf("[genskip %d]", lost); lost = lost * ch->size - ch->pos; ch->pos = 0; ch->gen = gen; } /* generation skipped !! */ /* XXX discard */ if (verbose) printf("[lost %d]", lost); ok: if (gen == ch->gen) rlen = pos - ch->pos; else rlen = ch->size - ch->pos; if (rlen > MAX_XFER) rlen = MAX_XFER; if (rlen > len) rlen = len; #if 1 if (verbose == 1) printf("[%d]", rlen); fflush(stdout); #endif again: dlen = dread(dc, buf, rlen, ch->buf + ch->pos); if (dlen < 0) { if (errno == ETIMEDOUT) if (retry -- > 0) goto again; dconschat_ready(dc, 0, "read buffer failed"); return(-1); } if (dlen != rlen) warnx("dlen(%d) != rlen(%d)\n", dlen, rlen); ch->pos += dlen; if (ch->pos >= ch->size) { ch->gen = next_gen; ch->pos = 0; if (verbose) printf("read_dcons: gen=%d", ch->gen); } return (dlen); } static int dconschat_write_dcons(struct dcons_state *dc, int port, char *buf, int blen) { struct dcons_ch *ch; u_int32_t ptr; int len, wlen; int retry = RETRY; ch = &dc->port[port].i; ptr = dc->port[port].iptr; /* the others may advance the pointer sync with it */ ch->gen = ptr >> DCONS_GEN_SHIFT; ch->pos = ptr & DCONS_POS_MASK; while(blen > 0) { wlen = MIN(blen, ch->size - ch->pos); wlen = MIN(wlen, MAX_XFER); len = dwrite(dc, buf, wlen, ch->buf + ch->pos); if (len < 0) { if (errno == ETIMEDOUT) if (retry -- > 0) continue; /* try again */ dconschat_ready(dc, 0, "write buffer failed"); return(-1); } ch->pos += len; buf += len; blen -= len; if (ch->pos >= ch->size) { ch->gen = DCONS_NEXT_GEN(ch->gen); ch->pos = 0; if (verbose) printf("write_dcons: gen=%d", ch->gen); } } ptr = DCONS_MAKE_PTR(ch); dc->port[port].iptr = ptr; if (verbose > 2) printf("(iptr: 0x%x)", ptr); again: len = dwrite(dc, &ptr, sizeof(u_int32_t), dc->paddr + __offsetof(struct dcons_buf, iptr[port])); if (len < 0) { if (errno == ETIMEDOUT) if (retry -- > 0) goto again; dconschat_ready(dc, 0, "write ptr failed"); return(-1); } return(0); } static int dconschat_write_socket(int fd, char *buf, int len) { write(fd, buf, len); if (verbose > 1) { buf[len] = 0; printf("<- %s\n", buf); } return (0); } static void dconschat_init_socket(struct dcons_state *dc, int port, char *host, int sport) { struct addrinfo hints, *res; int on = 1, error; char service[10]; struct kevent kev; struct dcons_port *p; p = &dc->port[port]; p->port = port; p->sport = sport; p->infd = p->outfd = -1; if (sport < 0) return; if (sport == 0) { /* Use stdin and stdout */ p->infd = STDIN_FILENO; p->outfd = STDOUT_FILENO; p->s = -1; if (tc_set == 0 && tcgetattr(STDIN_FILENO, &dc->tsave) == 0) { dc->traw = dc->tsave; cfmakeraw(&dc->traw); tcsetattr(STDIN_FILENO, TCSADRAIN, &dc->traw); tc_set = 1; } EV_SET(&kev, p->infd, EVFILT_READ, EV_ADD, NOTE_LOWAT, 1, (void *)p); kevent(dc->kq, &kev, 1, NULL, 0, &dc->zero); return; } memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_PASSIVE; #if 1 /* gdb can talk v4 only */ hints.ai_family = PF_INET; #else hints.ai_family = PF_UNSPEC; #endif hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = 0; if (verbose) printf("%s:%d for port %d\n", host == NULL ? "*" : host, sport, port); snprintf(service, sizeof(service), "%d", sport); error = getaddrinfo(host, service, &hints, &res); if (error) errx(1, "tcp/%s: %s\n", service, gai_strerror(error)); p->res = res; p->s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if (p->s < 0) err(1, "socket"); setsockopt(p->s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); if (bind(p->s, p->res->ai_addr, p->res->ai_addrlen) < 0) { err(1, "bind"); } if (listen(p->s, 1) < 0) err(1, "listen"); EV_SET(&kev, p->s, EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, (void *)p); error = kevent(dc->kq, &kev, 1, NULL, 0, &dc->to); if (error < 0) err(1, "kevent"); } static int dconschat_accept_socket(struct dcons_state *dc, struct dcons_port *p) { socklen_t addrlen; int ns, flags; struct kevent kev; /* accept connection */ addrlen = p->res->ai_addrlen; ns = accept(p->s, p->res->ai_addr, &addrlen); if (ns < 0) err(1, "accept"); if (verbose) printf("port%d accepted\n", p->port); flags = fcntl(ns, F_GETFL, 0); flags |= O_NDELAY; fcntl(ns, F_SETFL, flags); #if 1 if (IS_CONSOLE(p) && (dc->flags & F_TELNET) != 0) { char sga[] = {IAC, WILL, TELOPT_SGA}; char linemode[] = {IAC, DONT, TELOPT_LINEMODE}; char echo[] = {IAC, WILL, TELOPT_ECHO}; char bin[] = {IAC, DO, TELOPT_BINARY}; write(ns, sga, sizeof(sga)); write(ns, linemode, sizeof(linemode)); write(ns, echo, sizeof(echo)); write(ns, bin, sizeof(bin)); p->skip_read = 0; } #endif /* discard backlog on GDB port */ if (IS_GDB(p)) { char buf[2048]; int len; while ((len = dconschat_read_dcons(dc, DCONS_GDB, &buf[0], 2048)) > 0) if (verbose) printf("discard %d chars on GDB port\n", len); } p->infd = p->outfd = ns; EV_SET(&kev, ns, EVFILT_READ, EV_ADD, NOTE_LOWAT, 1, (void *)p); kevent(dc->kq, &kev, 1, NULL, 0, &dc->zero); return(0); } static int dconschat_read_filter(struct dcons_state *dc, struct dcons_port *p, u_char *sp, int slen, u_char *dp, int *dlen) { int skip; char *buf; while (slen > 0) { skip = 0; if (IS_CONSOLE(p)) { if ((dc->flags & F_TELNET) != 0) { /* XXX Telnet workarounds */ if (p->skip_read -- > 0) { sp ++; slen --; continue; } if (*sp == IAC) { if (verbose) printf("(IAC)"); p->skip_read = 2; sp ++; slen --; continue; } if (*sp == 0) { if (verbose) printf("(0 stripped)"); sp ++; slen --; continue; } } switch (dc->escape_state) { case STATE1: if (*sp == dc->escape) { skip = 1; dc->escape_state = STATE2; } else dc->escape_state = STATE0; break; case STATE2: dc->escape_state = STATE0; skip = 1; if (*sp == '.') dconschat_cleanup(0); else if (*sp == CTRL('B')) { bcopy(abreak, dp, 3); dp += 3; *dlen += 3; } else if (*sp == CTRL('G')) dconschat_fork_gdb(dc, p); else if ((*sp == CTRL('R')) && (dc->reset != 0)) { dc->escape_state = STATE3; buf = "\r\n[Are you sure to reset target? (y/N)]"; write(p->outfd, buf, strlen(buf)); } else if (*sp == CTRL('Z')) dconschat_suspend(dc, p); else { skip = 0; *dp++ = dc->escape; (*dlen) ++; } break; case STATE3: dc->escape_state = STATE0; skip = 1; if (*sp == 'y') dconschat_reset_target(dc, p); else { write(p->outfd, sp, 1); write(p->outfd, "\r\n", 2); } break; } if (*sp == KEY_CR) dc->escape_state = STATE1; } else if (IS_GDB(p)) { /* GDB: ^C -> CR+~+^B */ if (*sp == CTRL('C') && (dc->flags & F_ALT_BREAK) != 0) { bcopy(abreak, dp, 3); dp += 3; sp ++; *dlen += 3; /* discard rest of the packet */ slen = 0; break; } } if (!skip) { *dp++ = *sp; (*dlen) ++; } sp ++; slen --; } return (*dlen); } static int dconschat_read_socket(struct dcons_state *dc, struct dcons_port *p) { struct kevent kev; int len, wlen; char rbuf[MAX_XFER], wbuf[MAX_XFER+2]; if ((len = read(p->infd, rbuf, sizeof(rbuf))) > 0) { wlen = 0; dconschat_read_filter(dc, p, rbuf, len, wbuf, &wlen); /* XXX discard if not ready*/ if (wlen > 0 && (dc->flags & F_READY) != 0) { dconschat_write_dcons(dc, p->port, wbuf, wlen); if (verbose > 1) { wbuf[wlen] = 0; printf("-> %s\n", wbuf); } else if (verbose == 1) { printf("(%d)", wlen); fflush(stdout); } } } else { if (verbose) { if (len == 0) warnx("port%d: closed", p->port); else warn("port%d: read", p->port); } EV_SET(&kev, p->infd, EVFILT_READ, EV_DELETE, 0, 0, NULL); kevent(dc->kq, &kev, 1, NULL, 0, &dc->zero); close(p->infd); close(p->outfd); /* XXX exit for pipe case XXX */ EV_SET(&kev, p->s, EVFILT_READ, EV_ADD | EV_ONESHOT, 0, 0, (void *) p); kevent(dc->kq, &kev, 1, NULL, 0, &dc->zero); p->infd = p->outfd = -1; } return(0); } #define NEVENT 5 static int dconschat_proc_socket(struct dcons_state *dc) { struct kevent elist[NEVENT], *e; int i, n; struct dcons_port *p; n = kevent(dc->kq, NULL, 0, elist, NEVENT, &dc->to); for (i = 0; i < n; i ++) { e = &elist[i]; p = (struct dcons_port *)e->udata; if (e->ident == p->s) { dconschat_accept_socket(dc, p); } else { dconschat_read_socket(dc, p); } } return(0); } static int dconschat_proc_dcons(struct dcons_state *dc) { int port, len, err; char buf[MAX_XFER]; struct dcons_port *p; err = dconschat_get_ptr(dc); if (err) { /* XXX we should stop write operation too. */ return err; } for (port = 0; port < DCONS_NPORT; port ++) { p = &dc->port[port]; if (p->infd < 0) continue; while ((len = dconschat_read_dcons(dc, port, buf, sizeof(buf))) > 0) { dconschat_write_socket(p->outfd, buf, len); if ((err = dconschat_get_ptr(dc))) return (err); } if ((dc->flags & F_ONE_SHOT) != 0 && len <= 0) dconschat_cleanup(0); } return 0; } static int dconschat_start_session(struct dcons_state *dc) { int counter = 0; int retry = 0; int retry_unit_init = MAX(1, poll_hz / 10); int retry_unit_offline = poll_hz * DCONS_POLL_OFFLINE; int retry_unit = retry_unit_init; int retry_max = retry_unit_offline / retry_unit; while (1) { if (((dc->flags & F_READY) == 0) && ++counter > retry_unit) { counter = 0; retry ++; if (retry > retry_max) retry_unit = retry_unit_offline; if (verbose) { printf("%d/%d ", retry, retry_max); fflush(stdout); } dconschat_fetch_header(dc); } if ((dc->flags & F_READY) != 0) { counter = 0; retry = 0; retry_unit = retry_unit_init; dconschat_proc_dcons(dc); } dconschat_proc_socket(dc); } return (0); } static void usage(void) { fprintf(stderr, "usage: dconschat [-brvwRT1] [-h hz] [-C port] [-G port]\n" "\t\t\t[-M core] [-N system]\n" "\t\t\t[-u unit] [-a address] [-t target_eui64]\n" "\t-b translate ctrl-C to CR+~+ctrl-B on gdb port\n" "\t-v verbose\n" "\t-w listen on wildcard address rather than localhost\n" "\t-r replay old buffer on connection\n" "\t-R read-only\n" "\t-T enable Telnet protocol workaround on console port\n" "\t-1 one shot: read buffer and exit\n" "\t-h polling rate\n" "\t-C port number for console port\n" "\t-G port number for gdb port\n" "\t(for KVM)\n" "\t-M core file\n" "\t-N system file\n" "\t(for FireWire)\n" "\t-u specify unit number of the bus\n" "\t-t EUI64 of target host (must be specified)\n" "\t-a physical address of dcons buffer on target host\n" ); exit(0); } int main(int argc, char **argv) { struct dcons_state *dc; struct fw_eui64 eui; struct eui64 target; char devname[256], *core = NULL, *system = NULL; int i, ch, error; int unit=0, wildcard=0; int port[DCONS_NPORT]; bzero(&sc, sizeof(sc)); dc = ≻ dc->flags |= USE_CROM ? F_USE_CROM : 0; /* default ports */ port[0] = 0; /* stdin/out for console */ port[1] = -1; /* disable gdb port */ /* default escape char */ dc->escape = KEY_TILDE; while ((ch = getopt(argc, argv, "a:be:h:rt:u:vwC:G:M:N:RT1")) != -1) { switch(ch) { case 'a': dc->paddr = strtoull(optarg, NULL, 0); dc->flags &= ~F_USE_CROM; break; case 'b': dc->flags |= F_ALT_BREAK; break; case 'e': dc->escape = optarg[0]; break; case 'h': poll_hz = strtoul(optarg, NULL, 0); if (poll_hz == 0) poll_hz = DCONS_POLL_HZ; break; case 'r': dc->flags |= F_REPLAY; break; case 't': if (eui64_hostton(optarg, &target) != 0 && eui64_aton(optarg, &target) != 0) errx(1, "invalid target: %s", optarg); eui.hi = ntohl(*(u_int32_t*)&(target.octet[0])); eui.lo = ntohl(*(u_int32_t*)&(target.octet[4])); dc->type = TYPE_FW; break; case 'u': unit = strtol(optarg, NULL, 0); break; case 'v': verbose ++; break; case 'w': wildcard = 1; break; case 'C': port[0] = strtol(optarg, NULL, 0); break; case 'G': port[1] = strtol(optarg, NULL, 0); break; case 'M': core = optarg; break; case 'N': system = optarg; break; case 'R': dc->flags |= F_RD_ONLY; break; case 'T': dc->flags |= F_TELNET; break; case '1': dc->flags |= F_ONE_SHOT | F_REPLAY; break; default: usage(); } } if (dc->paddr == 0 && (dc->flags & F_USE_CROM) == 0) { warnx("no address specified"); usage(); } if (port[0] < 0 && port[1] < 0) { warnx("no port specified"); usage(); } /* set signal handler */ signal(SIGHUP, dconschat_cleanup); signal(SIGINT, dconschat_cleanup); signal(SIGPIPE, dconschat_cleanup); signal(SIGTERM, dconschat_cleanup); /* init firewire */ switch (dc->type) { case TYPE_FW: #define MAXDEV 10 for (i = 0; i < MAXDEV; i ++) { snprintf(devname, sizeof(devname), "/dev/fwmem%d.%d", unit, i); dc->fd = open(devname, O_RDWR); if (dc->fd >= 0) goto found; } err(1, "open"); found: error = ioctl(dc->fd, FW_SDEUI64, &eui); if (error) err(1, "ioctl"); break; case TYPE_KVM: { struct nlist nl[] = {{"dcons_buf"}, {""}}; void *dcons_buf; dc->kd = kvm_open(system, core, NULL, (dc->flags & F_RD_ONLY) ? O_RDONLY : O_RDWR, "dconschat"); if (dc->kd == NULL) errx(1, "kvm_open"); if (kvm_nlist(dc->kd, nl) < 0) errx(1, "kvm_nlist: %s", kvm_geterr(dc->kd)); if (kvm_read(dc->kd, nl[0].n_value, &dcons_buf, sizeof(void *)) < 0) errx(1, "kvm_read: %s", kvm_geterr(dc->kd)); dc->paddr = (uintptr_t)dcons_buf; if (verbose) printf("dcons_buf: 0x%x\n", (uint)dc->paddr); break; } } dconschat_fetch_header(dc); /* init sockets */ dc->kq = kqueue(); if (poll_hz == 1) { dc->to.tv_sec = 1; dc->to.tv_nsec = 0; } else { dc->to.tv_sec = 0; dc->to.tv_nsec = 1000 * 1000 * 1000 / poll_hz; } dc->zero.tv_sec = 0; dc->zero.tv_nsec = 0; for (i = 0; i < DCONS_NPORT; i++) dconschat_init_socket(dc, i, wildcard ? NULL : "localhost", port[i]); dconschat_start_session(dc); for (i = 0; i < DCONS_NPORT; i++) { freeaddrinfo(dc->port[i].res); } return (0); } diff --git a/usr.sbin/edquota/pathnames.h b/usr.sbin/edquota/pathnames.h index e5be2d24c518..19b9df68d565 100644 --- a/usr.sbin/edquota/pathnames.h +++ b/usr.sbin/edquota/pathnames.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #undef _PATH_TMP #define _PATH_TMP "/tmp/EdP.aXXXXX" diff --git a/usr.sbin/fifolog/lib/getdate.y b/usr.sbin/fifolog/lib/getdate.y index 57f3cb1d46fb..dfbfad9a9fda 100644 --- a/usr.sbin/fifolog/lib/getdate.y +++ b/usr.sbin/fifolog/lib/getdate.y @@ -1,877 +1,876 @@ %{ /* ** Originally written by Steven M. Bellovin while ** at the University of North Carolina at Chapel Hill. Later tweaked by ** a couple of people on Usenet. Completely overhauled by Rich $alz ** and Jim Berets in August, 1990; ** ** This grammar has 10 shift/reduce conflicts. ** ** This code is in the public domain and has no copyright. ** ** Picked up from CVS and slightly cleaned up by to WARNS=5 level by ** Poul-Henning Kamp ** -** $FreeBSD$ */ #include #include #include #include #include #include #include "libfifolog.h" #define yyparse getdate_yyparse #define yylex getdate_yylex #define yyerror getdate_yyerror static int yyparse(void); static int yylex(void); static int yyerror(const char *); #define EPOCH 1970 #define HOUR(x) ((time_t)(x) * 60) #define SECSPERDAY (24L * 60L * 60L) /* ** An entry in the lexical lookup table. */ typedef struct _TABLE { const char *name; int type; time_t value; } TABLE; /* ** Daylight-savings mode: on, off, or not yet known. */ typedef enum _DSTMODE { DSToff, DSTon, DSTmaybe } DSTMODE; /* ** Meridian: am, pm, or 24-hour style. */ typedef enum _MERIDIAN { MERam, MERpm, MER24 } MERIDIAN; /* ** Global variables. We could get rid of most of these by using a good ** union as the yacc stack. (This routine was originally written before ** yacc had the %union construct.) Maybe someday; right now we only use ** the %union very rarely. */ static char *yyInput; static DSTMODE yyDSTmode; static time_t yyDayOrdinal; static time_t yyDayNumber; static int yyHaveDate; static int yyHaveDay; static int yyHaveRel; static int yyHaveTime; static int yyHaveZone; static time_t yyTimezone; static time_t yyDay; static time_t yyHour; static time_t yyMinutes; static time_t yyMonth; static time_t yySeconds; static time_t yyYear; static MERIDIAN yyMeridian; static time_t yyRelMonth; static time_t yyRelSeconds; %} %union { time_t Number; enum _MERIDIAN Meridian; } %token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT %token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST %type tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT %type tSEC_UNIT tSNUMBER tUNUMBER tZONE %type tMERIDIAN o_merid %% spec : /* NULL */ | spec item ; item : time { yyHaveTime++; } | zone { yyHaveZone++; } | date { yyHaveDate++; } | day { yyHaveDay++; } | rel { yyHaveRel++; } | cvsstamp { yyHaveTime++; yyHaveDate++; yyHaveZone++; } | number ; cvsstamp: tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUMBER '.' tUNUMBER { yyYear = $1; if (yyYear < 100) yyYear += 1900; yyMonth = $3; yyDay = $5; yyHour = $7; yyMinutes = $9; yySeconds = $11; yyDSTmode = DSToff; yyTimezone = 0; } ; time : tUNUMBER tMERIDIAN { yyHour = $1; yyMinutes = 0; yySeconds = 0; yyMeridian = $2; } | tUNUMBER ':' tUNUMBER o_merid { yyHour = $1; yyMinutes = $3; yySeconds = 0; yyMeridian = $4; } | tUNUMBER ':' tUNUMBER tSNUMBER { yyHour = $1; yyMinutes = $3; yyMeridian = MER24; yyDSTmode = DSToff; yyTimezone = - ($4 % 100 + ($4 / 100) * 60); } | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { yyHour = $1; yyMinutes = $3; yySeconds = $5; yyMeridian = $6; } | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { yyHour = $1; yyMinutes = $3; yySeconds = $5; yyMeridian = MER24; yyDSTmode = DSToff; yyTimezone = - ($6 % 100 + ($6 / 100) * 60); } ; zone : tZONE { yyTimezone = $1; yyDSTmode = DSToff; } | tDAYZONE { yyTimezone = $1; yyDSTmode = DSTon; } | tZONE tDST { yyTimezone = $1; yyDSTmode = DSTon; } ; day : tDAY { yyDayOrdinal = 1; yyDayNumber = $1; } | tDAY ',' { yyDayOrdinal = 1; yyDayNumber = $1; } | tUNUMBER tDAY { yyDayOrdinal = $1; yyDayNumber = $2; } ; date : tUNUMBER '/' tUNUMBER { yyMonth = $1; yyDay = $3; } | tUNUMBER '/' tUNUMBER '/' tUNUMBER { if ($1 >= 100) { yyYear = $1; yyMonth = $3; yyDay = $5; } else { yyMonth = $1; yyDay = $3; yyYear = $5; } } | tUNUMBER tSNUMBER tSNUMBER { /* ISO 8601 format. yyyy-mm-dd. */ yyYear = $1; yyMonth = -$2; yyDay = -$3; } | tUNUMBER tMONTH tSNUMBER { /* e.g. 17-JUN-1992. */ yyDay = $1; yyMonth = $2; yyYear = -$3; } | tMONTH tUNUMBER { yyMonth = $1; yyDay = $2; } | tMONTH tUNUMBER ',' tUNUMBER { yyMonth = $1; yyDay = $2; yyYear = $4; } | tUNUMBER tMONTH { yyMonth = $2; yyDay = $1; } | tUNUMBER tMONTH tUNUMBER { yyMonth = $2; yyDay = $1; yyYear = $3; } ; rel : relunit tAGO { yyRelSeconds = -yyRelSeconds; yyRelMonth = -yyRelMonth; } | relunit ; relunit : tUNUMBER tMINUTE_UNIT { yyRelSeconds += $1 * $2 * 60L; } | tSNUMBER tMINUTE_UNIT { yyRelSeconds += $1 * $2 * 60L; } | tMINUTE_UNIT { yyRelSeconds += $1 * 60L; } | tSNUMBER tSEC_UNIT { yyRelSeconds += $1; } | tUNUMBER tSEC_UNIT { yyRelSeconds += $1; } | tSEC_UNIT { yyRelSeconds++; } | tSNUMBER tMONTH_UNIT { yyRelMonth += $1 * $2; } | tUNUMBER tMONTH_UNIT { yyRelMonth += $1 * $2; } | tMONTH_UNIT { yyRelMonth += $1; } ; number : tUNUMBER { if (yyHaveTime && yyHaveDate && !yyHaveRel) yyYear = $1; else { if($1>10000) { yyHaveDate++; yyDay= ($1)%100; yyMonth= ($1/100)%100; yyYear = $1/10000; } else { yyHaveTime++; if ($1 < 100) { yyHour = $1; yyMinutes = 0; } else { yyHour = $1 / 100; yyMinutes = $1 % 100; } yySeconds = 0; yyMeridian = MER24; } } } ; o_merid : /* NULL */ { $$ = MER24; } | tMERIDIAN { $$ = $1; } ; %% /* Month and day table. */ static TABLE const MonthDayTable[] = { { "january", tMONTH, 1 }, { "february", tMONTH, 2 }, { "march", tMONTH, 3 }, { "april", tMONTH, 4 }, { "may", tMONTH, 5 }, { "june", tMONTH, 6 }, { "july", tMONTH, 7 }, { "august", tMONTH, 8 }, { "september", tMONTH, 9 }, { "sept", tMONTH, 9 }, { "october", tMONTH, 10 }, { "november", tMONTH, 11 }, { "december", tMONTH, 12 }, { "sunday", tDAY, 0 }, { "monday", tDAY, 1 }, { "tuesday", tDAY, 2 }, { "tues", tDAY, 2 }, { "wednesday", tDAY, 3 }, { "wednes", tDAY, 3 }, { "thursday", tDAY, 4 }, { "thur", tDAY, 4 }, { "thurs", tDAY, 4 }, { "friday", tDAY, 5 }, { "saturday", tDAY, 6 }, { NULL, 0, 0 } }; /* Time units table. */ static TABLE const UnitsTable[] = { { "year", tMONTH_UNIT, 12 }, { "month", tMONTH_UNIT, 1 }, { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, { "week", tMINUTE_UNIT, 7 * 24 * 60 }, { "day", tMINUTE_UNIT, 1 * 24 * 60 }, { "hour", tMINUTE_UNIT, 60 }, { "minute", tMINUTE_UNIT, 1 }, { "min", tMINUTE_UNIT, 1 }, { "second", tSEC_UNIT, 1 }, { "sec", tSEC_UNIT, 1 }, { NULL, 0, 0 } }; /* Assorted relative-time words. */ static TABLE const OtherTable[] = { { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, { "today", tMINUTE_UNIT, 0 }, { "now", tMINUTE_UNIT, 0 }, { "last", tUNUMBER, -1 }, { "this", tMINUTE_UNIT, 0 }, { "next", tUNUMBER, 2 }, { "first", tUNUMBER, 1 }, /* { "second", tUNUMBER, 2 }, */ { "third", tUNUMBER, 3 }, { "fourth", tUNUMBER, 4 }, { "fifth", tUNUMBER, 5 }, { "sixth", tUNUMBER, 6 }, { "seventh", tUNUMBER, 7 }, { "eighth", tUNUMBER, 8 }, { "ninth", tUNUMBER, 9 }, { "tenth", tUNUMBER, 10 }, { "eleventh", tUNUMBER, 11 }, { "twelfth", tUNUMBER, 12 }, { "ago", tAGO, 1 }, { NULL, 0, 0 } }; /* The timezone table. */ /* Some of these are commented out because a time_t can't store a float. */ static TABLE const TimezoneTable[] = { { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ { "utc", tZONE, HOUR( 0) }, { "wet", tZONE, HOUR( 0) }, /* Western European */ { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ { "wat", tZONE, HOUR( 1) }, /* West Africa */ { "at", tZONE, HOUR( 2) }, /* Azores */ #if 0 /* For completeness. BST is also British Summer, and GST is * also Guam Standard. */ { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ #endif #if 0 { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ #endif { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ { "cst", tZONE, HOUR( 6) }, /* Central Standard */ { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ { "cat", tZONE, HOUR(10) }, /* Central Alaska */ { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ { "nt", tZONE, HOUR(11) }, /* Nome */ { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ { "cet", tZONE, -HOUR(1) }, /* Central European */ { "met", tZONE, -HOUR(1) }, /* Middle European */ { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ { "fwt", tZONE, -HOUR(1) }, /* French Winter */ { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ #if 0 { "it", tZONE, -HOUR(3.5) },/* Iran */ #endif { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ #if 0 { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ #endif { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ #if 0 /* For completeness. NST is also Newfoundland Stanard, and SST is * also Swedish Summer. */ { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ #endif /* 0 */ { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ #if 0 { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ #endif { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ #if 0 { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ #endif { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ { NULL, 0, 0 } }; /* Military timezone table. */ static TABLE const MilitaryTable[] = { { "a", tZONE, HOUR( 1) }, { "b", tZONE, HOUR( 2) }, { "c", tZONE, HOUR( 3) }, { "d", tZONE, HOUR( 4) }, { "e", tZONE, HOUR( 5) }, { "f", tZONE, HOUR( 6) }, { "g", tZONE, HOUR( 7) }, { "h", tZONE, HOUR( 8) }, { "i", tZONE, HOUR( 9) }, { "k", tZONE, HOUR( 10) }, { "l", tZONE, HOUR( 11) }, { "m", tZONE, HOUR( 12) }, { "n", tZONE, HOUR(- 1) }, { "o", tZONE, HOUR(- 2) }, { "p", tZONE, HOUR(- 3) }, { "q", tZONE, HOUR(- 4) }, { "r", tZONE, HOUR(- 5) }, { "s", tZONE, HOUR(- 6) }, { "t", tZONE, HOUR(- 7) }, { "u", tZONE, HOUR(- 8) }, { "v", tZONE, HOUR(- 9) }, { "w", tZONE, HOUR(-10) }, { "x", tZONE, HOUR(-11) }, { "y", tZONE, HOUR(-12) }, { "z", tZONE, HOUR( 0) }, { NULL, 0, 0 } }; /* ARGSUSED */ static int yyerror(const char *s __unused) { return 0; } static time_t ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian) { if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) return -1; switch (Meridian) { case MER24: if (Hours < 0 || Hours > 23) return -1; return (Hours * 60L + Minutes) * 60L + Seconds; case MERam: if (Hours < 1 || Hours > 12) return -1; if (Hours == 12) Hours = 0; return (Hours * 60L + Minutes) * 60L + Seconds; case MERpm: if (Hours < 1 || Hours > 12) return -1; if (Hours == 12) Hours = 0; return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; default: abort (); } /* NOTREACHED */ } /* Year is either * A negative number, which means to use its absolute value (why?) * A number from 0 to 99, which means a year from 1900 to 1999, or * The actual year (>=100). */ static time_t Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian, DSTMODE DSTmode) { static int DaysInMonth[12] = { 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; time_t tod; time_t Julian; int i; struct tm *ltm; if (Year < 0) Year = -Year; if (Year < 69) Year += 2000; else if (Year < 100) Year += 1900; DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 29 : 28; /* Checking for 2038 bogusly assumes that time_t is 32 bits. But I'm too lazy to try to check for time_t overflow in another way. */ if (Year < EPOCH || Year > 2038 || Month < 1 || Month > 12 /* Lint fluff: "conversion from long may lose accuracy" */ || Day < 1 || Day > DaysInMonth[(int)--Month]) /* FIXME: * It would be nice to set a global error string here. * "February 30 is not a valid date" is much more informative than * "Can't parse date/time: 100 months" when the user input was * "100 months" and addition resolved that to February 30, for * example. See rcs2-7 in src/sanity.sh for more. */ return -1; for (Julian = Day - 1, i = 0; i < Month; i++) Julian += DaysInMonth[i]; for (i = EPOCH; i < Year; i++) Julian += 365 + (i % 4 == 0); Julian *= SECSPERDAY; Julian += yyTimezone * 60L; if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) return -1; Julian += tod; ltm = localtime(&Julian); fprintf(stderr, "DST %d TZ %s %d\n", DSTmode, ltm->tm_zone, ltm->tm_isdst); if (DSTmode == DSTon || (DSTmode == DSTmaybe && localtime(&Julian)->tm_isdst)) Julian -= 60 * 60; return Julian; } static time_t DSTcorrect(time_t Start, time_t Future) { time_t StartDay; time_t FutureDay; StartDay = (localtime(&Start)->tm_hour + 1) % 24; FutureDay = (localtime(&Future)->tm_hour + 1) % 24; return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; } static time_t RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber) { struct tm *tm; time_t now; now = Start; tm = localtime(&now); now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); return DSTcorrect(Start, now); } static time_t RelativeMonth(time_t Start, time_t RelMonth) { struct tm *tm; time_t Month; time_t Year; if (RelMonth == 0) return 0; tm = localtime(&Start); Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth; Year = Month / 12; Month = Month % 12 + 1; return DSTcorrect(Start, Convert(Month, (time_t)tm->tm_mday, Year, (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, MER24, DSTmaybe)); } static int LookupWord(char *buff) { char *p; char *q; const TABLE *tp; int i; int abbrev; /* Make it lowercase. */ for (p = buff; *p; p++) if (isupper(*p)) *p = tolower(*p); if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { yylval.Meridian = MERam; return tMERIDIAN; } if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { yylval.Meridian = MERpm; return tMERIDIAN; } /* See if we have an abbreviation for a month. */ if (strlen(buff) == 3) abbrev = 1; else if (strlen(buff) == 4 && buff[3] == '.') { abbrev = 1; buff[3] = '\0'; } else abbrev = 0; for (tp = MonthDayTable; tp->name; tp++) { if (abbrev) { if (strncmp(buff, tp->name, 3) == 0) { yylval.Number = tp->value; return tp->type; } } else if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } } for (tp = TimezoneTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } if (strcmp(buff, "dst") == 0) return tDST; for (tp = UnitsTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } /* Strip off any plural and try the units table again. */ i = strlen(buff) - 1; if (buff[i] == 's') { buff[i] = '\0'; for (tp = UnitsTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } buff[i] = 's'; /* Put back for "this" in OtherTable. */ } for (tp = OtherTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } /* Military timezones. */ if (buff[1] == '\0' && isalpha(*buff)) { for (tp = MilitaryTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } } /* Drop out any periods and try the timezone table again. */ for (i = 0, p = q = buff; *q; q++) if (*q != '.') *p++ = *q; else i++; *p = '\0'; if (i) for (tp = TimezoneTable; tp->name; tp++) if (strcmp(buff, tp->name) == 0) { yylval.Number = tp->value; return tp->type; } return tID; } static int yylex(void) { char c; char *p; char buff[20]; int Count; int sign; for ( ; ; ) { while (isspace(*yyInput)) yyInput++; if (isdigit(c = *yyInput) || c == '-' || c == '+') { if (c == '-' || c == '+') { sign = c == '-' ? -1 : 1; if (!isdigit(*++yyInput)) /* skip the '-' sign */ continue; } else sign = 0; for (yylval.Number = 0; isdigit(c = *yyInput++); ) yylval.Number = 10 * yylval.Number + c - '0'; yyInput--; if (sign < 0) yylval.Number = -yylval.Number; return sign ? tSNUMBER : tUNUMBER; } if (isalpha(c)) { for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) if (p < &buff[sizeof buff - 1]) *p++ = c; *p = '\0'; yyInput--; return LookupWord(buff); } if (c != '(') return *yyInput++; Count = 0; do { c = *yyInput++; if (c == '\0') return c; if (c == '(') Count++; else if (c == ')') Count--; } while (Count > 0); } } #define TM_YEAR_ORIGIN 1900 time_t get_date(char *p) { struct tm *tm; time_t Start; time_t tod; time_t nowtime; yyInput = p; (void)time (&nowtime); if (! (tm = localtime (&nowtime))) return -1; yyYear = tm->tm_year + 1900; yyMonth = tm->tm_mon + 1; yyDay = tm->tm_mday; yyTimezone = tm->tm_gmtoff; yyDSTmode = DSTmaybe; yyHour = 0; yyMinutes = 0; yySeconds = 0; yyMeridian = MER24; yyRelSeconds = 0; yyRelMonth = 0; yyHaveDate = 0; yyHaveDay = 0; yyHaveRel = 0; yyHaveTime = 0; yyHaveZone = 0; if (yyparse() || yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1) return -1; if (yyHaveDate || yyHaveTime || yyHaveDay) { Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, yySeconds, yyMeridian, yyDSTmode); if (Start < 0) return -1; } else { Start = nowtime; if (!yyHaveRel) Start -= ((tm->tm_hour * 60L + tm->tm_min) * 60L) + tm->tm_sec; } Start += yyRelSeconds; Start += RelativeMonth(Start, yyRelMonth); if (yyHaveDay && !yyHaveDate) { tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); Start += tod; } /* Have to do *something* with a legitimate -1 so it's distinguishable * from the error return value. (Alternately could set errno on error.) */ return Start == -1 ? 0 : Start; } diff --git a/usr.sbin/fstyp/hammer_disk.h b/usr.sbin/fstyp/hammer_disk.h index 8b5654f748fa..4b5182d7e868 100644 --- a/usr.sbin/fstyp/hammer_disk.h +++ b/usr.sbin/fstyp/hammer_disk.h @@ -1,1091 +1,1090 @@ /*- * Copyright (c) 2007 The DragonFly Project. All rights reserved. * * This code is derived from software contributed to The DragonFly Project * by Matthew Dillon * * 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 DragonFly Project 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 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDERS 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. * * $DragonFly: src/sys/vfs/hammer/hammer_disk.h,v 1.55 2008/11/13 02:18:43 dillon Exp $ - * $FreeBSD$ */ #ifndef VFS_HAMMER_DISK_H_ #define VFS_HAMMER_DISK_H_ #include #ifndef _SYS_UUID_H_ #include #endif /* * The structures below represent the on-disk format for a HAMMER * filesystem. Note that all fields for on-disk structures are naturally * aligned. HAMMER uses little endian for fields in on-disk structures. * HAMMER doesn't support big endian arch, but is planned. * * Most of HAMMER revolves around the concept of an object identifier. An * obj_id is a 64 bit quantity which uniquely identifies a filesystem object * FOR THE ENTIRE LIFE OF THE FILESYSTEM. This uniqueness allows backups * and mirrors to retain varying amounts of filesystem history by removing * any possibility of conflict through identifier reuse. * * A HAMMER filesystem may span multiple volumes. * * A HAMMER filesystem uses a 16K filesystem buffer size. All filesystem * I/O is done in multiples of 16K. * * 64K X-bufs are used for blocks >= a file's 1MB mark. * * Per-volume storage limit: 52 bits 4096 TB * Per-Zone storage limit: 60 bits 1 MTB * Per-filesystem storage limit: 60 bits 1 MTB */ #define HAMMER_BUFSIZE 16384 #define HAMMER_XBUFSIZE 65536 #define HAMMER_HBUFSIZE (HAMMER_BUFSIZE / 2) #define HAMMER_XDEMARC (1024 * 1024) #define HAMMER_BUFMASK (HAMMER_BUFSIZE - 1) #define HAMMER_XBUFMASK (HAMMER_XBUFSIZE - 1) #define HAMMER_BUFSIZE64 ((uint64_t)HAMMER_BUFSIZE) #define HAMMER_BUFMASK64 ((uint64_t)HAMMER_BUFMASK) #define HAMMER_XBUFSIZE64 ((uint64_t)HAMMER_XBUFSIZE) #define HAMMER_XBUFMASK64 ((uint64_t)HAMMER_XBUFMASK) #define HAMMER_OFF_ZONE_MASK 0xF000000000000000ULL /* zone portion */ #define HAMMER_OFF_VOL_MASK 0x0FF0000000000000ULL /* volume portion */ #define HAMMER_OFF_SHORT_MASK 0x000FFFFFFFFFFFFFULL /* offset portion */ #define HAMMER_OFF_LONG_MASK 0x0FFFFFFFFFFFFFFFULL /* offset portion */ #define HAMMER_OFF_BAD ((hammer_off_t)-1) #define HAMMER_BUFSIZE_DOALIGN(offset) \ (((offset) + HAMMER_BUFMASK) & ~HAMMER_BUFMASK) #define HAMMER_BUFSIZE64_DOALIGN(offset) \ (((offset) + HAMMER_BUFMASK64) & ~HAMMER_BUFMASK64) #define HAMMER_XBUFSIZE_DOALIGN(offset) \ (((offset) + HAMMER_XBUFMASK) & ~HAMMER_XBUFMASK) #define HAMMER_XBUFSIZE64_DOALIGN(offset) \ (((offset) + HAMMER_XBUFMASK64) & ~HAMMER_XBUFMASK64) /* * The current limit of volumes that can make up a HAMMER FS */ #define HAMMER_MAX_VOLUMES 256 /* * Reserved space for (future) header junk after the volume header. */ #define HAMMER_MIN_VOL_JUNK (HAMMER_BUFSIZE * 16) /* 256 KB */ #define HAMMER_MAX_VOL_JUNK HAMMER_MIN_VOL_JUNK #define HAMMER_VOL_JUNK_SIZE HAMMER_MIN_VOL_JUNK /* * Hammer transaction ids are 64 bit unsigned integers and are usually * synchronized with the time of day in nanoseconds. * * Hammer offsets are used for FIFO indexing and embed a cycle counter * and volume number in addition to the offset. Most offsets are required * to be 16 KB aligned. */ typedef uint64_t hammer_tid_t; typedef uint64_t hammer_off_t; typedef uint32_t hammer_crc_t; typedef uuid_t hammer_uuid_t; #define HAMMER_MIN_TID 0ULL /* unsigned */ #define HAMMER_MAX_TID 0xFFFFFFFFFFFFFFFFULL /* unsigned */ #define HAMMER_MIN_KEY -0x8000000000000000LL /* signed */ #define HAMMER_MAX_KEY 0x7FFFFFFFFFFFFFFFLL /* signed */ #define HAMMER_MIN_OBJID HAMMER_MIN_KEY /* signed */ #define HAMMER_MAX_OBJID HAMMER_MAX_KEY /* signed */ #define HAMMER_MIN_RECTYPE 0x0U /* unsigned */ #define HAMMER_MAX_RECTYPE 0xFFFFU /* unsigned */ #define HAMMER_MIN_OFFSET 0ULL /* unsigned */ #define HAMMER_MAX_OFFSET 0xFFFFFFFFFFFFFFFFULL /* unsigned */ /* * hammer_off_t has several different encodings. Note that not all zones * encode a vol_no. Zone bits are not a part of filesystem capacity as * the zone bits aren't directly or indirectly mapped to physical volumes. * * In other words, HAMMER's logical filesystem offset consists of 64 bits, * but the filesystem is considered 60 bits filesystem, not 64 bits. * The maximum filesystem capacity is 1EB, not 16EB. * * zone 0: available, a big-block that contains the offset is unused * zone 1 (z,v,o): raw volume relative (offset 0 is the volume header) * zone 2 (z,v,o): raw buffer relative (offset 0 is the first buffer) * zone 3 (z,o): undo/redo fifo - fixed zone-2 offset array in volume header * zone 4 (z,v,o): freemap - only real blockmap * zone 8 (z,v,o): B-Tree - actually zone-2 address * zone 9 (z,v,o): meta - actually zone-2 address * zone 10 (z,v,o): large-data - actually zone-2 address * zone 11 (z,v,o): small-data - actually zone-2 address * zone 15: unavailable, usually the offset is beyond volume size * * layer1/layer2 direct map: * Maximum HAMMER filesystem capacity from volume aspect * 2^8(max volumes) * 2^52(max volume size) = 2^60 = 1EB (long offset) * <-------------------------------------------------------------> * 8bits 52bits (short offset) * <------><-----------------------------------------------------> * zzzzvvvvvvvvoooo oooooooooooooooo oooooooooooooooo oooooooooooooooo * ----111111111111 1111112222222222 222222222ooooooo oooooooooooooooo * <-----------------><------------------><----------------------> * 18bits 19bits 23bits * <-------------------------------------------------------------> * 2^18(layer1) * 2^19(layer2) * 2^23(big-block) = 2^60 = 1EB * Maximum HAMMER filesystem capacity from blockmap aspect * * volume#0 layout * +-------------------------> offset 0 of a device/partition * | volume header (1928 bytes) * | the rest of header junk space (HAMMER_BUFSIZE aligned) * +-------------------------> vol_bot_beg * | boot area (HAMMER_BUFSIZE aligned) * +-------------------------> vol_mem_beg * | memory log (HAMMER_BUFSIZE aligned) * +-------------------------> vol_buf_beg (physical offset of zone-2) * | zone-4 big-block for layer1 * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * | zone-4 big-blocks for layer2 * | ... (1 big-block per 4TB space) * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-3 big-blocks for UNDO/REDO FIFO * | ... (max 128 big-blocks) * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-8 big-block for root B-Tree node/etc * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-9 big-block for root inode/PFS/etc * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-X big-blocks * | ... (big-blocks for new zones after newfs_hammer) * | ... * | ... * | ... * | ... * +-------------------------> vol_buf_end (HAMMER_BUFSIZE aligned) * +-------------------------> end of a device/partition * * volume#N layout (0 offset 0 of a device/partition * | volume header (1928 bytes) * | the rest of header junk space (HAMMER_BUFSIZE aligned) * +-------------------------> vol_bot_beg * | boot area (HAMMER_BUFSIZE aligned) * +-------------------------> vol_mem_beg * | memory log (HAMMER_BUFSIZE aligned) * +-------------------------> vol_buf_beg (physical offset of zone-2) * | zone-4 big-blocks for layer2 * | ... (1 big-block per 4TB space) * +-------------------------> vol_buf_beg + HAMMER_BIGBLOCK_SIZE * ... * | zone-X big-blocks * | ... (unused until volume#(N-1) runs out of space) * | ... * | ... * | ... * | ... * +-------------------------> vol_buf_end (HAMMER_BUFSIZE aligned) * +-------------------------> end of a device/partition */ #define HAMMER_ZONE_RAW_VOLUME 0x1000000000000000ULL #define HAMMER_ZONE_RAW_BUFFER 0x2000000000000000ULL #define HAMMER_ZONE_UNDO 0x3000000000000000ULL #define HAMMER_ZONE_FREEMAP 0x4000000000000000ULL #define HAMMER_ZONE_RESERVED05 0x5000000000000000ULL /* not used */ #define HAMMER_ZONE_RESERVED06 0x6000000000000000ULL /* not used */ #define HAMMER_ZONE_RESERVED07 0x7000000000000000ULL /* not used */ #define HAMMER_ZONE_BTREE 0x8000000000000000ULL #define HAMMER_ZONE_META 0x9000000000000000ULL #define HAMMER_ZONE_LARGE_DATA 0xA000000000000000ULL #define HAMMER_ZONE_SMALL_DATA 0xB000000000000000ULL #define HAMMER_ZONE_RESERVED0C 0xC000000000000000ULL /* not used */ #define HAMMER_ZONE_RESERVED0D 0xD000000000000000ULL /* not used */ #define HAMMER_ZONE_RESERVED0E 0xE000000000000000ULL /* not used */ #define HAMMER_ZONE_UNAVAIL 0xF000000000000000ULL #define HAMMER_ZONE_RAW_VOLUME_INDEX 1 #define HAMMER_ZONE_RAW_BUFFER_INDEX 2 #define HAMMER_ZONE_UNDO_INDEX 3 #define HAMMER_ZONE_FREEMAP_INDEX 4 #define HAMMER_ZONE_BTREE_INDEX 8 #define HAMMER_ZONE_META_INDEX 9 #define HAMMER_ZONE_LARGE_DATA_INDEX 10 #define HAMMER_ZONE_SMALL_DATA_INDEX 11 #define HAMMER_ZONE_UNAVAIL_INDEX 15 #define HAMMER_MAX_ZONES 16 #define HAMMER_ZONE(offset) ((offset) & HAMMER_OFF_ZONE_MASK) #define hammer_is_zone_raw_volume(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_RAW_VOLUME) #define hammer_is_zone_raw_buffer(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_RAW_BUFFER) #define hammer_is_zone_undo(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_UNDO) #define hammer_is_zone_freemap(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_FREEMAP) #define hammer_is_zone_btree(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_BTREE) #define hammer_is_zone_meta(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_META) #define hammer_is_zone_large_data(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_LARGE_DATA) #define hammer_is_zone_small_data(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_SMALL_DATA) #define hammer_is_zone_unavail(offset) \ (HAMMER_ZONE(offset) == HAMMER_ZONE_UNAVAIL) #define hammer_is_zone_data(offset) \ (hammer_is_zone_large_data(offset) || hammer_is_zone_small_data(offset)) #define hammer_is_index_record(zone) \ ((zone) >= HAMMER_ZONE_BTREE_INDEX && \ (zone) < HAMMER_MAX_ZONES) #define hammer_is_zone_record(offset) \ hammer_is_index_record(HAMMER_ZONE_DECODE(offset)) #define hammer_is_index_direct_xlated(zone) \ (((zone) == HAMMER_ZONE_RAW_BUFFER_INDEX) || \ ((zone) == HAMMER_ZONE_FREEMAP_INDEX) || \ hammer_is_index_record(zone)) #define hammer_is_zone_direct_xlated(offset) \ hammer_is_index_direct_xlated(HAMMER_ZONE_DECODE(offset)) #define HAMMER_ZONE_ENCODE(zone, ham_off) \ (((hammer_off_t)(zone) << 60) | (ham_off)) #define HAMMER_ZONE_DECODE(ham_off) \ ((int)(((hammer_off_t)(ham_off) >> 60))) #define HAMMER_VOL_ENCODE(vol_no) \ ((hammer_off_t)((vol_no) & 255) << 52) #define HAMMER_VOL_DECODE(ham_off) \ ((int)(((hammer_off_t)(ham_off) >> 52) & 255)) #define HAMMER_OFF_SHORT_ENCODE(offset) \ ((hammer_off_t)(offset) & HAMMER_OFF_SHORT_MASK) #define HAMMER_OFF_LONG_ENCODE(offset) \ ((hammer_off_t)(offset) & HAMMER_OFF_LONG_MASK) #define HAMMER_ENCODE(zone, vol_no, offset) \ (((hammer_off_t)(zone) << 60) | \ HAMMER_VOL_ENCODE(vol_no) | \ HAMMER_OFF_SHORT_ENCODE(offset)) #define HAMMER_ENCODE_RAW_VOLUME(vol_no, offset) \ HAMMER_ENCODE(HAMMER_ZONE_RAW_VOLUME_INDEX, vol_no, offset) #define HAMMER_ENCODE_RAW_BUFFER(vol_no, offset) \ HAMMER_ENCODE(HAMMER_ZONE_RAW_BUFFER_INDEX, vol_no, offset) #define HAMMER_ENCODE_UNDO(offset) \ HAMMER_ENCODE(HAMMER_ZONE_UNDO_INDEX, HAMMER_ROOT_VOLNO, offset) #define HAMMER_ENCODE_FREEMAP(vol_no, offset) \ HAMMER_ENCODE(HAMMER_ZONE_FREEMAP_INDEX, vol_no, offset) /* * Translate a zone address to zone-X address. */ #define hammer_xlate_to_zoneX(zone, offset) \ HAMMER_ZONE_ENCODE((zone), (offset) & ~HAMMER_OFF_ZONE_MASK) #define hammer_xlate_to_zone2(offset) \ hammer_xlate_to_zoneX(HAMMER_ZONE_RAW_BUFFER_INDEX, (offset)) #define hammer_data_zone(data_len) \ (((data_len) >= HAMMER_BUFSIZE) ? \ HAMMER_ZONE_LARGE_DATA : \ HAMMER_ZONE_SMALL_DATA) #define hammer_data_zone_index(data_len) \ (((data_len) >= HAMMER_BUFSIZE) ? \ HAMMER_ZONE_LARGE_DATA_INDEX : \ HAMMER_ZONE_SMALL_DATA_INDEX) /* * Big-Block backing store * * A blockmap is a two-level map which translates a blockmap-backed zone * offset into a raw zone 2 offset. The layer 1 handles 18 bits and the * layer 2 handles 19 bits. The 8M big-block size is 23 bits so two * layers gives us 18+19+23 = 60 bits of address space. * * When using hinting for a blockmap lookup, the hint is lost when the * scan leaves the HINTBLOCK, which is typically several BIGBLOCK's. * HINTBLOCK is a heuristic. */ #define HAMMER_HINTBLOCK_SIZE (HAMMER_BIGBLOCK_SIZE * 4) #define HAMMER_HINTBLOCK_MASK64 ((uint64_t)HAMMER_HINTBLOCK_SIZE - 1) #define HAMMER_BIGBLOCK_SIZE (8192 * 1024) #define HAMMER_BIGBLOCK_SIZE64 ((uint64_t)HAMMER_BIGBLOCK_SIZE) #define HAMMER_BIGBLOCK_MASK (HAMMER_BIGBLOCK_SIZE - 1) #define HAMMER_BIGBLOCK_MASK64 ((uint64_t)HAMMER_BIGBLOCK_SIZE - 1) #define HAMMER_BIGBLOCK_BITS 23 #if 0 #define HAMMER_BIGBLOCK_OVERFILL (6144 * 1024) #endif #if (1 << HAMMER_BIGBLOCK_BITS) != HAMMER_BIGBLOCK_SIZE #error "HAMMER_BIGBLOCK_BITS BROKEN" #endif #define HAMMER_BUFFERS_PER_BIGBLOCK \ (HAMMER_BIGBLOCK_SIZE / HAMMER_BUFSIZE) #define HAMMER_BUFFERS_PER_BIGBLOCK_MASK \ (HAMMER_BUFFERS_PER_BIGBLOCK - 1) #define HAMMER_BUFFERS_PER_BIGBLOCK_MASK64 \ ((hammer_off_t)HAMMER_BUFFERS_PER_BIGBLOCK_MASK) #define HAMMER_BIGBLOCK_DOALIGN(offset) \ (((offset) + HAMMER_BIGBLOCK_MASK64) & ~HAMMER_BIGBLOCK_MASK64) /* * Maximum number of mirrors operating in master mode (multi-master * clustering and mirroring). Note that HAMMER1 does not support * multi-master clustering as of 2015. */ #define HAMMER_MAX_MASTERS 16 /* * The blockmap is somewhat of a degenerate structure. HAMMER only actually * uses it in its original incarnation to implement the freemap. * * zone:1 raw volume (no blockmap) * zone:2 raw buffer (no blockmap) * zone:3 undomap (direct layer2 array in volume header) * zone:4 freemap (the only real blockmap) * zone:8-15 zone id used to classify big-block only, address is actually * a zone-2 address. */ typedef struct hammer_blockmap { hammer_off_t phys_offset; /* zone-2 offset only used by zone-4 */ hammer_off_t first_offset; /* zone-X offset only used by zone-3 */ hammer_off_t next_offset; /* zone-X offset for allocation */ hammer_off_t alloc_offset; /* zone-X offset only used by zone-3 */ uint32_t reserved01; hammer_crc_t entry_crc; } *hammer_blockmap_t; #define HAMMER_BLOCKMAP_CRCSIZE \ offsetof(struct hammer_blockmap, entry_crc) /* * The blockmap is a 2-layer entity made up of big-blocks. The first layer * contains 262144 32-byte entries (18 bits), the second layer contains * 524288 16-byte entries (19 bits), representing 8MB (23 bit) blockmaps. * 18+19+23 = 60 bits. The top four bits are the zone id. * * Currently only the freemap utilizes both layers in all their glory. * All primary data/meta-data zones actually encode a zone-2 address * requiring no real blockmap translation. * * The freemap uses the upper 8 bits of layer-1 to identify the volume, * thus any space allocated via the freemap can be directly translated * to a zone:2 (or zone:8-15) address. * * zone-X blockmap offset: [zone:4][layer1:18][layer2:19][big-block:23] */ /* * 32 bytes layer1 entry for 8MB big-block. * A big-block can hold 2^23 / 2^5 = 2^18 layer1 entries, * which equals bits assigned for layer1 in zone-2 address. */ typedef struct hammer_blockmap_layer1 { hammer_off_t blocks_free; /* big-blocks free */ hammer_off_t phys_offset; /* UNAVAIL or zone-2 */ hammer_off_t reserved01; hammer_crc_t layer2_crc; /* xor'd crc's of HAMMER_BLOCKSIZE */ /* (not yet used) */ hammer_crc_t layer1_crc; /* MUST BE LAST FIELD OF STRUCTURE*/ } *hammer_blockmap_layer1_t; #define HAMMER_LAYER1_CRCSIZE \ offsetof(struct hammer_blockmap_layer1, layer1_crc) /* * 16 bytes layer2 entry for 8MB big-blocks. * A big-block can hold 2^23 / 2^4 = 2^19 layer2 entries, * which equals bits assigned for layer2 in zone-2 address. * * NOTE: bytes_free is signed and can legally go negative if/when data * de-dup occurs. This field will never go higher than * HAMMER_BIGBLOCK_SIZE. If exactly HAMMER_BIGBLOCK_SIZE * the big-block is completely free. */ typedef struct hammer_blockmap_layer2 { uint8_t zone; /* typed allocation zone */ uint8_t reserved01; uint16_t reserved02; uint32_t append_off; /* allocatable space index */ int32_t bytes_free; /* bytes free within this big-block */ hammer_crc_t entry_crc; } *hammer_blockmap_layer2_t; #define HAMMER_LAYER2_CRCSIZE \ offsetof(struct hammer_blockmap_layer2, entry_crc) #define HAMMER_BLOCKMAP_UNAVAIL ((hammer_off_t)-1LL) #define HAMMER_BLOCKMAP_RADIX1 /* 2^18 = 262144 */ \ ((int)(HAMMER_BIGBLOCK_SIZE / sizeof(struct hammer_blockmap_layer1))) #define HAMMER_BLOCKMAP_RADIX2 /* 2^19 = 524288 */ \ ((int)(HAMMER_BIGBLOCK_SIZE / sizeof(struct hammer_blockmap_layer2))) #define HAMMER_BLOCKMAP_LAYER1 /* 2^(18+19+23) = 1EB */ \ (HAMMER_BLOCKMAP_RADIX1 * HAMMER_BLOCKMAP_LAYER2) #define HAMMER_BLOCKMAP_LAYER2 /* 2^(19+23) = 4TB */ \ (HAMMER_BLOCKMAP_RADIX2 * HAMMER_BIGBLOCK_SIZE64) #define HAMMER_BLOCKMAP_LAYER1_MASK (HAMMER_BLOCKMAP_LAYER1 - 1) #define HAMMER_BLOCKMAP_LAYER2_MASK (HAMMER_BLOCKMAP_LAYER2 - 1) #define HAMMER_BLOCKMAP_LAYER2_DOALIGN(offset) \ (((offset) + HAMMER_BLOCKMAP_LAYER2_MASK) & \ ~HAMMER_BLOCKMAP_LAYER2_MASK) /* * Index within layer1 or layer2 big-block for the entry representing * a zone-2 physical offset. */ #define HAMMER_BLOCKMAP_LAYER1_INDEX(zone2_offset) \ ((int)(((zone2_offset) & HAMMER_BLOCKMAP_LAYER1_MASK) / \ HAMMER_BLOCKMAP_LAYER2)) #define HAMMER_BLOCKMAP_LAYER2_INDEX(zone2_offset) \ ((int)(((zone2_offset) & HAMMER_BLOCKMAP_LAYER2_MASK) / \ HAMMER_BIGBLOCK_SIZE64)) /* * Byte offset within layer1 or layer2 big-block for the entry representing * a zone-2 physical offset. Multiply the index by sizeof(blockmap_layer). */ #define HAMMER_BLOCKMAP_LAYER1_OFFSET(zone2_offset) \ (HAMMER_BLOCKMAP_LAYER1_INDEX(zone2_offset) * \ sizeof(struct hammer_blockmap_layer1)) #define HAMMER_BLOCKMAP_LAYER2_OFFSET(zone2_offset) \ (HAMMER_BLOCKMAP_LAYER2_INDEX(zone2_offset) * \ sizeof(struct hammer_blockmap_layer2)) /* * Move on to offset 0 of the next layer1 or layer2. */ #define HAMMER_ZONE_LAYER1_NEXT_OFFSET(offset) \ (((offset) + HAMMER_BLOCKMAP_LAYER2) & ~HAMMER_BLOCKMAP_LAYER2_MASK) #define HAMMER_ZONE_LAYER2_NEXT_OFFSET(offset) \ (((offset) + HAMMER_BIGBLOCK_SIZE) & ~HAMMER_BIGBLOCK_MASK64) /* * HAMMER UNDO parameters. The UNDO fifo is mapped directly in the volume * header with an array of zone-2 offsets. A maximum of (128x8MB) = 1GB, * and minimum of (64x8MB) = 512MB may be reserved. The size of the undo * fifo is usually set a newfs time. */ #define HAMMER_MIN_UNDO_BIGBLOCKS 64 #define HAMMER_MAX_UNDO_BIGBLOCKS 128 /* * All on-disk HAMMER structures which make up elements of the UNDO FIFO * contain a hammer_fifo_head and hammer_fifo_tail structure. This structure * contains all the information required to validate the fifo element * and to scan the fifo in either direction. The head is typically embedded * in higher level hammer on-disk structures while the tail is typically * out-of-band. hdr_size is the size of the whole mess, including the tail. * * All undo structures are guaranteed to not cross a 16K filesystem * buffer boundary. Most undo structures are fairly small. Data spaces * are not immediately reused by HAMMER so file data is not usually recorded * as part of an UNDO. * * PAD elements are allowed to take up only 8 bytes of space as a special * case, containing only hdr_signature, hdr_type, and hdr_size fields, * and with the tail overloaded onto the head structure for 8 bytes total. * * Every undo record has a sequence number. This number is unrelated to * transaction ids and instead collects the undo transactions associated * with a single atomic operation. A larger transactional operation, such * as a remove(), may consist of several smaller atomic operations * representing raw meta-data operations. * * HAMMER VERSION 4 CHANGES * * In HAMMER version 4 the undo structure alignment is reduced from 16384 * to 512 bytes in order to ensure that each 512 byte sector begins with * a header. The hdr_seq field in the header is a 32 bit sequence number * which allows the recovery code to detect missing sectors * without relying on the 32-bit crc and to definitively identify the current * undo sequence space without having to rely on information from the volume * header. In addition, new REDO entries in the undo space are used to * record write, write/extend, and transaction id updates. * * The grand result is: * * (1) The volume header no longer needs to be synchronized for most * flush and fsync operations. * * (2) Most fsync operations need only lay down REDO records * * (3) Data overwrite for nohistory operations covered by REDO records * can be supported (instead of rolling a new block allocation), * by rolling UNDO for the prior contents of the data. * * HAMMER VERSION 5 CHANGES * * Hammer version 5 contains a minor adjustment making layer2's bytes_free * field signed, allowing dedup to push it into the negative domain. */ #define HAMMER_HEAD_ALIGN 8 #define HAMMER_HEAD_ALIGN_MASK (HAMMER_HEAD_ALIGN - 1) #define HAMMER_HEAD_DOALIGN(bytes) \ (((bytes) + HAMMER_HEAD_ALIGN_MASK) & ~HAMMER_HEAD_ALIGN_MASK) #define HAMMER_UNDO_ALIGN 512 #define HAMMER_UNDO_ALIGN64 ((uint64_t)512) #define HAMMER_UNDO_MASK (HAMMER_UNDO_ALIGN - 1) #define HAMMER_UNDO_MASK64 (HAMMER_UNDO_ALIGN64 - 1) #define HAMMER_UNDO_DOALIGN(offset) \ (((offset) + HAMMER_UNDO_MASK) & ~HAMMER_UNDO_MASK64) typedef struct hammer_fifo_head { uint16_t hdr_signature; uint16_t hdr_type; uint32_t hdr_size; /* Aligned size of the whole mess */ uint32_t hdr_seq; /* Sequence number */ hammer_crc_t hdr_crc; /* XOR crc up to field w/ crc after field */ } *hammer_fifo_head_t; #define HAMMER_FIFO_HEAD_CRCOFF offsetof(struct hammer_fifo_head, hdr_crc) typedef struct hammer_fifo_tail { uint16_t tail_signature; uint16_t tail_type; uint32_t tail_size; /* aligned size of the whole mess */ } *hammer_fifo_tail_t; /* * Fifo header types. * * NOTE: 0x8000U part of HAMMER_HEAD_TYPE_PAD can be removed if the HAMMER * version ever gets bumped again. It exists only to keep compatibility with * older versions. */ #define HAMMER_HEAD_TYPE_PAD (0x0040U | 0x8000U) #define HAMMER_HEAD_TYPE_DUMMY 0x0041U /* dummy entry w/seqno */ #define HAMMER_HEAD_TYPE_UNDO 0x0043U /* random UNDO information */ #define HAMMER_HEAD_TYPE_REDO 0x0044U /* data REDO / fast fsync */ #define HAMMER_HEAD_SIGNATURE 0xC84EU #define HAMMER_TAIL_SIGNATURE 0xC74FU /* * Misc FIFO structures. * * UNDO - Raw meta-data media updates. */ typedef struct hammer_fifo_undo { struct hammer_fifo_head head; hammer_off_t undo_offset; /* zone-1,2 offset */ int32_t undo_data_bytes; int32_t undo_reserved01; /* followed by data */ } *hammer_fifo_undo_t; /* * REDO (HAMMER version 4+) - Logical file writes/truncates. * * REDOs contain information which will be duplicated in a later meta-data * update, allowing fast write()+fsync() operations. REDOs can be ignored * without harming filesystem integrity but must be processed if fsync() * semantics are desired. * * Unlike UNDOs which are processed backwards within the recovery span, * REDOs must be processed forwards starting further back (starting outside * the recovery span). * * WRITE - Write logical file (with payload). Executed both * out-of-span and in-span. Out-of-span WRITEs may be * filtered out by TERMs. * * TRUNC - Truncate logical file (no payload). Executed both * out-of-span and in-span. Out-of-span WRITEs may be * filtered out by TERMs. * * TERM_* - Indicates meta-data was committed (if out-of-span) or * will be rolled-back (in-span). Any out-of-span TERMs * matching earlier WRITEs remove those WRITEs from * consideration as they might conflict with a later data * commit (which is not being rolled-back). * * SYNC - The earliest in-span SYNC (the last one when scanning * backwards) tells the recovery code how far out-of-span * it must go to run REDOs. * * NOTE: WRITEs do not always have matching TERMs even under * perfect conditions because truncations might remove the * buffers from consideration. I/O problems can also remove * buffers from consideration. * * TRUNCSs do not always have matching TERMs because several * truncations may be aggregated together into a single TERM. */ typedef struct hammer_fifo_redo { struct hammer_fifo_head head; int64_t redo_objid; /* file being written */ hammer_off_t redo_offset; /* logical offset in file */ int32_t redo_data_bytes; uint32_t redo_flags; uint32_t redo_localization; uint32_t redo_reserved01; uint64_t redo_reserved02; /* followed by data */ } *hammer_fifo_redo_t; #define HAMMER_REDO_WRITE 0x00000001 #define HAMMER_REDO_TRUNC 0x00000002 #define HAMMER_REDO_TERM_WRITE 0x00000004 #define HAMMER_REDO_TERM_TRUNC 0x00000008 #define HAMMER_REDO_SYNC 0x00000010 typedef union hammer_fifo_any { struct hammer_fifo_head head; struct hammer_fifo_undo undo; struct hammer_fifo_redo redo; } *hammer_fifo_any_t; /* * Volume header types */ #define HAMMER_FSBUF_VOLUME 0xC8414D4DC5523031ULL /* HAMMER01 */ #define HAMMER_FSBUF_VOLUME_REV 0x313052C54D4D41C8ULL /* (reverse endian) */ /* * HAMMER Volume header * * A HAMMER filesystem can be built from 1-256 block devices, each block * device contains a volume header followed by however many buffers fit * into the volume. * * One of the volumes making up a HAMMER filesystem is the root volume. * The root volume is always volume #0 which is the first block device path * specified by newfs_hammer(8). All HAMMER volumes have a volume header, * however the root volume may be the only volume that has valid values for * some fields in the header. * * Special field notes: * * vol_bot_beg - offset of boot area (mem_beg - bot_beg bytes) * vol_mem_beg - offset of memory log (buf_beg - mem_beg bytes) * vol_buf_beg - offset of the first buffer in volume * vol_buf_end - offset of volume EOF (on buffer boundary) * * The memory log area allows a kernel to cache new records and data * in memory without allocating space in the actual filesystem to hold * the records and data. In the event that a filesystem becomes full, * any records remaining in memory can be flushed to the memory log * area. This allows the kernel to immediately return success. * * The buffer offset is a physical offset of zone-2 offset. The lower * 52 bits of the zone-2 offset is added to the buffer offset of each * volume to generate an actual I/O offset within the block device. * * NOTE: boot area and memory log are currently not used. */ /* * Filesystem type string */ #define HAMMER_FSTYPE_STRING "DragonFly HAMMER" /* * These macros are only used by userspace when userspace commands either * initialize or add a new HAMMER volume. */ #define HAMMER_BOOT_MINBYTES (32*1024) #define HAMMER_BOOT_NOMBYTES (64LL*1024*1024) #define HAMMER_BOOT_MAXBYTES (256LL*1024*1024) #define HAMMER_MEM_MINBYTES (256*1024) #define HAMMER_MEM_NOMBYTES (1LL*1024*1024*1024) #define HAMMER_MEM_MAXBYTES (64LL*1024*1024*1024) typedef struct hammer_volume_ondisk { uint64_t vol_signature; /* HAMMER_FSBUF_VOLUME for a valid header */ /* * These are relative to block device offset, not zone offsets. */ int64_t vol_bot_beg; /* offset of boot area */ int64_t vol_mem_beg; /* offset of memory log */ int64_t vol_buf_beg; /* offset of the first buffer in volume */ int64_t vol_buf_end; /* offset of volume EOF (on buffer boundary) */ int64_t vol_reserved01; hammer_uuid_t vol_fsid; /* identify filesystem */ hammer_uuid_t vol_fstype; /* identify filesystem type */ char vol_label[64]; /* filesystem label */ int32_t vol_no; /* volume number within filesystem */ int32_t vol_count; /* number of volumes making up filesystem */ uint32_t vol_version; /* version control information */ hammer_crc_t vol_crc; /* header crc */ uint32_t vol_flags; /* volume flags */ uint32_t vol_rootvol; /* the root volume number (must be 0) */ uint32_t vol_reserved[8]; /* * These fields are initialized and space is reserved in every * volume making up a HAMMER filesystem, but only the root volume * contains valid data. Note that vol0_stat_bigblocks does not * include big-blocks for freemap and undomap initially allocated * by newfs_hammer(8). */ int64_t vol0_stat_bigblocks; /* total big-blocks when fs is empty */ int64_t vol0_stat_freebigblocks;/* number of free big-blocks */ int64_t vol0_reserved01; int64_t vol0_stat_inodes; /* for statfs only */ int64_t vol0_reserved02; hammer_off_t vol0_btree_root; /* B-Tree root offset in zone-8 */ hammer_tid_t vol0_next_tid; /* highest partially synchronized TID */ hammer_off_t vol0_reserved03; /* * Blockmaps for zones. Not all zones use a blockmap. Note that * the entire root blockmap is cached in the hammer_mount structure. */ struct hammer_blockmap vol0_blockmap[HAMMER_MAX_ZONES]; /* * Array of zone-2 addresses for undo FIFO. */ hammer_off_t vol0_undo_array[HAMMER_MAX_UNDO_BIGBLOCKS]; } *hammer_volume_ondisk_t; #define HAMMER_ROOT_VOLNO 0 #define HAMMER_VOLF_NEEDFLUSH 0x0004 /* volume needs flush */ #define HAMMER_VOL_CRCSIZE1 \ offsetof(struct hammer_volume_ondisk, vol_crc) #define HAMMER_VOL_CRCSIZE2 \ (sizeof(struct hammer_volume_ondisk) - HAMMER_VOL_CRCSIZE1 - \ sizeof(hammer_crc_t)) #define HAMMER_VOL_VERSION_MIN 1 /* minimum supported version */ #define HAMMER_VOL_VERSION_DEFAULT 7 /* newfs default version */ #define HAMMER_VOL_VERSION_WIP 8 /* version >= this is WIP */ #define HAMMER_VOL_VERSION_MAX 7 /* maximum supported version */ #define HAMMER_VOL_VERSION_ONE 1 #define HAMMER_VOL_VERSION_TWO 2 /* new dirent layout (2.3+) */ #define HAMMER_VOL_VERSION_THREE 3 /* new snapshot layout (2.5+) */ #define HAMMER_VOL_VERSION_FOUR 4 /* new undo/flush (2.5+) */ #define HAMMER_VOL_VERSION_FIVE 5 /* dedup (2.9+) */ #define HAMMER_VOL_VERSION_SIX 6 /* DIRHASH_ALG1 */ #define HAMMER_VOL_VERSION_SEVEN 7 /* use the faster iscsi_crc */ /* * Translate a zone-2 address to physical address */ #define hammer_xlate_to_phys(volume, zone2_offset) \ ((volume)->vol_buf_beg + HAMMER_OFF_SHORT_ENCODE(zone2_offset)) /* * Translate a zone-3 address to zone-2 address */ #define HAMMER_UNDO_INDEX(zone3_offset) \ (HAMMER_OFF_SHORT_ENCODE(zone3_offset) / HAMMER_BIGBLOCK_SIZE) #define hammer_xlate_to_undo(volume, zone3_offset) \ ((volume)->vol0_undo_array[HAMMER_UNDO_INDEX(zone3_offset)] + \ (zone3_offset & HAMMER_BIGBLOCK_MASK64)) /* * Effective per-volume filesystem capacity including big-blocks for layer1/2 */ #define HAMMER_VOL_BUF_SIZE(volume) \ ((volume)->vol_buf_end - (volume)->vol_buf_beg) /* * Record types are fairly straightforward. The B-Tree includes the record * type in its index sort. */ #define HAMMER_RECTYPE_UNKNOWN 0x0000 #define HAMMER_RECTYPE_INODE 0x0001 /* inode in obj_id space */ #define HAMMER_RECTYPE_DATA 0x0010 #define HAMMER_RECTYPE_DIRENTRY 0x0011 #define HAMMER_RECTYPE_DB 0x0012 #define HAMMER_RECTYPE_EXT 0x0013 /* ext attributes */ #define HAMMER_RECTYPE_FIX 0x0014 /* fixed attribute */ #define HAMMER_RECTYPE_PFS 0x0015 /* PFS management */ #define HAMMER_RECTYPE_SNAPSHOT 0x0016 /* Snapshot management */ #define HAMMER_RECTYPE_CONFIG 0x0017 /* hammer cleanup config */ #define HAMMER_RECTYPE_MAX 0xFFFF #define HAMMER_RECTYPE_ENTRY_START (HAMMER_RECTYPE_INODE + 1) #define HAMMER_RECTYPE_CLEAN_START HAMMER_RECTYPE_EXT #define HAMMER_FIXKEY_SYMLINK 1 #define HAMMER_OBJTYPE_UNKNOWN 0 /* never exists on-disk as unknown */ #define HAMMER_OBJTYPE_DIRECTORY 1 #define HAMMER_OBJTYPE_REGFILE 2 #define HAMMER_OBJTYPE_DBFILE 3 #define HAMMER_OBJTYPE_FIFO 4 #define HAMMER_OBJTYPE_CDEV 5 #define HAMMER_OBJTYPE_BDEV 6 #define HAMMER_OBJTYPE_SOFTLINK 7 #define HAMMER_OBJTYPE_PSEUDOFS 8 /* pseudo filesystem obj */ #define HAMMER_OBJTYPE_SOCKET 9 /* * HAMMER inode attribute data * * The data reference for a HAMMER inode points to this structure. Any * modifications to the contents of this structure will result in a * replacement operation. * * parent_obj_id is only valid for directories (which cannot be hard-linked), * and specifies the parent directory obj_id. This field will also be set * for non-directory inodes as a recovery aid, but can wind up holding * stale information. However, since object id's are not reused, the worse * that happens is that the recovery code is unable to use it. * A parent_obj_id of 0 means it's a root inode of root or non-root PFS. * * NOTE: Future note on directory hardlinks. We can implement a record type * which allows us to point to multiple parent directories. */ typedef struct hammer_inode_data { uint16_t version; /* inode data version */ uint16_t mode; /* basic unix permissions */ uint32_t uflags; /* chflags */ uint32_t rmajor; /* used by device nodes */ uint32_t rminor; /* used by device nodes */ uint64_t ctime; int64_t parent_obj_id; /* parent directory obj_id */ hammer_uuid_t uid; hammer_uuid_t gid; uint8_t obj_type; uint8_t cap_flags; /* capability support flags (extension) */ uint16_t reserved01; uint32_t reserved02; uint64_t nlinks; /* hard links */ uint64_t size; /* filesystem object size */ union { char symlink[24]; /* HAMMER_INODE_BASESYMLEN */ } ext; uint64_t mtime; /* mtime must be second-to-last */ uint64_t atime; /* atime must be last */ } *hammer_inode_data_t; /* * Neither mtime nor atime updates are CRCd by the B-Tree element. * mtime updates have UNDO, atime updates do not. */ #define HAMMER_INODE_CRCSIZE \ offsetof(struct hammer_inode_data, mtime) #define HAMMER_INODE_DATA_VERSION 1 #define HAMMER_OBJID_ROOT 1 /* root inodes # */ #define HAMMER_INODE_BASESYMLEN 24 /* see ext.symlink */ /* * Capability & implementation flags. * * HAMMER_INODE_CAP_DIR_LOCAL_INO - Use inode B-Tree localization * for directory entries. Also see HAMMER_DIR_INODE_LOCALIZATION(). */ #define HAMMER_INODE_CAP_DIRHASH_MASK 0x03 /* directory: hash algorithm */ #define HAMMER_INODE_CAP_DIRHASH_ALG0 0x00 #define HAMMER_INODE_CAP_DIRHASH_ALG1 0x01 #define HAMMER_INODE_CAP_DIRHASH_ALG2 0x02 #define HAMMER_INODE_CAP_DIRHASH_ALG3 0x03 #define HAMMER_INODE_CAP_DIR_LOCAL_INO 0x04 /* use inode localization */ #define HAMMER_DATA_DOALIGN(offset) \ (((offset) + 15) & ~15) #define HAMMER_DATA_DOALIGN_WITH(type, offset) \ (((type)(offset) + 15) & (~(type)15)) /* * A HAMMER directory entry associates a HAMMER filesystem object with a * namespace. It is hooked into a pseudo-filesystem (with its own inode * numbering space) in the filesystem by setting the high 16 bits of the * localization field. The low 16 bits must be 0 and are reserved for * future use. * * Directory entries are indexed with a 128 bit namekey rather then an * offset. A portion of the namekey is an iterator/randomizer to deal * with collisions. * * NOTE: leaf.base.obj_type from the related B-Tree leaf entry holds * the filesystem object type of obj_id, e.g. a den_type equivalent. * It is not stored in hammer_direntry_data. * * NOTE: name field / the filename data reference is NOT terminated with \0. */ typedef struct hammer_direntry_data { int64_t obj_id; /* object being referenced */ uint32_t localization; /* identify pseudo-filesystem */ uint32_t reserved01; char name[16]; /* name (extended) */ } *hammer_direntry_data_t; #define HAMMER_ENTRY_NAME_OFF offsetof(struct hammer_direntry_data, name[0]) #define HAMMER_ENTRY_SIZE(nlen) offsetof(struct hammer_direntry_data, name[nlen]) /* * Symlink data which does not fit in the inode is stored in a separate * FIX type record. */ typedef struct hammer_symlink_data { char name[16]; /* name (extended) */ } *hammer_symlink_data_t; #define HAMMER_SYMLINK_NAME_OFF offsetof(struct hammer_symlink_data, name[0]) /* * The root inode for the primary filesystem and root inode for any * pseudo-fs may be tagged with an optional data structure using * HAMMER_RECTYPE_PFS and localization id. This structure allows * the node to be used as a mirroring master or slave. * * When operating as a slave CD's into the node automatically become read-only * and as-of sync_end_tid. * * When operating as a master the read PFSD info sets sync_end_tid to * the most recently flushed TID. * * sync_low_tid is not yet used but will represent the highest pruning * end-point, after which full history is available. * * We need to pack this structure making it equally sized on both 32-bit and * 64-bit machines as it is part of struct hammer_ioc_mrecord_pfs which is * send over the wire in hammer mirror operations. Only on 64-bit machines * the size of this struct differ when packed or not. This leads us to the * situation where old 64-bit systems (using the non-packed structure), * which were never able to mirror to/from 32-bit systems, are now no longer * able to mirror to/from newer 64-bit systems (using the packed structure). */ struct hammer_pseudofs_data { hammer_tid_t sync_low_tid; /* full history beyond this point */ hammer_tid_t sync_beg_tid; /* earliest tid w/ full history avail */ hammer_tid_t sync_end_tid; /* current synchronizatoin point */ uint64_t sync_beg_ts; /* real-time of last completed sync */ uint64_t sync_end_ts; /* initiation of current sync cycle */ hammer_uuid_t shared_uuid; /* shared uuid (match required) */ hammer_uuid_t unique_uuid; /* unique uuid of this master/slave */ int32_t reserved01; /* reserved for future master_id */ int32_t mirror_flags; /* misc flags */ char label[64]; /* filesystem space label */ char snapshots[64]; /* softlink dir for pruning */ int32_t reserved02; /* was prune_{time,freq} */ int32_t reserved03; /* was reblock_{time,freq} */ int32_t reserved04; /* was snapshot_freq */ int32_t prune_min; /* do not prune recent history */ int32_t prune_max; /* do not retain history beyond here */ int32_t reserved[16]; } __packed; typedef struct hammer_pseudofs_data *hammer_pseudofs_data_t; #define HAMMER_PFSD_SLAVE 0x00000001 #define HAMMER_PFSD_DELETED 0x80000000 #define hammer_is_pfs_slave(pfsd) \ (((pfsd)->mirror_flags & HAMMER_PFSD_SLAVE) != 0) #define hammer_is_pfs_master(pfsd) \ (!hammer_is_pfs_slave(pfsd)) #define hammer_is_pfs_deleted(pfsd) \ (((pfsd)->mirror_flags & HAMMER_PFSD_DELETED) != 0) #define HAMMER_MAX_PFS 65536 #define HAMMER_MAX_PFSID (HAMMER_MAX_PFS - 1) #define HAMMER_ROOT_PFSID 0 /* * Snapshot meta-data { Objid = HAMMER_OBJID_ROOT, Key = tid, rectype = SNAPSHOT }. * * Snapshot records replace the old /snapshots/ methodology. Snapshot * records are mirrored but may be independently managed once they are laid down on * a slave. * * NOTE: The b-tree key is signed, the tid is not, so callers must still sort the * results. * * NOTE: Reserved fields must be zero (as usual) */ typedef struct hammer_snapshot_data { hammer_tid_t tid; /* the snapshot TID itself (== key) */ uint64_t ts; /* real-time when snapshot was made */ uint64_t reserved01; uint64_t reserved02; char label[64]; /* user-supplied description */ uint64_t reserved03[4]; } *hammer_snapshot_data_t; /* * Config meta-data { ObjId = HAMMER_OBJID_ROOT, Key = 0, rectype = CONFIG }. * * Used to store the hammer cleanup config. This data is not mirrored. */ typedef struct hammer_config_data { char text[1024]; } *hammer_config_data_t; /* * Rollup various structures embedded as record data */ typedef union hammer_data_ondisk { struct hammer_direntry_data entry; struct hammer_inode_data inode; struct hammer_symlink_data symlink; struct hammer_pseudofs_data pfsd; struct hammer_snapshot_data snap; struct hammer_config_data config; } *hammer_data_ondisk_t; /* * Ondisk layout of B-Tree related structures */ #if 0 /* Not needed for fstype(8) */ #include "hammer_btree.h" #endif #define HAMMER_DIR_INODE_LOCALIZATION(ino_data) \ (((ino_data)->cap_flags & HAMMER_INODE_CAP_DIR_LOCAL_INO) ? \ HAMMER_LOCALIZE_INODE : \ HAMMER_LOCALIZE_MISC) #endif /* !VFS_HAMMER_DISK_H_ */ diff --git a/usr.sbin/fwcontrol/fwmpegts.c b/usr.sbin/fwcontrol/fwmpegts.c index c744b53a7d46..5a6551c62a8d 100644 --- a/usr.sbin/fwcontrol/fwmpegts.c +++ b/usr.sbin/fwcontrol/fwmpegts.c @@ -1,272 +1,271 @@ /*- * SPDX-License-Identifier: BSD-4-Clause * * Copyright (C) 2005 * Petr Holub, Hidetoshi Shimokawa. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * * This product includes software developed by Hidetoshi Shimokawa. * * 4. Neither the name of the author 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(__FreeBSD__) #include #include #elif defined(__NetBSD__) #include #include #else #warning "You need to add support for your OS" #endif #include "fwmethods.h" #define DEBUG 0 /***************************************************************************** MPEG-2 Transport Stream (MPEG TS) packet format according to IEC 61883: 31 15 0 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -------- | len |tag| channel | tcode | sy | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1394 | header_CRC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -------- |0|0| sid | dbs |fn | qpc |S|RSV| dbc | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ CIP |1|0| fmt | fdf | fdf/syt | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -------- | reserved | cycle_count | cycle_offset | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | N x . . MPEG . MPEG TS payload 188 bytes . . . | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -------- | data_CRC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ N.b. that CRCs are removed by firewire layer! The following fields are fixed for IEEE-1394: tag = 01b tcode = 1010b The length is payload length, i.e. includes CIP header and data size. The following fields are constant for MPEG TS: sph = 1 (denoted as S in CIP header above) dbs = 6 fmt = (1<<5) fdf = reserved In the supported streams we also require qpc = 0 fn = 3 and thus the payload is divided in 8 blocks as follows: +-----+-----+-----+-----+-----+-----+-----+-----+ | db0 | db1 | db2 | db3 | db4 | db5 | db6 | db7 | +-----+-----+-----+-----+-----+-----+-----+-----+ We have several cases of payload distribution based on stream bandwidth (R): 1) R < 1.5 Mbps: any of db0..db7 may be payload, 2) 1.5 < R < 3 Mbps: db0/db1 or db2/db3 or db4/db5 or db6/db7 is payload, 3) 3 < R < 6 Mbps: db0/db1/db2/db3 or db4/db5/db6/db7 is payload, 4) R > 6 Mbps: all db0..db7 contain the payload. Currently, only case (4) is supported in fwmpegts.c Each packet may contain N MPEG TS data blocks with timestamp header, which are (4+188)B long. Experimentally, the N ranges from 0 through 3. *****************************************************************************/ typedef uint8_t mpeg_ts_pld[188]; struct mpeg_pldt { #if BYTE_ORDER == BIG_ENDIAN uint32_t :7, c_count:13, c_offset:12; #else /* BYTE_ORDER != BIG_ENDIAN */ uint32_t c_offset:12, c_count:13, :7; #endif /* BYTE_ORDER == BIG_ENDIAN */ mpeg_ts_pld payload; }; #define NCHUNK 8 #define PSIZE 596 #define NPACKET_R 4096 #define RBUFSIZE (PSIZE * NPACKET_R) void mpegtsrecv(int d, const char *filename, char ich, int count) { struct ciphdr *ciph; struct fw_isochreq isoreq; struct fw_isobufreq bufreq; struct fw_pkt *pkt; struct mpeg_pldt *pld; uint32_t *ptr; int fd, k, len, m, pkt_size, startwr, tlen; char *buf; startwr = 0; if (strcmp(filename, "-") == 0) fd = STDOUT_FILENO; else { fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0660); if (fd == -1) err(EX_NOINPUT, "%s", filename); } buf = malloc(RBUFSIZE); bufreq.rx.nchunk = NCHUNK; bufreq.rx.npacket = NPACKET_R; bufreq.rx.psize = PSIZE; bufreq.tx.nchunk = 0; bufreq.tx.npacket = 0; bufreq.tx.psize = 0; if (ioctl(d, FW_SSTBUF, &bufreq) < 0) err(1, "ioctl"); isoreq.ch = ich & 0x3f; isoreq.tag = (ich >> 6) & 3; if (ioctl(d, FW_SRSTREAM, &isoreq) < 0) err(1, "ioctl"); k = m = 0; while (count <= 0 || k <= count) { len = tlen = read(d, buf, RBUFSIZE); #if DEBUG fprintf(stderr, "Read %d bytes.\n", len); #endif /* DEBUG */ if (len < 0) { if (errno == EAGAIN) { fprintf(stderr, "(EAGAIN) - push 'Play'?\n"); continue; } err(1, "read failed"); } ptr = (uint32_t *) buf; do { pkt = (struct fw_pkt *) ptr; #if DEBUG fprintf(stderr, "\nReading new packet.\n"); fprintf(stderr, "%08x %08x %08x %08x\n", htonl(ptr[0]), htonl(ptr[1]), htonl(ptr[2]), htonl(ptr[3])); #endif /* DEBUG */ /* there is no CRC in the 1394 header */ ciph = (struct ciphdr *)(ptr + 1); /* skip iso header */ if (ciph->fmt != CIP_FMT_MPEG) errx(1, "unknown format 0x%x", ciph->fmt); if (ciph->fn != 3) { errx(1, "unsupported MPEG TS stream, fn=%d (only fn=3 is supported)", ciph->fn); } ptr = (uint32_t *) (ciph + 1); /* skip cip header */ if (pkt->mode.stream.len <= sizeof(struct ciphdr)) { /* no payload */ /* tlen needs to be decremented before end of the loop */ goto next; } #if DEBUG else { fprintf(stderr, "Packet net payload length (IEEE1394 header): %d\n", pkt->mode.stream.len - sizeof(struct ciphdr)); fprintf(stderr, "Data block size (CIP header): %d [q], %d [B]\n", ciph->len, ciph->len * 4); fprintf(stderr, "Data fraction number (CIP header): %d => DBC increments with %d\n", ciph->fn, (1<fn) ); fprintf(stderr, "QCP (CIP header): %d\n", ciph->qpc ); fprintf(stderr, "DBC counter (CIP header): %d\n", ciph->dbc ); fprintf(stderr, "MPEG payload type size: %d\n", sizeof(struct mpeg_pldt)); } #endif /* DEBUG */ /* This is a condition that needs to be satisfied to start writing the data */ if (ciph->dbc % (1<fn) == 0) startwr = 1; /* Read out all the MPEG TS data blocks from current packet */ for (pld = (struct mpeg_pldt *)ptr; (intptr_t)pld < (intptr_t)((char *)ptr + pkt->mode.stream.len - sizeof(struct ciphdr)); pld++) { if (startwr == 1) write(fd, pld->payload, sizeof(pld->payload)); } next: /* CRCs are removed from both header and trailer so that only 4 bytes of 1394 header remains */ pkt_size = pkt->mode.stream.len + 4; ptr = (uint32_t *)((intptr_t)pkt + pkt_size); tlen -= pkt_size; } while (tlen > 0); #if DEBUG fprintf(stderr, "\nReading a data from firewire.\n"); #endif /* DEBUG */ } if (fd != STDOUT_FILENO) close(fd); fprintf(stderr, "\n"); } diff --git a/usr.sbin/inetd/pathnames.h b/usr.sbin/inetd/pathnames.h index d725cad4c624..e9cc994bd08e 100644 --- a/usr.sbin/inetd/pathnames.h +++ b/usr.sbin/inetd/pathnames.h @@ -1,38 +1,37 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include #define _PATH_INETDCONF "/etc/inetd.conf" #define _PATH_INETDPID _PATH_VARRUN "inetd.pid" diff --git a/usr.sbin/keyserv/keyserv.h b/usr.sbin/keyserv/keyserv.h index 07e4ab6efa8e..7eb5b4bae29f 100644 --- a/usr.sbin/keyserv/keyserv.h +++ b/usr.sbin/keyserv/keyserv.h @@ -1,17 +1,16 @@ /* - * $FreeBSD$ */ extern void setmodulus(char *modx); extern keystatus pk_setkey( uid_t, keybuf ); extern keystatus pk_encrypt( uid_t, char *, netobj *, des_block * ); extern keystatus pk_decrypt( uid_t, char *, netobj *, des_block * ); extern keystatus pk_netput( uid_t, key_netstarg * ); extern keystatus pk_netget( uid_t, key_netstarg * ); extern keystatus pk_get_conv_key( uid_t, keybuf, cryptkeyres * ); extern void pk_nodefaultkeys( void ); extern void crypt_prog_1( struct svc_req *, register SVCXPRT * ); extern void load_des( int, char * ); extern int (*_my_crypt)( char *, int, struct desparams * ); diff --git a/usr.sbin/lpr/chkprintcap/skimprintcap.h b/usr.sbin/lpr/chkprintcap/skimprintcap.h index c161234737bf..d7250ff6fff5 100644 --- a/usr.sbin/lpr/chkprintcap/skimprintcap.h +++ b/usr.sbin/lpr/chkprintcap/skimprintcap.h @@ -1,46 +1,45 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * ------+---------+---------+---------+---------+---------+---------+---------* * Copyright (c) 2001 - Garance Alistair Drosehn . * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The views and conclusions contained in the software and documentation * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the FreeBSD Project. * * ------+---------+---------+---------+---------+---------+---------+---------* - * $FreeBSD$ * ------+---------+---------+---------+---------+---------+---------+---------* */ struct skiminfo { int comments; int entries; int fatalerr; /* fatal error, msg already printed */ int lines; int warnings; }; struct skiminfo *skim_printcap(const char *_pcap, int _verbosity); diff --git a/usr.sbin/lpr/common_source/ctlinfo.h b/usr.sbin/lpr/common_source/ctlinfo.h index 87140e5380e9..82d0c92df458 100644 --- a/usr.sbin/lpr/common_source/ctlinfo.h +++ b/usr.sbin/lpr/common_source/ctlinfo.h @@ -1,75 +1,74 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * ------+---------+---------+---------+---------+---------+---------+---------* * Copyright (c) 2001,2011 - Garance Alistair Drosehn . * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The views and conclusions contained in the software and documentation * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the FreeBSD Project. * * ------+---------+---------+---------+---------+---------+---------+---------* - * $FreeBSD$ * ------+---------+---------+---------+---------+---------+---------+---------* */ /* * ctlinfo - This collection of routines will know everything there is to * know about the information inside a control file ('cf*') which is used * to describe a print job in lpr & friends. The eventual goal is that it * will be the ONLY source file to know what's inside these control-files. */ struct cjprivate; /* used internal to ctl* routines */ struct cjobinfo { int cji_dfcount; /* number of data files to print */ int cji_uncount; /* number of unlink-file requests */ char *cji_accthost; /* the host that this job came from, * for accounting purposes (usually * the host where the original 'lpr' * was done) */ char *cji_acctuser; /* userid who should be charged for * this job (usually, the userid which * did the original 'lpr') */ char *cji_class; /* class-name */ char *cji_curqueue; /* printer-queue that this cf-file is * currently sitting in (mainly used * in syslog error messages) */ char *cji_fname; /* filename of the control file */ char *cji_jobname; /* job-name (for banner) */ char *cji_mailto; /* userid to send email to (or null) */ char *cji_headruser; /* "literal" user-name (for banner) or * NULL if no banner-page is wanted */ struct cjprivate *cji_priv; }; #include "lp.cdefs.h" /* A cross-platform version of */ __BEGIN_DECLS void ctl_freeinf(struct cjobinfo *_cjinf); struct cjobinfo *ctl_readcf(const char *_ptrname, const char *_cfname); char *ctl_renametf(const char *_ptrname, const char *_tfname); __END_DECLS diff --git a/usr.sbin/lpr/common_source/lp.cdefs.h b/usr.sbin/lpr/common_source/lp.cdefs.h index 091a84baea54..c3ca409b6a8b 100644 --- a/usr.sbin/lpr/common_source/lp.cdefs.h +++ b/usr.sbin/lpr/common_source/lp.cdefs.h @@ -1,124 +1,123 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * ------+---------+---------+---------+---------+---------+---------+---------* * Copyright (c) 2003,2013 - Garance Alistair Drosehn . * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The views and conclusions contained in the software and documentation * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the FreeBSD Project. * * ------+---------+---------+---------+---------+---------+---------+---------* - * $FreeBSD$ * ------+---------+---------+---------+---------+---------+---------+---------* */ /* * The main goal of this include file is to provide a platform-neutral way * to define some macros that lpr wants from FreeBSD's . This * will simply use the standard when compiled in FreeBSD, but * other OS's may not have /usr/include/sys/cdefs.h (or even if that file * exists, it may not define all the macros that lpr will use). */ #if !defined(_LP_CDEFS_H_) #define _LP_CDEFS_H_ /* * For non-BSD platforms, you can compile lpr with -DHAVE_SYS_CDEFS_H * if should be included. */ #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) # define HAVE_SYS_CDEFS_H #endif #if defined(HAVE_SYS_CDEFS_H) # include #endif /* * FreeBSD added a closefrom() routine in release 8.0. When compiling * `lpr' on other platforms you might want to include bsd-closefrom.c * from the portable-openssh project. */ #ifndef USE_CLOSEFROM # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) # define USE_CLOSEFROM 1 # endif #endif /* The macro USE_CLOSEFROM must be defined with a value of 0 or 1. */ #ifndef USE_CLOSEFROM # define USE_CLOSEFROM 0 #endif /* * __unused is a compiler-specific trick which can be used to avoid * warnings about a variable which is defined but never referenced. * Some lpr files use this, so define a null version if it was not * defined by . */ #if !defined(__unused) # define __unused #endif /* * All the lpr source files will want to reference __FBSDID() to * handle rcs id's. */ #if !defined(__FBSDID) # if defined(lint) || defined(STRIP_FBSDID) # define __FBSDID(s) struct skip_rcsid_struct # elif defined(__IDSTRING) /* NetBSD */ # define __FBSDID(s) __IDSTRING(rcsid,s) # else # define __FBSDID(s) static const char rcsid[] __unused = s # endif #endif /* __FBSDID */ /* * Some lpr include files use __BEGIN_DECLS and __END_DECLS. */ #if !defined(__BEGIN_DECLS) # if defined(__cplusplus) # define __BEGIN_DECLS extern "C" { # define __END_DECLS } # else # define __BEGIN_DECLS # define __END_DECLS # endif #endif /* * __printflike and __printf0like are a compiler-specific tricks to * tell the compiler to check the format-codes in printf-like * routines wrt the args that will be formatted. */ #if !defined(__printflike) # define __printflike(fmtarg, firstvararg) #endif #if !defined(__printf0like) # define __printf0like(fmtarg, firstvararg) #endif #endif /* !_LP_CDEFS_H_ */ diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index bf9262db02a0..6b328427800c 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -1,319 +1,318 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * From: @(#)lp.h 8.2 (Berkeley) 4/28/95 - * $FreeBSD$ */ #include #include #include /* * All this information used to be in global static variables shared * mysteriously by various parts of the lpr/lpd suite. * This structure attempts to centralize all these declarations in the * hope that they can later be made more dynamic. */ enum lpd_filters { LPF_CIFPLOT, LPF_DVI, LPF_GRAPH, LPF_INPUT, LPF_DITROFF, LPF_OUTPUT, LPF_FORTRAN, LPF_TROFF, LPF_RASTER, LPF_COUNT }; /* NB: there is a table in common.c giving the mapping from capability names */ struct printer { char *printer; /* printer name */ int remote; /* true if RM points to a remote host */ int rp_matches_local; /* true if rp has same name as us */ int tof; /* true if we are at top-of-form */ /* ------------------------------------------------------ */ char *acct_file; /* AF: accounting file */ long baud_rate; /* BR: baud rate if lp is a tty */ char *filters[LPF_COUNT]; /* CF, DF, GF, IF, NF, OF, RF, TF, VF */ long conn_timeout; /* CT: TCP connection timeout */ long daemon_user; /* DU: daemon user id -- XXX belongs ???? */ char *form_feed; /* FF: form feed */ long header_last; /* HL: print header last */ char *log_file; /* LF: log file */ char *lock_file; /* LO: lock file */ char *lp; /* LP: device name or network address */ long max_copies; /* MC: maximum number of copies allowed */ long max_blocks; /* MX: maximum number of blocks to copy */ long price100; /* PC: price per 100 units of output */ long page_length; /* PL: page length */ long page_width; /* PW: page width */ long page_pwidth; /* PX: page width in pixels */ long page_plength; /* PY: page length in pixels */ long resend_copies; /* RC: resend copies to remote host */ char *restrict_grp; /* RG: restricted group */ char *remote_host; /* RM: remote machine name */ char *remote_queue; /* RP: remote printer name */ long restricted; /* RS: restricted to those with local accts */ long rw; /* RW: open LP for reading and writing */ long short_banner; /* SB: short banner */ long no_copies; /* SC: suppress multiple copies */ char *spool_dir; /* SD: spool directory */ long no_formfeed; /* SF: suppress FF on each print job */ long no_header; /* SH: suppress header page */ char *stat_recv; /* SR: statistics file, receiving jobs */ char *stat_send; /* SS: statistics file, sending jobs */ char *status_file; /* ST: status file name */ char *trailer; /* TR: trailer string send when Q empties */ char *mode_set; /* MS: mode set, a la stty */ /* variables used by trstat*() to keep statistics on file transfers */ #define JOBNUM_SIZE 8 char jobnum[JOBNUM_SIZE]; long jobdfnum; /* current datafile number within job */ struct timespec tr_start, tr_done; #define TIMESTR_SIZE 40 /* holds result from LPD_TIMESTAMP_PATTERN */ char tr_timestr[TIMESTR_SIZE]; #define DIFFTIME_TS(endTS,startTS) \ ((double)(endTS.tv_sec - startTS.tv_sec) \ + (endTS.tv_nsec - startTS.tv_nsec) * 1.0e-9) }; /* * Lists of user names and job numbers, for the benefit of the structs * defined below. We use TAILQs so that requests don't get mysteriously * reversed in process. */ struct req_user { TAILQ_ENTRY(req_user) ru_link; /* macro glue */ char ru_uname[1]; /* name of user */ }; TAILQ_HEAD(req_user_head, req_user); struct req_file { TAILQ_ENTRY(req_file) rf_link; /* macro glue */ char rf_type; /* type (lowercase cf file letter) of file */ char *rf_prettyname; /* user-visible name of file */ char rf_fname[1]; /* name of file */ }; TAILQ_HEAD(req_file_head, req_file); struct req_jobid { TAILQ_ENTRY(req_jobid) rj_link; /* macro glue */ int rj_job; /* job number */ }; TAILQ_HEAD(req_jobid_head, req_jobid); /* * Encapsulate all the information relevant to a request in the * lpr/lpd protocol. */ enum req_type { REQ_START, REQ_RECVJOB, REQ_LIST, REQ_DELETE }; struct request { enum req_type type; /* what sort of request is this? */ struct printer prtr; /* which printer is it for? */ int remote; /* did request arrive over network? */ char *logname; /* login name of requesting user */ char *authname; /* authenticated identity of requesting user */ char *prettyname; /* ``pretty'' name of requesting user */ int privileged; /* was the request from a privileged user? */ void *authinfo; /* authentication information */ int authentic; /* was the request securely authenticated? */ /* Information for queries and deletes... */ int nusers; /* length of following list... */ struct req_user_head users; /* list of users to query/delete */ int njobids; /* length of following list... */ struct req_jobid_head jobids; /* list of jobids to query/delete */ }; /* * Global definitions for the line printer system. */ extern char line[BUFSIZ]; extern const char *progname; /* program name (lpr, lpq, etc) */ /* * 'local_host' is the name of the machine that lpd (lpr, whatever) * is actually running on. * * 'from_host' will point to the 'host' variable when receiving a job * from a user on the same host, or "somewhere else" when receiving a * job from a remote host. If 'from_host != local_host', then 'from_ip' * is the character representation of the IP address of from_host (note * that string could be an IPv6 address). * * Also note that when 'from_host' is not pointing at 'local_host', the * string it is pointing at may be as long as NI_MAXHOST (which is very * likely to be much longer than MAXHOSTNAMELEN). */ extern char local_host[MAXHOSTNAMELEN]; extern const char *from_host; /* client's machine name */ extern const char *from_ip; /* client machine's IP address */ extern int requ[]; /* job number of spool entries */ extern int requests; /* # of spool requests */ extern char *user[]; /* users to process */ extern int users; /* # of users in user array */ extern char *person; /* name of person doing lprm */ extern u_char family; /* address family */ /* * Structure used for building a sorted list of control files. * The job_processed value can be used by callers of getq(), to keep * track of whatever processing they are doing. */ struct jobqueue { time_t job_time; /* last-mod time of cf-file */ int job_matched; /* used by match_jobspec() */ int job_processed; /* set to zero by getq() */ char job_cfname[MAXNAMLEN+1]; /* control file name */ }; /* lpr/lpd generates readable timestamps for logfiles, etc. Have all those * timestamps be in the same format wrt strftime(). This is ISO 8601 format, * with the addition of an easy-readable day-of-the-week field. Note that * '%T' = '%H:%M:%S', and that '%z' is not available on all platforms. */ #define LPD_TIMESTAMP_PATTERN "%Y-%m-%dT%T%z %a" /* * Codes to indicate which statistic records trstat_write should write. */ typedef enum { TR_SENDING, TR_RECVING, TR_PRINTING } tr_sendrecv; /* * Error codes for our mini printcap library. */ #define PCAPERR_TCLOOP (-3) #define PCAPERR_OSERR (-2) #define PCAPERR_NOTFOUND (-1) #define PCAPERR_SUCCESS 0 #define PCAPERR_TCOPEN 1 /* * File modes for the various status files maintained by lpd. */ #define LOCK_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define LFM_PRINT_DIS (S_IXUSR) #define LFM_QUEUE_DIS (S_IXGRP) #define LFM_RESET_QUE (S_IXOTH) #define STAT_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define LOG_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) #define TEMP_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH) /* * Bit-flags for set_qstate() actions, followed by the return values. */ #define SQS_DISABLEQ 0x01 /* Disable the queuing of new jobs */ #define SQS_STOPP 0x02 /* Stop the printing of jobs */ #define SQS_ENABLEQ 0x10 /* Enable the queuing of new jobs */ #define SQS_STARTP 0x20 /* Start the printing of jobs */ #define SQS_QCHANGED 0x80 /* The queue has changed (new jobs, etc) */ #define SQS_PARMERR -9 /* Invalid parameters from caller */ #define SQS_CREFAIL -3 /* File did not exist, and create failed */ #define SQS_CHGFAIL -2 /* File exists, but unable to change state */ #define SQS_STATFAIL -1 /* Unable to stat() the lock file */ #define SQS_CHGOK 1 /* File existed, and the state was changed */ #define SQS_CREOK 2 /* File did not exist, but was created OK */ #define SQS_SKIPCREOK 3 /* File did not exist, and there was */ /* no need to create it */ /* * Command codes used in the protocol. */ #define CMD_CHECK_QUE '\1' #define CMD_TAKE_THIS '\2' #define CMD_SHOWQ_SHORT '\3' #define CMD_SHOWQ_LONG '\4' #define CMD_RMJOB '\5' /* * seteuid() macros. */ extern uid_t uid, euid; #define PRIV_START { \ if (seteuid(euid) != 0) err(1, "seteuid failed"); \ } #define PRIV_END { \ if (seteuid(uid) != 0) err(1, "seteuid failed"); \ } #include "lp.cdefs.h" /* A cross-platform version of */ __BEGIN_DECLS struct dirent; void blankfill(int _tocol); int calc_jobnum(const char *_cfname, const char **_hostpp); char *checkremote(struct printer *_pp); int chk(char *_file); void closeallfds(int _start); void delay(int _millisec); void displayq(struct printer *_pp, int _format); void dump(const char *_nfile, const char *_datafile, int _copies); void fatal(const struct printer *_pp, const char *_msg, ...) __printflike(2, 3); int firstprinter(struct printer *_pp, int *_error); void free_printer(struct printer *_pp); void free_request(struct request *_rp); int get_line(FILE *_cfp); int getport(const struct printer *_pp, const char *_rhost, int _rport); int getprintcap(const char *_printer, struct printer *_pp); int getq(const struct printer *_pp, struct jobqueue *(*_namelist[])); void header(void); void inform(const struct printer *_pp, char *_cf); void init_printer(struct printer *_pp); void init_request(struct request *_rp); int inlist(char *_uname, char *_cfile); int iscf(const struct dirent *_d); void ldump(const char *_nfile, const char *_datafile, int _copies); void lastprinter(void); int lockchk(struct printer *_pp, char *_slockf); char *lock_file_name(const struct printer *_pp, char *_buf, size_t _len); void lpd_gettime(struct timespec *_tsp, char *_strp, size_t _strsize); int nextprinter(struct printer *_pp, int *_error); const char *pcaperr(int _error); void prank(int _n); void process(const struct printer *_pp, char *_file); void rmjob(const char *_printer); void rmremote(const struct printer *_pp); void setprintcap(char *_newfile); int set_qstate(int _action, const char *_lfname); void show(const char *_nfile, const char *_datafile, int _copies); int startdaemon(const struct printer *_pp); char *status_file_name(const struct printer *_pp, char *_buf, size_t _len); void trstat_init(struct printer *_pp, const char *_fname, int _filenum); void trstat_write(struct printer *_pp, tr_sendrecv _sendrecv, size_t _bytecnt, const char *_userid, const char *_otherhost, const char *_orighost); ssize_t writel(int _strm, ...); __END_DECLS diff --git a/usr.sbin/lpr/common_source/lp.local.h b/usr.sbin/lpr/common_source/lp.local.h index 6cf200c356c7..56439d9274ce 100644 --- a/usr.sbin/lpr/common_source/lp.local.h +++ b/usr.sbin/lpr/common_source/lp.local.h @@ -1,78 +1,77 @@ /*- * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)lp.local.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ /* * Possibly, local parameters to the spooling system */ /* * Defaults for line printer capabilities data base */ #define DEFLP "lp" #define DEFLOCK "lock" #define DEFSTAT "status" #define DEFMX 0 #define DEFMAXCOPIES 0 #define DEFFF "\f" #define DEFWIDTH 132 #define DEFLENGTH 66 #define DEFUID 1 #define DEFTIMEOUT 120 /* * When files are created in the spooling area, they are normally * readable only by their owner and the spooling group. If you * want otherwise, change this mode. */ #define FILMOD 0660 /* * Printer is assumed to support LINELEN (for block chars) * and background character (blank) is a space */ #define LINELEN 132 #define BACKGND ' ' #define HEIGHT 9 /* height of characters */ #define WIDTH 8 /* width of characters */ #define DROP 3 /* offset to drop characters with descenders */ /* * Define TERMCAP if the terminal capabilities are to be used for lpq. */ #define TERMCAP /* * Maximum number of user and job requests for lpq and lprm. */ #define MAXUSERS 50 #define MAXREQUESTS 50 diff --git a/usr.sbin/lpr/common_source/matchjobs.h b/usr.sbin/lpr/common_source/matchjobs.h index 4a3073db9f29..a3c28623e216 100644 --- a/usr.sbin/lpr/common_source/matchjobs.h +++ b/usr.sbin/lpr/common_source/matchjobs.h @@ -1,104 +1,103 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * ------+---------+---------+---------+---------+---------+---------+---------* * Copyright (c) 2002 - Garance Alistair Drosehn . * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The views and conclusions contained in the software and documentation * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the FreeBSD Project * or FreeBSD, Inc. * * ------+---------+---------+---------+---------+---------+---------+---------* - * $FreeBSD$ * ------+---------+---------+---------+---------+---------+---------+---------* */ #include /* * The "matcheduser" field is *only* valid during the call to the * given "doentry()" routine, and is only set if the specification * included a userid. */ struct jobspec { STAILQ_ENTRY(jobspec) nextjs; char *wantedhost; char *wanteduser; char *matcheduser; /* only valid for "doentry()" */ char *fmtoutput; /* set by format_jobspec() */ long startnum; long endrange; int pluralfmt; /* boolean set by format_jobspec() */ uint matchcnt; }; STAILQ_HEAD(jobspec_hdr, jobspec); /* * Format options for format_jobspec. */ #define FMTJS_TERSE 1 /* user:jobrange@host */ #define FMTJS_VERBOSE 2 /* jobrange from user@host */ /* * Options for scanq_jobspec. * * The caller must choose the order that entries should be scanned: * 1) JSORDER: Matched jobs are processed (by calling the "doentry()" * routine) in the order that the user specified those jobs. * 2) QORDER: Matched jobs are processed in the order that the jobs are * listed the queue. This guarantees that the "doentry()" routine * will be called only once per job. * * There is a "job_matched" variable in struct jobqueue, which is used * to make sure that the "doentry()" will only be called once for any * given job in JSORDER processing. The "doentry()" routine can turn * that off, if it does want to be called multiple times when the job * is matched by multiple specifiers. * * The JSORDER processing will also call the "doentry()" routine once * after each scan of the queue, with the jobqueue set to null. This * provides a way for the caller to print out a summary message for * each jobspec that was given. */ #define SCQ_JSORDER 0x0001 /* follow the user-specified order */ #define SCQ_QORDER 0x0002 /* the order of jobs in the queue */ #include "lp.cdefs.h" /* A cross-platform version of */ __BEGIN_DECLS struct jobqueue; typedef int process_jqe(void *_myinfo, struct jobqueue *_jq, struct jobspec *_jspec); void format_jobspec(struct jobspec *_jspec, int _fmt_wanted); void free_jobspec(struct jobspec_hdr *_js_hdr); int scanq_jobspec(int _qitems, struct jobqueue **_squeue, int _sopts, struct jobspec_hdr *_js_hdr, process_jqe _doentry, void *_doentryinfo); int parse_jobspec(char *_jobstr, struct jobspec_hdr *_js_hdr); __END_DECLS diff --git a/usr.sbin/lpr/lpd/extern.h b/usr.sbin/lpr/lpd/extern.h index 5b3d50d26903..513bc1ea19e9 100644 --- a/usr.sbin/lpr/lpd/extern.h +++ b/usr.sbin/lpr/lpd/extern.h @@ -1,48 +1,47 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * From: @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #include "lp.cdefs.h" /* A cross-platform version of */ extern char scnkey[][HEIGHT]; /* in lpdchar.c */ extern int lflag; /* in lpd.c */ struct printer; struct termios; __BEGIN_DECLS void printjob(struct printer *_pp); void startprinting(const char *_printer); void recvjob(const char *_printer); int msearch(char *_str, struct termios *_ip); __END_DECLS diff --git a/usr.sbin/makefs/ffs/ffs_extern.h b/usr.sbin/makefs/ffs/ffs_extern.h index 12ba0b77989c..7b66b1c6ba13 100644 --- a/usr.sbin/makefs/ffs/ffs_extern.h +++ b/usr.sbin/makefs/ffs/ffs_extern.h @@ -1,79 +1,78 @@ /* $NetBSD: ffs_extern.h,v 1.6 2003/08/07 11:25:33 agc Exp $ */ /* From: NetBSD: ffs_extern.h,v 1.19 2001/08/17 02:18:48 lukem Exp */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1991, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 - * $FreeBSD$ */ #include "ffs/buf.h" struct inode; /* * Structure used to pass around logical block paths generated by * ufs_getlbns and used by truncate and bmap code. */ struct indir { daddr_t in_lbn; /* Logical block number. */ int in_off; /* Offset in buffer. */ }; /* ffs.c */ _Noreturn void panic(const char *, ...) __printflike(1, 2); /* ffs_alloc.c */ int ffs_alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *); daddr_t ffs_blkpref_ufs1(struct inode *, daddr_t, int, int32_t *); daddr_t ffs_blkpref_ufs2(struct inode *, daddr_t, int, int64_t *); void ffs_blkfree(struct inode *, daddr_t, long); void ffs_clusteracct(struct fs *, struct cg *, int32_t, int); /* ffs_balloc.c */ int ffs_balloc(struct inode *, off_t, int, struct m_buf **); /* ffs_bswap.c */ void ffs_sb_swap(struct fs*, struct fs *); void ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *); void ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *); void ffs_csum_swap(struct csum *, struct csum *, int); void ffs_cg_swap(struct cg *, struct cg *, struct fs *); /* ffs_subr.c */ void ffs_fragacct(struct fs *, int, int32_t[], int, int); int ffs_isblock(struct fs *, u_char *, int32_t); int ffs_isfreeblock(struct fs *, u_char *, int32_t); void ffs_clrblock(struct fs *, u_char *, int32_t); void ffs_setblock(struct fs *, u_char *, int32_t); /* ufs_bmap.c */ int ufs_getlbns(struct inode *, daddr_t, struct indir *, int *); diff --git a/usr.sbin/makefs/ffs/ufs_inode.h b/usr.sbin/makefs/ffs/ufs_inode.h index e7baff23cbfc..67581dda3359 100644 --- a/usr.sbin/makefs/ffs/ufs_inode.h +++ b/usr.sbin/makefs/ffs/ufs_inode.h @@ -1,99 +1,98 @@ /* $NetBSD: ufs_inode.h,v 1.3 2003/08/07 11:25:34 agc Exp $ */ /* From: NetBSD: inode.h,v 1.27 2001/12/18 10:57:23 fvdl Exp $ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1982, 1989, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. * All or some portions of this file are derived from material licensed * to the University of California by American Telephone and Telegraph * Co. or Unix System Laboratories, Inc. and are reproduced herein with * the permission of UNIX System Laboratories, Inc. * * 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 University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)inode.h 8.9 (Berkeley) 5/14/95 - * $FreeBSD$ */ union dinode { struct ufs1_dinode ffs1_din; struct ufs2_dinode ffs2_din; }; struct inode { ino_t i_number; /* The identity of the inode. */ struct vnode *i_devvp; /* vnode pointer (contains fsopts) */ struct fs *i_fs; /* File system */ union dinode i_din; uint64_t i_size; }; #define i_ffs1_atime i_din.ffs1_din.di_atime #define i_ffs1_atimensec i_din.ffs1_din.di_atimensec #define i_ffs1_blocks i_din.ffs1_din.di_blocks #define i_ffs1_ctime i_din.ffs1_din.di_ctime #define i_ffs1_ctimensec i_din.ffs1_din.di_ctimensec #define i_ffs1_db i_din.ffs1_din.di_db #define i_ffs1_flags i_din.ffs1_din.di_flags #define i_ffs1_gen i_din.ffs1_din.di_gen #define i_ffs11_gid i_din.ffs1_din.di_gid #define i_ffs1_ib i_din.ffs1_din.di_ib #define i_ffs1_mode i_din.ffs1_din.di_mode #define i_ffs1_mtime i_din.ffs1_din.di_mtime #define i_ffs1_mtimensec i_din.ffs1_din.di_mtimensec #define i_ffs1_nlink i_din.ffs1_din.di_nlink #define i_ffs1_rdev i_din.ffs1_din.di_rdev #define i_ffs1_shortlink i_din.ffs1_din.di_shortlink #define i_ffs1_size i_din.ffs1_din.di_size #define i_ffs1_uid i_din.ffs1_din.di_uid #define i_ffs2_atime i_din.ffs2_din.di_atime #define i_ffs2_atimensec i_din.ffs2_din.di_atimensec #define i_ffs2_blocks i_din.ffs2_din.di_blocks #define i_ffs2_ctime i_din.ffs2_din.di_ctime #define i_ffs2_ctimensec i_din.ffs2_din.di_ctimensec #define i_ffs2_birthtime i_din.ffs2_din.di_birthtime #define i_ffs2_birthnsec i_din.ffs2_din.di_birthnsec #define i_ffs2_db i_din.ffs2_din.di_db #define i_ffs2_flags i_din.ffs2_din.di_flags #define i_ffs2_gen i_din.ffs2_din.di_gen #define i_ffs21_gid i_din.ffs2_din.di_gid #define i_ffs2_ib i_din.ffs2_din.di_ib #define i_ffs2_mode i_din.ffs2_din.di_mode #define i_ffs2_mtime i_din.ffs2_din.di_mtime #define i_ffs2_mtimensec i_din.ffs2_din.di_mtimensec #define i_ffs2_nlink i_din.ffs2_din.di_nlink #define i_ffs2_rdev i_din.ffs2_din.di_rdev #define i_ffs2_shortlink i_din.ffs2_din.di_shortlink #define i_ffs2_size i_din.ffs2_din.di_size #define i_ffs2_uid i_din.ffs2_din.di_uid #undef DIP #define DIP(ip, field) \ (((ip)->i_fs->fs_magic == FS_UFS1_MAGIC) ? \ (ip)->i_ffs1_##field : (ip)->i_ffs2_##field) diff --git a/usr.sbin/mountd/pathnames.h b/usr.sbin/mountd/pathnames.h index 0a0c74644cb1..293fe878eb12 100644 --- a/usr.sbin/mountd/pathnames.h +++ b/usr.sbin/mountd/pathnames.h @@ -1,39 +1,38 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 - * $FreeBSD$ */ #include #define _PATH_EXPORTS "/etc/exports" #define _PATH_RMOUNTLIST "/var/db/mountdtab" #define _PATH_MOUNTDPID "/var/run/mountd.pid" #define _PATH_MOUNTDDEBUG "/var/log/mountd.debug" diff --git a/usr.sbin/newsyslog/extern.h b/usr.sbin/newsyslog/extern.h index 54d86b6135d3..8337b314508e 100644 --- a/usr.sbin/newsyslog/extern.h +++ b/usr.sbin/newsyslog/extern.h @@ -1,72 +1,71 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * ------+---------+---------+---------+---------+---------+---------+---------* * Copyright (c) 2003 - Garance Alistair Drosehn . * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The views and conclusions contained in the software and documentation * are those of the authors and should not be interpreted as representing * official policies, either expressed or implied, of the FreeBSD Project. * * ------+---------+---------+---------+---------+---------+---------+---------* - * $FreeBSD$ * ------+---------+---------+---------+---------+---------+---------+---------* */ #include #include #define PTM_PARSE_ISO8601 0x0001 /* Parse ISO-standard format */ #define PTM_PARSE_DWM 0x0002 /* Parse Day-Week-Month format */ #define PTM_PARSE_MATCHDOM 0x0004 /* If the user specifies a day-of-month, * then the result should be a month * which actually has that day. Eg: * the user requests "day 31" when * the present month is February. */ struct ptime_data; /* Some global variables from newsyslog.c which might be of interest */ extern int dbg_at_times; /* cmdline debugging option */ extern int noaction; /* command-line option */ extern int verbose; /* command-line option */ extern struct ptime_data *dbg_timenow; __BEGIN_DECLS struct ptime_data *ptime_init(const struct ptime_data *_optsrc); int ptime_adjust4dst(struct ptime_data *_ptime, const struct ptime_data *_dstsrc); int ptime_free(struct ptime_data *_ptime); int ptime_relparse(struct ptime_data *_ptime, int _parseopts, time_t _basetime, const char *_str); const char *ptimeget_ctime(const struct ptime_data *_ptime); char *ptimeget_ctime_rfc5424(const struct ptime_data *_ptime, char *timebuf, size_t bufsize); double ptimeget_diff(const struct ptime_data *_minuend, const struct ptime_data *_subtrahend); time_t ptimeget_secs(const struct ptime_data *_ptime); int ptimeset_nxtime(struct ptime_data *_ptime); int ptimeset_time(struct ptime_data *_ptime, time_t _secs); __END_DECLS diff --git a/usr.sbin/ntp/libntpevent/event2/event-config.h b/usr.sbin/ntp/libntpevent/event2/event-config.h index 920b7bada257..e636a9fba1d5 100644 --- a/usr.sbin/ntp/libntpevent/event2/event-config.h +++ b/usr.sbin/ntp/libntpevent/event2/event-config.h @@ -1,648 +1,647 @@ /* event2/event-config.h -* $FreeBSD$ * * This file was generated by autoconf when libevent was built, and post- * processed by Libevent so that its macros would have a uniform prefix. * * DO NOT EDIT THIS FILE. * * Do not rely on macros in this file existing in later versions. */ #ifndef EVENT2_EVENT_CONFIG_H_INCLUDED_ #define EVENT2_EVENT_CONFIG_H_INCLUDED_ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define if libevent should build without support for a debug mode */ /* #undef EVENT__DISABLE_DEBUG_MODE */ /* Define if libevent should not allow replacing the mm functions */ /* #undef EVENT__DISABLE_MM_REPLACEMENT */ /* Define if libevent should not be compiled with thread support */ /* #undef EVENT__DISABLE_THREAD_SUPPORT */ /* Define to 1 if you have the `accept4' function. */ #define EVENT__HAVE_ACCEPT4 1 /* Define to 1 if you have the `arc4random' function. */ #define EVENT__HAVE_ARC4RANDOM 1 /* Define to 1 if you have the `arc4random_buf' function. */ #define EVENT__HAVE_ARC4RANDOM_BUF 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `clock_gettime' function. */ #define EVENT__HAVE_CLOCK_GETTIME 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_CTHREADS_H */ /* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you don't. */ #define EVENT__HAVE_DECL_CTL_KERN 1 /* Define to 1 if you have the declaration of `KERN_ARND', and to 0 if you don't. */ #define EVENT__HAVE_DECL_KERN_ARND 1 /* Define to 1 if you have the declaration of `KERN_RANDOM', and to 0 if you don't. */ #define EVENT__HAVE_DECL_KERN_RANDOM 0 /* Define to 1 if you have the declaration of `RANDOM_UUID', and to 0 if you don't. */ #define EVENT__HAVE_DECL_RANDOM_UUID 0 /* Define if /dev/poll is available */ /* #undef EVENT__HAVE_DEVPOLL */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_DLFCN_H 1 /* Define if your system supports the epoll system calls */ /* #undef EVENT__HAVE_EPOLL */ /* Define to 1 if you have the `epoll_create1' function. */ /* #undef EVENT__HAVE_EPOLL_CREATE1 */ /* Define to 1 if you have the `epoll_ctl' function. */ /* #undef EVENT__HAVE_EPOLL_CTL */ /* Define to 1 if you have the `eventfd' function. */ /* #undef EVENT__HAVE_EVENTFD */ /* Define if your system supports event ports */ /* #undef EVENT__HAVE_EVENT_PORTS */ /* Define to 1 if you have the `fcntl' function. */ #define EVENT__HAVE_FCNTL 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_FCNTL_H 1 /* Define to 1 if the system has the type `fd_mask'. */ #define EVENT__HAVE_FD_MASK 1 /* Do we have getaddrinfo()? */ #define EVENT__HAVE_GETADDRINFO 1 /* Define to 1 if you have the `getegid' function. */ #define EVENT__HAVE_GETEGID 1 /* Define to 1 if you have the `geteuid' function. */ #define EVENT__HAVE_GETEUID 1 /* Define this if you have any gethostbyname_r() */ /* #undef EVENT__HAVE_GETHOSTBYNAME_R */ /* Define this if gethostbyname_r takes 3 arguments */ /* #undef EVENT__HAVE_GETHOSTBYNAME_R_3_ARG */ /* Define this if gethostbyname_r takes 5 arguments */ /* #undef EVENT__HAVE_GETHOSTBYNAME_R_5_ARG */ /* Define this if gethostbyname_r takes 6 arguments */ /* #undef EVENT__HAVE_GETHOSTBYNAME_R_6_ARG */ /* Define to 1 if you have the `getifaddrs' function. */ #define EVENT__HAVE_GETIFADDRS 1 /* Define to 1 if you have the `getnameinfo' function. */ #define EVENT__HAVE_GETNAMEINFO 1 /* Define to 1 if you have the `getprotobynumber' function. */ #define EVENT__HAVE_GETPROTOBYNUMBER 1 /* Define to 1 if you have the `getservbyname' function. */ /* #undef EVENT__HAVE_GETSERVBYNAME */ /* Define to 1 if you have the `gettimeofday' function. */ #define EVENT__HAVE_GETTIMEOFDAY 1 /* if you have GNU Pth */ /* #undef EVENT__HAVE_GNU_PTH */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_IFADDRS_H 1 /* Define to 1 if you have the `inet_ntop' function. */ #define EVENT__HAVE_INET_NTOP 1 /* Define to 1 if you have the `inet_pton' function. */ #define EVENT__HAVE_INET_PTON 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_INTTYPES_H 1 /* Define to 1 if you have the `issetugid' function. */ #define EVENT__HAVE_ISSETUGID 1 /* Define to 1 if you have the `kqueue' function. */ #define EVENT__HAVE_KQUEUE 1 /* Define if the system has zlib */ #define EVENT__HAVE_LIBZ 1 /* if you have LinuxThreads */ /* #undef EVENT__HAVE_LINUX_THREADS */ /* if you have SunOS LWP package */ /* #undef EVENT__HAVE_LWP */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_LWP_LWP_H */ /* Define to 1 if you have the `mach_absolute_time' function. */ /* #undef EVENT__HAVE_MACH_ABSOLUTE_TIME */ /* define if you have Mach Cthreads */ /* #undef EVENT__HAVE_MACH_CTHREADS */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_MACH_CTHREADS_H */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_MACH_MACH_TIME_H */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_MEMORY_H 1 /* Define to 1 if you have the `mmap' function. */ #define EVENT__HAVE_MMAP 1 /* Define to 1 if you have the `nanosleep' function. */ #define EVENT__HAVE_NANOSLEEP 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_NETDB_H 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_NETINET_IN6_H */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_NETINET_IN_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_NETINET_TCP_H 1 /* if you have NT Event Log */ /* #undef EVENT__HAVE_NT_EVENT_LOG */ /* if you have NT Service Manager */ /* #undef EVENT__HAVE_NT_SERVICE_MANAGER */ /* if you have NT Threads */ /* #undef EVENT__HAVE_NT_THREADS */ /* Define if the system has openssl */ /* #undef EVENT__HAVE_OPENSSL */ /* Define to 1 if you have the `pipe' function. */ #define EVENT__HAVE_PIPE 1 /* Define to 1 if you have the `pipe2' function. */ #define EVENT__HAVE_PIPE2 1 /* Define to 1 if you have the `poll' function. */ #define EVENT__HAVE_POLL 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_POLL_H 1 /* Define to 1 if you have the `port_create' function. */ /* #undef EVENT__HAVE_PORT_CREATE */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_PORT_H */ /* Define if you have POSIX threads libraries and header files. */ /* #undef EVENT__HAVE_PTHREAD */ /* define to pthreads API spec revision */ #define EVENT__HAVE_PTHREADS 10 /* define if you have pthread_detach function */ #define EVENT__HAVE_PTHREAD_DETACH 1 /* Define to 1 if you have the `pthread_getconcurrency' function. */ #define EVENT__HAVE_PTHREAD_GETCONCURRENCY 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_PTHREAD_H 1 /* Define to 1 if you have the `pthread_kill' function. */ #define EVENT__HAVE_PTHREAD_KILL 1 /* Define to 1 if you have the `pthread_kill_other_threads_np' function. */ /* #undef EVENT__HAVE_PTHREAD_KILL_OTHER_THREADS_NP */ /* define if you have pthread_rwlock_destroy function */ #define EVENT__HAVE_PTHREAD_RWLOCK_DESTROY 1 /* Define to 1 if you have the `pthread_setconcurrency' function. */ #define EVENT__HAVE_PTHREAD_SETCONCURRENCY 1 /* Define to 1 if you have the `pthread_yield' function. */ #define EVENT__HAVE_PTHREAD_YIELD 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_PTH_H */ /* Define to 1 if you have the `putenv' function. */ #define EVENT__HAVE_PUTENV 1 /* Define to 1 if the system has the type `sa_family_t'. */ #define EVENT__HAVE_SA_FAMILY_T 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SCHED_H 1 /* Define to 1 if you have the `sched_yield' function. */ #define EVENT__HAVE_SCHED_YIELD 1 /* Define to 1 if you have the `select' function. */ #define EVENT__HAVE_SELECT 1 /* Define to 1 if you have the `sendfile' function. */ #define EVENT__HAVE_SENDFILE 1 /* Define to 1 if you have the `setenv' function. */ #define EVENT__HAVE_SETENV 1 /* Define if F_SETFD is defined in */ #define EVENT__HAVE_SETFD 1 /* Define to 1 if you have the `setrlimit' function. */ #define EVENT__HAVE_SETRLIMIT 1 /* Define to 1 if you have the `sigaction' function. */ #define EVENT__HAVE_SIGACTION 1 /* Define to 1 if you have the `signal' function. */ #define EVENT__HAVE_SIGNAL 1 /* Define to 1 if you have the `splice' function. */ /* #undef EVENT__HAVE_SPLICE */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STDARG_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STDDEF_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_STRING_H 1 /* Define to 1 if you have the `strlcpy' function. */ #define EVENT__HAVE_STRLCPY 1 /* Define to 1 if you have the `strsep' function. */ #define EVENT__HAVE_STRSEP 1 /* Define to 1 if you have the `strtok_r' function. */ #define EVENT__HAVE_STRTOK_R 1 /* Define to 1 if you have the `strtoll' function. */ #define EVENT__HAVE_STRTOLL 1 /* Define to 1 if the system has the type `struct addrinfo'. */ #define EVENT__HAVE_STRUCT_ADDRINFO 1 /* Define to 1 if the system has the type `struct in6_addr'. */ #define EVENT__HAVE_STRUCT_IN6_ADDR 1 /* Define to 1 if `s6_addr16' is a member of `struct in6_addr'. */ /* #undef EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR16 */ /* Define to 1 if `s6_addr32' is a member of `struct in6_addr'. */ /* #undef EVENT__HAVE_STRUCT_IN6_ADDR_S6_ADDR32 */ /* Define to 1 if the system has the type `struct sockaddr_in6'. */ #define EVENT__HAVE_STRUCT_SOCKADDR_IN6 1 /* Define to 1 if `sin6_len' is a member of `struct sockaddr_in6'. */ #define EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN 1 /* Define to 1 if `sin_len' is a member of `struct sockaddr_in'. */ #define EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 /* Define to 1 if the system has the type `struct sockaddr_storage'. */ #define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if `ss_family' is a member of `struct sockaddr_storage'. */ #define EVENT__HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1 /* Define to 1 if `__ss_family' is a member of `struct sockaddr_storage'. */ /* #undef EVENT__HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */ /* Define to 1 if the system has the type `struct so_linger'. */ /* #undef EVENT__HAVE_STRUCT_SO_LINGER */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYNCH_H */ /* Define to 1 if you have the `sysctl' function. */ #define EVENT__HAVE_SYSCTL 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYS_DEVPOLL_H */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYS_EPOLL_H */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYS_EVENTFD_H */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_EVENT_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_MMAN_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_QUEUE_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYS_SENDFILE_H */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_SYSCTL_H 1 /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_SYS_TIMERFD_H */ /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_UIO_H 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_SYS_WAIT_H 1 /* Define if TAILQ_FOREACH is defined in */ #define EVENT__HAVE_TAILQFOREACH 1 /* if you have Solaris LWP (thr) package */ /* #undef EVENT__HAVE_THR */ /* Define to 1 if you have the header file. */ /* #undef EVENT__HAVE_THREAD_H */ /* Define to 1 if you have the `thr_getconcurrency' function. */ /* #undef EVENT__HAVE_THR_GETCONCURRENCY */ /* Define to 1 if you have the `thr_setconcurrency' function. */ /* #undef EVENT__HAVE_THR_SETCONCURRENCY */ /* Define to 1 if you have the `thr_yield' function. */ /* #undef EVENT__HAVE_THR_YIELD */ /* Define if timeradd is defined in */ #define EVENT__HAVE_TIMERADD 1 /* Define if timerclear is defined in */ #define EVENT__HAVE_TIMERCLEAR 1 /* Define if timercmp is defined in */ #define EVENT__HAVE_TIMERCMP 1 /* Define to 1 if you have the `timerfd_create' function. */ /* #undef EVENT__HAVE_TIMERFD_CREATE */ /* Define if timerisset is defined in */ #define EVENT__HAVE_TIMERISSET 1 /* Define to 1 if the system has the type `uint16_t'. */ #define EVENT__HAVE_UINT16_T 1 /* Define to 1 if the system has the type `uint32_t'. */ #define EVENT__HAVE_UINT32_T 1 /* Define to 1 if the system has the type `uint64_t'. */ #define EVENT__HAVE_UINT64_T 1 /* Define to 1 if the system has the type `uint8_t'. */ #define EVENT__HAVE_UINT8_T 1 /* Define to 1 if the system has the type `uintptr_t'. */ #define EVENT__HAVE_UINTPTR_T 1 /* Define to 1 if you have the `umask' function. */ #define EVENT__HAVE_UMASK 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_UNISTD_H 1 /* Define to 1 if you have the `unsetenv' function. */ #define EVENT__HAVE_UNSETENV 1 /* Define to 1 if you have the `usleep' function. */ #define EVENT__HAVE_USLEEP 1 /* Define to 1 if you have the `vasprintf' function. */ #define EVENT__HAVE_VASPRINTF 1 /* Define if kqueue works correctly with pipes */ #define EVENT__HAVE_WORKING_KQUEUE 1 /* define if select implicitly yields */ #define EVENT__HAVE_YIELDING_SELECT 1 /* Define to 1 if you have the header file. */ #define EVENT__HAVE_ZLIB_H 1 /* define to 1 if library is thread safe */ #define EVENT__LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1 /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define EVENT__LT_OBJDIR ".libs/" /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* #undef EVENT__NO_MINUS_C_MINUS_O */ /* define if you have (or want) no threads */ /* #undef EVENT__NO_THREADS */ /* Numeric representation of the version */ #define EVENT__NUMERIC_VERSION 0x02010301 /* Name of package */ #define EVENT__PACKAGE "libevent" /* Define to the address where bug reports for this package should be sent. */ #define EVENT__PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define EVENT__PACKAGE_NAME "libevent" /* Define to the full name and version of this package. */ #define EVENT__PACKAGE_STRING "libevent 2.1.3-alpha-dev" /* Define to the one symbol short name of this package. */ #define EVENT__PACKAGE_TARNAME "libevent" /* Define to the home page for this package. */ #define EVENT__PACKAGE_URL "" /* Define to the version of this package. */ #define EVENT__PACKAGE_VERSION "2.1.3-alpha-dev" /* enable thread safety */ #define EVENT__REENTRANT 1 /* define if sched_yield yields the entire process */ /* #undef EVENT__REPLACE_BROKEN_YIELD */ /* The size of `int', as computed by sizeof. */ #define EVENT__SIZEOF_INT 4 /* The size of `long', as computed by sizeof. */ #define EVENT__SIZEOF_LONG 8 /* The size of `long long', as computed by sizeof. */ #define EVENT__SIZEOF_LONG_LONG 8 /* The size of `off_t', as computed by sizeof. */ #define EVENT__SIZEOF_OFF_T 8 /* The size of `pthread_t', as computed by sizeof. */ #define EVENT__SIZEOF_PTHREAD_T 8 /* The size of `short', as computed by sizeof. */ #define EVENT__SIZEOF_SHORT 2 /* The size of `size_t', as computed by sizeof. */ #define EVENT__SIZEOF_SIZE_T 8 /* The size of `void *', as computed by sizeof. */ #define EVENT__SIZEOF_VOID_P 8 /* Define to 1 if you have the ANSI C header files. */ #define EVENT__STDC_HEADERS 1 /* enable thread safety */ #define EVENT__THREADSAFE 1 /* enable thread safety */ #define EVENT__THREAD_SAFE 1 /* Define to 1 if you can safely include both and . */ #define EVENT__TIME_WITH_SYS_TIME 1 /* Version number of package */ #define EVENT__VERSION "2.1.3-alpha-dev" /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef EVENT___FILE_OFFSET_BITS */ /* Define for large files, on AIX-style hosts. */ /* #undef EVENT___LARGE_FILES */ /* Define to 1 if on MINIX. */ /* #undef EVENT___MINIX */ /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ /* #undef EVENT___POSIX_1_SOURCE */ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef EVENT___POSIX_SOURCE */ /* enable thread safety */ #define EVENT___REENTRANT 1 /* enable thread safety */ #define EVENT___SGI_MP_SOURCE 1 /* enable thread safety */ #define EVENT___THREADSAFE 1 /* enable thread safety */ #define EVENT___THREAD_SAFE 1 /* Define to 500 only on HP-UX. */ /* #undef EVENT___XOPEN_SOURCE */ /* Enable extensions on AIX 3, Interix. */ #ifndef EVENT___ALL_SOURCE # define EVENT___ALL_SOURCE 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef EVENT___GNU_SOURCE # define EVENT___GNU_SOURCE 1 #endif /* Enable threading extensions on Solaris. */ #ifndef EVENT___POSIX_PTHREAD_SEMANTICS # define EVENT___POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions on HP NonStop. */ #ifndef EVENT___TANDEM_SOURCE # define EVENT___TANDEM_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef EVENT____EXTENSIONS__ # define EVENT____EXTENSIONS__ 1 #endif /* Define to appropriate substitue if compiler doesnt have __func__ */ /* #undef EVENT____func__ */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef EVENT__const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef EVENT____cplusplus /* #undef EVENT__inline */ #endif /* Define to `int' if does not define. */ /* #undef EVENT__pid_t */ /* Define to `unsigned int' if does not define. */ /* #undef EVENT__size_t */ /* Define to unsigned int if you dont have it */ /* #undef EVENT__socklen_t */ /* Define to `int' if does not define. */ /* #undef EVENT__ssize_t */ #endif /* event2/event-config.h */ diff --git a/usr.sbin/rpc.ypupdated/ypupdated_extern.h b/usr.sbin/rpc.ypupdated/ypupdated_extern.h index 2cacb9511e1f..90968df36748 100644 --- a/usr.sbin/rpc.ypupdated/ypupdated_extern.h +++ b/usr.sbin/rpc.ypupdated/ypupdated_extern.h @@ -1,33 +1,32 @@ /* - * $FreeBSD$ */ #include #define YPOP_CHANGE 1 /* change, do not add */ #define YPOP_INSERT 2 /* add, do not change */ #define YPOP_DELETE 3 /* delete this entry */ #define YPOP_STORE 4 /* add, or change */ #define ERR_ACCESS 1 #define ERR_MALLOC 2 #define ERR_READ 3 #define ERR_WRITE 4 #define ERR_DBASE 5 #define ERR_KEY 6 #ifndef YPLIBDIR #define YPLIBDIR "/usr/libexec/" #endif #ifndef MAP_UPPATE #define MAP_UPDATE "ypupdate" #endif #define MAP_UPDATE_PATH YPLIBDIR MAP_UPDATE extern int children; extern void ypu_prog_1(struct svc_req *, register SVCXPRT *); extern int localupdate(char *, char *, u_int, u_int, char *, u_int, char *); extern int ypmap_update(char *, char *, u_int, u_int, char *, u_int, char *); extern int yp_del_record(DB *, DBT *); diff --git a/usr.sbin/rpcbind/rpcb_stat.c b/usr.sbin/rpcbind/rpcb_stat.c index 361ae4c7f2bb..296fb8206c21 100644 --- a/usr.sbin/rpcbind/rpcb_stat.c +++ b/usr.sbin/rpcbind/rpcb_stat.c @@ -1,206 +1,205 @@ /* * $NetBSD: rpcb_stat.c,v 1.2 2000/07/04 20:27:40 matt Exp $ - * $FreeBSD$ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. */ /* #pragma ident "@(#)rpcb_stat.c 1.7 94/04/25 SMI" */ /* * rpcb_stat.c * Allows for gathering of statistics * * Copyright (c) 1990 by Sun Microsystems, Inc. */ #include #include #include #include #ifdef PORTMAP #include #endif #include #include #include "rpcbind.h" static rpcb_stat_byvers inf; void rpcbs_init(void) { } void rpcbs_procinfo(rpcvers_t rtype, rpcproc_t proc) { switch (rtype + 2) { #ifdef PORTMAP case PMAPVERS: /* version 2 */ if (proc > rpcb_highproc_2) return; break; #endif case RPCBVERS: /* version 3 */ if (proc > rpcb_highproc_3) return; break; case RPCBVERS4: /* version 4 */ if (proc > rpcb_highproc_4) return; break; default: return; } inf[rtype].info[proc]++; return; } void rpcbs_set(rpcvers_t rtype, bool_t success) { if ((rtype >= RPCBVERS_STAT) || (success == FALSE)) return; inf[rtype].setinfo++; return; } void rpcbs_unset(rpcvers_t rtype, bool_t success) { if ((rtype >= RPCBVERS_STAT) || (success == FALSE)) return; inf[rtype].unsetinfo++; return; } void rpcbs_getaddr(rpcvers_t rtype, rpcprog_t prog, rpcvers_t vers, char *netid, char *uaddr) { rpcbs_addrlist *al; struct netconfig *nconf; if (rtype >= RPCBVERS_STAT) return; for (al = inf[rtype].addrinfo; al; al = al->next) { if(al->netid == NULL) return; if ((al->prog == prog) && (al->vers == vers) && (strcmp(al->netid, netid) == 0)) { if ((uaddr == NULL) || (uaddr[0] == 0)) al->failure++; else al->success++; return; } } nconf = rpcbind_get_conf(netid); if (nconf == NULL) { return; } al = (rpcbs_addrlist *) malloc(sizeof (rpcbs_addrlist)); if (al == NULL) { return; } al->prog = prog; al->vers = vers; al->netid = nconf->nc_netid; if ((uaddr == NULL) || (uaddr[0] == 0)) { al->failure = 1; al->success = 0; } else { al->failure = 0; al->success = 1; } al->next = inf[rtype].addrinfo; inf[rtype].addrinfo = al; } void rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t rpcbproc, rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, char *netid, rpcblist_ptr rbl) { rpcbs_rmtcalllist *rl; struct netconfig *nconf; if (rtype >= RPCBVERS_STAT) return; for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) { if(rl->netid == NULL) return; if ((rl->prog == prog) && (rl->vers == vers) && (rl->proc == proc) && (strcmp(rl->netid, netid) == 0)) { if ((rbl == NULL) || (rbl->rpcb_map.r_vers != vers)) rl->failure++; else rl->success++; if (rpcbproc == RPCBPROC_INDIRECT) rl->indirect++; return; } } nconf = rpcbind_get_conf(netid); if (nconf == NULL) { return; } rl = (rpcbs_rmtcalllist *) malloc(sizeof (rpcbs_rmtcalllist)); if (rl == NULL) { return; } rl->prog = prog; rl->vers = vers; rl->proc = proc; rl->netid = nconf->nc_netid; if ((rbl == NULL) || (rbl->rpcb_map.r_vers != vers)) { rl->failure = 1; rl->success = 0; } else { rl->failure = 0; rl->success = 1; } rl->indirect = 1; rl->next = inf[rtype].rmtinfo; inf[rtype].rmtinfo = rl; return; } void * rpcbproc_getstat(void *arg __unused, struct svc_req *req __unused, SVCXPRT *xprt __unused, rpcvers_t versnum __unused) { return (void *)&inf; } diff --git a/usr.sbin/rpcbind/rpcb_svc_4.c b/usr.sbin/rpcbind/rpcb_svc_4.c index ac96f3c39f8f..49ef3be6dab2 100644 --- a/usr.sbin/rpcbind/rpcb_svc_4.c +++ b/usr.sbin/rpcbind/rpcb_svc_4.c @@ -1,453 +1,452 @@ /* * $NetBSD: rpcb_svc_4.c,v 1.1 2000/06/02 23:15:41 fvdl Exp $ - * $FreeBSD$ */ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. */ /* * Copyright (c) 1986 - 1991 by Sun Microsystems, Inc. */ /* #ident "@(#)rpcb_svc_4.c 1.8 93/07/05 SMI" */ /* * rpcb_svc_4.c * The server procedure for the version 4 rpcbind. * */ #include #include #include #include #include #include #include #include "rpcbind.h" static void *rpcbproc_getaddr_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t); static void *rpcbproc_getversaddr_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t); static void *rpcbproc_getaddrlist_4_local (void *, struct svc_req *, SVCXPRT *, rpcvers_t); static void free_rpcb_entry_list(rpcb_entry_list_ptr *); static void *rpcbproc_dump_4_local(void *, struct svc_req *, SVCXPRT *, rpcvers_t); /* * Called by svc_getreqset. There is a separate server handle for * every transport that it waits on. */ void rpcb_service_4(struct svc_req *rqstp, SVCXPRT *transp) { union { rpcb rpcbproc_set_4_arg; rpcb rpcbproc_unset_4_arg; rpcb rpcbproc_getaddr_4_local_arg; char *rpcbproc_uaddr2taddr_4_arg; struct netbuf rpcbproc_taddr2uaddr_4_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; void *(*local)(void *, struct svc_req *, SVCXPRT *, rpcvers_t); rpcbs_procinfo(RPCBVERS_4_STAT, rqstp->rq_proc); switch (rqstp->rq_proc) { case NULLPROC: /* * Null proc call */ #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_NULL\n"); #endif check_access(transp, rqstp->rq_proc, NULL, RPCBVERS4); (void) svc_sendreply(transp, (xdrproc_t) xdr_void, (char *)NULL); return; case RPCBPROC_SET: /* * Check to see whether the message came from * loopback transports (for security reasons) */ xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_bool; local = rpcbproc_set_com; break; case RPCBPROC_UNSET: /* * Check to see whether the message came from * loopback transports (for security reasons) */ xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_bool; local = rpcbproc_unset_com; break; case RPCBPROC_GETADDR: xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_getaddr_4_local; break; case RPCBPROC_GETVERSADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETVERSADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_getversaddr_4_local; break; case RPCBPROC_DUMP: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_DUMP\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_rpcblist_ptr; local = rpcbproc_dump_4_local; break; case RPCBPROC_INDIRECT: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_INDIRECT\n"); #endif rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4); return; /* case RPCBPROC_CALLIT: */ case RPCBPROC_BCAST: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_BCAST\n"); #endif rpcbproc_callit_com(rqstp, transp, rqstp->rq_proc, RPCBVERS4); return; case RPCBPROC_GETTIME: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETTIME\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_u_long; local = rpcbproc_gettime_com; break; case RPCBPROC_UADDR2TADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_UADDR2TADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_wrapstring; xdr_result = (xdrproc_t)xdr_netbuf; local = rpcbproc_uaddr2taddr_com; break; case RPCBPROC_TADDR2UADDR: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_TADDR2UADDR\n"); #endif xdr_argument = (xdrproc_t)xdr_netbuf; xdr_result = (xdrproc_t)xdr_wrapstring; local = rpcbproc_taddr2uaddr_com; break; case RPCBPROC_GETADDRLIST: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETADDRLIST\n"); #endif xdr_argument = (xdrproc_t)xdr_rpcb; xdr_result = (xdrproc_t)xdr_rpcb_entry_list_ptr; local = rpcbproc_getaddrlist_4_local; break; case RPCBPROC_GETSTAT: #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "RPCBPROC_GETSTAT\n"); #endif xdr_argument = (xdrproc_t)xdr_void; xdr_result = (xdrproc_t)xdr_rpcb_stat_byvers; local = rpcbproc_getstat; break; default: svcerr_noproc(transp); return; } memset((char *)&argument, 0, sizeof (argument)); if (!svc_getargs(transp, (xdrproc_t) xdr_argument, (char *)&argument)) { svcerr_decode(transp); if (debugging) (void) fprintf(stderr, "rpcbind: could not decode\n"); return; } if (!check_access(transp, rqstp->rq_proc, &argument, RPCBVERS4)) { svcerr_weakauth(transp); goto done; } result = (*local)(&argument, rqstp, transp, RPCBVERS4); if (result != NULL && !svc_sendreply(transp, (xdrproc_t) xdr_result, result)) { svcerr_systemerr(transp); if (debugging) { (void) fprintf(stderr, "rpcbind: svc_sendreply\n"); if (doabort) { rpcbind_abort(); } } } done: if (!svc_freeargs(transp, (xdrproc_t) xdr_argument, (char *)&argument)) { if (debugging) { (void) fprintf(stderr, "unable to free arguments\n"); if (doabort) { rpcbind_abort(); } } } } /* * Lookup the mapping for a program, version and return its * address. Assuming that the caller wants the address of the * server running on the transport on which the request came. * Even if a service with a different version number is available, * it will return that address. The client should check with an * clnt_call to verify whether the service is the one that is desired. * We also try to resolve the universal address in terms of * address of the caller. */ /* ARGSUSED */ static void * rpcbproc_getaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp, rpcvers_t rpcbversnum __unused) { RPCB *regp = (RPCB *)arg; #ifdef RPCBIND_DEBUG if (debugging) { char *uaddr; uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), svc_getrpccaller(transp)); fprintf(stderr, "RPCB_GETADDR req for (%lu, %lu, %s) from %s: ", (unsigned long)regp->r_prog, (unsigned long)regp->r_vers, regp->r_netid, uaddr); free(uaddr); } #endif return (rpcbproc_getaddr_com(regp, rqstp, transp, RPCBVERS4, RPCB_ALLVERS)); } /* * Lookup the mapping for a program, version and return its * address. Assuming that the caller wants the address of the * server running on the transport on which the request came. * * We also try to resolve the universal address in terms of * address of the caller. */ /* ARGSUSED */ static void * rpcbproc_getversaddr_4_local(void *arg, struct svc_req *rqstp, SVCXPRT *transp, rpcvers_t versnum __unused) { RPCB *regp = (RPCB *)arg; #ifdef RPCBIND_DEBUG if (debugging) { char *uaddr; uaddr = taddr2uaddr(rpcbind_get_conf(transp->xp_netid), svc_getrpccaller(transp)); fprintf(stderr, "RPCB_GETVERSADDR rqst for (%lu, %lu, %s)" " from %s : ", (unsigned long)regp->r_prog, (unsigned long)regp->r_vers, regp->r_netid, uaddr); free(uaddr); } #endif return (rpcbproc_getaddr_com(regp, rqstp, transp, RPCBVERS4, RPCB_ONEVERS)); } /* * Lookup the mapping for a program, version and return the * addresses for all transports in the current transport family. * We return a merged address. */ /* ARGSUSED */ static void * rpcbproc_getaddrlist_4_local(void *arg, struct svc_req *rqstp __unused, SVCXPRT *transp, rpcvers_t versnum __unused) { RPCB *regp = (RPCB *)arg; static rpcb_entry_list_ptr rlist; register rpcblist_ptr rbl; rpcb_entry_list_ptr rp, tail; rpcprog_t prog; rpcvers_t vers; rpcb_entry *a; struct netconfig *nconf; struct netconfig *reg_nconf; char *saddr, *maddr = NULL; free_rpcb_entry_list(&rlist); tail = NULL; prog = regp->r_prog; vers = regp->r_vers; reg_nconf = rpcbind_get_conf(transp->xp_netid); if (reg_nconf == NULL) return (NULL); if (*(regp->r_addr) != '\0') { saddr = regp->r_addr; } else { saddr = NULL; } #ifdef RPCBIND_DEBUG if (debugging) { fprintf(stderr, "r_addr: %s r_netid: %s nc_protofmly: %s\n", regp->r_addr, regp->r_netid, reg_nconf->nc_protofmly); } #endif for (rbl = list_rbl; rbl != NULL; rbl = rbl->rpcb_next) { if ((rbl->rpcb_map.r_prog == prog) && (rbl->rpcb_map.r_vers == vers)) { nconf = rpcbind_get_conf(rbl->rpcb_map.r_netid); if (nconf == NULL) goto fail; if (strcmp(nconf->nc_protofmly, reg_nconf->nc_protofmly) != 0) { continue; /* not same proto family */ } #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, "\tmerge with: %s\n", rbl->rpcb_map.r_addr); #endif if ((maddr = mergeaddr(transp, rbl->rpcb_map.r_netid, rbl->rpcb_map.r_addr, saddr)) == NULL) { #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, " FAILED\n"); #endif continue; } else if (!maddr[0]) { #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, " SUCCEEDED, but port died - maddr: nullstring\n"); #endif /* The server died. Unset this combination */ delete_prog(regp->r_prog); continue; } #ifdef RPCBIND_DEBUG if (debugging) fprintf(stderr, " SUCCEEDED maddr: %s\n", maddr); #endif /* * Add it to rlist. */ rp = malloc(sizeof (rpcb_entry_list)); if (rp == NULL) goto fail; a = &rp->rpcb_entry_map; a->r_maddr = maddr; a->r_nc_netid = nconf->nc_netid; a->r_nc_semantics = nconf->nc_semantics; a->r_nc_protofmly = nconf->nc_protofmly; a->r_nc_proto = nconf->nc_proto; rp->rpcb_entry_next = NULL; if (rlist == NULL) { rlist = rp; tail = rp; } else { tail->rpcb_entry_next = rp; tail = rp; } rp = NULL; } } #ifdef RPCBIND_DEBUG if (debugging) { for (rp = rlist; rp; rp = rp->rpcb_entry_next) { fprintf(stderr, "\t%s %s\n", rp->rpcb_entry_map.r_maddr, rp->rpcb_entry_map.r_nc_proto); } } #endif /* * XXX: getaddrlist info is also being stuffed into getaddr. * Perhaps wrong, but better than it not getting counted at all. */ rpcbs_getaddr(RPCBVERS4 - 2, prog, vers, transp->xp_netid, maddr); return (void *)&rlist; fail: free_rpcb_entry_list(&rlist); return (NULL); } /* * Free only the allocated structure, rest is all a pointer to some * other data somewhere else. */ static void free_rpcb_entry_list(rpcb_entry_list_ptr *rlistp) { register rpcb_entry_list_ptr rbl, tmp; for (rbl = *rlistp; rbl != NULL; ) { tmp = rbl; rbl = rbl->rpcb_entry_next; free((char *)tmp->rpcb_entry_map.r_maddr); free((char *)tmp); } *rlistp = NULL; } /* ARGSUSED */ static void * rpcbproc_dump_4_local(void *arg __unused, struct svc_req *req __unused, SVCXPRT *xprt __unused, rpcvers_t versnum __unused) { return ((void *)&list_rbl); } diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index de792fc9f286..491c3e53b9e5 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -1,419 +1,418 @@ /* * $NetBSD: util.c,v 1.4 2000/08/03 00:04:30 fvdl Exp $ - * $FreeBSD$ */ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Frank van der Linden. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "rpcbind.h" static struct sockaddr_in *local_in4; #ifdef INET6 static struct sockaddr_in6 *local_in6; #endif static int bitmaskcmp(struct sockaddr *, struct sockaddr *, struct sockaddr *); /* * For all bits set in "mask", compare the corresponding bits in * "dst" and "src", and see if they match. Returns 0 if the addresses * match. */ static int bitmaskcmp(struct sockaddr *dst, struct sockaddr *src, struct sockaddr *mask) { int i; u_int8_t *p1, *p2, *netmask; int bytelen; if (dst->sa_family != src->sa_family || dst->sa_family != mask->sa_family) return (1); switch (dst->sa_family) { case AF_INET: p1 = (uint8_t*) &SA2SINADDR(dst); p2 = (uint8_t*) &SA2SINADDR(src); netmask = (uint8_t*) &SA2SINADDR(mask); bytelen = sizeof(struct in_addr); break; #ifdef INET6 case AF_INET6: p1 = (uint8_t*) &SA2SIN6ADDR(dst); p2 = (uint8_t*) &SA2SIN6ADDR(src); netmask = (uint8_t*) &SA2SIN6ADDR(mask); bytelen = sizeof(struct in6_addr); break; #endif default: return (1); } for (i = 0; i < bytelen; i++) if ((p1[i] & netmask[i]) != (p2[i] & netmask[i])) return (1); return (0); } /* * Find a server address that can be used by `caller' to contact * the local service specified by `serv_uaddr'. If `contct_uaddr' is * non-NULL, it is used instead of `caller' as a hint suggesting * the best address (e.g. the `r_addr' field of an rpc, which * contains the rpcbind server address that the caller used). * * Returns the best server address as a malloc'd "universal address" * string which should be freed by the caller. On error, returns NULL. */ char * addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *contct_uaddr, const char *netid) { struct ifaddrs *ifap, *ifp = NULL, *bestif; struct netbuf *serv_nbp = NULL, *hint_nbp = NULL, tbuf; struct sockaddr *caller_sa, *hint_sa, *ifsa, *ifmasksa, *serv_sa; struct sockaddr_storage ss; struct netconfig *nconf; char *caller_uaddr = NULL; #ifdef ND_DEBUG const char *hint_uaddr = NULL; #endif char *ret = NULL; int bestif_goodness; #ifdef ND_DEBUG if (debugging) fprintf(stderr, "addrmerge(caller, %s, %s, %s\n", serv_uaddr, contct_uaddr == NULL ? "NULL" : contct_uaddr, netid); #endif caller_sa = caller->buf; if ((nconf = rpcbind_get_conf(netid)) == NULL) goto freeit; if ((caller_uaddr = taddr2uaddr(nconf, caller)) == NULL) goto freeit; /* * Use `contct_uaddr' as the hint if non-NULL, but ignore it if its * address family is different from that of the caller. */ hint_sa = NULL; if (contct_uaddr != NULL) { #ifdef ND_DEBUG hint_uaddr = contct_uaddr; #endif if ((hint_nbp = uaddr2taddr(nconf, contct_uaddr)) == NULL) goto freeit; hint_sa = hint_nbp->buf; } if (hint_sa == NULL || hint_sa->sa_family != caller_sa->sa_family) { #ifdef ND_DEBUG hint_uaddr = caller_uaddr; #endif hint_sa = caller->buf; } #ifdef ND_DEBUG if (debugging) fprintf(stderr, "addrmerge: hint %s\n", hint_uaddr); #endif /* Local caller, just return the server address. */ if (strncmp(caller_uaddr, "0.0.0.0.", 8) == 0 || strncmp(caller_uaddr, "::.", 3) == 0 || caller_uaddr[0] == '/') { ret = strdup(serv_uaddr); goto freeit; } if (getifaddrs(&ifp) < 0) goto freeit; /* * Loop through all interface addresses. We are listening to an address * if any of the following are true: * a) It's a loopback address * b) It was specified with the -h command line option * c) There were no -h command line options. * * Among addresses on which we are listening, choose in order of * preference an address that is: * * a) Equal to the hint * b) A link local address with the same scope ID as the client's * address, if the client's address is also link local * c) An address on the same subnet as the client's address * d) A non-localhost, non-p2p address * e) Any usable address */ bestif = NULL; bestif_goodness = 0; for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { ifsa = ifap->ifa_addr; ifmasksa = ifap->ifa_netmask; /* Skip addresses where we don't listen */ if (ifsa == NULL || ifsa->sa_family != hint_sa->sa_family || !(ifap->ifa_flags & IFF_UP)) continue; if (!(ifap->ifa_flags & IFF_LOOPBACK) && !listen_addr(ifsa)) continue; if ((hint_sa->sa_family == AF_INET) && ((((struct sockaddr_in*)hint_sa)->sin_addr.s_addr == ((struct sockaddr_in*)ifsa)->sin_addr.s_addr))) { const int goodness = 4; bestif_goodness = goodness; bestif = ifap; goto found; } #ifdef INET6 if ((hint_sa->sa_family == AF_INET6) && (0 == memcmp(&((struct sockaddr_in6*)hint_sa)->sin6_addr, &((struct sockaddr_in6*)ifsa)->sin6_addr, sizeof(struct in6_addr))) && (((struct sockaddr_in6*)hint_sa)->sin6_scope_id == (((struct sockaddr_in6*)ifsa)->sin6_scope_id))) { const int goodness = 4; bestif_goodness = goodness; bestif = ifap; goto found; } if (hint_sa->sa_family == AF_INET6) { /* * For v6 link local addresses, if the caller is on * a link-local address then use the scope id to see * which one. */ if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(ifsa))) { if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(caller_sa)) && IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa)) && (SA2SIN6(ifsa)->sin6_scope_id == SA2SIN6(caller_sa)->sin6_scope_id)) { const int goodness = 3; if (bestif_goodness < goodness) { bestif = ifap; bestif_goodness = goodness; } } else { continue; } } } #endif /* INET6 */ if (0 == bitmaskcmp(hint_sa, ifsa, ifmasksa)) { const int goodness = 2; if (bestif_goodness < goodness) { bestif = ifap; bestif_goodness = goodness; } } if (!(ifap->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) { const int goodness = 1; if (bestif_goodness < goodness) { bestif = ifap; bestif_goodness = goodness; } } if (bestif == NULL) bestif = ifap; } if (bestif == NULL) goto freeit; found: /* * Construct the new address using the address from * `bestif', and the port number from `serv_uaddr'. */ serv_nbp = uaddr2taddr(nconf, serv_uaddr); if (serv_nbp == NULL) goto freeit; serv_sa = serv_nbp->buf; memcpy(&ss, bestif->ifa_addr, bestif->ifa_addr->sa_len); switch (ss.ss_family) { case AF_INET: SA2SIN(&ss)->sin_port = SA2SIN(serv_sa)->sin_port; break; #ifdef INET6 case AF_INET6: SA2SIN6(&ss)->sin6_port = SA2SIN6(serv_sa)->sin6_port; break; #endif } tbuf.len = ss.ss_len; tbuf.maxlen = sizeof(ss); tbuf.buf = &ss; ret = taddr2uaddr(nconf, &tbuf); freeit: free(caller_uaddr); if (hint_nbp != NULL) { free(hint_nbp->buf); free(hint_nbp); } if (serv_nbp != NULL) { free(serv_nbp->buf); free(serv_nbp); } if (ifp != NULL) freeifaddrs(ifp); #ifdef ND_DEBUG if (debugging) fprintf(stderr, "addrmerge: returning %s\n", ret); #endif return ret; } void network_init(void) { #ifdef INET6 struct ifaddrs *ifap, *ifp; struct ipv6_mreq mreq6; unsigned int ifindex; int s; #endif int ecode; struct addrinfo hints, *res; memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; if ((ecode = getaddrinfo(NULL, "sunrpc", &hints, &res))) { if (debugging) fprintf(stderr, "can't get local ip4 address: %s\n", gai_strerror(ecode)); } else { local_in4 = (struct sockaddr_in *)malloc(sizeof *local_in4); if (local_in4 == NULL) { if (debugging) fprintf(stderr, "can't alloc local ip4 addr\n"); exit(1); } memcpy(local_in4, res->ai_addr, sizeof *local_in4); freeaddrinfo(res); } #ifdef INET6 hints.ai_family = AF_INET6; if ((ecode = getaddrinfo(NULL, "sunrpc", &hints, &res))) { if (debugging) fprintf(stderr, "can't get local ip6 address: %s\n", gai_strerror(ecode)); } else { local_in6 = (struct sockaddr_in6 *)malloc(sizeof *local_in6); if (local_in6 == NULL) { if (debugging) fprintf(stderr, "can't alloc local ip6 addr\n"); exit(1); } memcpy(local_in6, res->ai_addr, sizeof *local_in6); freeaddrinfo(res); } /* * Now join the RPC ipv6 multicast group on all interfaces. */ if (getifaddrs(&ifp) < 0) return; mreq6.ipv6mr_interface = 0; inet_pton(AF_INET6, RPCB_MULTICAST_ADDR, &mreq6.ipv6mr_multiaddr); s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (s == -1) { if (debugging) fprintf(stderr, "couldn't create ip6 socket"); goto done_inet6; } /* * Loop through all interfaces. For each IPv6 multicast-capable * interface, join the RPC multicast group on that interface. */ for (ifap = ifp; ifap != NULL; ifap = ifap->ifa_next) { if (ifap->ifa_addr->sa_family != AF_INET6 || !(ifap->ifa_flags & IFF_MULTICAST)) continue; ifindex = if_nametoindex(ifap->ifa_name); if (ifindex == mreq6.ipv6mr_interface) /* * Already did this one. */ continue; mreq6.ipv6mr_interface = ifindex; if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6, sizeof mreq6) < 0) if (debugging) perror("setsockopt v6 multicast"); } done_inet6: freeifaddrs(ifp); #endif /* close(s); */ } struct sockaddr * local_sa(int af) { switch (af) { case AF_INET: return (struct sockaddr *)local_in4; #ifdef INET6 case AF_INET6: return (struct sockaddr *)local_in6; #endif default: return NULL; } } diff --git a/usr.sbin/rpcbind/warmstart.c b/usr.sbin/rpcbind/warmstart.c index 74ad91231e3d..0d259085aae3 100644 --- a/usr.sbin/rpcbind/warmstart.c +++ b/usr.sbin/rpcbind/warmstart.c @@ -1,180 +1,179 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2009, Sun Microsystems, Inc. * All rights reserved. * * 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 notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Sun Microsystems, Inc. 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 FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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. */ /* * warmstart.c * Allows for gathering of registrations from an earlier dumped file. * * Copyright (c) 1990 by Sun Microsystems, Inc. */ /* * #ident "@(#)warmstart.c 1.7 93/07/05 SMI" - * $FreeBSD$/ */ #include #include #include #include #include #include #ifdef PORTMAP #include #include #endif #include #include #include "rpcbind.h" /* * XXX this code is unsafe and is not used. It should be made safe. */ /* These files keep the pmap_list and rpcb_list in XDR format */ #define RPCBFILE "/tmp/rpcbind.file" #ifdef PORTMAP #define PMAPFILE "/tmp/portmap.file" #endif static bool_t write_struct(char *, xdrproc_t, void *); static bool_t read_struct(char *, xdrproc_t, void *); static bool_t write_struct(char *filename, xdrproc_t structproc, void *list) { FILE *fp; XDR xdrs; mode_t omask; omask = umask(077); fp = fopen(filename, "w"); if (fp == NULL) { int i; for (i = 0; i < 10; i++) close(i); fp = fopen(filename, "w"); if (fp == NULL) { syslog(LOG_ERR, "cannot open file = %s for writing", filename); syslog(LOG_ERR, "cannot save any registration"); return (FALSE); } } (void) umask(omask); xdrstdio_create(&xdrs, fp, XDR_ENCODE); if (structproc(&xdrs, list) == FALSE) { syslog(LOG_ERR, "rpcbind: xdr_%s: failed", filename); fclose(fp); return (FALSE); } XDR_DESTROY(&xdrs); fclose(fp); return (TRUE); } static bool_t read_struct(char *filename, xdrproc_t structproc, void *list) { FILE *fp; XDR xdrs; struct stat sbuf; if (stat(filename, &sbuf) != 0) { fprintf(stderr, "rpcbind: cannot stat file = %s for reading\n", filename); goto error; } if ((sbuf.st_uid != 0) || (sbuf.st_mode & S_IRWXG) || (sbuf.st_mode & S_IRWXO)) { fprintf(stderr, "rpcbind: invalid permissions on file = %s for reading\n", filename); goto error; } fp = fopen(filename, "r"); if (fp == NULL) { fprintf(stderr, "rpcbind: cannot open file = %s for reading\n", filename); goto error; } xdrstdio_create(&xdrs, fp, XDR_DECODE); if (structproc(&xdrs, list) == FALSE) { fprintf(stderr, "rpcbind: xdr_%s: failed\n", filename); fclose(fp); goto error; } XDR_DESTROY(&xdrs); fclose(fp); return (TRUE); error: fprintf(stderr, "rpcbind: will start from scratch\n"); return (FALSE); } void write_warmstart(void) { (void) write_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &list_rbl); #ifdef PORTMAP (void) write_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &list_pml); #endif } void read_warmstart(void) { rpcblist_ptr tmp_rpcbl = NULL; #ifdef PORTMAP struct pmaplist *tmp_pmapl = NULL; #endif int ok1, ok2 = TRUE; ok1 = read_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl); if (ok1 == FALSE) return; #ifdef PORTMAP ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl); #endif if (ok2 == FALSE) { xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&tmp_rpcbl); return; } xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&list_rbl); list_rbl = tmp_rpcbl; #ifdef PORTMAP xdr_free((xdrproc_t) xdr_pmaplist_ptr, (char *)&list_pml); list_pml = tmp_pmapl; #endif } diff --git a/usr.sbin/syslogd/pathnames.h b/usr.sbin/syslogd/pathnames.h index 7297ba5b95d7..78c356fa35be 100644 --- a/usr.sbin/syslogd/pathnames.h +++ b/usr.sbin/syslogd/pathnames.h @@ -1,37 +1,36 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD$ */ #define _PATH_KLOG "/dev/klog" #define _PATH_LOGCONF "/etc/syslog.conf" #define _PATH_LOGPID "/var/run/syslog.pid" diff --git a/usr.sbin/ypbind/yp_ping.h b/usr.sbin/ypbind/yp_ping.h index 80e6a7873011..09f88b9442ce 100644 --- a/usr.sbin/ypbind/yp_ping.h +++ b/usr.sbin/ypbind/yp_ping.h @@ -1,5 +1,4 @@ /* - * $FreeBSD$ */ extern int __yp_ping(struct in_addr *, int, char *, short *);