From 3531b5cc562b916112debe6538f6499dc0263d13 Mon Sep 17 00:00:00 2001 From: Juergen Schoenwaelder Date: Fri, 15 Oct 2004 15:17:20 +0000 Subject: [PATCH] Initial revision --- .deps/getopt.P | 31 + .deps/getopt1.P | 32 + .deps/gsnmp.P | 92 + .deps/xmalloc.P | 31 + AUTHORS | 6 + COPYING | 340 ++ ChangeLog | 4 + Makefile.am | 10 + Makefile.in | 444 +++ NEWS | 0 README | 30 + acinclude.m4 | 40 + aclocal.m4 | 7337 ++++++++++++++++++++++++++++++++++++ autogen.sh | 63 + config.h.in | 55 + configure.ac | 45 + examples/Makefile.am | 24 + examples/Makefile.in | 424 +++ examples/atm-mib.c | 2147 +++++++++++ examples/atm-mib.h | 521 +++ examples/atm-tc-mib.c | 155 + examples/atm-tc-mib.h | 102 + examples/atm.c | 75 + examples/gsnmp-iftable.c | 122 + examples/gsnmp-ping.c | 123 + examples/gsnmp-stub-ping.c | 100 + examples/gsnmp-walk.c | 184 + examples/ianaiftype-mib.c | 343 ++ examples/ianaiftype-mib.h | 354 ++ examples/if-mib.c | 1402 +++++++ examples/if-mib.h | 385 ++ examples/snmpv2-mib.c | 699 ++++ examples/snmpv2-mib.h | 236 ++ examples/snmpv2-tc.c | 37 + examples/snmpv2-tc.h | 46 + gsnmp.lsm.in | 21 + gsnmp.m4 | 7 + gsnmp.pc.in | 12 + gsnmp.spec.in | 93 + src/Makefile.am | 26 + src/Makefile.in | 396 ++ src/ber.c | 1168 ++++++ src/ber.h | 153 + src/dispatch.c | 744 ++++ src/dispatch.h | 59 + src/gsnmp.h | 64 + src/message.c | 680 ++++ src/message.h | 122 + src/pdu.c | 1467 +++++++ src/pdu.h | 225 ++ src/security.c | 289 ++ src/security.h | 81 + src/session.c | 801 ++++ src/session.h | 185 + src/table.c | 311 ++ src/transport.c | 393 ++ src/transport.h | 73 + src/utils.c | 480 +++ src/utils.h | 126 + src/walk.c | 302 ++ stamp-h.in | 1 + tests/Makefile.am | 7 + tests/Makefile.in | 373 ++ tests/gsnmp-test.c | 673 ++++ 64 files changed, 25371 insertions(+) create mode 100644 .deps/getopt.P create mode 100644 .deps/getopt1.P create mode 100644 .deps/gsnmp.P create mode 100644 .deps/xmalloc.P create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 README create mode 100644 acinclude.m4 create mode 100644 aclocal.m4 create mode 100755 autogen.sh create mode 100644 config.h.in create mode 100644 configure.ac create mode 100644 examples/Makefile.am create mode 100644 examples/Makefile.in create mode 100644 examples/atm-mib.c create mode 100644 examples/atm-mib.h create mode 100644 examples/atm-tc-mib.c create mode 100644 examples/atm-tc-mib.h create mode 100644 examples/atm.c create mode 100644 examples/gsnmp-iftable.c create mode 100644 examples/gsnmp-ping.c create mode 100644 examples/gsnmp-stub-ping.c create mode 100644 examples/gsnmp-walk.c create mode 100644 examples/ianaiftype-mib.c create mode 100644 examples/ianaiftype-mib.h create mode 100644 examples/if-mib.c create mode 100644 examples/if-mib.h create mode 100644 examples/snmpv2-mib.c create mode 100644 examples/snmpv2-mib.h create mode 100644 examples/snmpv2-tc.c create mode 100644 examples/snmpv2-tc.h create mode 100644 gsnmp.lsm.in create mode 100644 gsnmp.m4 create mode 100644 gsnmp.pc.in create mode 100644 gsnmp.spec.in create mode 100644 src/Makefile.am create mode 100644 src/Makefile.in create mode 100644 src/ber.c create mode 100644 src/ber.h create mode 100644 src/dispatch.c create mode 100644 src/dispatch.h create mode 100644 src/gsnmp.h create mode 100644 src/message.c create mode 100644 src/message.h create mode 100644 src/pdu.c create mode 100644 src/pdu.h create mode 100644 src/security.c create mode 100644 src/security.h create mode 100644 src/session.c create mode 100644 src/session.h create mode 100644 src/table.c create mode 100644 src/transport.c create mode 100644 src/transport.h create mode 100644 src/utils.c create mode 100644 src/utils.h create mode 100644 src/walk.c create mode 100644 stamp-h.in create mode 100644 tests/Makefile.am create mode 100644 tests/Makefile.in create mode 100644 tests/gsnmp-test.c diff --git a/.deps/getopt.P b/.deps/getopt.P new file mode 100644 index 0000000..b90f4ea --- /dev/null +++ b/.deps/getopt.P @@ -0,0 +1,31 @@ +getopt.o: getopt.c config.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/gnu-versions.h +getopt.c : +config.h : +/usr/include/stdio.h : +/usr/include/features.h : +/usr/include/sys/cdefs.h : +/usr/include/gnu/stubs.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h : +/usr/include/bits/types.h : +/usr/include/bits/pthreadtypes.h : +/usr/include/bits/sched.h : +/usr/include/libio.h : +/usr/include/_G_config.h : +/usr/include/wchar.h : +/usr/include/bits/wchar.h : +/usr/include/gconv.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h : +/usr/include/bits/stdio_lim.h : +/usr/include/bits/sys_errlist.h : +/usr/include/bits/stdio.h : +/usr/include/gnu-versions.h : diff --git a/.deps/getopt1.P b/.deps/getopt1.P new file mode 100644 index 0000000..cf4df80 --- /dev/null +++ b/.deps/getopt1.P @@ -0,0 +1,32 @@ +getopt1.o: getopt1.c config.h getopt.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/gnu-versions.h +getopt1.c : +config.h : +getopt.h : +/usr/include/stdio.h : +/usr/include/features.h : +/usr/include/sys/cdefs.h : +/usr/include/gnu/stubs.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h : +/usr/include/bits/types.h : +/usr/include/bits/pthreadtypes.h : +/usr/include/bits/sched.h : +/usr/include/libio.h : +/usr/include/_G_config.h : +/usr/include/wchar.h : +/usr/include/bits/wchar.h : +/usr/include/gconv.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h : +/usr/include/bits/stdio_lim.h : +/usr/include/bits/sys_errlist.h : +/usr/include/bits/stdio.h : +/usr/include/gnu-versions.h : diff --git a/.deps/gsnmp.P b/.deps/gsnmp.P new file mode 100644 index 0000000..3b7f7d2 --- /dev/null +++ b/.deps/gsnmp.P @@ -0,0 +1,92 @@ +gsnmp.o: gsnmp.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/bits/stdio.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h getopt.h system.h config.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h \ + /usr/include/sys/param.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/limits.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/linux/param.h \ + /usr/include/asm/param.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/utime.h /usr/include/string.h /usr/include/bits/string.h \ + /usr/include/bits/string2.h /usr/include/stdlib.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/alloca.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/dirent.h /usr/include/bits/dirent.h /usr/include/ctype.h \ + /usr/include/locale.h /usr/include/bits/locale.h +gsnmp.c : +/usr/include/stdio.h : +/usr/include/features.h : +/usr/include/sys/cdefs.h : +/usr/include/gnu/stubs.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h : +/usr/include/bits/types.h : +/usr/include/bits/pthreadtypes.h : +/usr/include/bits/sched.h : +/usr/include/libio.h : +/usr/include/_G_config.h : +/usr/include/wchar.h : +/usr/include/bits/wchar.h : +/usr/include/gconv.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stdarg.h : +/usr/include/bits/stdio_lim.h : +/usr/include/bits/sys_errlist.h : +/usr/include/bits/stdio.h : +/usr/include/sys/types.h : +/usr/include/time.h : +/usr/include/endian.h : +/usr/include/bits/endian.h : +/usr/include/sys/select.h : +/usr/include/bits/select.h : +/usr/include/bits/sigset.h : +/usr/include/bits/time.h : +/usr/include/sys/sysmacros.h : +getopt.h : +system.h : +config.h : +/usr/include/sys/stat.h : +/usr/include/bits/stat.h : +/usr/include/sys/param.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/limits.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/syslimits.h : +/usr/include/limits.h : +/usr/include/bits/posix1_lim.h : +/usr/include/bits/local_lim.h : +/usr/include/linux/limits.h : +/usr/include/bits/posix2_lim.h : +/usr/include/linux/param.h : +/usr/include/asm/param.h : +/usr/include/unistd.h : +/usr/include/bits/posix_opt.h : +/usr/include/bits/confname.h : +/usr/include/utime.h : +/usr/include/string.h : +/usr/include/bits/string.h : +/usr/include/bits/string2.h : +/usr/include/stdlib.h : +/usr/include/errno.h : +/usr/include/bits/errno.h : +/usr/include/linux/errno.h : +/usr/include/asm/errno.h : +/usr/include/alloca.h : +/usr/include/fcntl.h : +/usr/include/bits/fcntl.h : +/usr/include/dirent.h : +/usr/include/bits/dirent.h : +/usr/include/ctype.h : +/usr/include/locale.h : +/usr/include/bits/locale.h : diff --git a/.deps/xmalloc.P b/.deps/xmalloc.P new file mode 100644 index 0000000..a5fa43d --- /dev/null +++ b/.deps/xmalloc.P @@ -0,0 +1,31 @@ +xmalloc.o: xmalloc.c config.h /usr/include/sys/types.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/bits/types.h \ + /usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/stdlib.h \ + /usr/include/alloca.h /usr/include/error.h +xmalloc.c : +config.h : +/usr/include/sys/types.h : +/usr/include/features.h : +/usr/include/sys/cdefs.h : +/usr/include/gnu/stubs.h : +/usr/include/bits/types.h : +/usr/lib/gcc-lib/i386-linux/2.95.4/include/stddef.h : +/usr/include/bits/pthreadtypes.h : +/usr/include/bits/sched.h : +/usr/include/time.h : +/usr/include/endian.h : +/usr/include/bits/endian.h : +/usr/include/sys/select.h : +/usr/include/bits/select.h : +/usr/include/bits/sigset.h : +/usr/include/bits/time.h : +/usr/include/sys/sysmacros.h : +/usr/include/stdlib.h : +/usr/include/alloca.h : +/usr/include/error.h : diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..b9e4f78 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,6 @@ +Juergen Schoenwaelder + +Some parts of this package contain code originally written by Gregory +McLean, Jochen Friedrich and Dirk Wisse. See the various header files +for the details. + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..83febb8 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4 @@ +2002-11-05 Juergen Schoenwaelder + + * gsnmp: initial version. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..364fa75 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,10 @@ +SUBDIRS = src tests examples + +EXTRA_DIST = gsnmp.m4 gsnmp.pc + +m4datadir = $(datadir)/aclocal +m4data_DATA = gsnmp.m4 + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = gsnmp.pc +$(pkgconfig_DATA): config.status diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..f6b6cce --- /dev/null +++ b/Makefile.in @@ -0,0 +1,444 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AR = @AR@ +AS = @AS@ +CC = @CC@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GNET_CFLAGS = @GNET_CFLAGS@ +GNET_LIBS = @GNET_LIBS@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +HAVE_LIB = @HAVE_LIB@ +ISODATE = @ISODATE@ +LIB = @LIB@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIB = @LTLIB@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RC = @RC@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +SUBDIRS = src tests examples + +EXTRA_DIST = gsnmp.m4 gsnmp.pc + +m4datadir = $(datadir)/aclocal +m4data_DATA = gsnmp.m4 + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = gsnmp.pc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = gsnmp.lsm gsnmp.spec gsnmp.pc +DATA = $(m4data_DATA) $(pkgconfig_DATA) + +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ +Makefile.am Makefile.in NEWS acinclude.m4 aclocal.m4 config.guess \ +config.h.in config.sub configure configure.ac gsnmp.lsm.in gsnmp.pc.in \ +gsnmp.spec.in install-sh ltmain.sh missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +all: all-redirect +.SUFFIXES: +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.ac acinclude.m4 + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @echo timestamp > stamp-h 2> /dev/null +$(srcdir)/config.h.in: $(srcdir)/stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/stamp-h.in; \ + $(MAKE) $(srcdir)/stamp-h.in; \ + else :; fi +$(srcdir)/stamp-h.in: $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOHEADER) + @echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null + +mostlyclean-hdr: + +clean-hdr: + +distclean-hdr: + -rm -f config.h + +maintainer-clean-hdr: +gsnmp.lsm: $(top_builddir)/config.status gsnmp.lsm.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status +gsnmp.spec: $(top_builddir)/config.status gsnmp.spec.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status +gsnmp.pc: $(top_builddir)/config.status gsnmp.pc.in + cd $(top_builddir) && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +install-m4dataDATA: $(m4data_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(m4datadir) + @list='$(m4data_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(m4datadir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(m4datadir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(m4datadir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(m4datadir)/$$p; \ + fi; fi; \ + done + +uninstall-m4dataDATA: + @$(NORMAL_UNINSTALL) + list='$(m4data_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(m4datadir)/$$p; \ + done + +install-pkgconfigDATA: $(pkgconfig_DATA) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(pkgconfigdir) + @list='$(pkgconfig_DATA)'; for p in $$list; do \ + if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + else if test -f $$p; then \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(pkgconfigdir)/$$p; \ + fi; fi; \ + done + +uninstall-pkgconfigDATA: + @$(NORMAL_UNINSTALL) + list='$(pkgconfig_DATA)'; for p in $$list; do \ + rm -f $(DESTDIR)$(pkgconfigdir)/$$p; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" != "." || dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +all-recursive-am: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +install-exec-am: +install-exec: install-exec-recursive + +install-data-am: install-m4dataDATA install-pkgconfigDATA +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: uninstall-m4dataDATA uninstall-pkgconfigDATA +uninstall: uninstall-recursive +all-am: Makefile $(DATA) config.h +all-redirect: all-recursive-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(m4datadir) $(DESTDIR)$(pkgconfigdir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-hdr clean-tags clean-generic mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-hdr distclean-tags distclean-generic clean-am + -rm -f libtool + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \ +uninstall-m4dataDATA install-m4dataDATA uninstall-pkgconfigDATA \ +install-pkgconfigDATA install-data-recursive uninstall-data-recursive \ +install-exec-recursive uninstall-exec-recursive installdirs-recursive \ +uninstalldirs-recursive all-recursive check-recursive \ +installcheck-recursive info-recursive dvi-recursive \ +mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir info-am info \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all installdirs-am \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + +$(pkgconfig_DATA): config.status + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..cb4d9f5 --- /dev/null +++ b/README @@ -0,0 +1,30 @@ + GNET-SNMP + + Copyright (C) 2002-2004 Juergen Schoenwaelder + + GNET-SNMP is an SNMP library implementation based on glib [1] and + gnet [2]. This library has been developed as part of the scli [3] + package (an SNMP command line interface). Some examples + demonstrating the API can be found in the examples directory. Some + examples use stub files generated by the smidump MIB compiler, which + is part of the libsmi package [4]. As usual, comments, bug reports, + bug fixes and general suggestions are welcome. + + GNET-SNMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +[1] http://www.gtk.org/ +[2] http://www.gnetlibrary.org/ +[3] http://www.ibr.cs.tu-bs.de/projects/scli/ +[4] http://www.ibr.cs.tu-bs.de/projects/libsmi/ diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..1e36f39 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,40 @@ +#serial 3 + +dnl From Jim Meyering + +dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared -- +dnl usually in . +dnl Some systems have utime.h but don't declare the struct anywhere. + +AC_DEFUN(jm_CHECK_TYPE_STRUCT_UTIMBUF, +[ + AC_CHECK_HEADERS(utime.h) + AC_REQUIRE([AC_HEADER_TIME]) + AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf, + [AC_TRY_COMPILE( + [ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_UTIME_H +# include +#endif + ], + [static struct utimbuf x; x.actime = x.modtime;], + fu_cv_sys_struct_utimbuf=yes, + fu_cv_sys_struct_utimbuf=no) + ]) + + if test $fu_cv_sys_struct_utimbuf = yes; then + AC_DEFINE_UNQUOTED(HAVE_STRUCT_UTIMBUF, 1, +[Define if struct utimbuf is declared -- usually in . + Some systems have utime.h but don't declare the struct anywhere. ]) + fi +]) diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..1a506db --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,7337 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4-p6 + +dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +#serial 3 + +dnl From Jim Meyering + +dnl Define HAVE_STRUCT_UTIMBUF if `struct utimbuf' is declared -- +dnl usually in . +dnl Some systems have utime.h but don't declare the struct anywhere. + +AC_DEFUN(jm_CHECK_TYPE_STRUCT_UTIMBUF, +[ + AC_CHECK_HEADERS(utime.h) + AC_REQUIRE([AC_HEADER_TIME]) + AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf, + [AC_TRY_COMPILE( + [ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef HAVE_UTIME_H +# include +#endif + ], + [static struct utimbuf x; x.actime = x.modtime;], + fu_cv_sys_struct_utimbuf=yes, + fu_cv_sys_struct_utimbuf=no) + ]) + + if test $fu_cv_sys_struct_utimbuf = yes; then + AC_DEFINE_UNQUOTED(HAVE_STRUCT_UTIMBUF, 1, +[Define if struct utimbuf is declared -- usually in . + Some systems have utime.h but don't declare the struct anywhere. ]) + fi +]) + +# lib-prefix.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +# lib-link.m4 serial 4 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +# lib-ld.m4 serial 3 (gettext-0.13) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(acl_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# Copyright 2002 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# 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. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.4"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.4-p6])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN([AM_MISSING_PROG], +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +AC_DEFUN([AM_CONFIG_HEADER], +[AC_PREREQ([2.12]) +AC_CONFIG_HEADER([$1]) +dnl When config.status generates a header, we must update the stamp-h file. +dnl This file resides in the same directory as the config header +dnl that is generated. We must strip everything past the first ":", +dnl and everything past the last "/". +AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl +ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>, +<>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>, +<>; do + case " <<$>>CONFIG_HEADERS " in + *" <<$>>am_file "*<<)>> + echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx + ;; + esac + am_indx=`expr "<<$>>am_indx" + 1` +done<<>>dnl>>) +changequote([,]))]) + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 47 AC_PROG_LIBTOOL +# Debian $Rev: 214 $ + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + else + $2=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while (test "X"`$CONFIG_SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# -------------------- +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_unknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)"="Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=yes + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && test "X$CXX" != "Xno"; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 dll's +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +#- set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case "$host_cpu" in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/${ac_tool_prefix}nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + esac + fi + done + IFS="$lt_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided and an installed libltdl is not found, it is +# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/' +# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single +# quotes!). If your package is not flat and you're not using automake, +# define top_builddir and top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# -------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + +_LT_AC_SYS_COMPILER + +# +# Check for any special shared library compilation flags. +# +_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)= +if test "$GCC" = no; then + case $host_os in + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf' + ;; + esac +fi +if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then + AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries]) + if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then : + else + AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure]) + _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no + fi +fi + + +# +# Check to make sure the static flag actually works. +# +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + $_LT_AC_TAGVAR(lt_prog_compiler_static, $1), + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) + + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +# Report which librarie types wil actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + darwin* | rhapsody*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs$compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= + +# Source file extension for C++ test sources. +ac_ext=cc + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + dgux*) + case $cc_basename in + ec++) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case "$host_cpu" in + ia64*|hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + irix5* | irix6*) + case $cc_basename in + CC) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc) + # Intel C++ + with_gnu_ld=yes + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + cxx) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + osf3*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sco*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris* | sysv5*) + symcode='[[BDRT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + cxx) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + sco*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + *) + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + unixware*) + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + linux*) + _LT_AC_TAGVAR(link_all_deplibs, $1)=no + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds" + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=no + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi4*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + if test "$GXX" = yes ; then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-flat_namespace -undefined suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-undefined dynamic_lookup' + ;; + esac + fi + ;; + esac + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | grep 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC ${wl}-bind_at_load $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r ${wl}-bind_at_load -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-all_load $convenience' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd* | netbsdelf*-gnu | knetbsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4.2uw2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv5*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && break + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +SED=$lt_cv_path_SED +]) +AC_MSG_RESULT([$SED]) +]) + +# Configure paths for GLIB +# Owen Taylor 1997-2001 + +dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or +dnl gthread is specified in MODULES, pass to pkg-config +dnl +AC_DEFUN([AM_PATH_GLIB_2_0], +[dnl +dnl Get the cflags and libraries from pkg-config +dnl +AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program], + , enable_glibtest=yes) + + pkg_config_args=glib-2.0 + for module in . $4 + do + case "$module" in + gmodule) + pkg_config_args="$pkg_config_args gmodule-2.0" + ;; + gobject) + pkg_config_args="$pkg_config_args gobject-2.0" + ;; + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + esac + done + + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + + no_glib="" + + if test x$PKG_CONFIG != xno ; then + if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then + : + else + echo *** pkg-config too old; version 0.7 or better required. + no_glib=yes + PKG_CONFIG=no + fi + else + no_glib=yes + fi + + min_glib_version=ifelse([$1], ,2.0.0,$1) + AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) + + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH" + enable_glibtest=no + fi + + if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then + : + else + no_glib=yes + fi + fi + + if test x"$no_glib" = x ; then + GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0` + GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0` + GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` + + GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` + GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args` + glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_glibtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$GLIB_LIBS $LIBS" +dnl +dnl Now check if the installed GLIB is sufficiently new. (Also sanity +dnl checks the results of pkg-config to some extent) +dnl + rm -f conf.glibtest + AC_TRY_RUN([ +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.glibtest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_glib_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_glib_version"); + exit(1); + } + + if ((glib_major_version != $glib_config_major_version) || + (glib_minor_version != $glib_config_minor_version) || + (glib_micro_version != $glib_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", + $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version, + glib_major_version, glib_minor_version, glib_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GLib. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((glib_major_version != GLIB_MAJOR_VERSION) || + (glib_minor_version != GLIB_MINOR_VERSION) || + (glib_micro_version != GLIB_MICRO_VERSION)) + { + printf("*** GLIB header files (version %d.%d.%d) do not match\n", + GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + glib_major_version, glib_minor_version, glib_micro_version); + } + else + { + if ((glib_major_version > major) || + ((glib_major_version == major) && (glib_minor_version > minor)) || + ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n", + glib_major_version, glib_minor_version, glib_micro_version); + printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GLIB is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_glib" = x ; then + AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version)) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://www.freedesktop.org/software/pkgconfig/" + else + if test -f conf.glibtest ; then + : + else + echo "*** Could not run GLIB test program, checking why..." + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GLIB_CFLAGS" + LIBS="$LIBS $GLIB_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GLIB or finding the wrong" + echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GLIB is incorrectly installed."]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GLIB_CFLAGS="" + GLIB_LIBS="" + GLIB_GENMARSHAL="" + GOBJECT_QUERY="" + GLIB_MKENUMS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GLIB_CFLAGS) + AC_SUBST(GLIB_LIBS) + AC_SUBST(GLIB_GENMARSHAL) + AC_SUBST(GOBJECT_QUERY) + AC_SUBST(GLIB_MKENUMS) + rm -f conf.glibtest +]) + +# Configure paths for Gnet +# A hacked up version of Owen Taylor's glib-2.0.m4 (Copyright 1997-2001) + +dnl AM_PATH_GNET_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GNET, and define GNET_CFLAGS and GNET_LIBS, if gmodule, gobject or +dnl gthread is specified in MODULES, pass to pkg-config +dnl +AC_DEFUN(AM_PATH_GNET_2_0, +[dnl +dnl Get the cflags and libraries from pkg-config +dnl +AC_ARG_ENABLE(gnettest, [ --disable-gnettest do not try to compile and run a test GNET program], + , enable_gnettest=yes) + + pkg_config_args=gnet-2.0 + + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + + no_gnet="" + + if test x$PKG_CONFIG != xno ; then + if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then + : + else + echo *** pkg-config too old; version 0.7 or better required. + no_gnet=yes + PKG_CONFIG=no + fi + else + no_gnet=yes + fi + + min_gnet_version=ifelse([$1], , 2.0.0, $1) + AC_MSG_CHECKING(for GNET - version >= $min_gnet_version) + + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GNet found in PKG_CONFIG_PATH" + enable_gnettest=no + fi + + if $PKG_CONFIG --atleast-version $min_gnet_version $pkg_config_args; then + : + else + no_gnet=yes + fi + fi + + if test x"$no_gnet" = x ; then + GNET_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args` + GNET_LIBS=`$PKG_CONFIG --libs $pkg_config_args` + gnet_config_major_version=`$PKG_CONFIG --modversion gnet-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gnet_config_minor_version=`$PKG_CONFIG --modversion gnet-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gnet_config_micro_version=`$PKG_CONFIG --modversion gnet-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gnettest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GNET_CFLAGS" + LIBS="$GNET_LIBS $LIBS" +dnl +dnl Now check if the installed GNET is sufficiently new. (Also sanity +dnl checks the results of pkg-config to some extent) +dnl + rm -f conf.gnettest + AC_TRY_RUN([ +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gnettest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gnet_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gnet_version"); + exit(1); + } + + if ((gnet_major_version != $gnet_config_major_version) || + (gnet_minor_version != $gnet_config_minor_version) || + (gnet_micro_version != $gnet_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion gnet-2.0' returned %d.%d.%d, but GNET (%d.%d.%d)\n", + $gnet_config_major_version, $gnet_config_minor_version, $gnet_config_micro_version, + gnet_major_version, gnet_minor_version, gnet_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GNet. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((gnet_major_version != GNET_MAJOR_VERSION) || + (gnet_minor_version != GNET_MINOR_VERSION) || + (gnet_micro_version != GNET_MICRO_VERSION)) + { + printf("*** GNET header files (version %d.%d.%d) do not match\n", + GNET_MAJOR_VERSION, GNET_MINOR_VERSION, GNET_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gnet_major_version, gnet_minor_version, gnet_micro_version); + } + else + { + if ((gnet_major_version > major) || + ((gnet_major_version == major) && (gnet_minor_version > minor)) || + ((gnet_major_version == major) && (gnet_minor_version == minor) && (gnet_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GNET (%d.%d.%d) was found.\n", + gnet_major_version, gnet_minor_version, gnet_micro_version); + printf("*** You need a version of GNET newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GNET is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GNET, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gnet=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gnet" = x ; then + AC_MSG_RESULT(yes (version $gnet_config_major_version.$gnet_config_minor_version.$gnet_config_micro_version)) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://www.freedesktop.org/software/pkgconfig/" + else + if test -f conf.gnettest ; then + : + else + echo "*** Could not run GNET test program, checking why..." + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GNET_CFLAGS" + LIBS="$LIBS $GNET_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return ((gnet_major_version) || (gnet_minor_version) || (gnet_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GNET or finding the wrong" + echo "*** version of GNET. If it is not finding GNET, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GNET is incorrectly installed."]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GNET_CFLAGS="" + GNET_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GNET_CFLAGS) + AC_SUBST(GNET_LIBS) + rm -f conf.gnettest +]) + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..131d3ee --- /dev/null +++ b/autogen.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Run this to generate all the initial makefiles. +# +# $Id$ + +DIE=true +PROJECT="scli" + + +VER=`autoconf --version | grep '^autoconf' | sed 's/.*)//'` +case "$VER" in +0* | 1\.* | 2\.[0-9] | 2\.[0-9][a-z]* | \ +2\.1[0-2] | 2\.1[0-2][a-z]* ) + cat >&2 <<_EOF_ + + You must have autoconf 2.13 or later installed to compile $PROJECT. + Download the appropriate package for your distribution/OS, + or get the source tarball at ftp://ftp.gnu.org/pub/gnu/autoconf/ +_EOF_ + DIE="exit 1" + ;; +esac + + +VER=`automake --version | grep '^automake' | sed 's/.*)//'` +case "$VER" in +0* | 1\.[0-3] | 1\.[0-3][a-z]* ) + + cat >&2 <<_EOF_ + + You must have automake 1.4 or later installed to compile $PROJECT. + Download the appropriate package for your distribution/OS, + or get the source tarball at ftp://ftp.gnu.org/pub/gnu/automake/ +_EOF_ + DIE="exit 1" + ;; +esac + + +$DIE + +if test -z "$*"; then + echo "Running ./configure with no arguments. If you wish to pass any," + echo "please specify them on the $0 command line." +fi + +#aclocal_flags="`./aclocal-flags`" +aclocal_flags="-I /usr/local/share/aclocal" +aclocalinclude="$ACLOCAL_FLAGS $aclocal_flags"; \ +echo aclocal $aclocalinclude +aclocal $aclocalinclude || exit 1 +echo autoheader +autoheader || exit 1 +echo automake --add-missing --gnu $am_opt +automake --add-missing --gnu $am_opt || exit 1 +echo autoconf +autoconf || exit 1 + +./configure "$@" || exit 1 + +echo +echo "Now type 'make' to compile $PROJECT." diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..09ee04c --- /dev/null +++ b/config.h.in @@ -0,0 +1,55 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..96b20c7 --- /dev/null +++ b/configure.ac @@ -0,0 +1,45 @@ +dnl Process this file with autoconf to produce a configure script. + +AC_INIT(src/gsnmp.h) +dnl Every other copy of the package version number gets its value from here +AM_INIT_AUTOMAKE(gsnmp, 0.1.0) + +dnl create a config.h file (Automake will add -DHAVE_CONFIG_H) +AM_CONFIG_HEADER(config.h) + +AC_SUBST(VERSION) + +ISODATE=`date +%Y-%m-%d` +AC_SUBST(ISODATE) + +AC_CANONICAL_HOST + +dnl Checks for programs. +AC_PROG_INSTALL +AC_PROG_CC + +AC_PROG_LIBTOOL + +dnl Checks for libraries. + +AM_PATH_GLIB_2_0(2.0.0) +AM_PATH_GNET_2_0(2.0.4) + +dnl Checks for header files. +dnl AC_HEADER_STDC +dnl AC_CHECK_HEADERS(unistd.h sys/param.h sys/time.h time.h sys/mkdev.h sys/sysmacros.h string.h memory.h fcntl.h dirent.h sys/ndir.h ndir.h alloca.h locale.h ) + +dnl jm_CHECK_TYPE_STRUCT_UTIMBUF +dnl AC_HEADER_MAJOR +dnl AC_FUNC_ALLOCA +dnl AC_STRUCT_TM +dnl AC_STRUCT_ST_BLOCKS +dnl AC_FUNC_CLOSEDIR_VOID +dnl AC_CHECK_FUNCS(mkfifo) +dnl AC_CHECK_FUNC(mknod) + +dnl Checks for typedefs, structures, and compiler characteristics. + +dnl Checks for library functions. + +AC_OUTPUT(Makefile src/Makefile tests/Makefile examples/Makefile gsnmp.lsm gsnmp.spec gsnmp.pc) diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 0000000..2c8adda --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,24 @@ +INCLUDES = $(GNET_CFLAGS) -I$(top_builddir)/src + +bin_PROGRAMS = gsnmp-ping gsnmp-stub-ping gsnmp-iftable gsnmp-walk atm + +gsnmp_ping_SOURCES = gsnmp-ping.c +gsnmp_ping_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) + +gsnmp_stub_ping_SOURCES = gsnmp-stub-ping.c snmpv2-mib.c snmpv2-mib.h +gsnmp_stub_ping_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) + +gsnmp_iftable_SOURCES = gsnmp-iftable.c if-mib.c if-mib.h ianaiftype-mib.c ianaiftype-mib.h +gsnmp_iftable_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) + +gsnmp_walk_SOURCES = gsnmp-walk.c +gsnmp_walk_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) + +atm_SOURCES = atm.c atm-mib.c atm-mib.h atm-tc-mib.c atm-tc-mib.h snmpv2-tc.c snmpv2-tc.h +atm_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) + diff --git a/examples/Makefile.in b/examples/Makefile.in new file mode 100644 index 0000000..21e1db3 --- /dev/null +++ b/examples/Makefile.in @@ -0,0 +1,424 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AR = @AR@ +AS = @AS@ +CC = @CC@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GNET_CFLAGS = @GNET_CFLAGS@ +GNET_LIBS = @GNET_LIBS@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +HAVE_LIB = @HAVE_LIB@ +ISODATE = @ISODATE@ +LIB = @LIB@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIB = @LTLIB@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RC = @RC@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +INCLUDES = $(GNET_CFLAGS) -I$(top_builddir)/src + +bin_PROGRAMS = gsnmp-ping gsnmp-stub-ping gsnmp-iftable gsnmp-walk atm + +gsnmp_ping_SOURCES = gsnmp-ping.c +gsnmp_ping_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + + +gsnmp_stub_ping_SOURCES = gsnmp-stub-ping.c snmpv2-mib.c snmpv2-mib.h +gsnmp_stub_ping_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + + +gsnmp_iftable_SOURCES = gsnmp-iftable.c if-mib.c if-mib.h ianaiftype-mib.c ianaiftype-mib.h +gsnmp_iftable_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + + +gsnmp_walk_SOURCES = gsnmp-walk.c +gsnmp_walk_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + + +atm_SOURCES = atm.c atm-mib.c atm-mib.h atm-tc-mib.c atm-tc-mib.h snmpv2-tc.c snmpv2-tc.h +atm_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = gsnmp-ping$(EXEEXT) gsnmp-stub-ping$(EXEEXT) \ +gsnmp-iftable$(EXEEXT) gsnmp-walk$(EXEEXT) atm$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +gsnmp_ping_OBJECTS = gsnmp-ping.$(OBJEXT) +gsnmp_ping_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +gsnmp_ping_LDFLAGS = +gsnmp_stub_ping_OBJECTS = gsnmp-stub-ping.$(OBJEXT) \ +snmpv2-mib.$(OBJEXT) +gsnmp_stub_ping_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +gsnmp_stub_ping_LDFLAGS = +gsnmp_iftable_OBJECTS = gsnmp-iftable.$(OBJEXT) if-mib.$(OBJEXT) \ +ianaiftype-mib.$(OBJEXT) +gsnmp_iftable_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +gsnmp_iftable_LDFLAGS = +gsnmp_walk_OBJECTS = gsnmp-walk.$(OBJEXT) +gsnmp_walk_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +gsnmp_walk_LDFLAGS = +atm_OBJECTS = atm.$(OBJEXT) atm-mib.$(OBJEXT) atm-tc-mib.$(OBJEXT) \ +snmpv2-tc.$(OBJEXT) +atm_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +atm_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/atm-mib.P .deps/atm-tc-mib.P .deps/atm.P \ +.deps/gsnmp-iftable.P .deps/gsnmp-ping.P .deps/gsnmp-stub-ping.P \ +.deps/gsnmp-walk.P .deps/ianaiftype-mib.P .deps/if-mib.P \ +.deps/snmpv2-mib.P .deps/snmpv2-tc.P +SOURCES = $(gsnmp_ping_SOURCES) $(gsnmp_stub_ping_SOURCES) $(gsnmp_iftable_SOURCES) $(gsnmp_walk_SOURCES) $(atm_SOURCES) +OBJECTS = $(gsnmp_ping_OBJECTS) $(gsnmp_stub_ping_OBJECTS) $(gsnmp_iftable_OBJECTS) $(gsnmp_walk_OBJECTS) $(atm_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +gsnmp-ping$(EXEEXT): $(gsnmp_ping_OBJECTS) $(gsnmp_ping_DEPENDENCIES) + @rm -f gsnmp-ping$(EXEEXT) + $(LINK) $(gsnmp_ping_LDFLAGS) $(gsnmp_ping_OBJECTS) $(gsnmp_ping_LDADD) $(LIBS) + +gsnmp-stub-ping$(EXEEXT): $(gsnmp_stub_ping_OBJECTS) $(gsnmp_stub_ping_DEPENDENCIES) + @rm -f gsnmp-stub-ping$(EXEEXT) + $(LINK) $(gsnmp_stub_ping_LDFLAGS) $(gsnmp_stub_ping_OBJECTS) $(gsnmp_stub_ping_LDADD) $(LIBS) + +gsnmp-iftable$(EXEEXT): $(gsnmp_iftable_OBJECTS) $(gsnmp_iftable_DEPENDENCIES) + @rm -f gsnmp-iftable$(EXEEXT) + $(LINK) $(gsnmp_iftable_LDFLAGS) $(gsnmp_iftable_OBJECTS) $(gsnmp_iftable_LDADD) $(LIBS) + +gsnmp-walk$(EXEEXT): $(gsnmp_walk_OBJECTS) $(gsnmp_walk_DEPENDENCIES) + @rm -f gsnmp-walk$(EXEEXT) + $(LINK) $(gsnmp_walk_LDFLAGS) $(gsnmp_walk_OBJECTS) $(gsnmp_walk_LDADD) $(LIBS) + +atm$(EXEEXT): $(atm_OBJECTS) $(atm_DEPENDENCIES) + @rm -f atm$(EXEEXT) + $(LINK) $(atm_LDFLAGS) $(atm_OBJECTS) $(atm_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = examples + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu examples/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic \ + clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/atm-mib.c b/examples/atm-mib.c new file mode 100644 index 0000000..f3eab1c --- /dev/null +++ b/examples/atm-mib.c @@ -0,0 +1,2147 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli ATM-MIB + * + * Derived from ATM-MIB: + * This is the MIB Module for ATM and AAL5-related + * objects for managing ATM interfaces, ATM virtual + * links, ATM cross-connects, AAL5 entities, and + * and AAL5 connections. + * + * Revision 1998-10-19 12:00: + * The initial revision of this module was published + * as RFC 1695. Key revisions include: + * o Textual Conventions and OBJECT IDENTITIES have + * been moved to a separate MIB module. + * o Applicability of objects to PVCs, SVCs and Soft + * PVCs has been clarified. + * o DEFVAL clauses have been added. + * o The relationship of ifIndex values with different + * layers and sublayers related to ATM has been + * clarified. + * o atmTrafficQosClass has been deprecated + * and replaced with atmServiceCategory. + * o atmInterfaceCurrentMaxVpiBits and + * atmInterfaceCurrentMaxVciBits have been added with + * a description on their relationship with other + * objects. + * o atmInterfaceAddressType and atmInterfaceAdminAddress + * have been deprecated and replaced by + * atmInterfaceSubscrAddress. + * o atmInterfaceTCAlarmState has been clarified. + * o atmTrafficDescrParamIndexNext has been introduced + * in order to provide a manager a free + * atmTrafficDescrParamIndex value. + * o The atmTrafficFrameDiscard capability has been added. + * o A connection topology type (atmVpl/VclCastType) and + * a call control type (atmVpl/VclConnKind) have been + * added. + * o aal2 has been added to atmVccAalType. + * + * Revision 1994-06-07 22:45: + * The RFC1695 version of this MIB module. + * + * $Id$ + */ + +#include "atm-mib.h" + +GNetSnmpEnum const atm_mib_enums_atmInterfaceAddressType[] = { + { ATM_MIB_ATMINTERFACEADDRESSTYPE_PRIVATE, "private" }, + { ATM_MIB_ATMINTERFACEADDRESSTYPE_NSAPE164, "nsapE164" }, + { ATM_MIB_ATMINTERFACEADDRESSTYPE_NATIVEE164, "nativeE164" }, + { ATM_MIB_ATMINTERFACEADDRESSTYPE_OTHER, "other" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_mib_enums_atmInterfaceDs3PlcpAlarmState[] = { + { ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_NOALARM, "noAlarm" }, + { ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_RECEIVEDFARENDALARM, "receivedFarEndAlarm" }, + { ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_INCOMINGLOF, "incomingLOF" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_mib_enums_atmInterfaceTCAlarmState[] = { + { ATM_MIB_ATMINTERFACETCALARMSTATE_NOALARM, "noAlarm" }, + { ATM_MIB_ATMINTERFACETCALARMSTATE_LCDFAILURE, "lcdFailure" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_mib_enums_atmVccAalType[] = { + { ATM_MIB_ATMVCCAALTYPE_AAL1, "aal1" }, + { ATM_MIB_ATMVCCAALTYPE_AAL34, "aal34" }, + { ATM_MIB_ATMVCCAALTYPE_AAL5, "aal5" }, + { ATM_MIB_ATMVCCAALTYPE_OTHER, "other" }, + { ATM_MIB_ATMVCCAALTYPE_UNKNOWN, "unknown" }, + { ATM_MIB_ATMVCCAALTYPE_AAL2, "aal2" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_mib_enums_atmVccAal5EncapsType[] = { + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXROUTEDPROTOCOL, "vcMultiplexRoutedProtocol" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8023, "vcMultiplexBridgedProtocol8023" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8025, "vcMultiplexBridgedProtocol8025" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8026, "vcMultiplexBridgedProtocol8026" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXLANEMULATION8023, "vcMultiplexLANemulation8023" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXLANEMULATION8025, "vcMultiplexLANemulation8025" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_LLCENCAPSULATION, "llcEncapsulation" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_MULTIPROTOCOLFRAMERELAYSSCS, "multiprotocolFrameRelaySscs" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_OTHER, "other" }, + { ATM_MIB_ATMVCCAAL5ENCAPSTYPE_UNKNOWN, "unknown" }, + { 0, NULL } +}; + + +static gint32 atmVpCrossConnectIndexNext_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVcCrossConnectIndexNext_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmTrafficDescrParamIndexNext_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmInterfaceMaxVpcs_constraints[] = {0L, 4096L, 0, 0}; +static gint32 atmInterfaceMaxVccs_constraints[] = {0L, 65536L, 0, 0}; +static gint32 atmInterfaceConfVpcs_constraints[] = {0L, 4096L, 0, 0}; +static gint32 atmInterfaceConfVccs_constraints[] = {0L, 65536L, 0, 0}; +static gint32 atmInterfaceMaxActiveVpiBits_constraints[] = {0L, 12L, 0, 0}; +static gint32 atmInterfaceMaxActiveVciBits_constraints[] = {0L, 16L, 0, 0}; +static gint32 atmInterfaceIlmiVpi_constraints[] = {0L, 4095L, 0, 0}; +static gint32 atmInterfaceIlmiVci_constraints[] = {0L, 65535L, 0, 0}; +static guint16 atmInterfaceAdminAddress_constraints[] = {0U, 40U, 0, 0}; +static guint16 atmInterfaceMyNeighborIpAddress_constraints[] = {4U, 4U, 0, 0}; +static guint16 atmInterfaceMyNeighborIfName_constraints[] = {0U, 255U, 0, 0}; +static gint32 atmInterfaceCurrentMaxVpiBits_constraints[] = {0L, 12L, 0, 0}; +static gint32 atmInterfaceCurrentMaxVciBits_constraints[] = {0L, 16L, 0, 0}; +static guint16 atmInterfaceSubscrAddress_constraints[] = {0U, 40U, 0, 0}; +static gint32 atmTrafficQoSClass_constraints[] = {0L, 255L, 0, 0}; +static gint32 atmVplReceiveTrafficDescrIndex_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVplTransmitTrafficDescrIndex_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVplCrossConnectIdentifier_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVclReceiveTrafficDescrIndex_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVclTransmitTrafficDescrIndex_constraints[] = {0L, 2147483647L, 0, 0}; +static gint32 atmVccAal5CpcsTransmitSduSize_constraints[] = {1L, 65535L, 0, 0}; +static gint32 atmVccAal5CpcsReceiveSduSize_constraints[] = {1L, 65535L, 0, 0}; +static gint32 atmVclCrossConnectIdentifier_constraints[] = {0L, 2147483647L, 0, 0}; + + +static guint32 const atmMIBObjects_oid[] = {1, 3, 6, 1, 2, 1, 37, 1}; + +static GNetSnmpAttribute atmMIBObjects_attr[] = { + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPCROSSCONNECTINDEXNEXT, "atmVpCrossConnectIndexNext", + atmVpCrossConnectIndexNext_constraints, + G_STRUCT_OFFSET(atm_mib_atmMIBObjects_t, atmVpCrossConnectIndexNext), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCROSSCONNECTINDEXNEXT, "atmVcCrossConnectIndexNext", + atmVcCrossConnectIndexNext_constraints, + G_STRUCT_OFFSET(atm_mib_atmMIBObjects_t, atmVcCrossConnectIndexNext), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAMINDEXNEXT, "atmTrafficDescrParamIndexNext", + atmTrafficDescrParamIndexNext_constraints, + G_STRUCT_OFFSET(atm_mib_atmMIBObjects_t, atmTrafficDescrParamIndexNext), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmInterfaceConfEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 2, 1}; + +static GNetSnmpAttribute atmInterfaceConfEntry_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEMAXVPCS, "atmInterfaceMaxVpcs", + atmInterfaceMaxVpcs_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMaxVpcs), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEMAXVCCS, "atmInterfaceMaxVccs", + atmInterfaceMaxVccs_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMaxVccs), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACECONFVPCS, "atmInterfaceConfVpcs", + atmInterfaceConfVpcs_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceConfVpcs), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACECONFVCCS, "atmInterfaceConfVccs", + atmInterfaceConfVccs_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceConfVccs), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEMAXACTIVEVPIBITS, "atmInterfaceMaxActiveVpiBits", + atmInterfaceMaxActiveVpiBits_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMaxActiveVpiBits), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEMAXACTIVEVCIBITS, "atmInterfaceMaxActiveVciBits", + atmInterfaceMaxActiveVciBits_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMaxActiveVciBits), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEILMIVPI, "atmInterfaceIlmiVpi", + atmInterfaceIlmiVpi_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceIlmiVpi), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEILMIVCI, "atmInterfaceIlmiVci", + atmInterfaceIlmiVci_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceIlmiVci), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 9, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEADDRESSTYPE, "atmInterfaceAddressType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceAddressType), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + ATM_MIB_ATMINTERFACEADMINADDRESS, "atmInterfaceAdminAddress", + atmInterfaceAdminAddress_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceAdminAddress), + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, _atmInterfaceAdminAddressLength), + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_IPADDRESS, + ATM_MIB_ATMINTERFACEMYNEIGHBORIPADDRESS, "atmInterfaceMyNeighborIpAddress", + atmInterfaceMyNeighborIpAddress_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMyNeighborIpAddress), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 12, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + ATM_MIB_ATMINTERFACEMYNEIGHBORIFNAME, "atmInterfaceMyNeighborIfName", + atmInterfaceMyNeighborIfName_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceMyNeighborIfName), + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, _atmInterfaceMyNeighborIfNameLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 13, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACECURRENTMAXVPIBITS, "atmInterfaceCurrentMaxVpiBits", + atmInterfaceCurrentMaxVpiBits_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceCurrentMaxVpiBits), + 0, + 0 }, + { 14, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACECURRENTMAXVCIBITS, "atmInterfaceCurrentMaxVciBits", + atmInterfaceCurrentMaxVciBits_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceCurrentMaxVciBits), + 0, + 0 }, + { 15, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + ATM_MIB_ATMINTERFACESUBSCRADDRESS, "atmInterfaceSubscrAddress", + atmInterfaceSubscrAddress_constraints, + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, atmInterfaceSubscrAddress), + G_STRUCT_OFFSET(atm_mib_atmInterfaceConfEntry_t, _atmInterfaceSubscrAddressLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmInterfaceDs3PlcpEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 3, 1}; + +static GNetSnmpAttribute atmInterfaceDs3PlcpEntry_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_ATMINTERFACEDS3PLCPSEFSS, "atmInterfaceDs3PlcpSEFSs", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceDs3PlcpEntry_t, atmInterfaceDs3PlcpSEFSs), + 0, + 0 }, + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE, "atmInterfaceDs3PlcpAlarmState", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceDs3PlcpEntry_t, atmInterfaceDs3PlcpAlarmState), + 0, + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_ATMINTERFACEDS3PLCPUASS, "atmInterfaceDs3PlcpUASs", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceDs3PlcpEntry_t, atmInterfaceDs3PlcpUASs), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmInterfaceTCEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 4, 1}; + +static GNetSnmpAttribute atmInterfaceTCEntry_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_ATMINTERFACEOCDEVENTS, "atmInterfaceOCDEvents", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceTCEntry_t, atmInterfaceOCDEvents), + 0, + 0 }, + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMINTERFACETCALARMSTATE, "atmInterfaceTCAlarmState", + NULL, + G_STRUCT_OFFSET(atm_mib_atmInterfaceTCEntry_t, atmInterfaceTCAlarmState), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmTrafficDescrParamEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 5, 1}; + +static GNetSnmpAttribute atmTrafficDescrParamEntry_attr[] = { + { 2, GNET_SNMP_VARBIND_TYPE_OBJECTID, + ATM_MIB_ATMTRAFFICDESCRTYPE, "atmTrafficDescrType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrType), + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, _atmTrafficDescrTypeLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAM1, "atmTrafficDescrParam1", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrParam1), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAM2, "atmTrafficDescrParam2", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrParam2), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 5, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAM3, "atmTrafficDescrParam3", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrParam3), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAM4, "atmTrafficDescrParam4", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrParam4), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRPARAM5, "atmTrafficDescrParam5", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrParam5), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICQOSCLASS, "atmTrafficQoSClass", + atmTrafficQoSClass_constraints, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficQoSClass), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 9, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICDESCRROWSTATUS, "atmTrafficDescrRowStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficDescrRowStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 10, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMSERVICECATEGORY, "atmServiceCategory", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmServiceCategory), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 11, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMTRAFFICFRAMEDISCARD, "atmTrafficFrameDiscard", + NULL, + G_STRUCT_OFFSET(atm_mib_atmTrafficDescrParamEntry_t, atmTrafficFrameDiscard), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmVplEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 6, 1}; + +static GNetSnmpAttribute atmVplEntry_attr[] = { + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLADMINSTATUS, "atmVplAdminStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplAdminStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLOPERSTATUS, "atmVplOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplOperStatus), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVPLLASTCHANGE, "atmVplLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplLastChange), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLRECEIVETRAFFICDESCRINDEX, "atmVplReceiveTrafficDescrIndex", + atmVplReceiveTrafficDescrIndex_constraints, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplReceiveTrafficDescrIndex), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLTRANSMITTRAFFICDESCRINDEX, "atmVplTransmitTrafficDescrIndex", + atmVplTransmitTrafficDescrIndex_constraints, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplTransmitTrafficDescrIndex), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLCROSSCONNECTIDENTIFIER, "atmVplCrossConnectIdentifier", + atmVplCrossConnectIdentifier_constraints, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplCrossConnectIdentifier), + 0, + 0 }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLROWSTATUS, "atmVplRowStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplRowStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 9, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLCASTTYPE, "atmVplCastType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplCastType), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 10, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPLCONNKIND, "atmVplConnKind", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVplEntry_t, atmVplConnKind), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmVclEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 7, 1}; + +static GNetSnmpAttribute atmVclEntry_attr[] = { + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLADMINSTATUS, "atmVclAdminStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclAdminStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLOPERSTATUS, "atmVclOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclOperStatus), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVCLLASTCHANGE, "atmVclLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclLastChange), + 0, + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLRECEIVETRAFFICDESCRINDEX, "atmVclReceiveTrafficDescrIndex", + atmVclReceiveTrafficDescrIndex_constraints, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclReceiveTrafficDescrIndex), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLTRANSMITTRAFFICDESCRINDEX, "atmVclTransmitTrafficDescrIndex", + atmVclTransmitTrafficDescrIndex_constraints, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclTransmitTrafficDescrIndex), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCAALTYPE, "atmVccAalType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVccAalType), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 9, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCAAL5CPCSTRANSMITSDUSIZE, "atmVccAal5CpcsTransmitSduSize", + atmVccAal5CpcsTransmitSduSize_constraints, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVccAal5CpcsTransmitSduSize), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 10, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCAAL5CPCSRECEIVESDUSIZE, "atmVccAal5CpcsReceiveSduSize", + atmVccAal5CpcsReceiveSduSize_constraints, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVccAal5CpcsReceiveSduSize), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 11, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCAAL5ENCAPSTYPE, "atmVccAal5EncapsType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVccAal5EncapsType), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 12, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLCROSSCONNECTIDENTIFIER, "atmVclCrossConnectIdentifier", + atmVclCrossConnectIdentifier_constraints, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclCrossConnectIdentifier), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLROWSTATUS, "atmVclRowStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclRowStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 14, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLCASTTYPE, "atmVclCastType", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclCastType), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 15, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCLCONNKIND, "atmVclConnKind", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVclEntry_t, atmVclConnKind), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmVpCrossConnectEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 9, 1}; + +static GNetSnmpAttribute atmVpCrossConnectEntry_attr[] = { + { 6, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPCROSSCONNECTADMINSTATUS, "atmVpCrossConnectAdminStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectAdminStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPCROSSCONNECTL2HOPERSTATUS, "atmVpCrossConnectL2HOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectL2HOperStatus), + 0, + 0 }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPCROSSCONNECTH2LOPERSTATUS, "atmVpCrossConnectH2LOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectH2LOperStatus), + 0, + 0 }, + { 9, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVPCROSSCONNECTL2HLASTCHANGE, "atmVpCrossConnectL2HLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectL2HLastChange), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVPCROSSCONNECTH2LLASTCHANGE, "atmVpCrossConnectH2LLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectH2LLastChange), + 0, + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVPCROSSCONNECTROWSTATUS, "atmVpCrossConnectRowStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVpCrossConnectEntry_t, atmVpCrossConnectRowStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const atmVcCrossConnectEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 11, 1}; + +static GNetSnmpAttribute atmVcCrossConnectEntry_attr[] = { + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCROSSCONNECTADMINSTATUS, "atmVcCrossConnectAdminStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectAdminStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 9, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCROSSCONNECTL2HOPERSTATUS, "atmVcCrossConnectL2HOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectL2HOperStatus), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCROSSCONNECTH2LOPERSTATUS, "atmVcCrossConnectH2LOperStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectH2LOperStatus), + 0, + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVCCROSSCONNECTL2HLASTCHANGE, "atmVcCrossConnectL2HLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectL2HLastChange), + 0, + 0 }, + { 12, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ATM_MIB_ATMVCCROSSCONNECTH2LLASTCHANGE, "atmVcCrossConnectH2LLastChange", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectH2LLastChange), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_INTEGER32, + ATM_MIB_ATMVCCROSSCONNECTROWSTATUS, "atmVcCrossConnectRowStatus", + NULL, + G_STRUCT_OFFSET(atm_mib_atmVcCrossConnectEntry_t, atmVcCrossConnectRowStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const aal5VccEntry_oid[] = {1, 3, 6, 1, 2, 1, 37, 1, 12, 1}; + +static GNetSnmpAttribute aal5VccEntry_attr[] = { + { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_AAL5VCCCRCERRORS, "aal5VccCrcErrors", + NULL, + G_STRUCT_OFFSET(atm_mib_aal5VccEntry_t, aal5VccCrcErrors), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_AAL5VCCSARTIMEOUTS, "aal5VccSarTimeOuts", + NULL, + G_STRUCT_OFFSET(atm_mib_aal5VccEntry_t, aal5VccSarTimeOuts), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_COUNTER32, + ATM_MIB_AAL5VCCOVERSIZEDSDUS, "aal5VccOverSizedSDUs", + NULL, + G_STRUCT_OFFSET(atm_mib_aal5VccEntry_t, aal5VccOverSizedSDUs), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + + +atm_mib_atmMIBObjects_t * +atm_mib_new_atmMIBObjects() +{ + atm_mib_atmMIBObjects_t *atmMIBObjects; + + atmMIBObjects = (atm_mib_atmMIBObjects_t *) g_malloc0(sizeof(atm_mib_atmMIBObjects_t) + sizeof(gpointer)); + return atmMIBObjects; +} + +static inline atm_mib_atmMIBObjects_t * +assign_atmMIBObjects(GList *vbl) +{ + atm_mib_atmMIBObjects_t *atmMIBObjects; + char *p; + + atmMIBObjects = atm_mib_new_atmMIBObjects(); + p = (char *) atmMIBObjects + sizeof(atm_mib_atmMIBObjects_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, atmMIBObjects_oid, G_N_ELEMENTS(atmMIBObjects_oid), + atmMIBObjects_attr, atmMIBObjects); + + return atmMIBObjects; +} + +void +atm_mib_get_atmMIBObjects(GNetSnmp *s, atm_mib_atmMIBObjects_t **atmMIBObjects, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 0}; + + *atmMIBObjects = NULL; + + gnet_snmp_attr_get(s, &in, base, 9, 8, atmMIBObjects_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmMIBObjects = assign_atmMIBObjects(out); + } +} + +void +atm_mib_free_atmMIBObjects(atm_mib_atmMIBObjects_t *atmMIBObjects) +{ + GList *vbl; + char *p; + + if (atmMIBObjects) { + p = (char *) atmMIBObjects + sizeof(atm_mib_atmMIBObjects_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmMIBObjects); + } +} + +atm_mib_atmInterfaceConfEntry_t * +atm_mib_new_atmInterfaceConfEntry() +{ + atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry; + + atmInterfaceConfEntry = (atm_mib_atmInterfaceConfEntry_t *) g_malloc0(sizeof(atm_mib_atmInterfaceConfEntry_t) + sizeof(gpointer)); + return atmInterfaceConfEntry; +} + +static inline int +unpack_atmInterfaceConfEntry(GNetSnmpVarBind *vb, atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmInterfaceConfEntry->ifIndex = vb->oid[idx++]; + if ((atmInterfaceConfEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmInterfaceConfEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + return idx; +} + +static inline atm_mib_atmInterfaceConfEntry_t * +assign_atmInterfaceConfEntry(GList *vbl) +{ + atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry; + char *p; + + atmInterfaceConfEntry = atm_mib_new_atmInterfaceConfEntry(); + p = (char *) atmInterfaceConfEntry + sizeof(atm_mib_atmInterfaceConfEntry_t); + * (GList **) p = vbl; + + if (unpack_atmInterfaceConfEntry((GNetSnmpVarBind *) vbl->data, atmInterfaceConfEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmInterfaceConfEntry"); + g_free(atmInterfaceConfEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmInterfaceConfEntry_oid, G_N_ELEMENTS(atmInterfaceConfEntry_oid), + atmInterfaceConfEntry_attr, atmInterfaceConfEntry); + + return atmInterfaceConfEntry; +} + +void +atm_mib_get_atmInterfaceConfTable(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t ***atmInterfaceConfEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 2, 1, 0}; + + *atmInterfaceConfEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmInterfaceConfEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmInterfaceConfEntry = (atm_mib_atmInterfaceConfEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmInterfaceConfEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmInterfaceConfEntry)[i] = assign_atmInterfaceConfEntry(row->data); + } + } +} + +void +atm_mib_get_atmInterfaceConfEntry(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t **atmInterfaceConfEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmInterfaceConfEntry_oid, sizeof(atmInterfaceConfEntry_oid)); + len = pack_atmInterfaceConfEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmInterfaceConfEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmInterfaceConfEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmInterfaceConfEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmInterfaceConfEntry = assign_atmInterfaceConfEntry(out); + } +} + +void +atm_mib_set_atmInterfaceConfEntry(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmInterfaceConfEntry_oid, sizeof(atmInterfaceConfEntry_oid)); + len = pack_atmInterfaceConfEntry(base, atmInterfaceConfEntry->ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmInterfaceConfEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmInterfaceConfEntry_attr, mask, atmInterfaceConfEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmInterfaceConfEntry(atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry) +{ + GList *vbl; + char *p; + + if (atmInterfaceConfEntry) { + p = (char *) atmInterfaceConfEntry + sizeof(atm_mib_atmInterfaceConfEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmInterfaceConfEntry); + } +} + +void +atm_mib_free_atmInterfaceConfTable(atm_mib_atmInterfaceConfEntry_t **atmInterfaceConfEntry) +{ + int i; + + if (atmInterfaceConfEntry) { + for (i = 0; atmInterfaceConfEntry[i]; i++) { + atm_mib_free_atmInterfaceConfEntry(atmInterfaceConfEntry[i]); + } + g_free(atmInterfaceConfEntry); + } +} + +atm_mib_atmInterfaceDs3PlcpEntry_t * +atm_mib_new_atmInterfaceDs3PlcpEntry() +{ + atm_mib_atmInterfaceDs3PlcpEntry_t *atmInterfaceDs3PlcpEntry; + + atmInterfaceDs3PlcpEntry = (atm_mib_atmInterfaceDs3PlcpEntry_t *) g_malloc0(sizeof(atm_mib_atmInterfaceDs3PlcpEntry_t) + sizeof(gpointer)); + return atmInterfaceDs3PlcpEntry; +} + +static inline int +unpack_atmInterfaceDs3PlcpEntry(GNetSnmpVarBind *vb, atm_mib_atmInterfaceDs3PlcpEntry_t *atmInterfaceDs3PlcpEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmInterfaceDs3PlcpEntry->ifIndex = vb->oid[idx++]; + if ((atmInterfaceDs3PlcpEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmInterfaceDs3PlcpEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + return idx; +} + +static inline atm_mib_atmInterfaceDs3PlcpEntry_t * +assign_atmInterfaceDs3PlcpEntry(GList *vbl) +{ + atm_mib_atmInterfaceDs3PlcpEntry_t *atmInterfaceDs3PlcpEntry; + char *p; + + atmInterfaceDs3PlcpEntry = atm_mib_new_atmInterfaceDs3PlcpEntry(); + p = (char *) atmInterfaceDs3PlcpEntry + sizeof(atm_mib_atmInterfaceDs3PlcpEntry_t); + * (GList **) p = vbl; + + if (unpack_atmInterfaceDs3PlcpEntry((GNetSnmpVarBind *) vbl->data, atmInterfaceDs3PlcpEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmInterfaceDs3PlcpEntry"); + g_free(atmInterfaceDs3PlcpEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmInterfaceDs3PlcpEntry_oid, G_N_ELEMENTS(atmInterfaceDs3PlcpEntry_oid), + atmInterfaceDs3PlcpEntry_attr, atmInterfaceDs3PlcpEntry); + + return atmInterfaceDs3PlcpEntry; +} + +void +atm_mib_get_atmInterfaceDs3PlcpTable(GNetSnmp *s, atm_mib_atmInterfaceDs3PlcpEntry_t ***atmInterfaceDs3PlcpEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 3, 1, 0}; + + *atmInterfaceDs3PlcpEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmInterfaceDs3PlcpEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmInterfaceDs3PlcpEntry = (atm_mib_atmInterfaceDs3PlcpEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmInterfaceDs3PlcpEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmInterfaceDs3PlcpEntry)[i] = assign_atmInterfaceDs3PlcpEntry(row->data); + } + } +} + +void +atm_mib_get_atmInterfaceDs3PlcpEntry(GNetSnmp *s, atm_mib_atmInterfaceDs3PlcpEntry_t **atmInterfaceDs3PlcpEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmInterfaceDs3PlcpEntry_oid, sizeof(atmInterfaceDs3PlcpEntry_oid)); + len = pack_atmInterfaceDs3PlcpEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmInterfaceDs3PlcpEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmInterfaceDs3PlcpEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmInterfaceDs3PlcpEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmInterfaceDs3PlcpEntry = assign_atmInterfaceDs3PlcpEntry(out); + } +} + +void +atm_mib_free_atmInterfaceDs3PlcpEntry(atm_mib_atmInterfaceDs3PlcpEntry_t *atmInterfaceDs3PlcpEntry) +{ + GList *vbl; + char *p; + + if (atmInterfaceDs3PlcpEntry) { + p = (char *) atmInterfaceDs3PlcpEntry + sizeof(atm_mib_atmInterfaceDs3PlcpEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmInterfaceDs3PlcpEntry); + } +} + +void +atm_mib_free_atmInterfaceDs3PlcpTable(atm_mib_atmInterfaceDs3PlcpEntry_t **atmInterfaceDs3PlcpEntry) +{ + int i; + + if (atmInterfaceDs3PlcpEntry) { + for (i = 0; atmInterfaceDs3PlcpEntry[i]; i++) { + atm_mib_free_atmInterfaceDs3PlcpEntry(atmInterfaceDs3PlcpEntry[i]); + } + g_free(atmInterfaceDs3PlcpEntry); + } +} + +atm_mib_atmInterfaceTCEntry_t * +atm_mib_new_atmInterfaceTCEntry() +{ + atm_mib_atmInterfaceTCEntry_t *atmInterfaceTCEntry; + + atmInterfaceTCEntry = (atm_mib_atmInterfaceTCEntry_t *) g_malloc0(sizeof(atm_mib_atmInterfaceTCEntry_t) + sizeof(gpointer)); + return atmInterfaceTCEntry; +} + +static inline int +unpack_atmInterfaceTCEntry(GNetSnmpVarBind *vb, atm_mib_atmInterfaceTCEntry_t *atmInterfaceTCEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmInterfaceTCEntry->ifIndex = vb->oid[idx++]; + if ((atmInterfaceTCEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmInterfaceTCEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + return idx; +} + +static inline atm_mib_atmInterfaceTCEntry_t * +assign_atmInterfaceTCEntry(GList *vbl) +{ + atm_mib_atmInterfaceTCEntry_t *atmInterfaceTCEntry; + char *p; + + atmInterfaceTCEntry = atm_mib_new_atmInterfaceTCEntry(); + p = (char *) atmInterfaceTCEntry + sizeof(atm_mib_atmInterfaceTCEntry_t); + * (GList **) p = vbl; + + if (unpack_atmInterfaceTCEntry((GNetSnmpVarBind *) vbl->data, atmInterfaceTCEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmInterfaceTCEntry"); + g_free(atmInterfaceTCEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmInterfaceTCEntry_oid, G_N_ELEMENTS(atmInterfaceTCEntry_oid), + atmInterfaceTCEntry_attr, atmInterfaceTCEntry); + + return atmInterfaceTCEntry; +} + +void +atm_mib_get_atmInterfaceTCTable(GNetSnmp *s, atm_mib_atmInterfaceTCEntry_t ***atmInterfaceTCEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 4, 1, 0}; + + *atmInterfaceTCEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmInterfaceTCEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmInterfaceTCEntry = (atm_mib_atmInterfaceTCEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmInterfaceTCEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmInterfaceTCEntry)[i] = assign_atmInterfaceTCEntry(row->data); + } + } +} + +void +atm_mib_get_atmInterfaceTCEntry(GNetSnmp *s, atm_mib_atmInterfaceTCEntry_t **atmInterfaceTCEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmInterfaceTCEntry_oid, sizeof(atmInterfaceTCEntry_oid)); + len = pack_atmInterfaceTCEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmInterfaceTCEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmInterfaceTCEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmInterfaceTCEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmInterfaceTCEntry = assign_atmInterfaceTCEntry(out); + } +} + +void +atm_mib_free_atmInterfaceTCEntry(atm_mib_atmInterfaceTCEntry_t *atmInterfaceTCEntry) +{ + GList *vbl; + char *p; + + if (atmInterfaceTCEntry) { + p = (char *) atmInterfaceTCEntry + sizeof(atm_mib_atmInterfaceTCEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmInterfaceTCEntry); + } +} + +void +atm_mib_free_atmInterfaceTCTable(atm_mib_atmInterfaceTCEntry_t **atmInterfaceTCEntry) +{ + int i; + + if (atmInterfaceTCEntry) { + for (i = 0; atmInterfaceTCEntry[i]; i++) { + atm_mib_free_atmInterfaceTCEntry(atmInterfaceTCEntry[i]); + } + g_free(atmInterfaceTCEntry); + } +} + +atm_mib_atmTrafficDescrParamEntry_t * +atm_mib_new_atmTrafficDescrParamEntry() +{ + atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry; + + atmTrafficDescrParamEntry = (atm_mib_atmTrafficDescrParamEntry_t *) g_malloc0(sizeof(atm_mib_atmTrafficDescrParamEntry_t) + sizeof(gpointer)); + return atmTrafficDescrParamEntry; +} + +static inline int +unpack_atmTrafficDescrParamEntry(GNetSnmpVarBind *vb, atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmTrafficDescrParamEntry->atmTrafficDescrParamIndex = vb->oid[idx++]; + if ((atmTrafficDescrParamEntry->atmTrafficDescrParamIndex < 1) + && (atmTrafficDescrParamEntry->atmTrafficDescrParamIndex < 0)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmTrafficDescrParamEntry(guint32 *base, gint32 atmTrafficDescrParamIndex) +{ + guint8 idx = 11; + + base[idx++] = atmTrafficDescrParamIndex; + return idx; +} + +static inline atm_mib_atmTrafficDescrParamEntry_t * +assign_atmTrafficDescrParamEntry(GList *vbl) +{ + atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry; + char *p; + + atmTrafficDescrParamEntry = atm_mib_new_atmTrafficDescrParamEntry(); + p = (char *) atmTrafficDescrParamEntry + sizeof(atm_mib_atmTrafficDescrParamEntry_t); + * (GList **) p = vbl; + + if (unpack_atmTrafficDescrParamEntry((GNetSnmpVarBind *) vbl->data, atmTrafficDescrParamEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmTrafficDescrParamEntry"); + g_free(atmTrafficDescrParamEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmTrafficDescrParamEntry_oid, G_N_ELEMENTS(atmTrafficDescrParamEntry_oid), + atmTrafficDescrParamEntry_attr, atmTrafficDescrParamEntry); + + return atmTrafficDescrParamEntry; +} + +void +atm_mib_get_atmTrafficDescrParamTable(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t ***atmTrafficDescrParamEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 5, 1, 0}; + + *atmTrafficDescrParamEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmTrafficDescrParamEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmTrafficDescrParamEntry = (atm_mib_atmTrafficDescrParamEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmTrafficDescrParamEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmTrafficDescrParamEntry)[i] = assign_atmTrafficDescrParamEntry(row->data); + } + } +} + +void +atm_mib_get_atmTrafficDescrParamEntry(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t **atmTrafficDescrParamEntry, gint32 atmTrafficDescrParamIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmTrafficDescrParamEntry_oid, sizeof(atmTrafficDescrParamEntry_oid)); + len = pack_atmTrafficDescrParamEntry(base, atmTrafficDescrParamIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmTrafficDescrParamEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmTrafficDescrParamEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmTrafficDescrParamEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmTrafficDescrParamEntry = assign_atmTrafficDescrParamEntry(out); + } +} + +void +atm_mib_set_atmTrafficDescrParamEntry(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmTrafficDescrParamEntry_oid, sizeof(atmTrafficDescrParamEntry_oid)); + len = pack_atmTrafficDescrParamEntry(base, atmTrafficDescrParamEntry->atmTrafficDescrParamIndex); + if (len < 0) { + g_warning("%s: invalid index values", "atmTrafficDescrParamEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmTrafficDescrParamEntry_attr, mask, atmTrafficDescrParamEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmTrafficDescrParamEntry(atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry) +{ + GList *vbl; + char *p; + + if (atmTrafficDescrParamEntry) { + p = (char *) atmTrafficDescrParamEntry + sizeof(atm_mib_atmTrafficDescrParamEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmTrafficDescrParamEntry); + } +} + +void +atm_mib_free_atmTrafficDescrParamTable(atm_mib_atmTrafficDescrParamEntry_t **atmTrafficDescrParamEntry) +{ + int i; + + if (atmTrafficDescrParamEntry) { + for (i = 0; atmTrafficDescrParamEntry[i]; i++) { + atm_mib_free_atmTrafficDescrParamEntry(atmTrafficDescrParamEntry[i]); + } + g_free(atmTrafficDescrParamEntry); + } +} + +atm_mib_atmVplEntry_t * +atm_mib_new_atmVplEntry() +{ + atm_mib_atmVplEntry_t *atmVplEntry; + + atmVplEntry = (atm_mib_atmVplEntry_t *) g_malloc0(sizeof(atm_mib_atmVplEntry_t) + sizeof(gpointer)); + return atmVplEntry; +} + +static inline int +unpack_atmVplEntry(GNetSnmpVarBind *vb, atm_mib_atmVplEntry_t *atmVplEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmVplEntry->ifIndex = vb->oid[idx++]; + if ((atmVplEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVplEntry->atmVplVpi = vb->oid[idx++]; + if ((atmVplEntry->atmVplVpi < 0 || atmVplEntry->atmVplVpi > 4095)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmVplEntry(guint32 *base, gint32 ifIndex, gint32 atmVplVpi) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + base[idx++] = atmVplVpi; + return idx; +} + +static inline atm_mib_atmVplEntry_t * +assign_atmVplEntry(GList *vbl) +{ + atm_mib_atmVplEntry_t *atmVplEntry; + char *p; + + atmVplEntry = atm_mib_new_atmVplEntry(); + p = (char *) atmVplEntry + sizeof(atm_mib_atmVplEntry_t); + * (GList **) p = vbl; + + if (unpack_atmVplEntry((GNetSnmpVarBind *) vbl->data, atmVplEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmVplEntry"); + g_free(atmVplEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmVplEntry_oid, G_N_ELEMENTS(atmVplEntry_oid), + atmVplEntry_attr, atmVplEntry); + + return atmVplEntry; +} + +void +atm_mib_get_atmVplTable(GNetSnmp *s, atm_mib_atmVplEntry_t ***atmVplEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 6, 1, 0}; + + *atmVplEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmVplEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmVplEntry = (atm_mib_atmVplEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmVplEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmVplEntry)[i] = assign_atmVplEntry(row->data); + } + } +} + +void +atm_mib_get_atmVplEntry(GNetSnmp *s, atm_mib_atmVplEntry_t **atmVplEntry, gint32 ifIndex, gint32 atmVplVpi, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVplEntry_oid, sizeof(atmVplEntry_oid)); + len = pack_atmVplEntry(base, ifIndex, atmVplVpi); + if (len < 0) { + g_warning("%s: invalid index values", "atmVplEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmVplEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmVplEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmVplEntry = assign_atmVplEntry(out); + } +} + +void +atm_mib_set_atmVplEntry(GNetSnmp *s, atm_mib_atmVplEntry_t *atmVplEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVplEntry_oid, sizeof(atmVplEntry_oid)); + len = pack_atmVplEntry(base, atmVplEntry->ifIndex, atmVplEntry->atmVplVpi); + if (len < 0) { + g_warning("%s: invalid index values", "atmVplEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmVplEntry_attr, mask, atmVplEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmVplEntry(atm_mib_atmVplEntry_t *atmVplEntry) +{ + GList *vbl; + char *p; + + if (atmVplEntry) { + p = (char *) atmVplEntry + sizeof(atm_mib_atmVplEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmVplEntry); + } +} + +void +atm_mib_free_atmVplTable(atm_mib_atmVplEntry_t **atmVplEntry) +{ + int i; + + if (atmVplEntry) { + for (i = 0; atmVplEntry[i]; i++) { + atm_mib_free_atmVplEntry(atmVplEntry[i]); + } + g_free(atmVplEntry); + } +} + +atm_mib_atmVclEntry_t * +atm_mib_new_atmVclEntry() +{ + atm_mib_atmVclEntry_t *atmVclEntry; + + atmVclEntry = (atm_mib_atmVclEntry_t *) g_malloc0(sizeof(atm_mib_atmVclEntry_t) + sizeof(gpointer)); + return atmVclEntry; +} + +static inline int +unpack_atmVclEntry(GNetSnmpVarBind *vb, atm_mib_atmVclEntry_t *atmVclEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmVclEntry->ifIndex = vb->oid[idx++]; + if ((atmVclEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVclEntry->atmVclVpi = vb->oid[idx++]; + if ((atmVclEntry->atmVclVpi < 0 || atmVclEntry->atmVclVpi > 4095)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVclEntry->atmVclVci = vb->oid[idx++]; + if ((atmVclEntry->atmVclVci < 0 || atmVclEntry->atmVclVci > 65535)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmVclEntry(guint32 *base, gint32 ifIndex, gint32 atmVclVpi, gint32 atmVclVci) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + base[idx++] = atmVclVpi; + base[idx++] = atmVclVci; + return idx; +} + +static inline atm_mib_atmVclEntry_t * +assign_atmVclEntry(GList *vbl) +{ + atm_mib_atmVclEntry_t *atmVclEntry; + char *p; + + atmVclEntry = atm_mib_new_atmVclEntry(); + p = (char *) atmVclEntry + sizeof(atm_mib_atmVclEntry_t); + * (GList **) p = vbl; + + if (unpack_atmVclEntry((GNetSnmpVarBind *) vbl->data, atmVclEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmVclEntry"); + g_free(atmVclEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmVclEntry_oid, G_N_ELEMENTS(atmVclEntry_oid), + atmVclEntry_attr, atmVclEntry); + + return atmVclEntry; +} + +void +atm_mib_get_atmVclTable(GNetSnmp *s, atm_mib_atmVclEntry_t ***atmVclEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 7, 1, 0}; + + *atmVclEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmVclEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmVclEntry = (atm_mib_atmVclEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmVclEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmVclEntry)[i] = assign_atmVclEntry(row->data); + } + } +} + +void +atm_mib_get_atmVclEntry(GNetSnmp *s, atm_mib_atmVclEntry_t **atmVclEntry, gint32 ifIndex, gint32 atmVclVpi, gint32 atmVclVci, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVclEntry_oid, sizeof(atmVclEntry_oid)); + len = pack_atmVclEntry(base, ifIndex, atmVclVpi, atmVclVci); + if (len < 0) { + g_warning("%s: invalid index values", "atmVclEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmVclEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmVclEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmVclEntry = assign_atmVclEntry(out); + } +} + +void +atm_mib_set_atmVclEntry(GNetSnmp *s, atm_mib_atmVclEntry_t *atmVclEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVclEntry_oid, sizeof(atmVclEntry_oid)); + len = pack_atmVclEntry(base, atmVclEntry->ifIndex, atmVclEntry->atmVclVpi, atmVclEntry->atmVclVci); + if (len < 0) { + g_warning("%s: invalid index values", "atmVclEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmVclEntry_attr, mask, atmVclEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmVclEntry(atm_mib_atmVclEntry_t *atmVclEntry) +{ + GList *vbl; + char *p; + + if (atmVclEntry) { + p = (char *) atmVclEntry + sizeof(atm_mib_atmVclEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmVclEntry); + } +} + +void +atm_mib_free_atmVclTable(atm_mib_atmVclEntry_t **atmVclEntry) +{ + int i; + + if (atmVclEntry) { + for (i = 0; atmVclEntry[i]; i++) { + atm_mib_free_atmVclEntry(atmVclEntry[i]); + } + g_free(atmVclEntry); + } +} + +atm_mib_atmVpCrossConnectEntry_t * +atm_mib_new_atmVpCrossConnectEntry() +{ + atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry; + + atmVpCrossConnectEntry = (atm_mib_atmVpCrossConnectEntry_t *) g_malloc0(sizeof(atm_mib_atmVpCrossConnectEntry_t) + sizeof(gpointer)); + return atmVpCrossConnectEntry; +} + +static inline int +unpack_atmVpCrossConnectEntry(GNetSnmpVarBind *vb, atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmVpCrossConnectEntry->atmVpCrossConnectIndex = vb->oid[idx++]; + if ((atmVpCrossConnectEntry->atmVpCrossConnectIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVpCrossConnectEntry->atmVpCrossConnectLowIfIndex = vb->oid[idx++]; + if ((atmVpCrossConnectEntry->atmVpCrossConnectLowIfIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVpCrossConnectEntry->atmVpCrossConnectLowVpi = vb->oid[idx++]; + if ((atmVpCrossConnectEntry->atmVpCrossConnectLowVpi < 0 || atmVpCrossConnectEntry->atmVpCrossConnectLowVpi > 4095)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVpCrossConnectEntry->atmVpCrossConnectHighIfIndex = vb->oid[idx++]; + if ((atmVpCrossConnectEntry->atmVpCrossConnectHighIfIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVpCrossConnectEntry->atmVpCrossConnectHighVpi = vb->oid[idx++]; + if ((atmVpCrossConnectEntry->atmVpCrossConnectHighVpi < 0 || atmVpCrossConnectEntry->atmVpCrossConnectHighVpi > 4095)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmVpCrossConnectEntry(guint32 *base, gint32 atmVpCrossConnectIndex, gint32 atmVpCrossConnectLowIfIndex, gint32 atmVpCrossConnectLowVpi, gint32 atmVpCrossConnectHighIfIndex, gint32 atmVpCrossConnectHighVpi) +{ + guint8 idx = 11; + + base[idx++] = atmVpCrossConnectIndex; + base[idx++] = atmVpCrossConnectLowIfIndex; + base[idx++] = atmVpCrossConnectLowVpi; + base[idx++] = atmVpCrossConnectHighIfIndex; + base[idx++] = atmVpCrossConnectHighVpi; + return idx; +} + +static inline atm_mib_atmVpCrossConnectEntry_t * +assign_atmVpCrossConnectEntry(GList *vbl) +{ + atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry; + char *p; + + atmVpCrossConnectEntry = atm_mib_new_atmVpCrossConnectEntry(); + p = (char *) atmVpCrossConnectEntry + sizeof(atm_mib_atmVpCrossConnectEntry_t); + * (GList **) p = vbl; + + if (unpack_atmVpCrossConnectEntry((GNetSnmpVarBind *) vbl->data, atmVpCrossConnectEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmVpCrossConnectEntry"); + g_free(atmVpCrossConnectEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmVpCrossConnectEntry_oid, G_N_ELEMENTS(atmVpCrossConnectEntry_oid), + atmVpCrossConnectEntry_attr, atmVpCrossConnectEntry); + + return atmVpCrossConnectEntry; +} + +void +atm_mib_get_atmVpCrossConnectTable(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t ***atmVpCrossConnectEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 9, 1, 0}; + + *atmVpCrossConnectEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmVpCrossConnectEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmVpCrossConnectEntry = (atm_mib_atmVpCrossConnectEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmVpCrossConnectEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmVpCrossConnectEntry)[i] = assign_atmVpCrossConnectEntry(row->data); + } + } +} + +void +atm_mib_get_atmVpCrossConnectEntry(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t **atmVpCrossConnectEntry, gint32 atmVpCrossConnectIndex, gint32 atmVpCrossConnectLowIfIndex, gint32 atmVpCrossConnectLowVpi, gint32 atmVpCrossConnectHighIfIndex, gint32 atmVpCrossConnectHighVpi, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVpCrossConnectEntry_oid, sizeof(atmVpCrossConnectEntry_oid)); + len = pack_atmVpCrossConnectEntry(base, atmVpCrossConnectIndex, atmVpCrossConnectLowIfIndex, atmVpCrossConnectLowVpi, atmVpCrossConnectHighIfIndex, atmVpCrossConnectHighVpi); + if (len < 0) { + g_warning("%s: invalid index values", "atmVpCrossConnectEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmVpCrossConnectEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmVpCrossConnectEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmVpCrossConnectEntry = assign_atmVpCrossConnectEntry(out); + } +} + +void +atm_mib_set_atmVpCrossConnectEntry(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVpCrossConnectEntry_oid, sizeof(atmVpCrossConnectEntry_oid)); + len = pack_atmVpCrossConnectEntry(base, atmVpCrossConnectEntry->atmVpCrossConnectIndex, atmVpCrossConnectEntry->atmVpCrossConnectLowIfIndex, atmVpCrossConnectEntry->atmVpCrossConnectLowVpi, atmVpCrossConnectEntry->atmVpCrossConnectHighIfIndex, atmVpCrossConnectEntry->atmVpCrossConnectHighVpi); + if (len < 0) { + g_warning("%s: invalid index values", "atmVpCrossConnectEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmVpCrossConnectEntry_attr, mask, atmVpCrossConnectEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmVpCrossConnectEntry(atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry) +{ + GList *vbl; + char *p; + + if (atmVpCrossConnectEntry) { + p = (char *) atmVpCrossConnectEntry + sizeof(atm_mib_atmVpCrossConnectEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmVpCrossConnectEntry); + } +} + +void +atm_mib_free_atmVpCrossConnectTable(atm_mib_atmVpCrossConnectEntry_t **atmVpCrossConnectEntry) +{ + int i; + + if (atmVpCrossConnectEntry) { + for (i = 0; atmVpCrossConnectEntry[i]; i++) { + atm_mib_free_atmVpCrossConnectEntry(atmVpCrossConnectEntry[i]); + } + g_free(atmVpCrossConnectEntry); + } +} + +atm_mib_atmVcCrossConnectEntry_t * +atm_mib_new_atmVcCrossConnectEntry() +{ + atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry; + + atmVcCrossConnectEntry = (atm_mib_atmVcCrossConnectEntry_t *) g_malloc0(sizeof(atm_mib_atmVcCrossConnectEntry_t) + sizeof(gpointer)); + return atmVcCrossConnectEntry; +} + +static inline int +unpack_atmVcCrossConnectEntry(GNetSnmpVarBind *vb, atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectIndex = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectLowIfIndex = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectLowIfIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectLowVpi = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectLowVpi < 0 || atmVcCrossConnectEntry->atmVcCrossConnectLowVpi > 4095)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectLowVci = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectLowVci < 0 || atmVcCrossConnectEntry->atmVcCrossConnectLowVci > 65535)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectHighIfIndex = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectHighIfIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectHighVpi = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectHighVpi < 0 || atmVcCrossConnectEntry->atmVcCrossConnectHighVpi > 4095)) { + return -1; + } + if (vb->oid_len < idx) return -1; + atmVcCrossConnectEntry->atmVcCrossConnectHighVci = vb->oid[idx++]; + if ((atmVcCrossConnectEntry->atmVcCrossConnectHighVci < 0 || atmVcCrossConnectEntry->atmVcCrossConnectHighVci > 65535)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_atmVcCrossConnectEntry(guint32 *base, gint32 atmVcCrossConnectIndex, gint32 atmVcCrossConnectLowIfIndex, gint32 atmVcCrossConnectLowVpi, gint32 atmVcCrossConnectLowVci, gint32 atmVcCrossConnectHighIfIndex, gint32 atmVcCrossConnectHighVpi, gint32 atmVcCrossConnectHighVci) +{ + guint8 idx = 11; + + base[idx++] = atmVcCrossConnectIndex; + base[idx++] = atmVcCrossConnectLowIfIndex; + base[idx++] = atmVcCrossConnectLowVpi; + base[idx++] = atmVcCrossConnectLowVci; + base[idx++] = atmVcCrossConnectHighIfIndex; + base[idx++] = atmVcCrossConnectHighVpi; + base[idx++] = atmVcCrossConnectHighVci; + return idx; +} + +static inline atm_mib_atmVcCrossConnectEntry_t * +assign_atmVcCrossConnectEntry(GList *vbl) +{ + atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry; + char *p; + + atmVcCrossConnectEntry = atm_mib_new_atmVcCrossConnectEntry(); + p = (char *) atmVcCrossConnectEntry + sizeof(atm_mib_atmVcCrossConnectEntry_t); + * (GList **) p = vbl; + + if (unpack_atmVcCrossConnectEntry((GNetSnmpVarBind *) vbl->data, atmVcCrossConnectEntry) < 0) { + g_warning("%s: invalid instance identifier", "atmVcCrossConnectEntry"); + g_free(atmVcCrossConnectEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, atmVcCrossConnectEntry_oid, G_N_ELEMENTS(atmVcCrossConnectEntry_oid), + atmVcCrossConnectEntry_attr, atmVcCrossConnectEntry); + + return atmVcCrossConnectEntry; +} + +void +atm_mib_get_atmVcCrossConnectTable(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t ***atmVcCrossConnectEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 11, 1, 0}; + + *atmVcCrossConnectEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, atmVcCrossConnectEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *atmVcCrossConnectEntry = (atm_mib_atmVcCrossConnectEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_atmVcCrossConnectEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*atmVcCrossConnectEntry)[i] = assign_atmVcCrossConnectEntry(row->data); + } + } +} + +void +atm_mib_get_atmVcCrossConnectEntry(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t **atmVcCrossConnectEntry, gint32 atmVcCrossConnectIndex, gint32 atmVcCrossConnectLowIfIndex, gint32 atmVcCrossConnectLowVpi, gint32 atmVcCrossConnectLowVci, gint32 atmVcCrossConnectHighIfIndex, gint32 atmVcCrossConnectHighVpi, gint32 atmVcCrossConnectHighVci, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVcCrossConnectEntry_oid, sizeof(atmVcCrossConnectEntry_oid)); + len = pack_atmVcCrossConnectEntry(base, atmVcCrossConnectIndex, atmVcCrossConnectLowIfIndex, atmVcCrossConnectLowVpi, atmVcCrossConnectLowVci, atmVcCrossConnectHighIfIndex, atmVcCrossConnectHighVpi, atmVcCrossConnectHighVci); + if (len < 0) { + g_warning("%s: invalid index values", "atmVcCrossConnectEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *atmVcCrossConnectEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, atmVcCrossConnectEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *atmVcCrossConnectEntry = assign_atmVcCrossConnectEntry(out); + } +} + +void +atm_mib_set_atmVcCrossConnectEntry(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, atmVcCrossConnectEntry_oid, sizeof(atmVcCrossConnectEntry_oid)); + len = pack_atmVcCrossConnectEntry(base, atmVcCrossConnectEntry->atmVcCrossConnectIndex, atmVcCrossConnectEntry->atmVcCrossConnectLowIfIndex, atmVcCrossConnectEntry->atmVcCrossConnectLowVpi, atmVcCrossConnectEntry->atmVcCrossConnectLowVci, atmVcCrossConnectEntry->atmVcCrossConnectHighIfIndex, atmVcCrossConnectEntry->atmVcCrossConnectHighVpi, atmVcCrossConnectEntry->atmVcCrossConnectHighVci); + if (len < 0) { + g_warning("%s: invalid index values", "atmVcCrossConnectEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, atmVcCrossConnectEntry_attr, mask, atmVcCrossConnectEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +atm_mib_free_atmVcCrossConnectEntry(atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry) +{ + GList *vbl; + char *p; + + if (atmVcCrossConnectEntry) { + p = (char *) atmVcCrossConnectEntry + sizeof(atm_mib_atmVcCrossConnectEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(atmVcCrossConnectEntry); + } +} + +void +atm_mib_free_atmVcCrossConnectTable(atm_mib_atmVcCrossConnectEntry_t **atmVcCrossConnectEntry) +{ + int i; + + if (atmVcCrossConnectEntry) { + for (i = 0; atmVcCrossConnectEntry[i]; i++) { + atm_mib_free_atmVcCrossConnectEntry(atmVcCrossConnectEntry[i]); + } + g_free(atmVcCrossConnectEntry); + } +} + +atm_mib_aal5VccEntry_t * +atm_mib_new_aal5VccEntry() +{ + atm_mib_aal5VccEntry_t *aal5VccEntry; + + aal5VccEntry = (atm_mib_aal5VccEntry_t *) g_malloc0(sizeof(atm_mib_aal5VccEntry_t) + sizeof(gpointer)); + return aal5VccEntry; +} + +static inline int +unpack_aal5VccEntry(GNetSnmpVarBind *vb, atm_mib_aal5VccEntry_t *aal5VccEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + aal5VccEntry->ifIndex = vb->oid[idx++]; + if ((aal5VccEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + aal5VccEntry->aal5VccVpi = vb->oid[idx++]; + if ((aal5VccEntry->aal5VccVpi < 0 || aal5VccEntry->aal5VccVpi > 4095)) { + return -1; + } + if (vb->oid_len < idx) return -1; + aal5VccEntry->aal5VccVci = vb->oid[idx++]; + if ((aal5VccEntry->aal5VccVci < 0 || aal5VccEntry->aal5VccVci > 65535)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_aal5VccEntry(guint32 *base, gint32 ifIndex, gint32 aal5VccVpi, gint32 aal5VccVci) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + base[idx++] = aal5VccVpi; + base[idx++] = aal5VccVci; + return idx; +} + +static inline atm_mib_aal5VccEntry_t * +assign_aal5VccEntry(GList *vbl) +{ + atm_mib_aal5VccEntry_t *aal5VccEntry; + char *p; + + aal5VccEntry = atm_mib_new_aal5VccEntry(); + p = (char *) aal5VccEntry + sizeof(atm_mib_aal5VccEntry_t); + * (GList **) p = vbl; + + if (unpack_aal5VccEntry((GNetSnmpVarBind *) vbl->data, aal5VccEntry) < 0) { + g_warning("%s: invalid instance identifier", "aal5VccEntry"); + g_free(aal5VccEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, aal5VccEntry_oid, G_N_ELEMENTS(aal5VccEntry_oid), + aal5VccEntry_attr, aal5VccEntry); + + return aal5VccEntry; +} + +void +atm_mib_get_aal5VccTable(GNetSnmp *s, atm_mib_aal5VccEntry_t ***aal5VccEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 37, 1, 12, 1, 0}; + + *aal5VccEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, aal5VccEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *aal5VccEntry = (atm_mib_aal5VccEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(atm_mib_aal5VccEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*aal5VccEntry)[i] = assign_aal5VccEntry(row->data); + } + } +} + +void +atm_mib_get_aal5VccEntry(GNetSnmp *s, atm_mib_aal5VccEntry_t **aal5VccEntry, gint32 ifIndex, gint32 aal5VccVpi, gint32 aal5VccVci, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, aal5VccEntry_oid, sizeof(aal5VccEntry_oid)); + len = pack_aal5VccEntry(base, ifIndex, aal5VccVpi, aal5VccVci); + if (len < 0) { + g_warning("%s: invalid index values", "aal5VccEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *aal5VccEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, aal5VccEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *aal5VccEntry = assign_aal5VccEntry(out); + } +} + +void +atm_mib_free_aal5VccEntry(atm_mib_aal5VccEntry_t *aal5VccEntry) +{ + GList *vbl; + char *p; + + if (aal5VccEntry) { + p = (char *) aal5VccEntry + sizeof(atm_mib_aal5VccEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(aal5VccEntry); + } +} + +void +atm_mib_free_aal5VccTable(atm_mib_aal5VccEntry_t **aal5VccEntry) +{ + int i; + + if (aal5VccEntry) { + for (i = 0; aal5VccEntry[i]; i++) { + atm_mib_free_aal5VccEntry(aal5VccEntry[i]); + } + g_free(aal5VccEntry); + } +} + + diff --git a/examples/atm-mib.h b/examples/atm-mib.h new file mode 100644 index 0000000..907c1ee --- /dev/null +++ b/examples/atm-mib.h @@ -0,0 +1,521 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli ATM-MIB + * + * Derived from ATM-MIB: + * This is the MIB Module for ATM and AAL5-related + * objects for managing ATM interfaces, ATM virtual + * links, ATM cross-connects, AAL5 entities, and + * and AAL5 connections. + * + * Revision 1998-10-19 12:00: + * The initial revision of this module was published + * as RFC 1695. Key revisions include: + * o Textual Conventions and OBJECT IDENTITIES have + * been moved to a separate MIB module. + * o Applicability of objects to PVCs, SVCs and Soft + * PVCs has been clarified. + * o DEFVAL clauses have been added. + * o The relationship of ifIndex values with different + * layers and sublayers related to ATM has been + * clarified. + * o atmTrafficQosClass has been deprecated + * and replaced with atmServiceCategory. + * o atmInterfaceCurrentMaxVpiBits and + * atmInterfaceCurrentMaxVciBits have been added with + * a description on their relationship with other + * objects. + * o atmInterfaceAddressType and atmInterfaceAdminAddress + * have been deprecated and replaced by + * atmInterfaceSubscrAddress. + * o atmInterfaceTCAlarmState has been clarified. + * o atmTrafficDescrParamIndexNext has been introduced + * in order to provide a manager a free + * atmTrafficDescrParamIndex value. + * o The atmTrafficFrameDiscard capability has been added. + * o A connection topology type (atmVpl/VclCastType) and + * a call control type (atmVpl/VclConnKind) have been + * added. + * o aal2 has been added to atmVccAalType. + * + * Revision 1994-06-07 22:45: + * The RFC1695 version of this MIB module. + * + * $Id$ + */ + +#ifndef _ATM_MIB_H_ +#define _ATM_MIB_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define ATM_MIB_ATMINTERFACEADDRESSTYPE_PRIVATE 1 +#define ATM_MIB_ATMINTERFACEADDRESSTYPE_NSAPE164 2 +#define ATM_MIB_ATMINTERFACEADDRESSTYPE_NATIVEE164 3 +#define ATM_MIB_ATMINTERFACEADDRESSTYPE_OTHER 4 + +extern GNetSnmpEnum const atm_mib_enums_atmInterfaceAddressType[]; + +#define ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_NOALARM 1 +#define ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_RECEIVEDFARENDALARM 2 +#define ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE_INCOMINGLOF 3 + +extern GNetSnmpEnum const atm_mib_enums_atmInterfaceDs3PlcpAlarmState[]; + +#define ATM_MIB_ATMINTERFACETCALARMSTATE_NOALARM 1 +#define ATM_MIB_ATMINTERFACETCALARMSTATE_LCDFAILURE 2 + +extern GNetSnmpEnum const atm_mib_enums_atmInterfaceTCAlarmState[]; + +#define ATM_MIB_ATMVCCAALTYPE_AAL1 1 +#define ATM_MIB_ATMVCCAALTYPE_AAL34 2 +#define ATM_MIB_ATMVCCAALTYPE_AAL5 3 +#define ATM_MIB_ATMVCCAALTYPE_OTHER 4 +#define ATM_MIB_ATMVCCAALTYPE_UNKNOWN 5 +#define ATM_MIB_ATMVCCAALTYPE_AAL2 6 + +extern GNetSnmpEnum const atm_mib_enums_atmVccAalType[]; + +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXROUTEDPROTOCOL 1 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8023 2 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8025 3 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXBRIDGEDPROTOCOL8026 4 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXLANEMULATION8023 5 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_VCMULTIPLEXLANEMULATION8025 6 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_LLCENCAPSULATION 7 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_MULTIPROTOCOLFRAMERELAYSSCS 8 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_OTHER 9 +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE_UNKNOWN 10 + +extern GNetSnmpEnum const atm_mib_enums_atmVccAal5EncapsType[]; + + +/* + * C type definitions for ATM-MIB::atmMIBObjects. + */ + +#define ATM_MIB_ATMVPCROSSCONNECTINDEXNEXT (1 << 0) +#define ATM_MIB_ATMVCCROSSCONNECTINDEXNEXT (1 << 1) +#define ATM_MIB_ATMTRAFFICDESCRPARAMINDEXNEXT (1 << 2) + +typedef struct { + gint32 *atmVpCrossConnectIndexNext; /* ro */ + gint32 *atmVcCrossConnectIndexNext; /* ro */ + gint32 *atmTrafficDescrParamIndexNext; /* ro */ +} atm_mib_atmMIBObjects_t; + +extern atm_mib_atmMIBObjects_t * +atm_mib_new_atmMIBObjects(void); + +extern void +atm_mib_get_atmMIBObjects(GNetSnmp *s, atm_mib_atmMIBObjects_t **atmMIBObjects, gint64 mask); + +extern void +atm_mib_free_atmMIBObjects(atm_mib_atmMIBObjects_t *atmMIBObjects); + +/* + * C type definitions for ATM-MIB::atmInterfaceConfEntry. + */ + +#define ATM_MIB_ATMINTERFACEMAXVPCS (1 << 0) +#define ATM_MIB_ATMINTERFACEMAXVCCS (1 << 1) +#define ATM_MIB_ATMINTERFACECONFVPCS (1 << 2) +#define ATM_MIB_ATMINTERFACECONFVCCS (1 << 3) +#define ATM_MIB_ATMINTERFACEMAXACTIVEVPIBITS (1 << 4) +#define ATM_MIB_ATMINTERFACEMAXACTIVEVCIBITS (1 << 5) +#define ATM_MIB_ATMINTERFACEILMIVPI (1 << 6) +#define ATM_MIB_ATMINTERFACEILMIVCI (1 << 7) +#define ATM_MIB_ATMINTERFACEADDRESSTYPE (1 << 8) +#define ATM_MIB_ATMINTERFACEADMINADDRESS (1 << 9) +#define ATM_MIB_ATMINTERFACEMYNEIGHBORIPADDRESS (1 << 10) +#define ATM_MIB_ATMINTERFACEMYNEIGHBORIFNAME (1 << 11) +#define ATM_MIB_ATMINTERFACECURRENTMAXVPIBITS (1 << 12) +#define ATM_MIB_ATMINTERFACECURRENTMAXVCIBITS (1 << 13) +#define ATM_MIB_ATMINTERFACESUBSCRADDRESS (1 << 14) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + gint32 *atmInterfaceMaxVpcs; /* rw */ + gint32 *atmInterfaceMaxVccs; /* rw */ + gint32 *atmInterfaceConfVpcs; /* ro */ + gint32 *atmInterfaceConfVccs; /* ro */ + gint32 *atmInterfaceMaxActiveVpiBits; /* rw */ + gint32 *atmInterfaceMaxActiveVciBits; /* rw */ + gint32 *atmInterfaceIlmiVpi; /* rw ATM-TC-MIB::AtmVpIdentifier */ + gint32 *atmInterfaceIlmiVci; /* rw ATM-TC-MIB::AtmVcIdentifier */ + gint32 *atmInterfaceAddressType; /* ro */ + guchar *atmInterfaceAdminAddress; /* ro ATM-TC-MIB::AtmAddr */ +#define ATM_MIB_ATMINTERFACEADMINADDRESSMINLENGTH 0 +#define ATM_MIB_ATMINTERFACEADMINADDRESSMAXLENGTH 40 + guint16 _atmInterfaceAdminAddressLength; + guchar *atmInterfaceMyNeighborIpAddress; /* rw SNMPv2-SMI::IpAddress */ +#define ATM_MIB_ATMINTERFACEMYNEIGHBORIPADDRESSLENGTH 4 + guchar *atmInterfaceMyNeighborIfName; /* rw SNMPv2-TC::DisplayString */ +#define ATM_MIB_ATMINTERFACEMYNEIGHBORIFNAMEMINLENGTH 0 +#define ATM_MIB_ATMINTERFACEMYNEIGHBORIFNAMEMAXLENGTH 255 + guint16 _atmInterfaceMyNeighborIfNameLength; + gint32 *atmInterfaceCurrentMaxVpiBits; /* ro */ + gint32 *atmInterfaceCurrentMaxVciBits; /* ro */ + guchar *atmInterfaceSubscrAddress; /* rw ATM-TC-MIB::AtmAddr */ +#define ATM_MIB_ATMINTERFACESUBSCRADDRESSMINLENGTH 0 +#define ATM_MIB_ATMINTERFACESUBSCRADDRESSMAXLENGTH 40 + guint16 _atmInterfaceSubscrAddressLength; +} atm_mib_atmInterfaceConfEntry_t; + +extern void +atm_mib_get_atmInterfaceConfTable(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t ***atmInterfaceConfEntry, gint64 mask); + +extern void +atm_mib_free_atmInterfaceConfTable(atm_mib_atmInterfaceConfEntry_t **atmInterfaceConfEntry); + +extern atm_mib_atmInterfaceConfEntry_t * +atm_mib_new_atmInterfaceConfEntry(void); + +extern void +atm_mib_get_atmInterfaceConfEntry(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t **atmInterfaceConfEntry, gint32 ifIndex, gint64 mask); + +extern void +atm_mib_set_atmInterfaceConfEntry(GNetSnmp *s, atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry, gint64 mask); + +extern void +atm_mib_free_atmInterfaceConfEntry(atm_mib_atmInterfaceConfEntry_t *atmInterfaceConfEntry); + +/* + * C type definitions for ATM-MIB::atmInterfaceDs3PlcpEntry. + */ + +#define ATM_MIB_ATMINTERFACEDS3PLCPSEFSS (1 << 0) +#define ATM_MIB_ATMINTERFACEDS3PLCPALARMSTATE (1 << 1) +#define ATM_MIB_ATMINTERFACEDS3PLCPUASS (1 << 2) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + guint32 *atmInterfaceDs3PlcpSEFSs; /* ro SNMPv2-SMI::Counter32 */ + gint32 *atmInterfaceDs3PlcpAlarmState; /* ro */ + guint32 *atmInterfaceDs3PlcpUASs; /* ro SNMPv2-SMI::Counter32 */ +} atm_mib_atmInterfaceDs3PlcpEntry_t; + +extern void +atm_mib_get_atmInterfaceDs3PlcpTable(GNetSnmp *s, atm_mib_atmInterfaceDs3PlcpEntry_t ***atmInterfaceDs3PlcpEntry, gint64 mask); + +extern void +atm_mib_free_atmInterfaceDs3PlcpTable(atm_mib_atmInterfaceDs3PlcpEntry_t **atmInterfaceDs3PlcpEntry); + +extern atm_mib_atmInterfaceDs3PlcpEntry_t * +atm_mib_new_atmInterfaceDs3PlcpEntry(void); + +extern void +atm_mib_get_atmInterfaceDs3PlcpEntry(GNetSnmp *s, atm_mib_atmInterfaceDs3PlcpEntry_t **atmInterfaceDs3PlcpEntry, gint32 ifIndex, gint64 mask); + +extern void +atm_mib_free_atmInterfaceDs3PlcpEntry(atm_mib_atmInterfaceDs3PlcpEntry_t *atmInterfaceDs3PlcpEntry); + +/* + * C type definitions for ATM-MIB::atmInterfaceTCEntry. + */ + +#define ATM_MIB_ATMINTERFACEOCDEVENTS (1 << 0) +#define ATM_MIB_ATMINTERFACETCALARMSTATE (1 << 1) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + guint32 *atmInterfaceOCDEvents; /* ro SNMPv2-SMI::Counter32 */ + gint32 *atmInterfaceTCAlarmState; /* ro */ +} atm_mib_atmInterfaceTCEntry_t; + +extern void +atm_mib_get_atmInterfaceTCTable(GNetSnmp *s, atm_mib_atmInterfaceTCEntry_t ***atmInterfaceTCEntry, gint64 mask); + +extern void +atm_mib_free_atmInterfaceTCTable(atm_mib_atmInterfaceTCEntry_t **atmInterfaceTCEntry); + +extern atm_mib_atmInterfaceTCEntry_t * +atm_mib_new_atmInterfaceTCEntry(void); + +extern void +atm_mib_get_atmInterfaceTCEntry(GNetSnmp *s, atm_mib_atmInterfaceTCEntry_t **atmInterfaceTCEntry, gint32 ifIndex, gint64 mask); + +extern void +atm_mib_free_atmInterfaceTCEntry(atm_mib_atmInterfaceTCEntry_t *atmInterfaceTCEntry); + +/* + * C type definitions for ATM-MIB::atmTrafficDescrParamEntry. + */ + +#define ATM_MIB_ATMTRAFFICDESCRTYPE (1 << 0) +#define ATM_MIB_ATMTRAFFICDESCRPARAM1 (1 << 1) +#define ATM_MIB_ATMTRAFFICDESCRPARAM2 (1 << 2) +#define ATM_MIB_ATMTRAFFICDESCRPARAM3 (1 << 3) +#define ATM_MIB_ATMTRAFFICDESCRPARAM4 (1 << 4) +#define ATM_MIB_ATMTRAFFICDESCRPARAM5 (1 << 5) +#define ATM_MIB_ATMTRAFFICQOSCLASS (1 << 6) +#define ATM_MIB_ATMTRAFFICDESCRROWSTATUS (1 << 7) +#define ATM_MIB_ATMSERVICECATEGORY (1 << 8) +#define ATM_MIB_ATMTRAFFICFRAMEDISCARD (1 << 9) + +typedef struct { + gint32 atmTrafficDescrParamIndex; /* na */ + guint32 *atmTrafficDescrType; /* rw ObjectIdentifier */ +#define ATM_MIB_ATMTRAFFICDESCRTYPEMINLENGTH 0 +#define ATM_MIB_ATMTRAFFICDESCRTYPEMAXLENGTH 128 + guint16 _atmTrafficDescrTypeLength; + gint32 *atmTrafficDescrParam1; /* rw Integer32 */ + gint32 *atmTrafficDescrParam2; /* rw Integer32 */ + gint32 *atmTrafficDescrParam3; /* rw Integer32 */ + gint32 *atmTrafficDescrParam4; /* rw Integer32 */ + gint32 *atmTrafficDescrParam5; /* rw Integer32 */ + gint32 *atmTrafficQoSClass; /* rw */ + gint32 *atmTrafficDescrRowStatus; /* rw SNMPv2-TC::RowStatus */ + gint32 *atmServiceCategory; /* rw ATM-TC-MIB::AtmServiceCategory */ + gint32 *atmTrafficFrameDiscard; /* rw SNMPv2-TC::TruthValue */ +} atm_mib_atmTrafficDescrParamEntry_t; + +extern void +atm_mib_get_atmTrafficDescrParamTable(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t ***atmTrafficDescrParamEntry, gint64 mask); + +extern void +atm_mib_free_atmTrafficDescrParamTable(atm_mib_atmTrafficDescrParamEntry_t **atmTrafficDescrParamEntry); + +extern atm_mib_atmTrafficDescrParamEntry_t * +atm_mib_new_atmTrafficDescrParamEntry(void); + +extern void +atm_mib_get_atmTrafficDescrParamEntry(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t **atmTrafficDescrParamEntry, gint32 atmTrafficDescrParamIndex, gint64 mask); + +extern void +atm_mib_set_atmTrafficDescrParamEntry(GNetSnmp *s, atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry, gint64 mask); + +extern void +atm_mib_free_atmTrafficDescrParamEntry(atm_mib_atmTrafficDescrParamEntry_t *atmTrafficDescrParamEntry); + +/* + * C type definitions for ATM-MIB::atmVplEntry. + */ + +#define ATM_MIB_ATMVPLADMINSTATUS (1 << 0) +#define ATM_MIB_ATMVPLOPERSTATUS (1 << 1) +#define ATM_MIB_ATMVPLLASTCHANGE (1 << 2) +#define ATM_MIB_ATMVPLRECEIVETRAFFICDESCRINDEX (1 << 3) +#define ATM_MIB_ATMVPLTRANSMITTRAFFICDESCRINDEX (1 << 4) +#define ATM_MIB_ATMVPLCROSSCONNECTIDENTIFIER (1 << 5) +#define ATM_MIB_ATMVPLROWSTATUS (1 << 6) +#define ATM_MIB_ATMVPLCASTTYPE (1 << 7) +#define ATM_MIB_ATMVPLCONNKIND (1 << 8) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + gint32 atmVplVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 *atmVplAdminStatus; /* rw ATM-TC-MIB::AtmVorXAdminStatus */ + gint32 *atmVplOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + guint32 *atmVplLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + gint32 *atmVplReceiveTrafficDescrIndex; /* rw ATM-TC-MIB::AtmTrafficDescrParamIndex */ + gint32 *atmVplTransmitTrafficDescrIndex; /* rw ATM-TC-MIB::AtmTrafficDescrParamIndex */ + gint32 *atmVplCrossConnectIdentifier; /* ro */ + gint32 *atmVplRowStatus; /* rw SNMPv2-TC::RowStatus */ + gint32 *atmVplCastType; /* rw ATM-TC-MIB::AtmConnCastType */ + gint32 *atmVplConnKind; /* rw ATM-TC-MIB::AtmConnKind */ +} atm_mib_atmVplEntry_t; + +extern void +atm_mib_get_atmVplTable(GNetSnmp *s, atm_mib_atmVplEntry_t ***atmVplEntry, gint64 mask); + +extern void +atm_mib_free_atmVplTable(atm_mib_atmVplEntry_t **atmVplEntry); + +extern atm_mib_atmVplEntry_t * +atm_mib_new_atmVplEntry(void); + +extern void +atm_mib_get_atmVplEntry(GNetSnmp *s, atm_mib_atmVplEntry_t **atmVplEntry, gint32 ifIndex, gint32 atmVplVpi, gint64 mask); + +extern void +atm_mib_set_atmVplEntry(GNetSnmp *s, atm_mib_atmVplEntry_t *atmVplEntry, gint64 mask); + +extern void +atm_mib_free_atmVplEntry(atm_mib_atmVplEntry_t *atmVplEntry); + +/* + * C type definitions for ATM-MIB::atmVclEntry. + */ + +#define ATM_MIB_ATMVCLADMINSTATUS (1 << 0) +#define ATM_MIB_ATMVCLOPERSTATUS (1 << 1) +#define ATM_MIB_ATMVCLLASTCHANGE (1 << 2) +#define ATM_MIB_ATMVCLRECEIVETRAFFICDESCRINDEX (1 << 3) +#define ATM_MIB_ATMVCLTRANSMITTRAFFICDESCRINDEX (1 << 4) +#define ATM_MIB_ATMVCCAALTYPE (1 << 5) +#define ATM_MIB_ATMVCCAAL5CPCSTRANSMITSDUSIZE (1 << 6) +#define ATM_MIB_ATMVCCAAL5CPCSRECEIVESDUSIZE (1 << 7) +#define ATM_MIB_ATMVCCAAL5ENCAPSTYPE (1 << 8) +#define ATM_MIB_ATMVCLCROSSCONNECTIDENTIFIER (1 << 9) +#define ATM_MIB_ATMVCLROWSTATUS (1 << 10) +#define ATM_MIB_ATMVCLCASTTYPE (1 << 11) +#define ATM_MIB_ATMVCLCONNKIND (1 << 12) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + gint32 atmVclVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 atmVclVci; /* na ATM-TC-MIB::AtmVcIdentifier */ + gint32 *atmVclAdminStatus; /* rw ATM-TC-MIB::AtmVorXAdminStatus */ + gint32 *atmVclOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + guint32 *atmVclLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + gint32 *atmVclReceiveTrafficDescrIndex; /* rw ATM-TC-MIB::AtmTrafficDescrParamIndex */ + gint32 *atmVclTransmitTrafficDescrIndex; /* rw ATM-TC-MIB::AtmTrafficDescrParamIndex */ + gint32 *atmVccAalType; /* rw */ + gint32 *atmVccAal5CpcsTransmitSduSize; /* rw */ + gint32 *atmVccAal5CpcsReceiveSduSize; /* rw */ + gint32 *atmVccAal5EncapsType; /* rw */ + gint32 *atmVclCrossConnectIdentifier; /* ro */ + gint32 *atmVclRowStatus; /* rw SNMPv2-TC::RowStatus */ + gint32 *atmVclCastType; /* rw ATM-TC-MIB::AtmConnCastType */ + gint32 *atmVclConnKind; /* rw ATM-TC-MIB::AtmConnKind */ +} atm_mib_atmVclEntry_t; + +extern void +atm_mib_get_atmVclTable(GNetSnmp *s, atm_mib_atmVclEntry_t ***atmVclEntry, gint64 mask); + +extern void +atm_mib_free_atmVclTable(atm_mib_atmVclEntry_t **atmVclEntry); + +extern atm_mib_atmVclEntry_t * +atm_mib_new_atmVclEntry(void); + +extern void +atm_mib_get_atmVclEntry(GNetSnmp *s, atm_mib_atmVclEntry_t **atmVclEntry, gint32 ifIndex, gint32 atmVclVpi, gint32 atmVclVci, gint64 mask); + +extern void +atm_mib_set_atmVclEntry(GNetSnmp *s, atm_mib_atmVclEntry_t *atmVclEntry, gint64 mask); + +extern void +atm_mib_free_atmVclEntry(atm_mib_atmVclEntry_t *atmVclEntry); + +/* + * C type definitions for ATM-MIB::atmVpCrossConnectEntry. + */ + +#define ATM_MIB_ATMVPCROSSCONNECTADMINSTATUS (1 << 0) +#define ATM_MIB_ATMVPCROSSCONNECTL2HOPERSTATUS (1 << 1) +#define ATM_MIB_ATMVPCROSSCONNECTH2LOPERSTATUS (1 << 2) +#define ATM_MIB_ATMVPCROSSCONNECTL2HLASTCHANGE (1 << 3) +#define ATM_MIB_ATMVPCROSSCONNECTH2LLASTCHANGE (1 << 4) +#define ATM_MIB_ATMVPCROSSCONNECTROWSTATUS (1 << 5) + +typedef struct { + gint32 atmVpCrossConnectIndex; /* na */ + gint32 atmVpCrossConnectLowIfIndex; /* na IF-MIB::InterfaceIndex */ + gint32 atmVpCrossConnectLowVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 atmVpCrossConnectHighIfIndex; /* na IF-MIB::InterfaceIndex */ + gint32 atmVpCrossConnectHighVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 *atmVpCrossConnectAdminStatus; /* rw ATM-TC-MIB::AtmVorXAdminStatus */ + gint32 *atmVpCrossConnectL2HOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + gint32 *atmVpCrossConnectH2LOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + guint32 *atmVpCrossConnectL2HLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + guint32 *atmVpCrossConnectH2LLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + gint32 *atmVpCrossConnectRowStatus; /* rw SNMPv2-TC::RowStatus */ +} atm_mib_atmVpCrossConnectEntry_t; + +extern void +atm_mib_get_atmVpCrossConnectTable(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t ***atmVpCrossConnectEntry, gint64 mask); + +extern void +atm_mib_free_atmVpCrossConnectTable(atm_mib_atmVpCrossConnectEntry_t **atmVpCrossConnectEntry); + +extern atm_mib_atmVpCrossConnectEntry_t * +atm_mib_new_atmVpCrossConnectEntry(void); + +extern void +atm_mib_get_atmVpCrossConnectEntry(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t **atmVpCrossConnectEntry, gint32 atmVpCrossConnectIndex, gint32 atmVpCrossConnectLowIfIndex, gint32 atmVpCrossConnectLowVpi, gint32 atmVpCrossConnectHighIfIndex, gint32 atmVpCrossConnectHighVpi, gint64 mask); + +extern void +atm_mib_set_atmVpCrossConnectEntry(GNetSnmp *s, atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry, gint64 mask); + +extern void +atm_mib_free_atmVpCrossConnectEntry(atm_mib_atmVpCrossConnectEntry_t *atmVpCrossConnectEntry); + +/* + * C type definitions for ATM-MIB::atmVcCrossConnectEntry. + */ + +#define ATM_MIB_ATMVCCROSSCONNECTADMINSTATUS (1 << 0) +#define ATM_MIB_ATMVCCROSSCONNECTL2HOPERSTATUS (1 << 1) +#define ATM_MIB_ATMVCCROSSCONNECTH2LOPERSTATUS (1 << 2) +#define ATM_MIB_ATMVCCROSSCONNECTL2HLASTCHANGE (1 << 3) +#define ATM_MIB_ATMVCCROSSCONNECTH2LLASTCHANGE (1 << 4) +#define ATM_MIB_ATMVCCROSSCONNECTROWSTATUS (1 << 5) + +typedef struct { + gint32 atmVcCrossConnectIndex; /* na */ + gint32 atmVcCrossConnectLowIfIndex; /* na IF-MIB::InterfaceIndex */ + gint32 atmVcCrossConnectLowVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 atmVcCrossConnectLowVci; /* na ATM-TC-MIB::AtmVcIdentifier */ + gint32 atmVcCrossConnectHighIfIndex; /* na IF-MIB::InterfaceIndex */ + gint32 atmVcCrossConnectHighVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 atmVcCrossConnectHighVci; /* na ATM-TC-MIB::AtmVcIdentifier */ + gint32 *atmVcCrossConnectAdminStatus; /* rw ATM-TC-MIB::AtmVorXAdminStatus */ + gint32 *atmVcCrossConnectL2HOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + gint32 *atmVcCrossConnectH2LOperStatus; /* ro ATM-TC-MIB::AtmVorXOperStatus */ + guint32 *atmVcCrossConnectL2HLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + guint32 *atmVcCrossConnectH2LLastChange; /* ro ATM-TC-MIB::AtmVorXLastChange */ + gint32 *atmVcCrossConnectRowStatus; /* rw SNMPv2-TC::RowStatus */ +} atm_mib_atmVcCrossConnectEntry_t; + +extern void +atm_mib_get_atmVcCrossConnectTable(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t ***atmVcCrossConnectEntry, gint64 mask); + +extern void +atm_mib_free_atmVcCrossConnectTable(atm_mib_atmVcCrossConnectEntry_t **atmVcCrossConnectEntry); + +extern atm_mib_atmVcCrossConnectEntry_t * +atm_mib_new_atmVcCrossConnectEntry(void); + +extern void +atm_mib_get_atmVcCrossConnectEntry(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t **atmVcCrossConnectEntry, gint32 atmVcCrossConnectIndex, gint32 atmVcCrossConnectLowIfIndex, gint32 atmVcCrossConnectLowVpi, gint32 atmVcCrossConnectLowVci, gint32 atmVcCrossConnectHighIfIndex, gint32 atmVcCrossConnectHighVpi, gint32 atmVcCrossConnectHighVci, gint64 mask); + +extern void +atm_mib_set_atmVcCrossConnectEntry(GNetSnmp *s, atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry, gint64 mask); + +extern void +atm_mib_free_atmVcCrossConnectEntry(atm_mib_atmVcCrossConnectEntry_t *atmVcCrossConnectEntry); + +/* + * C type definitions for ATM-MIB::aal5VccEntry. + */ + +#define ATM_MIB_AAL5VCCCRCERRORS (1 << 0) +#define ATM_MIB_AAL5VCCSARTIMEOUTS (1 << 1) +#define ATM_MIB_AAL5VCCOVERSIZEDSDUS (1 << 2) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + gint32 aal5VccVpi; /* na ATM-TC-MIB::AtmVpIdentifier */ + gint32 aal5VccVci; /* na ATM-TC-MIB::AtmVcIdentifier */ + guint32 *aal5VccCrcErrors; /* ro SNMPv2-SMI::Counter32 */ + guint32 *aal5VccSarTimeOuts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *aal5VccOverSizedSDUs; /* ro SNMPv2-SMI::Counter32 */ +} atm_mib_aal5VccEntry_t; + +extern void +atm_mib_get_aal5VccTable(GNetSnmp *s, atm_mib_aal5VccEntry_t ***aal5VccEntry, gint64 mask); + +extern void +atm_mib_free_aal5VccTable(atm_mib_aal5VccEntry_t **aal5VccEntry); + +extern atm_mib_aal5VccEntry_t * +atm_mib_new_aal5VccEntry(void); + +extern void +atm_mib_get_aal5VccEntry(GNetSnmp *s, atm_mib_aal5VccEntry_t **aal5VccEntry, gint32 ifIndex, gint32 aal5VccVpi, gint32 aal5VccVci, gint64 mask); + +extern void +atm_mib_free_aal5VccEntry(atm_mib_aal5VccEntry_t *aal5VccEntry); + + +G_END_DECLS + +#endif /* _ATM_MIB_H_ */ diff --git a/examples/atm-tc-mib.c b/examples/atm-tc-mib.c new file mode 100644 index 0000000..ce9abd3 --- /dev/null +++ b/examples/atm-tc-mib.c @@ -0,0 +1,155 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli ATM-TC-MIB + * + * Derived from ATM-TC-MIB: + * This MIB Module provides Textual Conventions + * and OBJECT-IDENTITY Objects to be used by + * ATM systems. + * + * Revision 1998-10-19 02:00: + * [Revision added by libsmi due to a LAST-UPDATED clause.] + * + * $Id$ + */ + +#include "atm-tc-mib.h" + +GNetSnmpEnum const atm_tc_mib_enums_AtmConnCastType[] = { + { ATM_TC_MIB_ATMCONNCASTTYPE_P2P, "p2p" }, + { ATM_TC_MIB_ATMCONNCASTTYPE_P2MPROOT, "p2mpRoot" }, + { ATM_TC_MIB_ATMCONNCASTTYPE_P2MPLEAF, "p2mpLeaf" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_tc_mib_enums_AtmConnKind[] = { + { ATM_TC_MIB_ATMCONNKIND_PVC, "pvc" }, + { ATM_TC_MIB_ATMCONNKIND_SVCINCOMING, "svcIncoming" }, + { ATM_TC_MIB_ATMCONNKIND_SVCOUTGOING, "svcOutgoing" }, + { ATM_TC_MIB_ATMCONNKIND_SPVCINITIATOR, "spvcInitiator" }, + { ATM_TC_MIB_ATMCONNKIND_SPVCTARGET, "spvcTarget" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_tc_mib_enums_AtmInterfaceType[] = { + { ATM_TC_MIB_ATMINTERFACETYPE_OTHER, "other" }, + { ATM_TC_MIB_ATMINTERFACETYPE_AUTOCONFIG, "autoConfig" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ITUDSS2, "ituDss2" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI3DOT0, "atmfUni3Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI3DOT1, "atmfUni3Dot1" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI4DOT0, "atmfUni4Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI3DOT0, "atmfIispUni3Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI3DOT1, "atmfIispUni3Dot1" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI4DOT0, "atmfIispUni4Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFPNNI1DOT0, "atmfPnni1Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFBICI2DOT0, "atmfBici2Dot0" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNIPVCONLY, "atmfUniPvcOnly" }, + { ATM_TC_MIB_ATMINTERFACETYPE_ATMFNNIPVCONLY, "atmfNniPvcOnly" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_tc_mib_enums_AtmServiceCategory[] = { + { ATM_TC_MIB_ATMSERVICECATEGORY_OTHER, "other" }, + { ATM_TC_MIB_ATMSERVICECATEGORY_CBR, "cbr" }, + { ATM_TC_MIB_ATMSERVICECATEGORY_RTVBR, "rtVbr" }, + { ATM_TC_MIB_ATMSERVICECATEGORY_NRTVBR, "nrtVbr" }, + { ATM_TC_MIB_ATMSERVICECATEGORY_ABR, "abr" }, + { ATM_TC_MIB_ATMSERVICECATEGORY_UBR, "ubr" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_tc_mib_enums_AtmVorXAdminStatus[] = { + { ATM_TC_MIB_ATMVORXADMINSTATUS_UP, "up" }, + { ATM_TC_MIB_ATMVORXADMINSTATUS_DOWN, "down" }, + { 0, NULL } +}; + +GNetSnmpEnum const atm_tc_mib_enums_AtmVorXOperStatus[] = { + { ATM_TC_MIB_ATMVORXOPERSTATUS_UP, "up" }, + { ATM_TC_MIB_ATMVORXOPERSTATUS_DOWN, "down" }, + { ATM_TC_MIB_ATMVORXOPERSTATUS_UNKNOWN, "unknown" }, + { 0, NULL } +}; + + +static guint32 const atmNoTrafficDescriptor[] + = { ATM_TC_MIB_ATMNOTRAFFICDESCRIPTOR }; +static guint32 const atmNoClpNoScr[] + = { ATM_TC_MIB_ATMNOCLPNOSCR }; +static guint32 const atmClpNoTaggingNoScr[] + = { ATM_TC_MIB_ATMCLPNOTAGGINGNOSCR }; +static guint32 const atmClpTaggingNoScr[] + = { ATM_TC_MIB_ATMCLPTAGGINGNOSCR }; +static guint32 const atmNoClpScr[] + = { ATM_TC_MIB_ATMNOCLPSCR }; +static guint32 const atmClpNoTaggingScr[] + = { ATM_TC_MIB_ATMCLPNOTAGGINGSCR }; +static guint32 const atmClpTaggingScr[] + = { ATM_TC_MIB_ATMCLPTAGGINGSCR }; +static guint32 const atmClpNoTaggingMcr[] + = { ATM_TC_MIB_ATMCLPNOTAGGINGMCR }; +static guint32 const atmClpTransparentNoScr[] + = { ATM_TC_MIB_ATMCLPTRANSPARENTNOSCR }; +static guint32 const atmClpTransparentScr[] + = { ATM_TC_MIB_ATMCLPTRANSPARENTSCR }; +static guint32 const atmNoClpTaggingNoScr[] + = { ATM_TC_MIB_ATMNOCLPTAGGINGNOSCR }; +static guint32 const atmNoClpNoScrCdvt[] + = { ATM_TC_MIB_ATMNOCLPNOSCRCDVT }; +static guint32 const atmNoClpScrCdvt[] + = { ATM_TC_MIB_ATMNOCLPSCRCDVT }; +static guint32 const atmClpNoTaggingScrCdvt[] + = { ATM_TC_MIB_ATMCLPNOTAGGINGSCRCDVT }; +static guint32 const atmClpTaggingScrCdvt[] + = { ATM_TC_MIB_ATMCLPTAGGINGSCRCDVT }; + +GNetSnmpIdentity const atm_tc_mib_identities[] = { + { atmNoTrafficDescriptor, + sizeof(atmNoTrafficDescriptor)/sizeof(guint32), + "atmNoTrafficDescriptor" }, + { atmNoClpNoScr, + sizeof(atmNoClpNoScr)/sizeof(guint32), + "atmNoClpNoScr" }, + { atmClpNoTaggingNoScr, + sizeof(atmClpNoTaggingNoScr)/sizeof(guint32), + "atmClpNoTaggingNoScr" }, + { atmClpTaggingNoScr, + sizeof(atmClpTaggingNoScr)/sizeof(guint32), + "atmClpTaggingNoScr" }, + { atmNoClpScr, + sizeof(atmNoClpScr)/sizeof(guint32), + "atmNoClpScr" }, + { atmClpNoTaggingScr, + sizeof(atmClpNoTaggingScr)/sizeof(guint32), + "atmClpNoTaggingScr" }, + { atmClpTaggingScr, + sizeof(atmClpTaggingScr)/sizeof(guint32), + "atmClpTaggingScr" }, + { atmClpNoTaggingMcr, + sizeof(atmClpNoTaggingMcr)/sizeof(guint32), + "atmClpNoTaggingMcr" }, + { atmClpTransparentNoScr, + sizeof(atmClpTransparentNoScr)/sizeof(guint32), + "atmClpTransparentNoScr" }, + { atmClpTransparentScr, + sizeof(atmClpTransparentScr)/sizeof(guint32), + "atmClpTransparentScr" }, + { atmNoClpTaggingNoScr, + sizeof(atmNoClpTaggingNoScr)/sizeof(guint32), + "atmNoClpTaggingNoScr" }, + { atmNoClpNoScrCdvt, + sizeof(atmNoClpNoScrCdvt)/sizeof(guint32), + "atmNoClpNoScrCdvt" }, + { atmNoClpScrCdvt, + sizeof(atmNoClpScrCdvt)/sizeof(guint32), + "atmNoClpScrCdvt" }, + { atmClpNoTaggingScrCdvt, + sizeof(atmClpNoTaggingScrCdvt)/sizeof(guint32), + "atmClpNoTaggingScrCdvt" }, + { atmClpTaggingScrCdvt, + sizeof(atmClpTaggingScrCdvt)/sizeof(guint32), + "atmClpTaggingScrCdvt" }, + { 0, 0, NULL } +}; + + diff --git a/examples/atm-tc-mib.h b/examples/atm-tc-mib.h new file mode 100644 index 0000000..c404f0f --- /dev/null +++ b/examples/atm-tc-mib.h @@ -0,0 +1,102 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli ATM-TC-MIB + * + * Derived from ATM-TC-MIB: + * This MIB Module provides Textual Conventions + * and OBJECT-IDENTITY Objects to be used by + * ATM systems. + * + * Revision 1998-10-19 02:00: + * [Revision added by libsmi due to a LAST-UPDATED clause.] + * + * $Id$ + */ + +#ifndef _ATM_TC_MIB_H_ +#define _ATM_TC_MIB_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define ATM_TC_MIB_ATMCONNCASTTYPE_P2P 1 +#define ATM_TC_MIB_ATMCONNCASTTYPE_P2MPROOT 2 +#define ATM_TC_MIB_ATMCONNCASTTYPE_P2MPLEAF 3 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmConnCastType[]; + +#define ATM_TC_MIB_ATMCONNKIND_PVC 1 +#define ATM_TC_MIB_ATMCONNKIND_SVCINCOMING 2 +#define ATM_TC_MIB_ATMCONNKIND_SVCOUTGOING 3 +#define ATM_TC_MIB_ATMCONNKIND_SPVCINITIATOR 4 +#define ATM_TC_MIB_ATMCONNKIND_SPVCTARGET 5 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmConnKind[]; + +#define ATM_TC_MIB_ATMINTERFACETYPE_OTHER 1 +#define ATM_TC_MIB_ATMINTERFACETYPE_AUTOCONFIG 2 +#define ATM_TC_MIB_ATMINTERFACETYPE_ITUDSS2 3 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI3DOT0 4 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI3DOT1 5 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNI4DOT0 6 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI3DOT0 7 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI3DOT1 8 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFIISPUNI4DOT0 9 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFPNNI1DOT0 10 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFBICI2DOT0 11 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFUNIPVCONLY 12 +#define ATM_TC_MIB_ATMINTERFACETYPE_ATMFNNIPVCONLY 13 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmInterfaceType[]; + +#define ATM_TC_MIB_ATMSERVICECATEGORY_OTHER 1 +#define ATM_TC_MIB_ATMSERVICECATEGORY_CBR 2 +#define ATM_TC_MIB_ATMSERVICECATEGORY_RTVBR 3 +#define ATM_TC_MIB_ATMSERVICECATEGORY_NRTVBR 4 +#define ATM_TC_MIB_ATMSERVICECATEGORY_ABR 5 +#define ATM_TC_MIB_ATMSERVICECATEGORY_UBR 6 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmServiceCategory[]; + +#define ATM_TC_MIB_ATMVORXADMINSTATUS_UP 1 +#define ATM_TC_MIB_ATMVORXADMINSTATUS_DOWN 2 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmVorXAdminStatus[]; + +#define ATM_TC_MIB_ATMVORXOPERSTATUS_UP 1 +#define ATM_TC_MIB_ATMVORXOPERSTATUS_DOWN 2 +#define ATM_TC_MIB_ATMVORXOPERSTATUS_UNKNOWN 3 + +extern GNetSnmpEnum const atm_tc_mib_enums_AtmVorXOperStatus[]; + + +/* + * Tables to map identities to strings and vice versa. + */ + +#define ATM_TC_MIB_ATMNOTRAFFICDESCRIPTOR 1,3,6,1,2,1,37,1,1,1 +#define ATM_TC_MIB_ATMNOCLPNOSCR 1,3,6,1,2,1,37,1,1,2 +#define ATM_TC_MIB_ATMCLPNOTAGGINGNOSCR 1,3,6,1,2,1,37,1,1,3 +#define ATM_TC_MIB_ATMCLPTAGGINGNOSCR 1,3,6,1,2,1,37,1,1,4 +#define ATM_TC_MIB_ATMNOCLPSCR 1,3,6,1,2,1,37,1,1,5 +#define ATM_TC_MIB_ATMCLPNOTAGGINGSCR 1,3,6,1,2,1,37,1,1,6 +#define ATM_TC_MIB_ATMCLPTAGGINGSCR 1,3,6,1,2,1,37,1,1,7 +#define ATM_TC_MIB_ATMCLPNOTAGGINGMCR 1,3,6,1,2,1,37,1,1,8 +#define ATM_TC_MIB_ATMCLPTRANSPARENTNOSCR 1,3,6,1,2,1,37,1,1,9 +#define ATM_TC_MIB_ATMCLPTRANSPARENTSCR 1,3,6,1,2,1,37,1,1,10 +#define ATM_TC_MIB_ATMNOCLPTAGGINGNOSCR 1,3,6,1,2,1,37,1,1,11 +#define ATM_TC_MIB_ATMNOCLPNOSCRCDVT 1,3,6,1,2,1,37,1,1,12 +#define ATM_TC_MIB_ATMNOCLPSCRCDVT 1,3,6,1,2,1,37,1,1,13 +#define ATM_TC_MIB_ATMCLPNOTAGGINGSCRCDVT 1,3,6,1,2,1,37,1,1,14 +#define ATM_TC_MIB_ATMCLPTAGGINGSCRCDVT 1,3,6,1,2,1,37,1,1,15 + +extern GNetSnmpIdentity const atm_tc_mib_identities[]; + +G_END_DECLS + +#endif /* _ATM_TC_MIB_H_ */ diff --git a/examples/atm.c b/examples/atm.c new file mode 100644 index 0000000..3975f82 --- /dev/null +++ b/examples/atm.c @@ -0,0 +1,75 @@ +/* + * This example creates an entry in the atm traffic description + * parameter table. This example was motivated by Marek Malowidzki + * who wanted to see how complicated and how + * readable this code would be. Judge yourself. + * + * Compile using the following command line: + * + * gcc -g `pkg-config --cflags gsnmp gnet` -o atm atm.c \ + * snmpv2-tc.c atm-tc-mib.c atm-mib.c \ + * `pkg-config --libs gsnmp gnet` + */ + +#include + +#include "snmpv2-tc.h" +#include "atm-tc-mib.h" +#include "atm-mib.h" + +static const char *progname = "atm"; + +static gint32 createAndGo = SNMPV2_TC_ROWSTATUS_CREATEANDGO; +static gint32 on = SNMPV2_TC_TRUTHVALUE_TRUE; + +static guint32 noclpnoscr[] = { ATM_TC_MIB_ATMNOCLPNOSCR }; +static gint32 cbr = ATM_TC_MIB_ATMSERVICECATEGORY_CBR; + +int +main() +{ + GNetSnmp *s; + GURI *uri; + atm_mib_atmMIBObjects_t *o; + atm_mib_atmTrafficDescrParamEntry_t *p; + gint32 param1 = 500; + const char *uri_string = "snmp://public@localhost/"; + + if (! gnet_snmp_init(FALSE)) { + exit(1); + } + + uri = gnet_snmp_parse_uri(uri_string); + if (! uri) { + g_printerr("%s: invalid snmp uri: %s\n", progname, uri_string); + exit(1); + } + s = gnet_snmp_new_uri(uri); + if (! s) { + g_printerr("%s: unable to create session\n", progname); + exit(1); + } + gnet_snmp_set_version(s, GNET_SNMP_V1); + + atm_mib_get_atmMIBObjects(s, &o, ATM_MIB_ATMTRAFFICDESCRPARAMINDEXNEXT); + if (s->error_status || !o || !o->atmTrafficDescrParamIndexNext) return 2; + + p = atm_mib_new_atmTrafficDescrParamEntry(); + p->atmTrafficDescrParamIndex = *o->atmTrafficDescrParamIndexNext; + p->atmTrafficDescrType = noclpnoscr; + p->_atmTrafficDescrTypeLength = G_N_ELEMENTS(noclpnoscr); + p->atmTrafficDescrParam1 = ¶m1; + p->atmTrafficDescrRowStatus = &createAndGo; + p->atmServiceCategory = &cbr; + p->atmTrafficFrameDiscard = &on; + atm_mib_set_atmTrafficDescrParamEntry(s, p, 0); + if (s->error_status) return 3; + + atm_mib_free_atmMIBObjects(o); + atm_mib_free_atmTrafficDescrParamEntry(p); + + gnet_snmp_delete(s); + gnet_uri_delete(uri); + + return 0; +} diff --git a/examples/gsnmp-iftable.c b/examples/gsnmp-iftable.c new file mode 100644 index 0000000..1d9990c --- /dev/null +++ b/examples/gsnmp-iftable.c @@ -0,0 +1,122 @@ +/* + * gsnmp-iftable.c -- + * + * A simple program to retrieve some data from the interface table. + */ + +#include +#include + +#include "ianaiftype-mib.h" +#include "if-mib.h" + +static const char *progname = "gsnmp-iftable"; + +static void +show_ifentry(if_mib_ifEntry_t *ifEntry) +{ + const char *ifType = NULL; + const char *ifAdminStatus = NULL; + const char *ifOperStatus = NULL; + + if (ifEntry->ifType) { + ifType = gnet_snmp_enum_get_label(ianaiftype_mib_enums_IANAifType, + *ifEntry->ifType); + } + if (ifEntry->ifAdminStatus) { + ifAdminStatus = gnet_snmp_enum_get_label(if_mib_enums_ifAdminStatus, + *ifEntry->ifAdminStatus); + } + if (ifEntry->ifOperStatus) { + ifOperStatus = gnet_snmp_enum_get_label(if_mib_enums_ifOperStatus, + *ifEntry->ifOperStatus); + } + g_print("%8d %-16s %-8s %-8s %.*s\n", + ifEntry->ifIndex, + ifType ? ifType : "", + ifAdminStatus ? ifAdminStatus : "", + ifOperStatus ? ifOperStatus : "", + ifEntry->_ifDescrLength, ifEntry->ifDescr); +} + +static void +show_iftable(GNetSnmp *snmp) +{ + if_mib_ifEntry_t **ifTable; + int i; + gchar *s; + + s = gnet_uri_get_string(gnet_snmp_get_uri(snmp)); + g_print("<%s>:\n", s); + g_free(s); + +#if 0 + if_mib_get_ifTable(snmp, &ifTable, IF_MIB_IFDESCR | IF_MIB_IFTYPE + | IF_MIB_IFADMINSTATUS | IF_MIB_IFOPERSTATUS); +#else + if_mib_get_ifTable(snmp, &ifTable, 0); +#endif + if (! snmp->error_status && ifTable) { + for (i = 0; ifTable[i]; i++) { + show_ifentry(ifTable[i]); + } + } + + if (ifTable) if_mib_free_ifTable(ifTable); +} + +int +main(int argc, char **argv) +{ + GNetSnmp *snmp; + GURI *uri; + int c, tflag = 0; + + while ((c = getopt(argc, argv, "dt")) >= 0) { + switch (c) { + case 'd': +#if 0 + gnet_snmp_debug_flags = GNET_SNMP_DEBUG_ALL; +#else + gnet_snmp_debug_flags = GNET_SNMP_DEBUG_SESSION + | GNET_SNMP_DEBUG_REQUESTS; +#endif + break; + case 't': + tflag = 1; + break; + default: + g_printerr("usage: %s [-d] [-t] [snmp-uri ...]\n", progname); + exit(EXIT_FAILURE); + } + } + + if (! gnet_snmp_init(FALSE)) { + exit(1); + } + + for (; optind < argc; optind++) { + + uri = gnet_snmp_parse_uri(argv[optind]); + if (! uri) { + g_printerr("%s: invalid snmp uri: %s\n", progname, argv[optind]); + continue; + } + + snmp = gnet_snmp_new_uri(uri); + if (! snmp) { + g_printerr("%s: unable to create session\n", progname); + gnet_uri_delete(uri); + continue; + } + gnet_snmp_set_version(snmp, GNET_SNMP_V1); + + show_iftable(snmp); + + gnet_snmp_delete(snmp); + gnet_uri_delete(uri); + } + + return 0; +} + diff --git a/examples/gsnmp-ping.c b/examples/gsnmp-ping.c new file mode 100644 index 0000000..e44e965 --- /dev/null +++ b/examples/gsnmp-ping.c @@ -0,0 +1,123 @@ +/* + * gsnmp-ping.c -- + * + * A simple program to retrieve some data with the gnet-snmp API. + */ + +#include "gsnmp.h" + +#include +#include + +static const char *progname = "gsnmp-ping"; + +static void +print(gpointer data, gpointer user) +{ + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) data; + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + g_print("%.*s", vb->value_len, vb->value.ui8v); + break; + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + g_print("%u: ", vb->value.ui32); + break; + default: + break; + } +} + +static void +ping(GNetSnmp *s, int sflag) +{ + GNetSnmpVarBind *vb; + GList *in = NULL, *out = NULL; + guint32 n1[] = { 1, 3, 6, 1, 2, 1, 1, 3, 0 }; /* sysUpTime.0 */ + guint32 n2[] = { 1, 3, 6, 1, 2, 1, 1, 1, 0 }; /* sysDescr.0 */ + + vb = gnet_snmp_varbind_new(n1, sizeof(n1)/sizeof(n1[0]), + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + in = g_list_append(in, vb); + vb = gnet_snmp_varbind_new(n2, sizeof(n2)/sizeof(n2[0]), + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + in = g_list_append(in, vb); + + out = gnet_snmp_sync_get(s, in); + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_printerr("snmp error: %s @ %d\n", + gnet_snmp_enum_get_label(gnet_snmp_enum_error_table, + s->error_status), + s->error_index); + goto cleanup; + } + + if (!sflag) { + g_list_foreach(out, print, NULL); + g_print("\n"); + } + + cleanup: + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); +} + +int +main(int argc, char **argv) +{ + GNetSnmp *s; + GURI *uri; + int i, c, iterations = 1, sflag = 0, tflag = 0; + + while ((c = getopt(argc, argv, "dl:st")) >= 0) { + switch (c) { + case 'd': + gnet_snmp_debug_flags = GNET_SNMP_DEBUG_ALL; + break; + case 'l': + iterations = atoi(optarg); + break; + case 's': + sflag = 1; + break; + case 't': + tflag = 1; + break; + default: + g_printerr("usage: %s [-d] [-l iterations] [-s] [-t] snmp-uri\n", + progname); + exit(EXIT_FAILURE); + } + } + + if (! gnet_snmp_init(FALSE)) { + exit(1); + } + + if (optind != argc-1) { + g_printerr("gsnmp-walk: wrong number of arguments\n"); + exit(EXIT_FAILURE); + } + + uri = gnet_snmp_parse_uri(argv[optind]); + if (! uri) { + g_printerr("%s: invalid snmp uri: %s\n", progname, argv[optind]); + exit(1); + } + s = gnet_snmp_new_uri(uri); + if (! s) { + g_printerr("%s: unable to create session\n", progname); + exit(1); + } + gnet_snmp_set_version(s, GNET_SNMP_V1); + + for (i = 0; i < iterations; i++) { + ping(s, sflag); + } + + gnet_snmp_delete(s); + gnet_uri_delete(uri); + + return 0; +} diff --git a/examples/gsnmp-stub-ping.c b/examples/gsnmp-stub-ping.c new file mode 100644 index 0000000..e37b62e --- /dev/null +++ b/examples/gsnmp-stub-ping.c @@ -0,0 +1,100 @@ +/* + * gsnmp-stub-ping.c -- + * + * A simple program to retrieve some data with the gnet-snmp API and + * scli stub procedures generated by smidump. The stubs also validates + * the received values against type, range or indexing errors. + */ + +#include +#include + +#include "snmpv2-mib.h" + +static const char *progname = "gsnmp-stub-ping"; + +static void +ping(GNetSnmp *s, int sflag) +{ + snmpv2_mib_system_t *system; + + snmpv2_mib_get_system(s, &system, + SNMPV2_MIB_SYSUPTIME | SNMPV2_MIB_SYSDESCR); + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_printerr("%s: snmp error: %s @ %d\n", progname, + gnet_snmp_enum_get_label(gnet_snmp_enum_error_table, + s->error_status), + s->error_index); + goto cleanup; + } + + if (system && system->sysUpTime) { + if (!sflag) { + g_print("%u: %.*s\n", *system->sysUpTime, + system->_sysDescrLength, system->sysDescr); + } + } + + cleanup: + if (system) snmpv2_mib_free_system(system); +} + +int +main(int argc, char **argv) +{ + GNetSnmp *s; + GURI *uri; + int i, c, iterations = 1, sflag = 0, tflag = 0; + + while ((c = getopt(argc, argv, "dl:st")) >= 0) { + switch (c) { + case 'd': + gnet_snmp_debug_flags = GNET_SNMP_DEBUG_ALL; + break; + case 'l': + iterations = atoi(optarg); + break; + case 's': + sflag = 1; + break; + case 't': + tflag = 1; + break; + default: + g_printerr("usage: %s [-d] [-l iterations] [-s] [-t] snmp-uri\n", + progname); + exit(EXIT_FAILURE); + } + } + + if (! gnet_snmp_init(FALSE)) { + exit(1); + } + + if (optind != argc-1) { + g_printerr("gsnmp-walk: wrong number of arguments\n"); + exit(EXIT_FAILURE); + } + + uri = gnet_snmp_parse_uri(argv[optind]); + if (! uri) { + g_printerr("%s: invalid snmp uri: %s\n", progname, argv[optind]); + exit(1); + } + s = gnet_snmp_new_uri(uri); + if (! s) { + g_printerr("%s: unable to create session\n", progname); + exit(1); + } + gnet_snmp_set_version(s, GNET_SNMP_V1); + + for (i = 0; i < iterations; i++) { + ping(s, sflag); + } + + gnet_snmp_delete(s); + gnet_uri_delete(uri); + + return 0; +} + diff --git a/examples/gsnmp-walk.c b/examples/gsnmp-walk.c new file mode 100644 index 0000000..9948922 --- /dev/null +++ b/examples/gsnmp-walk.c @@ -0,0 +1,184 @@ +/* + * gsnmp-walk.c -- + * + * A simple program to walk a MIB using the gnet-snmp API. + */ + +#include +#include +#include + +#include "gsnmp.h" + +static const char *progname = "gsnmp-walk"; + +static void +print(gpointer data, gpointer user) +{ + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) data; + gint i; + + for (i = 0; i < vb->oid_len; i++) { + g_print("%s%u", i ? "." : "", vb->oid[i]); + } + g_print(" = "); + + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_NULL: + g_print("[NULL]"); + break; + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + for (i = 0; i < vb->value_len; i++) { + if (! isprint(vb->value.ui8v[i])) break; + } + if (i == vb->value_len) { + g_print("%.*s", vb->value_len, vb->value.ui8v); + } else { + for (i = 0; i < vb->value_len; i++) { + g_print("%s%02x", i ? ":" : "", vb->value.ui8v[i]); + } + } + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + for (i = 0; i < vb->value_len; i++) { + g_print("%s%u", i ? "." : "", vb->value.ui32v[i]); + } + break; + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + if (vb->value_len == 4) { + g_print("%d.%d.%d.%d", + vb->value.ui8v[0], vb->value.ui8v[1], + vb->value.ui8v[2], vb->value.ui8v[3]); + } + break; + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + g_print("%u", vb->value.i32); + break; + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + g_print("%u", vb->value.ui32); + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + g_print("%u", vb->value.ui32); + break; + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + g_print("%u", vb->value.ui32); + break; + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + for (i = 0; i < vb->value_len; i++) { + g_print("%s%02x", i ? ":" : "", vb->value.ui8v[i]); + } + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + g_print("%llu", vb->value.ui64); + break; + case GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT: + g_print("[NOSUCHOBJECT]"); + break; + case GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE: + g_print("[NOSUCHINSTANCE]"); + break; + case GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW: + g_print("[ENDOFMIBVIEW]"); + break; + } + g_print("\n"); +} + +static void +walk(GNetSnmp *s, int sflag) +{ + GURI *uri; + GNetSnmpVarBind *vb; + GList *in = NULL, *out = NULL; + guint32 iso_org[] = { 1, 3, 6, 1, 2 }; /* SNMPv2-SMI::mib-2 */ + + uri = gnet_snmp_get_uri(s); + if (uri) { + gchar *name = gnet_uri_get_string(uri); + g_print("walking <%s>:\n", name); + g_free(name); + } + + vb = gnet_snmp_varbind_new(iso_org, G_N_ELEMENTS(iso_org), + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + in = g_list_append(in, vb); + out = gnet_snmp_sync_walk(s, in); + if (s->error_status != GNET_SNMP_ERR_NOERROR + && s->error_status != GNET_SNMP_ERR_NOSUCHNAME) { + g_printerr("snmp error: %s @ %d\n", + gnet_snmp_enum_get_label(gnet_snmp_enum_error_table, + s->error_status), + s->error_index); + goto cleanup; + } + + if (!sflag) { + g_list_foreach(out, print, NULL); + g_print("\n"); + } + + cleanup: + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); +} + +int +main(int argc, char **argv) +{ + GNetSnmp *s; + GURI *uri; + int i, c, iterations = 1, sflag = 0, tflag = 0; + + while ((c = getopt(argc, argv, "dl:st")) >= 0) { + switch (c) { + case 'd': + gnet_snmp_debug_flags = GNET_SNMP_DEBUG_ALL; + break; + case 'l': + iterations = atoi(optarg); + break; + case 's': + sflag = 1; + break; + case 't': + tflag = 1; + break; + default: + g_printerr("usage: %s [-d] [-l iterations] [-s] [-t] snmp-uri\n", + progname); + exit(EXIT_FAILURE); + } + } + + if (! gnet_snmp_init(FALSE)) { + exit(1); + } + + if (optind != argc-1) { + g_printerr("gsnmp-walk: wrong number of arguments\n"); + exit(EXIT_FAILURE); + } + + uri = gnet_snmp_parse_uri(argv[optind]); + if (! uri) { + g_printerr("%s: invalid snmp uri: %s\n", progname, argv[optind]); + exit(1); + } + s = gnet_snmp_new_uri(uri); + if (! s) { + g_printerr("%s: unable to create session\n", progname); + exit(1); + } + gnet_snmp_set_version(s, GNET_SNMP_V1); + + for (i = 0; i < iterations; i++) { + walk(s, sflag); + } + + gnet_snmp_delete(s); + gnet_uri_delete(uri); + + return 0; +} diff --git a/examples/ianaiftype-mib.c b/examples/ianaiftype-mib.c new file mode 100644 index 0000000..cdd2d40 --- /dev/null +++ b/examples/ianaiftype-mib.c @@ -0,0 +1,343 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli IANAifType-MIB + * + * Derived from IANAifType-MIB: + * This MIB module defines the IANAifType Textual + * Convention, and thus the enumerated values of + * the ifType object defined in MIB-II's ifTable. + * + * Revision 2002-10-17 00:00: + * Registration of new IANAifType + * 219. + * + * Revision 2002-07-16 00:00: + * Registration of new IANAifTypes + * 217 and 218. + * + * Revision 2002-07-10 00:00: + * Registration of new IANAifTypes + * 215 and 216. + * + * Revision 2002-06-19 00:00: + * Registration of new IANAifType + * 214. + * + * Revision 2002-01-04 00:00: + * Registration of new IANAifTypes + * 211, 212 and 213. + * + * Revision 2001-12-20 00:00: + * Registration of new IANAifTypes + * 209 and 210. + * + * Revision 2001-11-15 00:00: + * Registration of new IANAifTypes + * 207 and 208. + * + * Revision 2001-11-06 00:00: + * Registration of new IANAifType + * 206. + * + * Revision 2001-11-02 00:00: + * Registration of new IANAifType + * 205. + * + * Revision 2001-10-16 00:00: + * Registration of new IANAifTypes + * 199, 200, 201, 202, 203, and 204. + * + * Revision 2001-09-19 00:00: + * Registration of new IANAifType + * 198. + * + * Revision 2001-05-11 00:00: + * Registration of new IANAifType + * 197. + * + * Revision 2001-01-12 00:00: + * Registration of new IANAifTypes + * 195 and 196. + * + * Revision 2000-12-19 00:00: + * Registration of new IANAifTypes + * 193 and 194. + * + * Revision 2000-12-07 00:00: + * Registration of new IANAifTypes + * 191 and 192. + * + * Revision 2000-12-04 00:00: + * Registration of new IANAifType + * 190. + * + * Revision 2000-10-17 00:00: + * Registration of new IANAifTypes + * 188 and 189. + * + * Revision 2000-10-02 00:00: + * Registration of new IANAifType 187. + * + * Revision 2000-09-01 00:00: + * Registration of new IANAifTypes + * 184, 185, and 186. + * + * Revision 2000-08-24 00:00: + * Registration of new IANAifType 183. + * + * Revision 2000-08-23 00:00: + * Registration of new IANAifTypes + * 174-182. + * + * Revision 2000-08-22 00:00: + * Registration of new IANAifTypes 170, + * 171, 172 and 173. + * + * Revision 2000-04-25 00:00: + * Registration of new IANAifTypes 168 and 169. + * + * Revision 2000-03-06 00:00: + * Fixed a missing semi-colon in the IMPORT. + * Also cleaned up the REVISION log a bit. + * It is not complete, but from now on it will + * be maintained and kept up to date with each + * change to this MIB module. + * + * Revision 1999-10-08 14:30: + * Include new name assignments up to cnr(85). + * This is the first version available via the WWW + * at: ftp://ftp.isi.edu/mib/ianaiftype.mib + * + * Revision 1994-01-31 00:00: + * Initial version of this MIB as published in + * RFC 1573. + * + * $Id$ + */ + +#include "ianaiftype-mib.h" + +GNetSnmpEnum const ianaiftype_mib_enums_IANAifType[] = { + { IANAIFTYPE_MIB_IANAIFTYPE_OTHER, "other" }, + { IANAIFTYPE_MIB_IANAIFTYPE_REGULAR1822, "regular1822" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HDH1822, "hdh1822" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DDNX25, "ddnX25" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RFC877X25, "rfc877x25" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ETHERNETCSMACD, "ethernetCsmacd" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88023CSMACD, "iso88023Csmacd" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88024TOKENBUS, "iso88024TokenBus" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88025TOKENRING, "iso88025TokenRing" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88026MAN, "iso88026Man" }, + { IANAIFTYPE_MIB_IANAIFTYPE_STARLAN, "starLan" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROTEON10MBIT, "proteon10Mbit" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROTEON80MBIT, "proteon80Mbit" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HYPERCHANNEL, "hyperchannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FDDI, "fddi" }, + { IANAIFTYPE_MIB_IANAIFTYPE_LAPB, "lapb" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SDLC, "sdlc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DS1, "ds1" }, + { IANAIFTYPE_MIB_IANAIFTYPE_E1, "e1" }, + { IANAIFTYPE_MIB_IANAIFTYPE_BASICISDN, "basicISDN" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PRIMARYISDN, "primaryISDN" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPPOINTTOPOINTSERIAL, "propPointToPointSerial" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PPP, "ppp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SOFTWARELOOPBACK, "softwareLoopback" }, + { IANAIFTYPE_MIB_IANAIFTYPE_EON, "eon" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ETHERNET3MBIT, "ethernet3Mbit" }, + { IANAIFTYPE_MIB_IANAIFTYPE_NSIP, "nsip" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SLIP, "slip" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ULTRA, "ultra" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DS3, "ds3" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SIP, "sip" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAY, "frameRelay" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RS232, "rs232" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PARA, "para" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ARCNET, "arcnet" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ARCNETPLUS, "arcnetPlus" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATM, "atm" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MIOX25, "miox25" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SONET, "sonet" }, + { IANAIFTYPE_MIB_IANAIFTYPE_X25PLE, "x25ple" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88022LLC, "iso88022llc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_LOCALTALK, "localTalk" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SMDSDXI, "smdsDxi" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYSERVICE, "frameRelayService" }, + { IANAIFTYPE_MIB_IANAIFTYPE_V35, "v35" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HSSI, "hssi" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HIPPI, "hippi" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MODEM, "modem" }, + { IANAIFTYPE_MIB_IANAIFTYPE_AAL5, "aal5" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SONETPATH, "sonetPath" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SONETVT, "sonetVT" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SMDSICIP, "smdsIcip" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPVIRTUAL, "propVirtual" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPMULTIPLEXOR, "propMultiplexor" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IEEE80212, "ieee80212" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FIBRECHANNEL, "fibreChannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HIPPIINTERFACE, "hippiInterface" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYINTERCONNECT, "frameRelayInterconnect" }, + { IANAIFTYPE_MIB_IANAIFTYPE_AFLANE8023, "aflane8023" }, + { IANAIFTYPE_MIB_IANAIFTYPE_AFLANE8025, "aflane8025" }, + { IANAIFTYPE_MIB_IANAIFTYPE_CCTEMUL, "cctEmul" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FASTETHER, "fastEther" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISDN, "isdn" }, + { IANAIFTYPE_MIB_IANAIFTYPE_V11, "v11" }, + { IANAIFTYPE_MIB_IANAIFTYPE_V36, "v36" }, + { IANAIFTYPE_MIB_IANAIFTYPE_G703AT64K, "g703at64k" }, + { IANAIFTYPE_MIB_IANAIFTYPE_G703AT2MB, "g703at2mb" }, + { IANAIFTYPE_MIB_IANAIFTYPE_QLLC, "qllc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FASTETHERFX, "fastEtherFX" }, + { IANAIFTYPE_MIB_IANAIFTYPE_CHANNEL, "channel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IEEE80211, "ieee80211" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IBM370PARCHAN, "ibm370parChan" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ESCON, "escon" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DLSW, "dlsw" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISDNS, "isdns" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISDNU, "isdnu" }, + { IANAIFTYPE_MIB_IANAIFTYPE_LAPD, "lapd" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IPSWITCH, "ipSwitch" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RSRB, "rsrb" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMLOGICAL, "atmLogical" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DS0, "ds0" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DS0BUNDLE, "ds0Bundle" }, + { IANAIFTYPE_MIB_IANAIFTYPE_BSC, "bsc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ASYNC, "async" }, + { IANAIFTYPE_MIB_IANAIFTYPE_CNR, "cnr" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88025DTR, "iso88025Dtr" }, + { IANAIFTYPE_MIB_IANAIFTYPE_EPLRS, "eplrs" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ARAP, "arap" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPCNLS, "propCnls" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HOSTPAD, "hostPad" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TERMPAD, "termPad" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYMPI, "frameRelayMPI" }, + { IANAIFTYPE_MIB_IANAIFTYPE_X213, "x213" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ADSL, "adsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RADSL, "radsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SDSL, "sdsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VDSL, "vdsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88025CRFPINT, "iso88025CRFPInt" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MYRINET, "myrinet" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEEM, "voiceEM" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEFXO, "voiceFXO" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEFXS, "voiceFXS" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEENCAP, "voiceEncap" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERIP, "voiceOverIp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMDXI, "atmDxi" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMFUNI, "atmFuni" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMIMA, "atmIma" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PPPMULTILINKBUNDLE, "pppMultilinkBundle" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IPOVERCDLC, "ipOverCdlc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IPOVERCLAW, "ipOverClaw" }, + { IANAIFTYPE_MIB_IANAIFTYPE_STACKTOSTACK, "stackToStack" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VIRTUALIPADDRESS, "virtualIpAddress" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MPC, "mpc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IPOVERATM, "ipOverAtm" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISO88025FIBER, "iso88025Fiber" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TDLC, "tdlc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_GIGABITETHERNET, "gigabitEthernet" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HDLC, "hdlc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_LAPF, "lapf" }, + { IANAIFTYPE_MIB_IANAIFTYPE_V37, "v37" }, + { IANAIFTYPE_MIB_IANAIFTYPE_X25MLP, "x25mlp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_X25HUNTGROUP, "x25huntGroup" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TRASNPHDLC, "trasnpHdlc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_INTERLEAVE, "interleave" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FAST, "fast" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IP, "ip" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEMACLAYER, "docsCableMaclayer" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEDOWNSTREAM, "docsCableDownstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEUPSTREAM, "docsCableUpstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_A12MPPSWITCH, "a12MppSwitch" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TUNNEL, "tunnel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_COFFEE, "coffee" }, + { IANAIFTYPE_MIB_IANAIFTYPE_CES, "ces" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMSUBINTERFACE, "atmSubInterface" }, + { IANAIFTYPE_MIB_IANAIFTYPE_L2VLAN, "l2vlan" }, + { IANAIFTYPE_MIB_IANAIFTYPE_L3IPVLAN, "l3ipvlan" }, + { IANAIFTYPE_MIB_IANAIFTYPE_L3IPXVLAN, "l3ipxvlan" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DIGITALPOWERLINE, "digitalPowerline" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MEDIAMAILOVERIP, "mediaMailOverIp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DTM, "dtm" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DCN, "dcn" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IPFORWARD, "ipForward" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MSDSL, "msdsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IEEE1394, "ieee1394" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IF_GSN, "if-gsn" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCMACLAYER, "dvbRccMacLayer" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCDOWNSTREAM, "dvbRccDownstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCUPSTREAM, "dvbRccUpstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMVIRTUAL, "atmVirtual" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MPLSTUNNEL, "mplsTunnel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SRP, "srp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERATM, "voiceOverAtm" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERFRAMERELAY, "voiceOverFrameRelay" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IDSL, "idsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_COMPOSITELINK, "compositeLink" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SS7SIGLINK, "ss7SigLink" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPWIRELESSP2P, "propWirelessP2P" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRFORWARD, "frForward" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RFC1483, "rfc1483" }, + { IANAIFTYPE_MIB_IANAIFTYPE_USB, "usb" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IEEE8023ADLAG, "ieee8023adLag" }, + { IANAIFTYPE_MIB_IANAIFTYPE_BGPPOLICYACCOUNTING, "bgppolicyaccounting" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRF16MFRBUNDLE, "frf16MfrBundle" }, + { IANAIFTYPE_MIB_IANAIFTYPE_H323GATEKEEPER, "h323Gatekeeper" }, + { IANAIFTYPE_MIB_IANAIFTYPE_H323PROXY, "h323Proxy" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MPLS, "mpls" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MFSIGLINK, "mfSigLink" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HDSL2, "hdsl2" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SHDSL, "shdsl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DS1FDL, "ds1FDL" }, + { IANAIFTYPE_MIB_IANAIFTYPE_POS, "pos" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DVBASIIN, "dvbAsiIn" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DVBASIOUT, "dvbAsiOut" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PLC, "plc" }, + { IANAIFTYPE_MIB_IANAIFTYPE_NFAS, "nfas" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TR008, "tr008" }, + { IANAIFTYPE_MIB_IANAIFTYPE_GR303RDT, "gr303RDT" }, + { IANAIFTYPE_MIB_IANAIFTYPE_GR303IDT, "gr303IDT" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ISUP, "isup" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSMACLAYER, "propDocsWirelessMaclayer" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSDOWNSTREAM, "propDocsWirelessDownstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSUPSTREAM, "propDocsWirelessUpstream" }, + { IANAIFTYPE_MIB_IANAIFTYPE_HIPERLAN2, "hiperlan2" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPBWAP2MP, "propBWAp2Mp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SONETOVERHEADCHANNEL, "sonetOverheadChannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DIGITALWRAPPEROVERHEADCHANNEL, "digitalWrapperOverheadChannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_AAL2, "aal2" }, + { IANAIFTYPE_MIB_IANAIFTYPE_RADIOMAC, "radioMAC" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMRADIO, "atmRadio" }, + { IANAIFTYPE_MIB_IANAIFTYPE_IMT, "imt" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MVL, "mvl" }, + { IANAIFTYPE_MIB_IANAIFTYPE_REACHDSL, "reachDSL" }, + { IANAIFTYPE_MIB_IANAIFTYPE_FRDLCIENDPT, "frDlciEndPt" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ATMVCIENDPT, "atmVciEndPt" }, + { IANAIFTYPE_MIB_IANAIFTYPE_OPTICALCHANNEL, "opticalChannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_OPTICALTRANSPORT, "opticalTransport" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PROPATM, "propAtm" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERCABLE, "voiceOverCable" }, + { IANAIFTYPE_MIB_IANAIFTYPE_INFINIBAND, "infiniband" }, + { IANAIFTYPE_MIB_IANAIFTYPE_TELINK, "teLink" }, + { IANAIFTYPE_MIB_IANAIFTYPE_Q2931, "q2931" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VIRTUALTG, "virtualTg" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SIPTG, "sipTg" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SIPSIG, "sipSig" }, + { IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEUPSTREAMCHANNEL, "docsCableUpstreamChannel" }, + { IANAIFTYPE_MIB_IANAIFTYPE_ECONET, "econet" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PON155, "pon155" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PON622, "pon622" }, + { IANAIFTYPE_MIB_IANAIFTYPE_BRIDGE, "bridge" }, + { IANAIFTYPE_MIB_IANAIFTYPE_LINEGROUP, "linegroup" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEEMFGD, "voiceEMFGD" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEFGDEANA, "voiceFGDEANA" }, + { IANAIFTYPE_MIB_IANAIFTYPE_VOICEDID, "voiceDID" }, + { IANAIFTYPE_MIB_IANAIFTYPE_MPEGTRANSPORT, "mpegTransport" }, + { IANAIFTYPE_MIB_IANAIFTYPE_SIXTOFOUR, "sixToFour" }, + { IANAIFTYPE_MIB_IANAIFTYPE_GTP, "gtp" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PDNETHERLOOP1, "pdnEtherLoop1" }, + { IANAIFTYPE_MIB_IANAIFTYPE_PDNETHERLOOP2, "pdnEtherLoop2" }, + { IANAIFTYPE_MIB_IANAIFTYPE_OPTICALCHANNELGROUP, "opticalChannelGroup" }, + { 0, NULL } +}; + + diff --git a/examples/ianaiftype-mib.h b/examples/ianaiftype-mib.h new file mode 100644 index 0000000..2555ec1 --- /dev/null +++ b/examples/ianaiftype-mib.h @@ -0,0 +1,354 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli IANAifType-MIB + * + * Derived from IANAifType-MIB: + * This MIB module defines the IANAifType Textual + * Convention, and thus the enumerated values of + * the ifType object defined in MIB-II's ifTable. + * + * Revision 2002-10-17 00:00: + * Registration of new IANAifType + * 219. + * + * Revision 2002-07-16 00:00: + * Registration of new IANAifTypes + * 217 and 218. + * + * Revision 2002-07-10 00:00: + * Registration of new IANAifTypes + * 215 and 216. + * + * Revision 2002-06-19 00:00: + * Registration of new IANAifType + * 214. + * + * Revision 2002-01-04 00:00: + * Registration of new IANAifTypes + * 211, 212 and 213. + * + * Revision 2001-12-20 00:00: + * Registration of new IANAifTypes + * 209 and 210. + * + * Revision 2001-11-15 00:00: + * Registration of new IANAifTypes + * 207 and 208. + * + * Revision 2001-11-06 00:00: + * Registration of new IANAifType + * 206. + * + * Revision 2001-11-02 00:00: + * Registration of new IANAifType + * 205. + * + * Revision 2001-10-16 00:00: + * Registration of new IANAifTypes + * 199, 200, 201, 202, 203, and 204. + * + * Revision 2001-09-19 00:00: + * Registration of new IANAifType + * 198. + * + * Revision 2001-05-11 00:00: + * Registration of new IANAifType + * 197. + * + * Revision 2001-01-12 00:00: + * Registration of new IANAifTypes + * 195 and 196. + * + * Revision 2000-12-19 00:00: + * Registration of new IANAifTypes + * 193 and 194. + * + * Revision 2000-12-07 00:00: + * Registration of new IANAifTypes + * 191 and 192. + * + * Revision 2000-12-04 00:00: + * Registration of new IANAifType + * 190. + * + * Revision 2000-10-17 00:00: + * Registration of new IANAifTypes + * 188 and 189. + * + * Revision 2000-10-02 00:00: + * Registration of new IANAifType 187. + * + * Revision 2000-09-01 00:00: + * Registration of new IANAifTypes + * 184, 185, and 186. + * + * Revision 2000-08-24 00:00: + * Registration of new IANAifType 183. + * + * Revision 2000-08-23 00:00: + * Registration of new IANAifTypes + * 174-182. + * + * Revision 2000-08-22 00:00: + * Registration of new IANAifTypes 170, + * 171, 172 and 173. + * + * Revision 2000-04-25 00:00: + * Registration of new IANAifTypes 168 and 169. + * + * Revision 2000-03-06 00:00: + * Fixed a missing semi-colon in the IMPORT. + * Also cleaned up the REVISION log a bit. + * It is not complete, but from now on it will + * be maintained and kept up to date with each + * change to this MIB module. + * + * Revision 1999-10-08 14:30: + * Include new name assignments up to cnr(85). + * This is the first version available via the WWW + * at: ftp://ftp.isi.edu/mib/ianaiftype.mib + * + * Revision 1994-01-31 00:00: + * Initial version of this MIB as published in + * RFC 1573. + * + * $Id$ + */ + +#ifndef _IANAIFTYPE_MIB_H_ +#define _IANAIFTYPE_MIB_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define IANAIFTYPE_MIB_IANAIFTYPE_OTHER 1 +#define IANAIFTYPE_MIB_IANAIFTYPE_REGULAR1822 2 +#define IANAIFTYPE_MIB_IANAIFTYPE_HDH1822 3 +#define IANAIFTYPE_MIB_IANAIFTYPE_DDNX25 4 +#define IANAIFTYPE_MIB_IANAIFTYPE_RFC877X25 5 +#define IANAIFTYPE_MIB_IANAIFTYPE_ETHERNETCSMACD 6 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88023CSMACD 7 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88024TOKENBUS 8 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88025TOKENRING 9 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88026MAN 10 +#define IANAIFTYPE_MIB_IANAIFTYPE_STARLAN 11 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROTEON10MBIT 12 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROTEON80MBIT 13 +#define IANAIFTYPE_MIB_IANAIFTYPE_HYPERCHANNEL 14 +#define IANAIFTYPE_MIB_IANAIFTYPE_FDDI 15 +#define IANAIFTYPE_MIB_IANAIFTYPE_LAPB 16 +#define IANAIFTYPE_MIB_IANAIFTYPE_SDLC 17 +#define IANAIFTYPE_MIB_IANAIFTYPE_DS1 18 +#define IANAIFTYPE_MIB_IANAIFTYPE_E1 19 +#define IANAIFTYPE_MIB_IANAIFTYPE_BASICISDN 20 +#define IANAIFTYPE_MIB_IANAIFTYPE_PRIMARYISDN 21 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPPOINTTOPOINTSERIAL 22 +#define IANAIFTYPE_MIB_IANAIFTYPE_PPP 23 +#define IANAIFTYPE_MIB_IANAIFTYPE_SOFTWARELOOPBACK 24 +#define IANAIFTYPE_MIB_IANAIFTYPE_EON 25 +#define IANAIFTYPE_MIB_IANAIFTYPE_ETHERNET3MBIT 26 +#define IANAIFTYPE_MIB_IANAIFTYPE_NSIP 27 +#define IANAIFTYPE_MIB_IANAIFTYPE_SLIP 28 +#define IANAIFTYPE_MIB_IANAIFTYPE_ULTRA 29 +#define IANAIFTYPE_MIB_IANAIFTYPE_DS3 30 +#define IANAIFTYPE_MIB_IANAIFTYPE_SIP 31 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAY 32 +#define IANAIFTYPE_MIB_IANAIFTYPE_RS232 33 +#define IANAIFTYPE_MIB_IANAIFTYPE_PARA 34 +#define IANAIFTYPE_MIB_IANAIFTYPE_ARCNET 35 +#define IANAIFTYPE_MIB_IANAIFTYPE_ARCNETPLUS 36 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATM 37 +#define IANAIFTYPE_MIB_IANAIFTYPE_MIOX25 38 +#define IANAIFTYPE_MIB_IANAIFTYPE_SONET 39 +#define IANAIFTYPE_MIB_IANAIFTYPE_X25PLE 40 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88022LLC 41 +#define IANAIFTYPE_MIB_IANAIFTYPE_LOCALTALK 42 +#define IANAIFTYPE_MIB_IANAIFTYPE_SMDSDXI 43 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYSERVICE 44 +#define IANAIFTYPE_MIB_IANAIFTYPE_V35 45 +#define IANAIFTYPE_MIB_IANAIFTYPE_HSSI 46 +#define IANAIFTYPE_MIB_IANAIFTYPE_HIPPI 47 +#define IANAIFTYPE_MIB_IANAIFTYPE_MODEM 48 +#define IANAIFTYPE_MIB_IANAIFTYPE_AAL5 49 +#define IANAIFTYPE_MIB_IANAIFTYPE_SONETPATH 50 +#define IANAIFTYPE_MIB_IANAIFTYPE_SONETVT 51 +#define IANAIFTYPE_MIB_IANAIFTYPE_SMDSICIP 52 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPVIRTUAL 53 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPMULTIPLEXOR 54 +#define IANAIFTYPE_MIB_IANAIFTYPE_IEEE80212 55 +#define IANAIFTYPE_MIB_IANAIFTYPE_FIBRECHANNEL 56 +#define IANAIFTYPE_MIB_IANAIFTYPE_HIPPIINTERFACE 57 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYINTERCONNECT 58 +#define IANAIFTYPE_MIB_IANAIFTYPE_AFLANE8023 59 +#define IANAIFTYPE_MIB_IANAIFTYPE_AFLANE8025 60 +#define IANAIFTYPE_MIB_IANAIFTYPE_CCTEMUL 61 +#define IANAIFTYPE_MIB_IANAIFTYPE_FASTETHER 62 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISDN 63 +#define IANAIFTYPE_MIB_IANAIFTYPE_V11 64 +#define IANAIFTYPE_MIB_IANAIFTYPE_V36 65 +#define IANAIFTYPE_MIB_IANAIFTYPE_G703AT64K 66 +#define IANAIFTYPE_MIB_IANAIFTYPE_G703AT2MB 67 +#define IANAIFTYPE_MIB_IANAIFTYPE_QLLC 68 +#define IANAIFTYPE_MIB_IANAIFTYPE_FASTETHERFX 69 +#define IANAIFTYPE_MIB_IANAIFTYPE_CHANNEL 70 +#define IANAIFTYPE_MIB_IANAIFTYPE_IEEE80211 71 +#define IANAIFTYPE_MIB_IANAIFTYPE_IBM370PARCHAN 72 +#define IANAIFTYPE_MIB_IANAIFTYPE_ESCON 73 +#define IANAIFTYPE_MIB_IANAIFTYPE_DLSW 74 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISDNS 75 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISDNU 76 +#define IANAIFTYPE_MIB_IANAIFTYPE_LAPD 77 +#define IANAIFTYPE_MIB_IANAIFTYPE_IPSWITCH 78 +#define IANAIFTYPE_MIB_IANAIFTYPE_RSRB 79 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMLOGICAL 80 +#define IANAIFTYPE_MIB_IANAIFTYPE_DS0 81 +#define IANAIFTYPE_MIB_IANAIFTYPE_DS0BUNDLE 82 +#define IANAIFTYPE_MIB_IANAIFTYPE_BSC 83 +#define IANAIFTYPE_MIB_IANAIFTYPE_ASYNC 84 +#define IANAIFTYPE_MIB_IANAIFTYPE_CNR 85 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88025DTR 86 +#define IANAIFTYPE_MIB_IANAIFTYPE_EPLRS 87 +#define IANAIFTYPE_MIB_IANAIFTYPE_ARAP 88 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPCNLS 89 +#define IANAIFTYPE_MIB_IANAIFTYPE_HOSTPAD 90 +#define IANAIFTYPE_MIB_IANAIFTYPE_TERMPAD 91 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRAMERELAYMPI 92 +#define IANAIFTYPE_MIB_IANAIFTYPE_X213 93 +#define IANAIFTYPE_MIB_IANAIFTYPE_ADSL 94 +#define IANAIFTYPE_MIB_IANAIFTYPE_RADSL 95 +#define IANAIFTYPE_MIB_IANAIFTYPE_SDSL 96 +#define IANAIFTYPE_MIB_IANAIFTYPE_VDSL 97 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88025CRFPINT 98 +#define IANAIFTYPE_MIB_IANAIFTYPE_MYRINET 99 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEEM 100 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEFXO 101 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEFXS 102 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEENCAP 103 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERIP 104 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMDXI 105 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMFUNI 106 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMIMA 107 +#define IANAIFTYPE_MIB_IANAIFTYPE_PPPMULTILINKBUNDLE 108 +#define IANAIFTYPE_MIB_IANAIFTYPE_IPOVERCDLC 109 +#define IANAIFTYPE_MIB_IANAIFTYPE_IPOVERCLAW 110 +#define IANAIFTYPE_MIB_IANAIFTYPE_STACKTOSTACK 111 +#define IANAIFTYPE_MIB_IANAIFTYPE_VIRTUALIPADDRESS 112 +#define IANAIFTYPE_MIB_IANAIFTYPE_MPC 113 +#define IANAIFTYPE_MIB_IANAIFTYPE_IPOVERATM 114 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISO88025FIBER 115 +#define IANAIFTYPE_MIB_IANAIFTYPE_TDLC 116 +#define IANAIFTYPE_MIB_IANAIFTYPE_GIGABITETHERNET 117 +#define IANAIFTYPE_MIB_IANAIFTYPE_HDLC 118 +#define IANAIFTYPE_MIB_IANAIFTYPE_LAPF 119 +#define IANAIFTYPE_MIB_IANAIFTYPE_V37 120 +#define IANAIFTYPE_MIB_IANAIFTYPE_X25MLP 121 +#define IANAIFTYPE_MIB_IANAIFTYPE_X25HUNTGROUP 122 +#define IANAIFTYPE_MIB_IANAIFTYPE_TRASNPHDLC 123 +#define IANAIFTYPE_MIB_IANAIFTYPE_INTERLEAVE 124 +#define IANAIFTYPE_MIB_IANAIFTYPE_FAST 125 +#define IANAIFTYPE_MIB_IANAIFTYPE_IP 126 +#define IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEMACLAYER 127 +#define IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEDOWNSTREAM 128 +#define IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEUPSTREAM 129 +#define IANAIFTYPE_MIB_IANAIFTYPE_A12MPPSWITCH 130 +#define IANAIFTYPE_MIB_IANAIFTYPE_TUNNEL 131 +#define IANAIFTYPE_MIB_IANAIFTYPE_COFFEE 132 +#define IANAIFTYPE_MIB_IANAIFTYPE_CES 133 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMSUBINTERFACE 134 +#define IANAIFTYPE_MIB_IANAIFTYPE_L2VLAN 135 +#define IANAIFTYPE_MIB_IANAIFTYPE_L3IPVLAN 136 +#define IANAIFTYPE_MIB_IANAIFTYPE_L3IPXVLAN 137 +#define IANAIFTYPE_MIB_IANAIFTYPE_DIGITALPOWERLINE 138 +#define IANAIFTYPE_MIB_IANAIFTYPE_MEDIAMAILOVERIP 139 +#define IANAIFTYPE_MIB_IANAIFTYPE_DTM 140 +#define IANAIFTYPE_MIB_IANAIFTYPE_DCN 141 +#define IANAIFTYPE_MIB_IANAIFTYPE_IPFORWARD 142 +#define IANAIFTYPE_MIB_IANAIFTYPE_MSDSL 143 +#define IANAIFTYPE_MIB_IANAIFTYPE_IEEE1394 144 +#define IANAIFTYPE_MIB_IANAIFTYPE_IF_GSN 145 +#define IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCMACLAYER 146 +#define IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCDOWNSTREAM 147 +#define IANAIFTYPE_MIB_IANAIFTYPE_DVBRCCUPSTREAM 148 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMVIRTUAL 149 +#define IANAIFTYPE_MIB_IANAIFTYPE_MPLSTUNNEL 150 +#define IANAIFTYPE_MIB_IANAIFTYPE_SRP 151 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERATM 152 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERFRAMERELAY 153 +#define IANAIFTYPE_MIB_IANAIFTYPE_IDSL 154 +#define IANAIFTYPE_MIB_IANAIFTYPE_COMPOSITELINK 155 +#define IANAIFTYPE_MIB_IANAIFTYPE_SS7SIGLINK 156 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPWIRELESSP2P 157 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRFORWARD 158 +#define IANAIFTYPE_MIB_IANAIFTYPE_RFC1483 159 +#define IANAIFTYPE_MIB_IANAIFTYPE_USB 160 +#define IANAIFTYPE_MIB_IANAIFTYPE_IEEE8023ADLAG 161 +#define IANAIFTYPE_MIB_IANAIFTYPE_BGPPOLICYACCOUNTING 162 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRF16MFRBUNDLE 163 +#define IANAIFTYPE_MIB_IANAIFTYPE_H323GATEKEEPER 164 +#define IANAIFTYPE_MIB_IANAIFTYPE_H323PROXY 165 +#define IANAIFTYPE_MIB_IANAIFTYPE_MPLS 166 +#define IANAIFTYPE_MIB_IANAIFTYPE_MFSIGLINK 167 +#define IANAIFTYPE_MIB_IANAIFTYPE_HDSL2 168 +#define IANAIFTYPE_MIB_IANAIFTYPE_SHDSL 169 +#define IANAIFTYPE_MIB_IANAIFTYPE_DS1FDL 170 +#define IANAIFTYPE_MIB_IANAIFTYPE_POS 171 +#define IANAIFTYPE_MIB_IANAIFTYPE_DVBASIIN 172 +#define IANAIFTYPE_MIB_IANAIFTYPE_DVBASIOUT 173 +#define IANAIFTYPE_MIB_IANAIFTYPE_PLC 174 +#define IANAIFTYPE_MIB_IANAIFTYPE_NFAS 175 +#define IANAIFTYPE_MIB_IANAIFTYPE_TR008 176 +#define IANAIFTYPE_MIB_IANAIFTYPE_GR303RDT 177 +#define IANAIFTYPE_MIB_IANAIFTYPE_GR303IDT 178 +#define IANAIFTYPE_MIB_IANAIFTYPE_ISUP 179 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSMACLAYER 180 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSDOWNSTREAM 181 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPDOCSWIRELESSUPSTREAM 182 +#define IANAIFTYPE_MIB_IANAIFTYPE_HIPERLAN2 183 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPBWAP2MP 184 +#define IANAIFTYPE_MIB_IANAIFTYPE_SONETOVERHEADCHANNEL 185 +#define IANAIFTYPE_MIB_IANAIFTYPE_DIGITALWRAPPEROVERHEADCHANNEL 186 +#define IANAIFTYPE_MIB_IANAIFTYPE_AAL2 187 +#define IANAIFTYPE_MIB_IANAIFTYPE_RADIOMAC 188 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMRADIO 189 +#define IANAIFTYPE_MIB_IANAIFTYPE_IMT 190 +#define IANAIFTYPE_MIB_IANAIFTYPE_MVL 191 +#define IANAIFTYPE_MIB_IANAIFTYPE_REACHDSL 192 +#define IANAIFTYPE_MIB_IANAIFTYPE_FRDLCIENDPT 193 +#define IANAIFTYPE_MIB_IANAIFTYPE_ATMVCIENDPT 194 +#define IANAIFTYPE_MIB_IANAIFTYPE_OPTICALCHANNEL 195 +#define IANAIFTYPE_MIB_IANAIFTYPE_OPTICALTRANSPORT 196 +#define IANAIFTYPE_MIB_IANAIFTYPE_PROPATM 197 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEOVERCABLE 198 +#define IANAIFTYPE_MIB_IANAIFTYPE_INFINIBAND 199 +#define IANAIFTYPE_MIB_IANAIFTYPE_TELINK 200 +#define IANAIFTYPE_MIB_IANAIFTYPE_Q2931 201 +#define IANAIFTYPE_MIB_IANAIFTYPE_VIRTUALTG 202 +#define IANAIFTYPE_MIB_IANAIFTYPE_SIPTG 203 +#define IANAIFTYPE_MIB_IANAIFTYPE_SIPSIG 204 +#define IANAIFTYPE_MIB_IANAIFTYPE_DOCSCABLEUPSTREAMCHANNEL 205 +#define IANAIFTYPE_MIB_IANAIFTYPE_ECONET 206 +#define IANAIFTYPE_MIB_IANAIFTYPE_PON155 207 +#define IANAIFTYPE_MIB_IANAIFTYPE_PON622 208 +#define IANAIFTYPE_MIB_IANAIFTYPE_BRIDGE 209 +#define IANAIFTYPE_MIB_IANAIFTYPE_LINEGROUP 210 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEEMFGD 211 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEFGDEANA 212 +#define IANAIFTYPE_MIB_IANAIFTYPE_VOICEDID 213 +#define IANAIFTYPE_MIB_IANAIFTYPE_MPEGTRANSPORT 214 +#define IANAIFTYPE_MIB_IANAIFTYPE_SIXTOFOUR 215 +#define IANAIFTYPE_MIB_IANAIFTYPE_GTP 216 +#define IANAIFTYPE_MIB_IANAIFTYPE_PDNETHERLOOP1 217 +#define IANAIFTYPE_MIB_IANAIFTYPE_PDNETHERLOOP2 218 +#define IANAIFTYPE_MIB_IANAIFTYPE_OPTICALCHANNELGROUP 219 + +extern GNetSnmpEnum const ianaiftype_mib_enums_IANAifType[]; + + +G_END_DECLS + +#endif /* _IANAIFTYPE_MIB_H_ */ diff --git a/examples/if-mib.c b/examples/if-mib.c new file mode 100644 index 0000000..88fe66f --- /dev/null +++ b/examples/if-mib.c @@ -0,0 +1,1402 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli IF-MIB + * + * Derived from IF-MIB: + * The MIB module to describe generic objects for network + * interface sub-layers. This MIB is an updated version of + * MIB-II's ifTable, and incorporates the extensions defined in + * RFC 1229. + * + * Revision 2000-06-14 00:00: + * Clarifications agreed upon by the Interfaces MIB WG, and + * published as RFC 2863. + * + * Revision 1996-02-28 21:55: + * Revisions made by the Interfaces MIB WG, and published in + * RFC 2233. + * + * Revision 1993-11-08 21:55: + * Initial revision, published as part of RFC 1573. + * + * $Id$ + */ + +#include "if-mib.h" + +GNetSnmpEnum const if_mib_enums_ifAdminStatus[] = { + { IF_MIB_IFADMINSTATUS_UP, "up" }, + { IF_MIB_IFADMINSTATUS_DOWN, "down" }, + { IF_MIB_IFADMINSTATUS_TESTING, "testing" }, + { 0, NULL } +}; + +GNetSnmpEnum const if_mib_enums_ifOperStatus[] = { + { IF_MIB_IFOPERSTATUS_UP, "up" }, + { IF_MIB_IFOPERSTATUS_DOWN, "down" }, + { IF_MIB_IFOPERSTATUS_TESTING, "testing" }, + { IF_MIB_IFOPERSTATUS_UNKNOWN, "unknown" }, + { IF_MIB_IFOPERSTATUS_DORMANT, "dormant" }, + { IF_MIB_IFOPERSTATUS_NOTPRESENT, "notPresent" }, + { IF_MIB_IFOPERSTATUS_LOWERLAYERDOWN, "lowerLayerDown" }, + { 0, NULL } +}; + +GNetSnmpEnum const if_mib_enums_ifLinkUpDownTrapEnable[] = { + { IF_MIB_IFLINKUPDOWNTRAPENABLE_ENABLED, "enabled" }, + { IF_MIB_IFLINKUPDOWNTRAPENABLE_DISABLED, "disabled" }, + { 0, NULL } +}; + +GNetSnmpEnum const if_mib_enums_ifTestStatus[] = { + { IF_MIB_IFTESTSTATUS_NOTINUSE, "notInUse" }, + { IF_MIB_IFTESTSTATUS_INUSE, "inUse" }, + { 0, NULL } +}; + +GNetSnmpEnum const if_mib_enums_ifTestResult[] = { + { IF_MIB_IFTESTRESULT_NONE, "none" }, + { IF_MIB_IFTESTRESULT_SUCCESS, "success" }, + { IF_MIB_IFTESTRESULT_INPROGRESS, "inProgress" }, + { IF_MIB_IFTESTRESULT_NOTSUPPORTED, "notSupported" }, + { IF_MIB_IFTESTRESULT_UNABLETORUN, "unAbleToRun" }, + { IF_MIB_IFTESTRESULT_ABORTED, "aborted" }, + { IF_MIB_IFTESTRESULT_FAILED, "failed" }, + { 0, NULL } +}; + +GNetSnmpEnum const if_mib_enums_ifRcvAddressType[] = { + { IF_MIB_IFRCVADDRESSTYPE_OTHER, "other" }, + { IF_MIB_IFRCVADDRESSTYPE_VOLATILE, "volatile" }, + { IF_MIB_IFRCVADDRESSTYPE_NONVOLATILE, "nonVolatile" }, + { 0, NULL } +}; + + +static guint16 ifDescr_constraints[] = {0U, 255U, 0, 0}; +static guint16 ifName_constraints[] = {0U, 255U, 0, 0}; +static guint16 ifAlias_constraints[] = {0U, 64U, 0, 0}; +static gint32 ifTestId_constraints[] = {0L, 2147483647L, 0, 0}; +static guint16 ifTestOwner_constraints[] = {0U, 255U, 0, 0}; + + +static guint32 const interfaces_oid[] = {1, 3, 6, 1, 2, 1, 2}; + +static GNetSnmpAttribute interfaces_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFNUMBER, "ifNumber", + NULL, + G_STRUCT_OFFSET(if_mib_interfaces_t, ifNumber), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifEntry_oid[] = {1, 3, 6, 1, 2, 1, 2, 2, 1}; + +static GNetSnmpAttribute ifEntry_attr[] = { + { 2, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + IF_MIB_IFDESCR, "ifDescr", + ifDescr_constraints, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifDescr), + G_STRUCT_OFFSET(if_mib_ifEntry_t, _ifDescrLength), + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFTYPE, "ifType", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifType), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFMTU, "ifMtu", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifMtu), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, + IF_MIB_IFSPEED, "ifSpeed", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifSpeed), + 0, + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + IF_MIB_IFPHYSADDRESS, "ifPhysAddress", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifPhysAddress), + G_STRUCT_OFFSET(if_mib_ifEntry_t, _ifPhysAddressLength), + 0 }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFADMINSTATUS, "ifAdminStatus", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifAdminStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 8, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFOPERSTATUS, "ifOperStatus", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOperStatus), + 0, + 0 }, + { 9, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + IF_MIB_IFLASTCHANGE, "ifLastChange", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifLastChange), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINOCTETS, "ifInOctets", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInOctets), + 0, + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINUCASTPKTS, "ifInUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInUcastPkts), + 0, + 0 }, + { 12, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINNUCASTPKTS, "ifInNUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInNUcastPkts), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINDISCARDS, "ifInDiscards", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInDiscards), + 0, + 0 }, + { 14, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINERRORS, "ifInErrors", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInErrors), + 0, + 0 }, + { 15, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINUNKNOWNPROTOS, "ifInUnknownProtos", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifInUnknownProtos), + 0, + 0 }, + { 16, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTOCTETS, "ifOutOctets", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutOctets), + 0, + 0 }, + { 17, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTUCASTPKTS, "ifOutUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutUcastPkts), + 0, + 0 }, + { 18, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTNUCASTPKTS, "ifOutNUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutNUcastPkts), + 0, + 0 }, + { 19, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTDISCARDS, "ifOutDiscards", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutDiscards), + 0, + 0 }, + { 20, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTERRORS, "ifOutErrors", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutErrors), + 0, + 0 }, + { 21, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, + IF_MIB_IFOUTQLEN, "ifOutQLen", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifOutQLen), + 0, + 0 }, + { 22, GNET_SNMP_VARBIND_TYPE_OBJECTID, + IF_MIB_IFSPECIFIC, "ifSpecific", + NULL, + G_STRUCT_OFFSET(if_mib_ifEntry_t, ifSpecific), + G_STRUCT_OFFSET(if_mib_ifEntry_t, _ifSpecificLength), + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifMIBObjects_oid[] = {1, 3, 6, 1, 2, 1, 31, 1}; + +static GNetSnmpAttribute ifMIBObjects_attr[] = { + { 5, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + IF_MIB_IFTABLELASTCHANGE, "ifTableLastChange", + NULL, + G_STRUCT_OFFSET(if_mib_ifMIBObjects_t, ifTableLastChange), + 0, + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + IF_MIB_IFSTACKLASTCHANGE, "ifStackLastChange", + NULL, + G_STRUCT_OFFSET(if_mib_ifMIBObjects_t, ifStackLastChange), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifXEntry_oid[] = {1, 3, 6, 1, 2, 1, 31, 1, 1, 1}; + +static GNetSnmpAttribute ifXEntry_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + IF_MIB_IFNAME, "ifName", + ifName_constraints, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifName), + G_STRUCT_OFFSET(if_mib_ifXEntry_t, _ifNameLength), + 0 }, + { 2, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINMULTICASTPKTS, "ifInMulticastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifInMulticastPkts), + 0, + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFINBROADCASTPKTS, "ifInBroadcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifInBroadcastPkts), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTMULTICASTPKTS, "ifOutMulticastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifOutMulticastPkts), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_COUNTER32, + IF_MIB_IFOUTBROADCASTPKTS, "ifOutBroadcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifOutBroadcastPkts), + 0, + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCINOCTETS, "ifHCInOctets", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCInOctets), + 0, + 0 }, + { 7, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCINUCASTPKTS, "ifHCInUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCInUcastPkts), + 0, + 0 }, + { 8, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCINMULTICASTPKTS, "ifHCInMulticastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCInMulticastPkts), + 0, + 0 }, + { 9, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCINBROADCASTPKTS, "ifHCInBroadcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCInBroadcastPkts), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCOUTOCTETS, "ifHCOutOctets", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCOutOctets), + 0, + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCOUTUCASTPKTS, "ifHCOutUcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCOutUcastPkts), + 0, + 0 }, + { 12, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCOUTMULTICASTPKTS, "ifHCOutMulticastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCOutMulticastPkts), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_COUNTER64, + IF_MIB_IFHCOUTBROADCASTPKTS, "ifHCOutBroadcastPkts", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHCOutBroadcastPkts), + 0, + 0 }, + { 14, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFLINKUPDOWNTRAPENABLE, "ifLinkUpDownTrapEnable", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifLinkUpDownTrapEnable), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 15, GNET_SNMP_VARBIND_TYPE_UNSIGNED32, + IF_MIB_IFHIGHSPEED, "ifHighSpeed", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifHighSpeed), + 0, + 0 }, + { 16, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFPROMISCUOUSMODE, "ifPromiscuousMode", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifPromiscuousMode), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 17, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFCONNECTORPRESENT, "ifConnectorPresent", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifConnectorPresent), + 0, + 0 }, + { 18, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + IF_MIB_IFALIAS, "ifAlias", + ifAlias_constraints, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifAlias), + G_STRUCT_OFFSET(if_mib_ifXEntry_t, _ifAliasLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 19, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + IF_MIB_IFCOUNTERDISCONTINUITYTIME, "ifCounterDiscontinuityTime", + NULL, + G_STRUCT_OFFSET(if_mib_ifXEntry_t, ifCounterDiscontinuityTime), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifStackEntry_oid[] = {1, 3, 6, 1, 2, 1, 31, 1, 2, 1}; + +static GNetSnmpAttribute ifStackEntry_attr[] = { + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFSTACKSTATUS, "ifStackStatus", + NULL, + G_STRUCT_OFFSET(if_mib_ifStackEntry_t, ifStackStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifTestEntry_oid[] = {1, 3, 6, 1, 2, 1, 31, 1, 3, 1}; + +static GNetSnmpAttribute ifTestEntry_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFTESTID, "ifTestId", + ifTestId_constraints, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestId), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFTESTSTATUS, "ifTestStatus", + NULL, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 3, GNET_SNMP_VARBIND_TYPE_OBJECTID, + IF_MIB_IFTESTTYPE, "ifTestType", + NULL, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestType), + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, _ifTestTypeLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 4, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFTESTRESULT, "ifTestResult", + NULL, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestResult), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_OBJECTID, + IF_MIB_IFTESTCODE, "ifTestCode", + NULL, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestCode), + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, _ifTestCodeLength), + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + IF_MIB_IFTESTOWNER, "ifTestOwner", + ifTestOwner_constraints, + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, ifTestOwner), + G_STRUCT_OFFSET(if_mib_ifTestEntry_t, _ifTestOwnerLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + +static guint32 const ifRcvAddressEntry_oid[] = {1, 3, 6, 1, 2, 1, 31, 1, 4, 1}; + +static GNetSnmpAttribute ifRcvAddressEntry_attr[] = { + { 2, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFRCVADDRESSSTATUS, "ifRcvAddressStatus", + NULL, + G_STRUCT_OFFSET(if_mib_ifRcvAddressEntry_t, ifRcvAddressStatus), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 3, GNET_SNMP_VARBIND_TYPE_INTEGER32, + IF_MIB_IFRCVADDRESSTYPE, "ifRcvAddressType", + NULL, + G_STRUCT_OFFSET(if_mib_ifRcvAddressEntry_t, ifRcvAddressType), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + + +if_mib_interfaces_t * +if_mib_new_interfaces() +{ + if_mib_interfaces_t *interfaces; + + interfaces = (if_mib_interfaces_t *) g_malloc0(sizeof(if_mib_interfaces_t) + sizeof(gpointer)); + return interfaces; +} + +static inline if_mib_interfaces_t * +assign_interfaces(GList *vbl) +{ + if_mib_interfaces_t *interfaces; + char *p; + + interfaces = if_mib_new_interfaces(); + p = (char *) interfaces + sizeof(if_mib_interfaces_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, interfaces_oid, G_N_ELEMENTS(interfaces_oid), + interfaces_attr, interfaces); + + return interfaces; +} + +void +if_mib_get_interfaces(GNetSnmp *s, if_mib_interfaces_t **interfaces, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 2, 0}; + + *interfaces = NULL; + + gnet_snmp_attr_get(s, &in, base, 8, 7, interfaces_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *interfaces = assign_interfaces(out); + } +} + +void +if_mib_free_interfaces(if_mib_interfaces_t *interfaces) +{ + GList *vbl; + char *p; + + if (interfaces) { + p = (char *) interfaces + sizeof(if_mib_interfaces_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(interfaces); + } +} + +if_mib_ifEntry_t * +if_mib_new_ifEntry() +{ + if_mib_ifEntry_t *ifEntry; + + ifEntry = (if_mib_ifEntry_t *) g_malloc0(sizeof(if_mib_ifEntry_t) + sizeof(gpointer)); + return ifEntry; +} + +static inline int +unpack_ifEntry(GNetSnmpVarBind *vb, if_mib_ifEntry_t *ifEntry) +{ + guint8 idx = 10; + + if (vb->oid_len < idx) return -1; + ifEntry->ifIndex = vb->oid[idx++]; + if ((ifEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_ifEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 10; + + base[idx++] = ifIndex; + return idx; +} + +static inline if_mib_ifEntry_t * +assign_ifEntry(GList *vbl) +{ + if_mib_ifEntry_t *ifEntry; + char *p; + + ifEntry = if_mib_new_ifEntry(); + p = (char *) ifEntry + sizeof(if_mib_ifEntry_t); + * (GList **) p = vbl; + + if (unpack_ifEntry((GNetSnmpVarBind *) vbl->data, ifEntry) < 0) { + g_warning("%s: invalid instance identifier", "ifEntry"); + g_free(ifEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, ifEntry_oid, G_N_ELEMENTS(ifEntry_oid), + ifEntry_attr, ifEntry); + + return ifEntry; +} + +void +if_mib_get_ifTable(GNetSnmp *s, if_mib_ifEntry_t ***ifEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 2, 2, 1, 0}; + + *ifEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 10, 9, ifEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *ifEntry = (if_mib_ifEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(if_mib_ifEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*ifEntry)[i] = assign_ifEntry(row->data); + } + } +} + +void +if_mib_get_ifEntry(GNetSnmp *s, if_mib_ifEntry_t **ifEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifEntry_oid, sizeof(ifEntry_oid)); + len = pack_ifEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *ifEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 9, ifEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifEntry = assign_ifEntry(out); + } +} + +void +if_mib_set_ifEntry(GNetSnmp *s, if_mib_ifEntry_t *ifEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifEntry_oid, sizeof(ifEntry_oid)); + len = pack_ifEntry(base, ifEntry->ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 9, ifEntry_attr, mask, ifEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +if_mib_free_ifEntry(if_mib_ifEntry_t *ifEntry) +{ + GList *vbl; + char *p; + + if (ifEntry) { + p = (char *) ifEntry + sizeof(if_mib_ifEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifEntry); + } +} + +void +if_mib_free_ifTable(if_mib_ifEntry_t **ifEntry) +{ + int i; + + if (ifEntry) { + for (i = 0; ifEntry[i]; i++) { + if_mib_free_ifEntry(ifEntry[i]); + } + g_free(ifEntry); + } +} + +if_mib_ifMIBObjects_t * +if_mib_new_ifMIBObjects() +{ + if_mib_ifMIBObjects_t *ifMIBObjects; + + ifMIBObjects = (if_mib_ifMIBObjects_t *) g_malloc0(sizeof(if_mib_ifMIBObjects_t) + sizeof(gpointer)); + return ifMIBObjects; +} + +static inline if_mib_ifMIBObjects_t * +assign_ifMIBObjects(GList *vbl) +{ + if_mib_ifMIBObjects_t *ifMIBObjects; + char *p; + + ifMIBObjects = if_mib_new_ifMIBObjects(); + p = (char *) ifMIBObjects + sizeof(if_mib_ifMIBObjects_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, ifMIBObjects_oid, G_N_ELEMENTS(ifMIBObjects_oid), + ifMIBObjects_attr, ifMIBObjects); + + return ifMIBObjects; +} + +void +if_mib_get_ifMIBObjects(GNetSnmp *s, if_mib_ifMIBObjects_t **ifMIBObjects, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 31, 1, 0}; + + *ifMIBObjects = NULL; + + gnet_snmp_attr_get(s, &in, base, 9, 8, ifMIBObjects_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifMIBObjects = assign_ifMIBObjects(out); + } +} + +void +if_mib_free_ifMIBObjects(if_mib_ifMIBObjects_t *ifMIBObjects) +{ + GList *vbl; + char *p; + + if (ifMIBObjects) { + p = (char *) ifMIBObjects + sizeof(if_mib_ifMIBObjects_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifMIBObjects); + } +} + +if_mib_ifXEntry_t * +if_mib_new_ifXEntry() +{ + if_mib_ifXEntry_t *ifXEntry; + + ifXEntry = (if_mib_ifXEntry_t *) g_malloc0(sizeof(if_mib_ifXEntry_t) + sizeof(gpointer)); + return ifXEntry; +} + +static inline int +unpack_ifXEntry(GNetSnmpVarBind *vb, if_mib_ifXEntry_t *ifXEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + ifXEntry->ifIndex = vb->oid[idx++]; + if ((ifXEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_ifXEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + return idx; +} + +static inline if_mib_ifXEntry_t * +assign_ifXEntry(GList *vbl) +{ + if_mib_ifXEntry_t *ifXEntry; + char *p; + + ifXEntry = if_mib_new_ifXEntry(); + p = (char *) ifXEntry + sizeof(if_mib_ifXEntry_t); + * (GList **) p = vbl; + + if (unpack_ifXEntry((GNetSnmpVarBind *) vbl->data, ifXEntry) < 0) { + g_warning("%s: invalid instance identifier", "ifXEntry"); + g_free(ifXEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, ifXEntry_oid, G_N_ELEMENTS(ifXEntry_oid), + ifXEntry_attr, ifXEntry); + + return ifXEntry; +} + +void +if_mib_get_ifXTable(GNetSnmp *s, if_mib_ifXEntry_t ***ifXEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 0}; + + *ifXEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, ifXEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *ifXEntry = (if_mib_ifXEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(if_mib_ifXEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*ifXEntry)[i] = assign_ifXEntry(row->data); + } + } +} + +void +if_mib_get_ifXEntry(GNetSnmp *s, if_mib_ifXEntry_t **ifXEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifXEntry_oid, sizeof(ifXEntry_oid)); + len = pack_ifXEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifXEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *ifXEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, ifXEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifXEntry = assign_ifXEntry(out); + } +} + +void +if_mib_set_ifXEntry(GNetSnmp *s, if_mib_ifXEntry_t *ifXEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifXEntry_oid, sizeof(ifXEntry_oid)); + len = pack_ifXEntry(base, ifXEntry->ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifXEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, ifXEntry_attr, mask, ifXEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +if_mib_free_ifXEntry(if_mib_ifXEntry_t *ifXEntry) +{ + GList *vbl; + char *p; + + if (ifXEntry) { + p = (char *) ifXEntry + sizeof(if_mib_ifXEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifXEntry); + } +} + +void +if_mib_free_ifXTable(if_mib_ifXEntry_t **ifXEntry) +{ + int i; + + if (ifXEntry) { + for (i = 0; ifXEntry[i]; i++) { + if_mib_free_ifXEntry(ifXEntry[i]); + } + g_free(ifXEntry); + } +} + +if_mib_ifStackEntry_t * +if_mib_new_ifStackEntry() +{ + if_mib_ifStackEntry_t *ifStackEntry; + + ifStackEntry = (if_mib_ifStackEntry_t *) g_malloc0(sizeof(if_mib_ifStackEntry_t) + sizeof(gpointer)); + return ifStackEntry; +} + +static inline int +unpack_ifStackEntry(GNetSnmpVarBind *vb, if_mib_ifStackEntry_t *ifStackEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + ifStackEntry->ifStackHigherLayer = vb->oid[idx++]; + if ((ifStackEntry->ifStackHigherLayer < 0)) { + return -1; + } + if (vb->oid_len < idx) return -1; + ifStackEntry->ifStackLowerLayer = vb->oid[idx++]; + if ((ifStackEntry->ifStackLowerLayer < 0)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_ifStackEntry(guint32 *base, gint32 ifStackHigherLayer, gint32 ifStackLowerLayer) +{ + guint8 idx = 11; + + base[idx++] = ifStackHigherLayer; + base[idx++] = ifStackLowerLayer; + return idx; +} + +static inline if_mib_ifStackEntry_t * +assign_ifStackEntry(GList *vbl) +{ + if_mib_ifStackEntry_t *ifStackEntry; + char *p; + + ifStackEntry = if_mib_new_ifStackEntry(); + p = (char *) ifStackEntry + sizeof(if_mib_ifStackEntry_t); + * (GList **) p = vbl; + + if (unpack_ifStackEntry((GNetSnmpVarBind *) vbl->data, ifStackEntry) < 0) { + g_warning("%s: invalid instance identifier", "ifStackEntry"); + g_free(ifStackEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, ifStackEntry_oid, G_N_ELEMENTS(ifStackEntry_oid), + ifStackEntry_attr, ifStackEntry); + + return ifStackEntry; +} + +void +if_mib_get_ifStackTable(GNetSnmp *s, if_mib_ifStackEntry_t ***ifStackEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 31, 1, 2, 1, 0}; + + *ifStackEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, ifStackEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *ifStackEntry = (if_mib_ifStackEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(if_mib_ifStackEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*ifStackEntry)[i] = assign_ifStackEntry(row->data); + } + } +} + +void +if_mib_get_ifStackEntry(GNetSnmp *s, if_mib_ifStackEntry_t **ifStackEntry, gint32 ifStackHigherLayer, gint32 ifStackLowerLayer, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifStackEntry_oid, sizeof(ifStackEntry_oid)); + len = pack_ifStackEntry(base, ifStackHigherLayer, ifStackLowerLayer); + if (len < 0) { + g_warning("%s: invalid index values", "ifStackEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *ifStackEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, ifStackEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifStackEntry = assign_ifStackEntry(out); + } +} + +void +if_mib_set_ifStackEntry(GNetSnmp *s, if_mib_ifStackEntry_t *ifStackEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifStackEntry_oid, sizeof(ifStackEntry_oid)); + len = pack_ifStackEntry(base, ifStackEntry->ifStackHigherLayer, ifStackEntry->ifStackLowerLayer); + if (len < 0) { + g_warning("%s: invalid index values", "ifStackEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, ifStackEntry_attr, mask, ifStackEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +if_mib_free_ifStackEntry(if_mib_ifStackEntry_t *ifStackEntry) +{ + GList *vbl; + char *p; + + if (ifStackEntry) { + p = (char *) ifStackEntry + sizeof(if_mib_ifStackEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifStackEntry); + } +} + +void +if_mib_free_ifStackTable(if_mib_ifStackEntry_t **ifStackEntry) +{ + int i; + + if (ifStackEntry) { + for (i = 0; ifStackEntry[i]; i++) { + if_mib_free_ifStackEntry(ifStackEntry[i]); + } + g_free(ifStackEntry); + } +} + +if_mib_ifTestEntry_t * +if_mib_new_ifTestEntry() +{ + if_mib_ifTestEntry_t *ifTestEntry; + + ifTestEntry = (if_mib_ifTestEntry_t *) g_malloc0(sizeof(if_mib_ifTestEntry_t) + sizeof(gpointer)); + return ifTestEntry; +} + +static inline int +unpack_ifTestEntry(GNetSnmpVarBind *vb, if_mib_ifTestEntry_t *ifTestEntry) +{ + guint8 idx = 11; + + if (vb->oid_len < idx) return -1; + ifTestEntry->ifIndex = vb->oid[idx++]; + if ((ifTestEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_ifTestEntry(guint32 *base, gint32 ifIndex) +{ + guint8 idx = 11; + + base[idx++] = ifIndex; + return idx; +} + +static inline if_mib_ifTestEntry_t * +assign_ifTestEntry(GList *vbl) +{ + if_mib_ifTestEntry_t *ifTestEntry; + char *p; + + ifTestEntry = if_mib_new_ifTestEntry(); + p = (char *) ifTestEntry + sizeof(if_mib_ifTestEntry_t); + * (GList **) p = vbl; + + if (unpack_ifTestEntry((GNetSnmpVarBind *) vbl->data, ifTestEntry) < 0) { + g_warning("%s: invalid instance identifier", "ifTestEntry"); + g_free(ifTestEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, ifTestEntry_oid, G_N_ELEMENTS(ifTestEntry_oid), + ifTestEntry_attr, ifTestEntry); + + return ifTestEntry; +} + +void +if_mib_get_ifTestTable(GNetSnmp *s, if_mib_ifTestEntry_t ***ifTestEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 31, 1, 3, 1, 0}; + + *ifTestEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, ifTestEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *ifTestEntry = (if_mib_ifTestEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(if_mib_ifTestEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*ifTestEntry)[i] = assign_ifTestEntry(row->data); + } + } +} + +void +if_mib_get_ifTestEntry(GNetSnmp *s, if_mib_ifTestEntry_t **ifTestEntry, gint32 ifIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifTestEntry_oid, sizeof(ifTestEntry_oid)); + len = pack_ifTestEntry(base, ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifTestEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *ifTestEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, ifTestEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifTestEntry = assign_ifTestEntry(out); + } +} + +void +if_mib_set_ifTestEntry(GNetSnmp *s, if_mib_ifTestEntry_t *ifTestEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifTestEntry_oid, sizeof(ifTestEntry_oid)); + len = pack_ifTestEntry(base, ifTestEntry->ifIndex); + if (len < 0) { + g_warning("%s: invalid index values", "ifTestEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, ifTestEntry_attr, mask, ifTestEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +if_mib_free_ifTestEntry(if_mib_ifTestEntry_t *ifTestEntry) +{ + GList *vbl; + char *p; + + if (ifTestEntry) { + p = (char *) ifTestEntry + sizeof(if_mib_ifTestEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifTestEntry); + } +} + +void +if_mib_free_ifTestTable(if_mib_ifTestEntry_t **ifTestEntry) +{ + int i; + + if (ifTestEntry) { + for (i = 0; ifTestEntry[i]; i++) { + if_mib_free_ifTestEntry(ifTestEntry[i]); + } + g_free(ifTestEntry); + } +} + +if_mib_ifRcvAddressEntry_t * +if_mib_new_ifRcvAddressEntry() +{ + if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry; + + ifRcvAddressEntry = (if_mib_ifRcvAddressEntry_t *) g_malloc0(sizeof(if_mib_ifRcvAddressEntry_t) + sizeof(gpointer)); + return ifRcvAddressEntry; +} + +static inline int +unpack_ifRcvAddressEntry(GNetSnmpVarBind *vb, if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry) +{ + guint8 idx = 11; + guint16 i, len; + + if (vb->oid_len < idx) return -1; + ifRcvAddressEntry->ifIndex = vb->oid[idx++]; + if ((ifRcvAddressEntry->ifIndex < 1)) { + return -1; + } + if (vb->oid_len < idx) return -1; + len = vb->oid[idx++]; + if (len > 117) return -1; + if (vb->oid_len < idx + len) return -1; + for (i = 0; i < len; i++) { + ifRcvAddressEntry->ifRcvAddressAddress[i] = vb->oid[idx++]; + } + ifRcvAddressEntry->_ifRcvAddressAddressLength = len; + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_ifRcvAddressEntry(guint32 *base, gint32 ifIndex, guchar *ifRcvAddressAddress, guint16 _ifRcvAddressAddressLength) +{ + guint8 idx = 11; + guint16 i, len; + + base[idx++] = ifIndex; + len = _ifRcvAddressAddressLength; + base[idx++] = len; + if (len > 117) return -1; + for (i = 0; i < len; i++) { + base[idx++] = ifRcvAddressAddress[i]; + if (idx >= 128) return -1; + } + return idx; +} + +static inline if_mib_ifRcvAddressEntry_t * +assign_ifRcvAddressEntry(GList *vbl) +{ + if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry; + char *p; + + ifRcvAddressEntry = if_mib_new_ifRcvAddressEntry(); + p = (char *) ifRcvAddressEntry + sizeof(if_mib_ifRcvAddressEntry_t); + * (GList **) p = vbl; + + if (unpack_ifRcvAddressEntry((GNetSnmpVarBind *) vbl->data, ifRcvAddressEntry) < 0) { + g_warning("%s: invalid instance identifier", "ifRcvAddressEntry"); + g_free(ifRcvAddressEntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, ifRcvAddressEntry_oid, G_N_ELEMENTS(ifRcvAddressEntry_oid), + ifRcvAddressEntry_attr, ifRcvAddressEntry); + + return ifRcvAddressEntry; +} + +void +if_mib_get_ifRcvAddressTable(GNetSnmp *s, if_mib_ifRcvAddressEntry_t ***ifRcvAddressEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 31, 1, 4, 1, 0}; + + *ifRcvAddressEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 11, 10, ifRcvAddressEntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *ifRcvAddressEntry = (if_mib_ifRcvAddressEntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(if_mib_ifRcvAddressEntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*ifRcvAddressEntry)[i] = assign_ifRcvAddressEntry(row->data); + } + } +} + +void +if_mib_get_ifRcvAddressEntry(GNetSnmp *s, if_mib_ifRcvAddressEntry_t **ifRcvAddressEntry, gint32 ifIndex, guchar *ifRcvAddressAddress, guint16 _ifRcvAddressAddressLength, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifRcvAddressEntry_oid, sizeof(ifRcvAddressEntry_oid)); + len = pack_ifRcvAddressEntry(base, ifIndex, ifRcvAddressAddress, _ifRcvAddressAddressLength); + if (len < 0) { + g_warning("%s: invalid index values", "ifRcvAddressEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *ifRcvAddressEntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 10, ifRcvAddressEntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *ifRcvAddressEntry = assign_ifRcvAddressEntry(out); + } +} + +void +if_mib_set_ifRcvAddressEntry(GNetSnmp *s, if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, ifRcvAddressEntry_oid, sizeof(ifRcvAddressEntry_oid)); + len = pack_ifRcvAddressEntry(base, ifRcvAddressEntry->ifIndex, ifRcvAddressEntry->ifRcvAddressAddress, ifRcvAddressEntry->_ifRcvAddressAddressLength); + if (len < 0) { + g_warning("%s: invalid index values", "ifRcvAddressEntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + gnet_snmp_attr_set(s, &in, base, len, 10, ifRcvAddressEntry_attr, mask, ifRcvAddressEntry); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +if_mib_free_ifRcvAddressEntry(if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry) +{ + GList *vbl; + char *p; + + if (ifRcvAddressEntry) { + p = (char *) ifRcvAddressEntry + sizeof(if_mib_ifRcvAddressEntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(ifRcvAddressEntry); + } +} + +void +if_mib_free_ifRcvAddressTable(if_mib_ifRcvAddressEntry_t **ifRcvAddressEntry) +{ + int i; + + if (ifRcvAddressEntry) { + for (i = 0; ifRcvAddressEntry[i]; i++) { + if_mib_free_ifRcvAddressEntry(ifRcvAddressEntry[i]); + } + g_free(ifRcvAddressEntry); + } +} + + diff --git a/examples/if-mib.h b/examples/if-mib.h new file mode 100644 index 0000000..b30b4d3 --- /dev/null +++ b/examples/if-mib.h @@ -0,0 +1,385 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli IF-MIB + * + * Derived from IF-MIB: + * The MIB module to describe generic objects for network + * interface sub-layers. This MIB is an updated version of + * MIB-II's ifTable, and incorporates the extensions defined in + * RFC 1229. + * + * Revision 2000-06-14 00:00: + * Clarifications agreed upon by the Interfaces MIB WG, and + * published as RFC 2863. + * + * Revision 1996-02-28 21:55: + * Revisions made by the Interfaces MIB WG, and published in + * RFC 2233. + * + * Revision 1993-11-08 21:55: + * Initial revision, published as part of RFC 1573. + * + * $Id$ + */ + +#ifndef _IF_MIB_H_ +#define _IF_MIB_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define IF_MIB_IFADMINSTATUS_UP 1 +#define IF_MIB_IFADMINSTATUS_DOWN 2 +#define IF_MIB_IFADMINSTATUS_TESTING 3 + +extern GNetSnmpEnum const if_mib_enums_ifAdminStatus[]; + +#define IF_MIB_IFOPERSTATUS_UP 1 +#define IF_MIB_IFOPERSTATUS_DOWN 2 +#define IF_MIB_IFOPERSTATUS_TESTING 3 +#define IF_MIB_IFOPERSTATUS_UNKNOWN 4 +#define IF_MIB_IFOPERSTATUS_DORMANT 5 +#define IF_MIB_IFOPERSTATUS_NOTPRESENT 6 +#define IF_MIB_IFOPERSTATUS_LOWERLAYERDOWN 7 + +extern GNetSnmpEnum const if_mib_enums_ifOperStatus[]; + +#define IF_MIB_IFLINKUPDOWNTRAPENABLE_ENABLED 1 +#define IF_MIB_IFLINKUPDOWNTRAPENABLE_DISABLED 2 + +extern GNetSnmpEnum const if_mib_enums_ifLinkUpDownTrapEnable[]; + +#define IF_MIB_IFTESTSTATUS_NOTINUSE 1 +#define IF_MIB_IFTESTSTATUS_INUSE 2 + +extern GNetSnmpEnum const if_mib_enums_ifTestStatus[]; + +#define IF_MIB_IFTESTRESULT_NONE 1 +#define IF_MIB_IFTESTRESULT_SUCCESS 2 +#define IF_MIB_IFTESTRESULT_INPROGRESS 3 +#define IF_MIB_IFTESTRESULT_NOTSUPPORTED 4 +#define IF_MIB_IFTESTRESULT_UNABLETORUN 5 +#define IF_MIB_IFTESTRESULT_ABORTED 6 +#define IF_MIB_IFTESTRESULT_FAILED 7 + +extern GNetSnmpEnum const if_mib_enums_ifTestResult[]; + +#define IF_MIB_IFRCVADDRESSTYPE_OTHER 1 +#define IF_MIB_IFRCVADDRESSTYPE_VOLATILE 2 +#define IF_MIB_IFRCVADDRESSTYPE_NONVOLATILE 3 + +extern GNetSnmpEnum const if_mib_enums_ifRcvAddressType[]; + + +/* + * C type definitions for IF-MIB::interfaces. + */ + +#define IF_MIB_IFNUMBER (1 << 0) + +typedef struct { + gint32 *ifNumber; /* ro Integer32 */ +} if_mib_interfaces_t; + +extern if_mib_interfaces_t * +if_mib_new_interfaces(void); + +extern void +if_mib_get_interfaces(GNetSnmp *s, if_mib_interfaces_t **interfaces, gint64 mask); + +extern void +if_mib_free_interfaces(if_mib_interfaces_t *interfaces); + +/* + * C type definitions for IF-MIB::ifEntry. + */ + +#define IF_MIB_IFINDEX (1 << 0) +#define IF_MIB_IFDESCR (1 << 1) +#define IF_MIB_IFTYPE (1 << 2) +#define IF_MIB_IFMTU (1 << 3) +#define IF_MIB_IFSPEED (1 << 4) +#define IF_MIB_IFPHYSADDRESS (1 << 5) +#define IF_MIB_IFADMINSTATUS (1 << 6) +#define IF_MIB_IFOPERSTATUS (1 << 7) +#define IF_MIB_IFLASTCHANGE (1 << 8) +#define IF_MIB_IFINOCTETS (1 << 9) +#define IF_MIB_IFINUCASTPKTS (1 << 10) +#define IF_MIB_IFINNUCASTPKTS (1 << 11) +#define IF_MIB_IFINDISCARDS (1 << 12) +#define IF_MIB_IFINERRORS (1 << 13) +#define IF_MIB_IFINUNKNOWNPROTOS (1 << 14) +#define IF_MIB_IFOUTOCTETS (1 << 15) +#define IF_MIB_IFOUTUCASTPKTS (1 << 16) +#define IF_MIB_IFOUTNUCASTPKTS (1 << 17) +#define IF_MIB_IFOUTDISCARDS (1 << 18) +#define IF_MIB_IFOUTERRORS (1 << 19) +#define IF_MIB_IFOUTQLEN (1 << 20) +#define IF_MIB_IFSPECIFIC (1 << 21) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + guchar *ifDescr; /* ro */ +#define IF_MIB_IFDESCRMINLENGTH 0 +#define IF_MIB_IFDESCRMAXLENGTH 255 + guint16 _ifDescrLength; + gint32 *ifType; /* ro IANAifType-MIB::IANAifType */ + gint32 *ifMtu; /* ro Integer32 */ + guint32 *ifSpeed; /* ro SNMPv2-SMI::Gauge32 */ + guchar *ifPhysAddress; /* ro SNMPv2-TC::PhysAddress */ +#define IF_MIB_IFPHYSADDRESSMINLENGTH 0 +#define IF_MIB_IFPHYSADDRESSMAXLENGTH 65535 + guint16 _ifPhysAddressLength; + gint32 *ifAdminStatus; /* rw */ + gint32 *ifOperStatus; /* ro */ + guint32 *ifLastChange; /* ro SNMPv2-SMI::TimeTicks */ + guint32 *ifInOctets; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInUcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInNUcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInDiscards; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInErrors; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInUnknownProtos; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutOctets; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutUcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutNUcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutDiscards; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutErrors; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutQLen; /* ro SNMPv2-SMI::Gauge32 */ + guint32 *ifSpecific; /* ro ObjectIdentifier */ +#define IF_MIB_IFSPECIFICMINLENGTH 0 +#define IF_MIB_IFSPECIFICMAXLENGTH 128 + guint16 _ifSpecificLength; +} if_mib_ifEntry_t; + +extern void +if_mib_get_ifTable(GNetSnmp *s, if_mib_ifEntry_t ***ifEntry, gint64 mask); + +extern void +if_mib_free_ifTable(if_mib_ifEntry_t **ifEntry); + +extern if_mib_ifEntry_t * +if_mib_new_ifEntry(void); + +extern void +if_mib_get_ifEntry(GNetSnmp *s, if_mib_ifEntry_t **ifEntry, gint32 ifIndex, gint64 mask); + +extern void +if_mib_set_ifEntry(GNetSnmp *s, if_mib_ifEntry_t *ifEntry, gint64 mask); + +extern void +if_mib_free_ifEntry(if_mib_ifEntry_t *ifEntry); + +/* + * C type definitions for IF-MIB::ifMIBObjects. + */ + +#define IF_MIB_IFTABLELASTCHANGE (1 << 0) +#define IF_MIB_IFSTACKLASTCHANGE (1 << 1) + +typedef struct { + guint32 *ifTableLastChange; /* ro SNMPv2-SMI::TimeTicks */ + guint32 *ifStackLastChange; /* ro SNMPv2-SMI::TimeTicks */ +} if_mib_ifMIBObjects_t; + +extern if_mib_ifMIBObjects_t * +if_mib_new_ifMIBObjects(void); + +extern void +if_mib_get_ifMIBObjects(GNetSnmp *s, if_mib_ifMIBObjects_t **ifMIBObjects, gint64 mask); + +extern void +if_mib_free_ifMIBObjects(if_mib_ifMIBObjects_t *ifMIBObjects); + +/* + * C type definitions for IF-MIB::ifXEntry. + */ + +#define IF_MIB_IFNAME (1 << 0) +#define IF_MIB_IFINMULTICASTPKTS (1 << 1) +#define IF_MIB_IFINBROADCASTPKTS (1 << 2) +#define IF_MIB_IFOUTMULTICASTPKTS (1 << 3) +#define IF_MIB_IFOUTBROADCASTPKTS (1 << 4) +#define IF_MIB_IFHCINOCTETS (1 << 5) +#define IF_MIB_IFHCINUCASTPKTS (1 << 6) +#define IF_MIB_IFHCINMULTICASTPKTS (1 << 7) +#define IF_MIB_IFHCINBROADCASTPKTS (1 << 8) +#define IF_MIB_IFHCOUTOCTETS (1 << 9) +#define IF_MIB_IFHCOUTUCASTPKTS (1 << 10) +#define IF_MIB_IFHCOUTMULTICASTPKTS (1 << 11) +#define IF_MIB_IFHCOUTBROADCASTPKTS (1 << 12) +#define IF_MIB_IFLINKUPDOWNTRAPENABLE (1 << 13) +#define IF_MIB_IFHIGHSPEED (1 << 14) +#define IF_MIB_IFPROMISCUOUSMODE (1 << 15) +#define IF_MIB_IFCONNECTORPRESENT (1 << 16) +#define IF_MIB_IFALIAS (1 << 17) +#define IF_MIB_IFCOUNTERDISCONTINUITYTIME (1 << 18) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + guchar *ifName; /* ro SNMPv2-TC::DisplayString */ +#define IF_MIB_IFNAMEMINLENGTH 0 +#define IF_MIB_IFNAMEMAXLENGTH 255 + guint16 _ifNameLength; + guint32 *ifInMulticastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifInBroadcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutMulticastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *ifOutBroadcastPkts; /* ro SNMPv2-SMI::Counter32 */ + guint64 *ifHCInOctets; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCInUcastPkts; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCInMulticastPkts; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCInBroadcastPkts; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCOutOctets; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCOutUcastPkts; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCOutMulticastPkts; /* ro SNMPv2-SMI::Counter64 */ + guint64 *ifHCOutBroadcastPkts; /* ro SNMPv2-SMI::Counter64 */ + gint32 *ifLinkUpDownTrapEnable; /* rw */ + guint32 *ifHighSpeed; /* ro SNMPv2-SMI::Gauge32 */ + gint32 *ifPromiscuousMode; /* rw SNMPv2-TC::TruthValue */ + gint32 *ifConnectorPresent; /* ro SNMPv2-TC::TruthValue */ + guchar *ifAlias; /* rw */ +#define IF_MIB_IFALIASMINLENGTH 0 +#define IF_MIB_IFALIASMAXLENGTH 64 + guint16 _ifAliasLength; + guint32 *ifCounterDiscontinuityTime; /* ro SNMPv2-TC::TimeStamp */ +} if_mib_ifXEntry_t; + +extern void +if_mib_get_ifXTable(GNetSnmp *s, if_mib_ifXEntry_t ***ifXEntry, gint64 mask); + +extern void +if_mib_free_ifXTable(if_mib_ifXEntry_t **ifXEntry); + +extern if_mib_ifXEntry_t * +if_mib_new_ifXEntry(void); + +extern void +if_mib_get_ifXEntry(GNetSnmp *s, if_mib_ifXEntry_t **ifXEntry, gint32 ifIndex, gint64 mask); + +extern void +if_mib_set_ifXEntry(GNetSnmp *s, if_mib_ifXEntry_t *ifXEntry, gint64 mask); + +extern void +if_mib_free_ifXEntry(if_mib_ifXEntry_t *ifXEntry); + +/* + * C type definitions for IF-MIB::ifStackEntry. + */ + +#define IF_MIB_IFSTACKSTATUS (1 << 0) + +typedef struct { + gint32 ifStackHigherLayer; /* na IF-MIB::InterfaceIndexOrZero */ + gint32 ifStackLowerLayer; /* na IF-MIB::InterfaceIndexOrZero */ + gint32 *ifStackStatus; /* rw SNMPv2-TC::RowStatus */ +} if_mib_ifStackEntry_t; + +extern void +if_mib_get_ifStackTable(GNetSnmp *s, if_mib_ifStackEntry_t ***ifStackEntry, gint64 mask); + +extern void +if_mib_free_ifStackTable(if_mib_ifStackEntry_t **ifStackEntry); + +extern if_mib_ifStackEntry_t * +if_mib_new_ifStackEntry(void); + +extern void +if_mib_get_ifStackEntry(GNetSnmp *s, if_mib_ifStackEntry_t **ifStackEntry, gint32 ifStackHigherLayer, gint32 ifStackLowerLayer, gint64 mask); + +extern void +if_mib_set_ifStackEntry(GNetSnmp *s, if_mib_ifStackEntry_t *ifStackEntry, gint64 mask); + +extern void +if_mib_free_ifStackEntry(if_mib_ifStackEntry_t *ifStackEntry); + +/* + * C type definitions for IF-MIB::ifTestEntry. + */ + +#define IF_MIB_IFTESTID (1 << 0) +#define IF_MIB_IFTESTSTATUS (1 << 1) +#define IF_MIB_IFTESTTYPE (1 << 2) +#define IF_MIB_IFTESTRESULT (1 << 3) +#define IF_MIB_IFTESTCODE (1 << 4) +#define IF_MIB_IFTESTOWNER (1 << 5) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + gint32 *ifTestId; /* rw SNMPv2-TC::TestAndIncr */ + gint32 *ifTestStatus; /* rw */ + guint32 *ifTestType; /* rw SNMPv2-TC::AutonomousType */ +#define IF_MIB_IFTESTTYPEMINLENGTH 0 +#define IF_MIB_IFTESTTYPEMAXLENGTH 128 + guint16 _ifTestTypeLength; + gint32 *ifTestResult; /* ro */ + guint32 *ifTestCode; /* ro ObjectIdentifier */ +#define IF_MIB_IFTESTCODEMINLENGTH 0 +#define IF_MIB_IFTESTCODEMAXLENGTH 128 + guint16 _ifTestCodeLength; + guchar *ifTestOwner; /* rw IF-MIB::OwnerString */ +#define IF_MIB_IFTESTOWNERMINLENGTH 0 +#define IF_MIB_IFTESTOWNERMAXLENGTH 255 + guint16 _ifTestOwnerLength; +} if_mib_ifTestEntry_t; + +extern void +if_mib_get_ifTestTable(GNetSnmp *s, if_mib_ifTestEntry_t ***ifTestEntry, gint64 mask); + +extern void +if_mib_free_ifTestTable(if_mib_ifTestEntry_t **ifTestEntry); + +extern if_mib_ifTestEntry_t * +if_mib_new_ifTestEntry(void); + +extern void +if_mib_get_ifTestEntry(GNetSnmp *s, if_mib_ifTestEntry_t **ifTestEntry, gint32 ifIndex, gint64 mask); + +extern void +if_mib_set_ifTestEntry(GNetSnmp *s, if_mib_ifTestEntry_t *ifTestEntry, gint64 mask); + +extern void +if_mib_free_ifTestEntry(if_mib_ifTestEntry_t *ifTestEntry); + +/* + * C type definitions for IF-MIB::ifRcvAddressEntry. + */ + +#define IF_MIB_IFRCVADDRESSSTATUS (1 << 0) +#define IF_MIB_IFRCVADDRESSTYPE (1 << 1) + +typedef struct { + gint32 ifIndex; /* ro IF-MIB::InterfaceIndex */ + guchar ifRcvAddressAddress[117]; /* na SNMPv2-TC::PhysAddress */ +#define IF_MIB_IFRCVADDRESSADDRESSMINLENGTH 0 +#define IF_MIB_IFRCVADDRESSADDRESSMAXLENGTH 117 + guint16 _ifRcvAddressAddressLength; + gint32 *ifRcvAddressStatus; /* rw SNMPv2-TC::RowStatus */ + gint32 *ifRcvAddressType; /* rw */ +} if_mib_ifRcvAddressEntry_t; + +extern void +if_mib_get_ifRcvAddressTable(GNetSnmp *s, if_mib_ifRcvAddressEntry_t ***ifRcvAddressEntry, gint64 mask); + +extern void +if_mib_free_ifRcvAddressTable(if_mib_ifRcvAddressEntry_t **ifRcvAddressEntry); + +extern if_mib_ifRcvAddressEntry_t * +if_mib_new_ifRcvAddressEntry(void); + +extern void +if_mib_get_ifRcvAddressEntry(GNetSnmp *s, if_mib_ifRcvAddressEntry_t **ifRcvAddressEntry, gint32 ifIndex, guchar *ifRcvAddressAddress, guint16 _ifRcvAddressAddressLength, gint64 mask); + +extern void +if_mib_set_ifRcvAddressEntry(GNetSnmp *s, if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry, gint64 mask); + +extern void +if_mib_free_ifRcvAddressEntry(if_mib_ifRcvAddressEntry_t *ifRcvAddressEntry); + + +G_END_DECLS + +#endif /* _IF_MIB_H_ */ diff --git a/examples/snmpv2-mib.c b/examples/snmpv2-mib.c new file mode 100644 index 0000000..e870f3a --- /dev/null +++ b/examples/snmpv2-mib.c @@ -0,0 +1,699 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli SNMPv2-MIB + * + * Derived from SNMPv2-MIB: + * The MIB module for SNMP entities. + * + * Copyright (C) The Internet Society (2002). This + * version of this MIB module is part of RFC 3418; + * see the RFC itself for full legal notices. + * + * Revision 2002-10-16 00:00: + * This revision of this MIB module was published as + * RFC 3418. + * + * Revision 1995-11-09 00:00: + * This revision of this MIB module was published as + * RFC 1907. + * + * Revision 1993-04-01 00:00: + * The initial revision of this MIB module was published + * as RFC 1450. + * + * $Id$ + */ + +#include "snmpv2-mib.h" + +GNetSnmpEnum const snmpv2_mib_enums_snmpEnableAuthenTraps[] = { + { SNMPV2_MIB_SNMPENABLEAUTHENTRAPS_ENABLED, "enabled" }, + { SNMPV2_MIB_SNMPENABLEAUTHENTRAPS_DISABLED, "disabled" }, + { 0, NULL } +}; + + +static guint16 sysDescr_constraints[] = {0U, 255U, 0, 0}; +static guint16 sysContact_constraints[] = {0U, 255U, 0, 0}; +static guint16 sysName_constraints[] = {0U, 255U, 0, 0}; +static guint16 sysLocation_constraints[] = {0U, 255U, 0, 0}; +static gint32 sysServices_constraints[] = {0L, 127L, 0, 0}; +static guint16 sysORDescr_constraints[] = {0U, 255U, 0, 0}; +static gint32 snmpSetSerialNo_constraints[] = {0L, 2147483647L, 0, 0}; + + +static guint32 const system_oid[] = {1, 3, 6, 1, 2, 1, 1}; + +static GNetSnmpAttribute system_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + SNMPV2_MIB_SYSDESCR, "sysDescr", + sysDescr_constraints, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysDescr), + G_STRUCT_OFFSET(snmpv2_mib_system_t, _sysDescrLength), + 0 }, + { 2, GNET_SNMP_VARBIND_TYPE_OBJECTID, + SNMPV2_MIB_SYSOBJECTID, "sysObjectID", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysObjectID), + G_STRUCT_OFFSET(snmpv2_mib_system_t, _sysObjectIDLength), + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + SNMPV2_MIB_SYSUPTIME, "sysUpTime", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysUpTime), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + SNMPV2_MIB_SYSCONTACT, "sysContact", + sysContact_constraints, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysContact), + G_STRUCT_OFFSET(snmpv2_mib_system_t, _sysContactLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 5, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + SNMPV2_MIB_SYSNAME, "sysName", + sysName_constraints, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysName), + G_STRUCT_OFFSET(snmpv2_mib_system_t, _sysNameLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 6, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + SNMPV2_MIB_SYSLOCATION, "sysLocation", + sysLocation_constraints, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysLocation), + G_STRUCT_OFFSET(snmpv2_mib_system_t, _sysLocationLength), + GSNMP_ATTR_FLAG_WRITABLE }, + { 7, GNET_SNMP_VARBIND_TYPE_INTEGER32, + SNMPV2_MIB_SYSSERVICES, "sysServices", + sysServices_constraints, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysServices), + 0, + 0 }, + { 8, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + SNMPV2_MIB_SYSORLASTCHANGE, "sysORLastChange", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_system_t, sysORLastChange), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const sysOREntry_oid[] = {1, 3, 6, 1, 2, 1, 1, 9, 1}; + +static GNetSnmpAttribute sysOREntry_attr[] = { + { 2, GNET_SNMP_VARBIND_TYPE_OBJECTID, + SNMPV2_MIB_SYSORID, "sysORID", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_sysOREntry_t, sysORID), + G_STRUCT_OFFSET(snmpv2_mib_sysOREntry_t, _sysORIDLength), + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + SNMPV2_MIB_SYSORDESCR, "sysORDescr", + sysORDescr_constraints, + G_STRUCT_OFFSET(snmpv2_mib_sysOREntry_t, sysORDescr), + G_STRUCT_OFFSET(snmpv2_mib_sysOREntry_t, _sysORDescrLength), + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_TIMETICKS, + SNMPV2_MIB_SYSORUPTIME, "sysORUpTime", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_sysOREntry_t, sysORUpTime), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const snmp_oid[] = {1, 3, 6, 1, 2, 1, 11}; + +static GNetSnmpAttribute snmp_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINPKTS, "snmpInPkts", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInPkts), + 0, + 0 }, + { 2, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTPKTS, "snmpOutPkts", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutPkts), + 0, + 0 }, + { 3, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINBADVERSIONS, "snmpInBadVersions", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInBadVersions), + 0, + 0 }, + { 4, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINBADCOMMUNITYNAMES, "snmpInBadCommunityNames", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInBadCommunityNames), + 0, + 0 }, + { 5, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINBADCOMMUNITYUSES, "snmpInBadCommunityUses", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInBadCommunityUses), + 0, + 0 }, + { 6, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINASNPARSEERRS, "snmpInASNParseErrs", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInASNParseErrs), + 0, + 0 }, + { 8, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINTOOBIGS, "snmpInTooBigs", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInTooBigs), + 0, + 0 }, + { 9, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINNOSUCHNAMES, "snmpInNoSuchNames", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInNoSuchNames), + 0, + 0 }, + { 10, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINBADVALUES, "snmpInBadValues", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInBadValues), + 0, + 0 }, + { 11, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINREADONLYS, "snmpInReadOnlys", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInReadOnlys), + 0, + 0 }, + { 12, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINGENERRS, "snmpInGenErrs", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInGenErrs), + 0, + 0 }, + { 13, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINTOTALREQVARS, "snmpInTotalReqVars", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInTotalReqVars), + 0, + 0 }, + { 14, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINTOTALSETVARS, "snmpInTotalSetVars", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInTotalSetVars), + 0, + 0 }, + { 15, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINGETREQUESTS, "snmpInGetRequests", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInGetRequests), + 0, + 0 }, + { 16, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINGETNEXTS, "snmpInGetNexts", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInGetNexts), + 0, + 0 }, + { 17, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINSETREQUESTS, "snmpInSetRequests", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInSetRequests), + 0, + 0 }, + { 18, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINGETRESPONSES, "snmpInGetResponses", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInGetResponses), + 0, + 0 }, + { 19, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPINTRAPS, "snmpInTraps", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpInTraps), + 0, + 0 }, + { 20, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTTOOBIGS, "snmpOutTooBigs", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutTooBigs), + 0, + 0 }, + { 21, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTNOSUCHNAMES, "snmpOutNoSuchNames", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutNoSuchNames), + 0, + 0 }, + { 22, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTBADVALUES, "snmpOutBadValues", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutBadValues), + 0, + 0 }, + { 24, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTGENERRS, "snmpOutGenErrs", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutGenErrs), + 0, + 0 }, + { 25, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTGETREQUESTS, "snmpOutGetRequests", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutGetRequests), + 0, + 0 }, + { 26, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTGETNEXTS, "snmpOutGetNexts", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutGetNexts), + 0, + 0 }, + { 27, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTSETREQUESTS, "snmpOutSetRequests", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutSetRequests), + 0, + 0 }, + { 28, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTGETRESPONSES, "snmpOutGetResponses", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutGetResponses), + 0, + 0 }, + { 29, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPOUTTRAPS, "snmpOutTraps", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpOutTraps), + 0, + 0 }, + { 30, GNET_SNMP_VARBIND_TYPE_INTEGER32, + SNMPV2_MIB_SNMPENABLEAUTHENTRAPS, "snmpEnableAuthenTraps", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpEnableAuthenTraps), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 31, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPSILENTDROPS, "snmpSilentDrops", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpSilentDrops), + 0, + 0 }, + { 32, GNET_SNMP_VARBIND_TYPE_COUNTER32, + SNMPV2_MIB_SNMPPROXYDROPS, "snmpProxyDrops", + NULL, + G_STRUCT_OFFSET(snmpv2_mib_snmp_t, snmpProxyDrops), + 0, + 0 }, + { 0, 0, 0, NULL } +}; + +static guint32 const snmpSet_oid[] = {1, 3, 6, 1, 6, 3, 1, 1, 6}; + +static GNetSnmpAttribute snmpSet_attr[] = { + { 1, GNET_SNMP_VARBIND_TYPE_INTEGER32, + SNMPV2_MIB_SNMPSETSERIALNO, "snmpSetSerialNo", + snmpSetSerialNo_constraints, + G_STRUCT_OFFSET(snmpv2_mib_snmpSet_t, snmpSetSerialNo), + 0, + GSNMP_ATTR_FLAG_WRITABLE }, + { 0, 0, 0, NULL } +}; + + +snmpv2_mib_system_t * +snmpv2_mib_new_system() +{ + snmpv2_mib_system_t *system; + + system = (snmpv2_mib_system_t *) g_malloc0(sizeof(snmpv2_mib_system_t) + sizeof(gpointer)); + return system; +} + +static inline snmpv2_mib_system_t * +assign_system(GList *vbl) +{ + snmpv2_mib_system_t *system; + char *p; + + system = snmpv2_mib_new_system(); + p = (char *) system + sizeof(snmpv2_mib_system_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, system_oid, G_N_ELEMENTS(system_oid), + system_attr, system); + + return system; +} + +void +snmpv2_mib_get_system(GNetSnmp *s, snmpv2_mib_system_t **system, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 1, 0}; + + *system = NULL; + + gnet_snmp_attr_get(s, &in, base, 8, 7, system_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *system = assign_system(out); + } +} + +void +snmpv2_mib_set_system(GNetSnmp *s, snmpv2_mib_system_t *system, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 1, 0, 0}; + + gnet_snmp_attr_set(s, &in, base, 9, 7, system_attr, mask, system); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +snmpv2_mib_free_system(snmpv2_mib_system_t *system) +{ + GList *vbl; + char *p; + + if (system) { + p = (char *) system + sizeof(snmpv2_mib_system_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(system); + } +} + +snmpv2_mib_sysOREntry_t * +snmpv2_mib_new_sysOREntry() +{ + snmpv2_mib_sysOREntry_t *sysOREntry; + + sysOREntry = (snmpv2_mib_sysOREntry_t *) g_malloc0(sizeof(snmpv2_mib_sysOREntry_t) + sizeof(gpointer)); + return sysOREntry; +} + +static inline int +unpack_sysOREntry(GNetSnmpVarBind *vb, snmpv2_mib_sysOREntry_t *sysOREntry) +{ + guint8 idx = 10; + + if (vb->oid_len < idx) return -1; + sysOREntry->sysORIndex = vb->oid[idx++]; + if ((sysOREntry->sysORIndex < 1)) { + return -1; + } + if (vb->oid_len > idx) return -1; + return 0; +} + +static inline gint8 +pack_sysOREntry(guint32 *base, gint32 sysORIndex) +{ + guint8 idx = 10; + + base[idx++] = sysORIndex; + return idx; +} + +static inline snmpv2_mib_sysOREntry_t * +assign_sysOREntry(GList *vbl) +{ + snmpv2_mib_sysOREntry_t *sysOREntry; + char *p; + + sysOREntry = snmpv2_mib_new_sysOREntry(); + p = (char *) sysOREntry + sizeof(snmpv2_mib_sysOREntry_t); + * (GList **) p = vbl; + + if (unpack_sysOREntry((GNetSnmpVarBind *) vbl->data, sysOREntry) < 0) { + g_warning("%s: invalid instance identifier", "sysOREntry"); + g_free(sysOREntry); + return NULL; + } + + gnet_snmp_attr_assign(vbl, sysOREntry_oid, G_N_ELEMENTS(sysOREntry_oid), + sysOREntry_attr, sysOREntry); + + return sysOREntry; +} + +void +snmpv2_mib_get_sysORTable(GNetSnmp *s, snmpv2_mib_sysOREntry_t ***sysOREntry, gint64 mask) +{ + GList *in = NULL, *out = NULL; + GList *row; + int i; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 1, 9, 1, 0}; + + *sysOREntry = NULL; + + gnet_snmp_attr_get(s, &in, base, 10, 9, sysOREntry_attr, mask); + + out = gnet_snmp_sync_table(s, in); + /* gnet_snmp_varbind_list_free(in); */ + + if (out) { + *sysOREntry = (snmpv2_mib_sysOREntry_t **) g_malloc0((g_list_length(out) + 1) * sizeof(snmpv2_mib_sysOREntry_t *)); + for (row = out, i = 0; row; row = g_list_next(row), i++) { + (*sysOREntry)[i] = assign_sysOREntry(row->data); + } + } +} + +void +snmpv2_mib_get_sysOREntry(GNetSnmp *s, snmpv2_mib_sysOREntry_t **sysOREntry, gint32 sysORIndex, gint64 mask) +{ + GList *in = NULL, *out = NULL; + guint32 base[128]; + gint8 len; + + memcpy(base, sysOREntry_oid, sizeof(sysOREntry_oid)); + len = pack_sysOREntry(base, sysORIndex); + if (len < 0) { + g_warning("%s: invalid index values", "sysOREntry"); + s->error_status = GNET_SNMP_ERR_INTERNAL; + return; + } + + *sysOREntry = NULL; + + gnet_snmp_attr_get(s, &in, base, len, 9, sysOREntry_attr, mask); + + out = gnet_snmp_sync_get(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *sysOREntry = assign_sysOREntry(out); + } +} + +void +snmpv2_mib_free_sysOREntry(snmpv2_mib_sysOREntry_t *sysOREntry) +{ + GList *vbl; + char *p; + + if (sysOREntry) { + p = (char *) sysOREntry + sizeof(snmpv2_mib_sysOREntry_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(sysOREntry); + } +} + +void +snmpv2_mib_free_sysORTable(snmpv2_mib_sysOREntry_t **sysOREntry) +{ + int i; + + if (sysOREntry) { + for (i = 0; sysOREntry[i]; i++) { + snmpv2_mib_free_sysOREntry(sysOREntry[i]); + } + g_free(sysOREntry); + } +} + +snmpv2_mib_snmp_t * +snmpv2_mib_new_snmp() +{ + snmpv2_mib_snmp_t *snmp; + + snmp = (snmpv2_mib_snmp_t *) g_malloc0(sizeof(snmpv2_mib_snmp_t) + sizeof(gpointer)); + return snmp; +} + +static inline snmpv2_mib_snmp_t * +assign_snmp(GList *vbl) +{ + snmpv2_mib_snmp_t *snmp; + char *p; + + snmp = snmpv2_mib_new_snmp(); + p = (char *) snmp + sizeof(snmpv2_mib_snmp_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, snmp_oid, G_N_ELEMENTS(snmp_oid), + snmp_attr, snmp); + + return snmp; +} + +void +snmpv2_mib_get_snmp(GNetSnmp *s, snmpv2_mib_snmp_t **snmp, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 11, 0}; + + *snmp = NULL; + + gnet_snmp_attr_get(s, &in, base, 8, 7, snmp_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *snmp = assign_snmp(out); + } +} + +void +snmpv2_mib_set_snmp(GNetSnmp *s, snmpv2_mib_snmp_t *snmp, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 2, 1, 11, 0, 0}; + + gnet_snmp_attr_set(s, &in, base, 9, 7, snmp_attr, mask, snmp); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +snmpv2_mib_free_snmp(snmpv2_mib_snmp_t *snmp) +{ + GList *vbl; + char *p; + + if (snmp) { + p = (char *) snmp + sizeof(snmpv2_mib_snmp_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(snmp); + } +} + +snmpv2_mib_snmpSet_t * +snmpv2_mib_new_snmpSet() +{ + snmpv2_mib_snmpSet_t *snmpSet; + + snmpSet = (snmpv2_mib_snmpSet_t *) g_malloc0(sizeof(snmpv2_mib_snmpSet_t) + sizeof(gpointer)); + return snmpSet; +} + +static inline snmpv2_mib_snmpSet_t * +assign_snmpSet(GList *vbl) +{ + snmpv2_mib_snmpSet_t *snmpSet; + char *p; + + snmpSet = snmpv2_mib_new_snmpSet(); + p = (char *) snmpSet + sizeof(snmpv2_mib_snmpSet_t); + * (GList **) p = vbl; + + gnet_snmp_attr_assign(vbl, snmpSet_oid, G_N_ELEMENTS(snmpSet_oid), + snmpSet_attr, snmpSet); + + return snmpSet; +} + +void +snmpv2_mib_get_snmpSet(GNetSnmp *s, snmpv2_mib_snmpSet_t **snmpSet, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 6, 3, 1, 1, 6, 0}; + + *snmpSet = NULL; + + gnet_snmp_attr_get(s, &in, base, 10, 9, snmpSet_attr, mask); + + out = gnet_snmp_sync_getnext(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + if (s->error_status != GNET_SNMP_ERR_NOERROR) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + return; + } + *snmpSet = assign_snmpSet(out); + } +} + +void +snmpv2_mib_set_snmpSet(GNetSnmp *s, snmpv2_mib_snmpSet_t *snmpSet, gint64 mask) +{ + GList *in = NULL, *out = NULL; + static guint32 base[] = {1, 3, 6, 1, 6, 3, 1, 1, 6, 0, 0}; + + gnet_snmp_attr_set(s, &in, base, 11, 9, snmpSet_attr, mask, snmpSet); + + out = gnet_snmp_sync_set(s, in); + g_list_foreach(in, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(in); + if (out) { + g_list_foreach(out, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(out); + } +} + +void +snmpv2_mib_free_snmpSet(snmpv2_mib_snmpSet_t *snmpSet) +{ + GList *vbl; + char *p; + + if (snmpSet) { + p = (char *) snmpSet + sizeof(snmpv2_mib_snmpSet_t); + vbl = * (GList **) p; + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + g_free(snmpSet); + } +} + + diff --git a/examples/snmpv2-mib.h b/examples/snmpv2-mib.h new file mode 100644 index 0000000..5db5046 --- /dev/null +++ b/examples/snmpv2-mib.h @@ -0,0 +1,236 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli SNMPv2-MIB + * + * Derived from SNMPv2-MIB: + * The MIB module for SNMP entities. + * + * Copyright (C) The Internet Society (2002). This + * version of this MIB module is part of RFC 3418; + * see the RFC itself for full legal notices. + * + * Revision 2002-10-16 00:00: + * This revision of this MIB module was published as + * RFC 3418. + * + * Revision 1995-11-09 00:00: + * This revision of this MIB module was published as + * RFC 1907. + * + * Revision 1993-04-01 00:00: + * The initial revision of this MIB module was published + * as RFC 1450. + * + * $Id$ + */ + +#ifndef _SNMPV2_MIB_H_ +#define _SNMPV2_MIB_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define SNMPV2_MIB_SNMPENABLEAUTHENTRAPS_ENABLED 1 +#define SNMPV2_MIB_SNMPENABLEAUTHENTRAPS_DISABLED 2 + +extern GNetSnmpEnum const snmpv2_mib_enums_snmpEnableAuthenTraps[]; + + +/* + * C type definitions for SNMPv2-MIB::system. + */ + +#define SNMPV2_MIB_SYSDESCR (1 << 0) +#define SNMPV2_MIB_SYSOBJECTID (1 << 1) +#define SNMPV2_MIB_SYSUPTIME (1 << 2) +#define SNMPV2_MIB_SYSCONTACT (1 << 3) +#define SNMPV2_MIB_SYSNAME (1 << 4) +#define SNMPV2_MIB_SYSLOCATION (1 << 5) +#define SNMPV2_MIB_SYSSERVICES (1 << 6) +#define SNMPV2_MIB_SYSORLASTCHANGE (1 << 7) + +typedef struct { + guchar *sysDescr; /* ro */ +#define SNMPV2_MIB_SYSDESCRMINLENGTH 0 +#define SNMPV2_MIB_SYSDESCRMAXLENGTH 255 + guint16 _sysDescrLength; + guint32 *sysObjectID; /* ro ObjectIdentifier */ +#define SNMPV2_MIB_SYSOBJECTIDMINLENGTH 0 +#define SNMPV2_MIB_SYSOBJECTIDMAXLENGTH 128 + guint16 _sysObjectIDLength; + guint32 *sysUpTime; /* ro SNMPv2-SMI::TimeTicks */ + guchar *sysContact; /* rw */ +#define SNMPV2_MIB_SYSCONTACTMINLENGTH 0 +#define SNMPV2_MIB_SYSCONTACTMAXLENGTH 255 + guint16 _sysContactLength; + guchar *sysName; /* rw */ +#define SNMPV2_MIB_SYSNAMEMINLENGTH 0 +#define SNMPV2_MIB_SYSNAMEMAXLENGTH 255 + guint16 _sysNameLength; + guchar *sysLocation; /* rw */ +#define SNMPV2_MIB_SYSLOCATIONMINLENGTH 0 +#define SNMPV2_MIB_SYSLOCATIONMAXLENGTH 255 + guint16 _sysLocationLength; + gint32 *sysServices; /* ro */ + guint32 *sysORLastChange; /* ro SNMPv2-TC::TimeStamp */ +} snmpv2_mib_system_t; + +extern snmpv2_mib_system_t * +snmpv2_mib_new_system(void); + +extern void +snmpv2_mib_get_system(GNetSnmp *s, snmpv2_mib_system_t **system, gint64 mask); + +extern void +snmpv2_mib_set_system(GNetSnmp *s, snmpv2_mib_system_t *system, gint64 mask); + +extern void +snmpv2_mib_free_system(snmpv2_mib_system_t *system); + +/* + * C type definitions for SNMPv2-MIB::sysOREntry. + */ + +#define SNMPV2_MIB_SYSORID (1 << 0) +#define SNMPV2_MIB_SYSORDESCR (1 << 1) +#define SNMPV2_MIB_SYSORUPTIME (1 << 2) + +typedef struct { + gint32 sysORIndex; /* na */ + guint32 *sysORID; /* ro ObjectIdentifier */ +#define SNMPV2_MIB_SYSORIDMINLENGTH 0 +#define SNMPV2_MIB_SYSORIDMAXLENGTH 128 + guint16 _sysORIDLength; + guchar *sysORDescr; /* ro SNMPv2-TC::DisplayString */ +#define SNMPV2_MIB_SYSORDESCRMINLENGTH 0 +#define SNMPV2_MIB_SYSORDESCRMAXLENGTH 255 + guint16 _sysORDescrLength; + guint32 *sysORUpTime; /* ro SNMPv2-TC::TimeStamp */ +} snmpv2_mib_sysOREntry_t; + +extern void +snmpv2_mib_get_sysORTable(GNetSnmp *s, snmpv2_mib_sysOREntry_t ***sysOREntry, gint64 mask); + +extern void +snmpv2_mib_free_sysORTable(snmpv2_mib_sysOREntry_t **sysOREntry); + +extern snmpv2_mib_sysOREntry_t * +snmpv2_mib_new_sysOREntry(void); + +extern void +snmpv2_mib_get_sysOREntry(GNetSnmp *s, snmpv2_mib_sysOREntry_t **sysOREntry, gint32 sysORIndex, gint64 mask); + +extern void +snmpv2_mib_free_sysOREntry(snmpv2_mib_sysOREntry_t *sysOREntry); + +/* + * C type definitions for SNMPv2-MIB::snmp. + */ + +#define SNMPV2_MIB_SNMPINPKTS (1 << 0) +#define SNMPV2_MIB_SNMPOUTPKTS (1 << 1) +#define SNMPV2_MIB_SNMPINBADVERSIONS (1 << 2) +#define SNMPV2_MIB_SNMPINBADCOMMUNITYNAMES (1 << 3) +#define SNMPV2_MIB_SNMPINBADCOMMUNITYUSES (1 << 4) +#define SNMPV2_MIB_SNMPINASNPARSEERRS (1 << 5) +#define SNMPV2_MIB_SNMPINTOOBIGS (1 << 6) +#define SNMPV2_MIB_SNMPINNOSUCHNAMES (1 << 7) +#define SNMPV2_MIB_SNMPINBADVALUES (1 << 8) +#define SNMPV2_MIB_SNMPINREADONLYS (1 << 9) +#define SNMPV2_MIB_SNMPINGENERRS (1 << 10) +#define SNMPV2_MIB_SNMPINTOTALREQVARS (1 << 11) +#define SNMPV2_MIB_SNMPINTOTALSETVARS (1 << 12) +#define SNMPV2_MIB_SNMPINGETREQUESTS (1 << 13) +#define SNMPV2_MIB_SNMPINGETNEXTS (1 << 14) +#define SNMPV2_MIB_SNMPINSETREQUESTS (1 << 15) +#define SNMPV2_MIB_SNMPINGETRESPONSES (1 << 16) +#define SNMPV2_MIB_SNMPINTRAPS (1 << 17) +#define SNMPV2_MIB_SNMPOUTTOOBIGS (1 << 18) +#define SNMPV2_MIB_SNMPOUTNOSUCHNAMES (1 << 19) +#define SNMPV2_MIB_SNMPOUTBADVALUES (1 << 20) +#define SNMPV2_MIB_SNMPOUTGENERRS (1 << 21) +#define SNMPV2_MIB_SNMPOUTGETREQUESTS (1 << 22) +#define SNMPV2_MIB_SNMPOUTGETNEXTS (1 << 23) +#define SNMPV2_MIB_SNMPOUTSETREQUESTS (1 << 24) +#define SNMPV2_MIB_SNMPOUTGETRESPONSES (1 << 25) +#define SNMPV2_MIB_SNMPOUTTRAPS (1 << 26) +#define SNMPV2_MIB_SNMPENABLEAUTHENTRAPS (1 << 27) +#define SNMPV2_MIB_SNMPSILENTDROPS (1 << 28) +#define SNMPV2_MIB_SNMPPROXYDROPS (1 << 29) + +typedef struct { + guint32 *snmpInPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutPkts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInBadVersions; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInBadCommunityNames; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInBadCommunityUses; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInASNParseErrs; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInTooBigs; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInNoSuchNames; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInBadValues; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInReadOnlys; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInGenErrs; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInTotalReqVars; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInTotalSetVars; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInGetRequests; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInGetNexts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInSetRequests; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInGetResponses; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpInTraps; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutTooBigs; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutNoSuchNames; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutBadValues; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutGenErrs; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutGetRequests; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutGetNexts; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutSetRequests; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutGetResponses; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpOutTraps; /* ro SNMPv2-SMI::Counter32 */ + gint32 *snmpEnableAuthenTraps; /* rw */ + guint32 *snmpSilentDrops; /* ro SNMPv2-SMI::Counter32 */ + guint32 *snmpProxyDrops; /* ro SNMPv2-SMI::Counter32 */ +} snmpv2_mib_snmp_t; + +extern snmpv2_mib_snmp_t * +snmpv2_mib_new_snmp(void); + +extern void +snmpv2_mib_get_snmp(GNetSnmp *s, snmpv2_mib_snmp_t **snmp, gint64 mask); + +extern void +snmpv2_mib_set_snmp(GNetSnmp *s, snmpv2_mib_snmp_t *snmp, gint64 mask); + +extern void +snmpv2_mib_free_snmp(snmpv2_mib_snmp_t *snmp); + +/* + * C type definitions for SNMPv2-MIB::snmpSet. + */ + +#define SNMPV2_MIB_SNMPSETSERIALNO (1 << 0) + +typedef struct { + gint32 *snmpSetSerialNo; /* rw SNMPv2-TC::TestAndIncr */ +} snmpv2_mib_snmpSet_t; + +extern snmpv2_mib_snmpSet_t * +snmpv2_mib_new_snmpSet(void); + +extern void +snmpv2_mib_get_snmpSet(GNetSnmp *s, snmpv2_mib_snmpSet_t **snmpSet, gint64 mask); + +extern void +snmpv2_mib_set_snmpSet(GNetSnmp *s, snmpv2_mib_snmpSet_t *snmpSet, gint64 mask); + +extern void +snmpv2_mib_free_snmpSet(snmpv2_mib_snmpSet_t *snmpSet); + + +G_END_DECLS + +#endif /* _SNMPV2_MIB_H_ */ diff --git a/examples/snmpv2-tc.c b/examples/snmpv2-tc.c new file mode 100644 index 0000000..1370110 --- /dev/null +++ b/examples/snmpv2-tc.c @@ -0,0 +1,37 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli SNMPv2-TC + * + * Derived from SNMPv2-TC: + * + * $Id$ + */ + +#include "snmpv2-tc.h" + +GNetSnmpEnum const snmpv2_tc_enums_TruthValue[] = { + { SNMPV2_TC_TRUTHVALUE_TRUE, "true" }, + { SNMPV2_TC_TRUTHVALUE_FALSE, "false" }, + { 0, NULL } +}; + +GNetSnmpEnum const snmpv2_tc_enums_RowStatus[] = { + { SNMPV2_TC_ROWSTATUS_ACTIVE, "active" }, + { SNMPV2_TC_ROWSTATUS_NOTINSERVICE, "notInService" }, + { SNMPV2_TC_ROWSTATUS_NOTREADY, "notReady" }, + { SNMPV2_TC_ROWSTATUS_CREATEANDGO, "createAndGo" }, + { SNMPV2_TC_ROWSTATUS_CREATEANDWAIT, "createAndWait" }, + { SNMPV2_TC_ROWSTATUS_DESTROY, "destroy" }, + { 0, NULL } +}; + +GNetSnmpEnum const snmpv2_tc_enums_StorageType[] = { + { SNMPV2_TC_STORAGETYPE_OTHER, "other" }, + { SNMPV2_TC_STORAGETYPE_VOLATILE, "volatile" }, + { SNMPV2_TC_STORAGETYPE_NONVOLATILE, "nonVolatile" }, + { SNMPV2_TC_STORAGETYPE_PERMANENT, "permanent" }, + { SNMPV2_TC_STORAGETYPE_READONLY, "readOnly" }, + { 0, NULL } +}; + + diff --git a/examples/snmpv2-tc.h b/examples/snmpv2-tc.h new file mode 100644 index 0000000..fc7b0a7 --- /dev/null +++ b/examples/snmpv2-tc.h @@ -0,0 +1,46 @@ +/* -- DO NOT EDIT -- + * Generated by smidump version 0.4.3-pre1: + * smidump -f scli SNMPv2-TC + * + * Derived from SNMPv2-TC: + * + * $Id$ + */ + +#ifndef _SNMPV2_TC_H_ +#define _SNMPV2_TC_H_ + +#include "gsnmp.h" + +G_BEGIN_DECLS + +/* + * Tables to map enumerations to strings and vice versa. + */ + +#define SNMPV2_TC_TRUTHVALUE_TRUE 1 +#define SNMPV2_TC_TRUTHVALUE_FALSE 2 + +extern GNetSnmpEnum const snmpv2_tc_enums_TruthValue[]; + +#define SNMPV2_TC_ROWSTATUS_ACTIVE 1 +#define SNMPV2_TC_ROWSTATUS_NOTINSERVICE 2 +#define SNMPV2_TC_ROWSTATUS_NOTREADY 3 +#define SNMPV2_TC_ROWSTATUS_CREATEANDGO 4 +#define SNMPV2_TC_ROWSTATUS_CREATEANDWAIT 5 +#define SNMPV2_TC_ROWSTATUS_DESTROY 6 + +extern GNetSnmpEnum const snmpv2_tc_enums_RowStatus[]; + +#define SNMPV2_TC_STORAGETYPE_OTHER 1 +#define SNMPV2_TC_STORAGETYPE_VOLATILE 2 +#define SNMPV2_TC_STORAGETYPE_NONVOLATILE 3 +#define SNMPV2_TC_STORAGETYPE_PERMANENT 4 +#define SNMPV2_TC_STORAGETYPE_READONLY 5 + +extern GNetSnmpEnum const snmpv2_tc_enums_StorageType[]; + + +G_END_DECLS + +#endif /* _SNMPV2_TC_H_ */ diff --git a/gsnmp.lsm.in b/gsnmp.lsm.in new file mode 100644 index 0000000..3f9e792 --- /dev/null +++ b/gsnmp.lsm.in @@ -0,0 +1,21 @@ +Begin3 +Title: gsnmp +Version: @VERSION@ +Entered-date: @ISODATE@ +Description: A glib-based SNMP protocol implementation. + @configure_input@ + Please edit gsnmp.lsm.in to fix the Keywords and + Primary-site entries, add several more lines of + description here if appropriate, and to delete these + instructions. +Keywords: [substitute your keywords here] +Author: schoenw@informatik.uni-osnabrueck.de (Juergen Schoenwaelder) +Maintained-by: schoenw@informatik.uni-osnabrueck.de (Juergen Schoenwaelder) +Primary-site: metlab.unc.edu pub/Linux/apps/some/directory + 31k gsnmp-@VERSION@.tar.gz + 500 gsnmp.lsm +Alternate-site: +Original-site: +Platforms: +Copying-policy: GNU copyleft +End diff --git a/gsnmp.m4 b/gsnmp.m4 new file mode 100644 index 0000000..0f3d286 --- /dev/null +++ b/gsnmp.m4 @@ -0,0 +1,7 @@ +dnl AM_PATH_GSNMP() +dnl + +AC_DEFUN(AM_PATH_GSNMP, +[ + PKG_CHECK_MODULES(GSNMP, glib-2.0 >= 2.0.1) +]) diff --git a/gsnmp.pc.in b/gsnmp.pc.in new file mode 100644 index 0000000..f7d90ca --- /dev/null +++ b/gsnmp.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: gsnmp +Description: glib-based SNMP library +Requires: glib-2.0 +Version: @VERSION@ +Libs: -L${libdir} -lgsnmp +Cflags: -I${includedir}/gsnmp + diff --git a/gsnmp.spec.in b/gsnmp.spec.in new file mode 100644 index 0000000..6ee21a1 --- /dev/null +++ b/gsnmp.spec.in @@ -0,0 +1,93 @@ +# gsnmp.spec +# +# Copyright (c) 2002 Juergen Schoenwaelder schoenw@informatik.uni-osnabrueck.de +# +%define name gsnmp +%define version @VERSION@ +%define release 1 +%define manifest %{_builddir}/%{name}-%{version}-%{release}.manifest + +# required items +Name: %{name} +Version: %{version} +Release: %{release} +Copyright: GPL +Group: Application/Misc + +# optional items +#Vendor: Juergen Schoenwaelder +#Distribution: +#Icon: +#URL: +#Packager: Juergen Schoenwaelder schoenw@informatik.uni-osnabrueck.de + +# source + patches +Source: %{name}-%{version}.tar.gz +#Source1: +#Patch: +#Patch1: + +# RPM info +#Provides: +#Requires: +#Conflicts: +#Prereq: + +#Prefix: /usr +BuildRoot: /var/tmp/%{name}-%{version} + +Summary: A glib-based SNMP protocol implementation. + +%description +A glib-based SNMP protocol implementation. +@configure_input@ +Please edit gsnmp.spec.in to add several more lines of description +here if appropriate, and to delete these instructions. + +%prep +%setup -q +#%patch0 -p1 + +%build +%configure +make + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT +%makeinstall + +# __os_install_post is implicitly expanded after the +# %install section... do it now, and then disable it, +# so all work is done before building manifest. + +%{?__os_install_post} +%define __os_install_post %{nil} + +# build the file list automagically into %{manifest} + +cd $RPM_BUILD_ROOT +rm -f %{manifest} +find . -type d \ + | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' >> %{manifest} +find . -type f \ + | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest} +find . -type l \ + | sed 's,^\.,\%attr(-\,root\,root) ,' >> %{manifest} + +#%pre +#%post +#%preun +#%postun + +%clean +rm -f %{manifest} +rm -rf $RPM_BUILD_ROOT + +%files -f %{manifest} +%defattr(-,root,root) +#%doc README +#%docdir +#%config + +%changelog diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..94f10ae --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,26 @@ +INCLUDES = $(GNET_CFLAGS) + +lib_LTLIBRARIES = libgsnmp.la +libgsnmp_la_SOURCES = ber.c ber.h \ + pdu.c pdu.h \ + dispatch.c dispatch.h \ + message.c message.h \ + security.c security.h \ + session.c session.h \ + walk.c table.c \ + transport.c transport.h \ + utils.c utils.h \ + gsnmp.h + +gsnmpincludedir=$(includedir)/gsnmp +gsnmpinclude_HEADERS = ber.h \ + pdu.h \ + dispatch.h \ + message.h \ + security.h \ + session.h \ + transport.h \ + utils.h \ + gsnmp.h + +# libgsnmp_la_LDFLAGS = -version-info @VERSION_LIBTOOL@ diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..4d1b951 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,396 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AR = @AR@ +AS = @AS@ +CC = @CC@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GNET_CFLAGS = @GNET_CFLAGS@ +GNET_LIBS = @GNET_LIBS@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +HAVE_LIB = @HAVE_LIB@ +ISODATE = @ISODATE@ +LIB = @LIB@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIB = @LTLIB@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RC = @RC@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +INCLUDES = $(GNET_CFLAGS) + +lib_LTLIBRARIES = libgsnmp.la +libgsnmp_la_SOURCES = ber.c ber.h pdu.c pdu.h dispatch.c dispatch.h message.c message.h security.c security.h session.c session.h walk.c table.c transport.c transport.h utils.c utils.h gsnmp.h + + +gsnmpincludedir = $(includedir)/gsnmp +gsnmpinclude_HEADERS = ber.h pdu.h dispatch.h message.h security.h session.h transport.h utils.h gsnmp.h + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libgsnmp_la_LDFLAGS = +libgsnmp_la_LIBADD = +libgsnmp_la_OBJECTS = ber.lo pdu.lo dispatch.lo message.lo security.lo \ +session.lo walk.lo table.lo transport.lo utils.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(gsnmpinclude_HEADERS) + +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/ber.P .deps/dispatch.P .deps/message.P .deps/pdu.P \ +.deps/security.P .deps/session.P .deps/table.P .deps/transport.P \ +.deps/utils.P .deps/walk.P +SOURCES = $(libgsnmp_la_SOURCES) +OBJECTS = $(libgsnmp_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libgsnmp.la: $(libgsnmp_la_OBJECTS) $(libgsnmp_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libgsnmp_la_LDFLAGS) $(libgsnmp_la_OBJECTS) $(libgsnmp_la_LIBADD) $(LIBS) + +install-gsnmpincludeHEADERS: $(gsnmpinclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(gsnmpincludedir) + @list='$(gsnmpinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(gsnmpincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(gsnmpincludedir)/$$p; \ + done + +uninstall-gsnmpincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(gsnmpinclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(gsnmpincludedir)/$$p; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = src + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu src/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLTLIBRARIES +install-exec: install-exec-am + +install-data-am: install-gsnmpincludeHEADERS +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLTLIBRARIES uninstall-gsnmpincludeHEADERS +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(gsnmpincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLTLIBRARIES clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool uninstall-gsnmpincludeHEADERS \ +install-gsnmpincludeHEADERS tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir mostlyclean-depend \ +distclean-depend clean-depend maintainer-clean-depend info-am info \ +dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ +install-exec install-data-am install-data install-am install \ +uninstall-am uninstall all-redirect all-am all installdirs \ +mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +# libgsnmp_la_LDFLAGS = -version-info @VERSION_LIBTOOL@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/ber.c b/src/ber.c new file mode 100644 index 0000000..125d5cf --- /dev/null +++ b/src/ber.c @@ -0,0 +1,1168 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * Copyright (c) 1990 Dirk Wisse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +/* + * MT safe + */ + +#include "ber.h" + +struct _GNetSnmpBer +{ + guchar *pointer; /* octet just encoded or to be decoded */ + guchar *begin; /* first octet */ + guchar *end; /* octet after last octet */ +}; + + +GQuark +gnet_snmp_ber_error_quark(void) +{ + static GQuark quark = 0; + if (quark == 0) { + quark = g_quark_from_static_string("gnet-snmp-ber-error-quark"); + } + return quark; +} + + +/** + * gnet_snmp_ber_enc_new: + * &buf: the address of the buffer to encode into. + * &buf_len: the length of the buffer which will be filled. + * + * Initializes a #GNetSnmpBer buffer for encoding. + */ + +GNetSnmpBer * +gnet_snmp_ber_enc_new(guchar *buf, gsize buf_len) +{ + GNetSnmpBer *asn1; + + asn1 = g_new(GNetSnmpBer, 1); + asn1->begin = buf; + asn1->end = buf + buf_len; + asn1->pointer = asn1->end; + return asn1; +} + +/** + * gnet_snmp_ber_dec_new: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &buf: the address of the buffer to decode. + * &buf_len: the length of the buffer which will be decoded. + * + * Initializes a #GNetSnmpBer buffer for decoding. + */ + +GNetSnmpBer* +gnet_snmp_ber_dec_new(guchar *buf, gsize buf_len) +{ + GNetSnmpBer *asn1; + + asn1 = g_new(GNetSnmpBer, 1); + asn1->begin = buf; + asn1->end = buf + buf_len; + asn1->pointer = asn1->begin; + return asn1; +} + +/** + * gnet_snmp_ber_enc_delete: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &buf: the pointer to store the address of the encoded bytes. + * &len: the pointer to store the length of the encoded bytes. + * + * Delete a #GNetSnmpBer encoding buffer and returns the address + * and length of the encoded bytes. + */ + +void +gnet_snmp_ber_enc_delete(GNetSnmpBer *asn1, guchar **buf, guint *len) +{ + if (buf) *buf = asn1->pointer; + if (len) *len = asn1->end - asn1->pointer; + g_free(asn1); +} + +/** + * gnet_snmp_ber_dec_delete: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &buf: the pointer to store the address of the decoded bytes. + * &len: the pointer to store the length of the decoded bytes. + * + * Delete a #GNetSnmpBer decoding buffer and returns the address + * and length of the decoded bytes. + */ + +void +gnet_snmp_ber_dec_delete(GNetSnmpBer *asn1, guchar **buf, guint *len) +{ + if (buf) *buf = asn1->pointer; + if (len) *len = asn1->end - asn1->pointer; + g_free(asn1); +} + + +/** + * enc_octet: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @ch: the octet to encode. + * @error: the error object used to report errors. + * + * Encodes an octet if there is still buffer space to encode. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +enc_octet(GNetSnmpBer *asn1, guchar ch, GError **error) +{ + if (asn1->pointer <= asn1->begin) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_FULL, + "BER encoding buffer overflow"); + } + return FALSE; + } + *--(asn1->pointer) = ch; + return TRUE; +} + +/** + * dec_octet: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @ch: the pointer used to store the decoded octet. + * @error: the error object used to report errors. + * + * Decodes an octet if there is still buffer space to decode. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +dec_octet(GNetSnmpBer *asn1, guchar *ch, GError **error) +{ + if (asn1->pointer >= asn1->end) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_EMPTY, + "BER encoding buffer underflow"); + } + return FALSE; + } + *ch = *(asn1->pointer)++; + return TRUE; +} + +/** + * enc_tag: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @tag: the tag to encode. + * @error: the error object used to report errors. + * + * Encodes a tag value. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +enc_tag(GNetSnmpBer *asn1, guint tag, GError **error) +{ + guchar ch; + + ch = (guchar) (tag & 0x7F); + tag >>= 7; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + while (tag > 0) { + ch = (guchar) (tag | 0x80); + tag >>= 7; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } + return TRUE; +} + +/** + * dec_tag: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @tag: the pointer used to store the decoded tag value. + * @error: the error object used to report errors. + * + * Decodes a tag value. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +dec_tag(GNetSnmpBer *asn1, guint *tag, GError **error) +{ + guchar ch; + + *tag = 0; + do { + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *tag <<= 7; + *tag |= ch & 0x7F; + } + while ((ch & 0x80) == 0x80); + return TRUE; +} + +/** + * enc_id: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @cls: the ASN.1 class value. + * @con: the ASN.1 constructed value. + * @tag: the ASN.1 tag value. + * @error: the error object used to report errors. + * + * Encodes an identifier. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +enc_id(GNetSnmpBer *asn1, guint cls, guint con, guint tag, GError **error) +{ + guint ch; + + if (tag >= 0x1F) { + if (!enc_tag(asn1, tag, error)) { + return FALSE; + } + tag = 0x1F; + } + ch = (guchar) ((cls << 6) | (con << 5) | (tag)); + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + return TRUE; +} + +/** + * dec_id: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @cls: the pointer used to store the ASN.1 class value. + * @con: the pointer used to store the ASN.1 constructed value. + * @tag: the pointer used to store the ASN.1 tag value. + * @error: the error object used to report errors. + * + * Decodes an identifier. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +dec_id(GNetSnmpBer *asn1, guint *cls, guint *con, guint *tag, GError **error) +{ + guchar ch; + + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *cls = (ch & 0xC0) >> 6; + *con = (ch & 0x20) >> 5; + *tag = (ch & 0x1F); + if (*tag == 0x1F) { + if (!dec_tag(asn1, tag, error)) { + return FALSE; + } + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_length: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @def: flag indicating (in)definite encoding. + * @len: the length to encode. + * @error: the error object used to report errors. + * + * Encodes a definite or indefinite length. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_length(GNetSnmpBer *asn1, guint def, gsize len, + GError **error) +{ + guchar ch, cnt; + + g_assert(asn1); + + if (!def) { + ch = 0x80; + } else { + if (len < 0x80) { + ch = (guchar) len; + } else { + cnt = 0; + while (len > 0) { + ch = (guchar) len; + len >>= 8; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + cnt++; + } + ch = (guchar) (cnt | 0x80); + } + } + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_length: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @def: the pointer to store a flag indicating (in)definite encoding. + * @len: the pointer to store the decoded length. + * @error: the error object used to report errors. + * + * Decodes a definite or indefinite length. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_length(GNetSnmpBer *asn1, guint *def, gsize *len, + GError **error) +{ + guchar ch, cnt; + + g_assert(asn1); + + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + if (ch == 0x80) { + *def = 0; + } else { + *def = 1; + if (ch < 0x80) { + *len = ch; + } else { + cnt = (guchar) (ch & 0x7F); + *len = 0; + while (cnt > 0) { + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *len <<= 8; + *len |= ch; + cnt--; + } + } + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_header: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding or NULL is indefinite. + * @cls: the ASN.1 tag class. + * @con: the primitve/constructed flag. + * @tag: the ASN.1 tag value. + * @error: the error object used to report errors. + * + * Encodes an ASN1/BER header. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_header(GNetSnmpBer *asn1, guchar *eoc, + guint cls, guint con, guint tag, + GError **error) +{ + guint def, len; + + g_assert(asn1); + + if (eoc == 0) { + def = 0; + len = 0; + } else { + def = 1; + len = eoc - asn1->pointer; + } + if (!gnet_snmp_ber_enc_length(asn1, def, len, error)) { + return FALSE; + } + if (!enc_id(asn1, cls, con, tag, error)) { + return FALSE; + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_header: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to store the end of encoding or NULL is indefinite. + * @cls: the pointer to store ASN.1 tag class. + * @con: the pointer to store the primitve/constructed flag. + * @tag: the pointer to store the ASN.1 tag value. + * @error: the error object used to report errors. + * + * Decodes an ASN1/BER header. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_header(GNetSnmpBer *asn1, guchar **eoc, + guint *cls, guint *con, guint *tag, + GError **error) +{ + guint def, len; + + g_assert(asn1); + + if (!dec_id(asn1, cls, con, tag, error)) { + return FALSE; + } + if (!gnet_snmp_ber_dec_length(asn1, &def, &len, error)) { + return FALSE; + } + if (def) + *eoc = asn1->pointer + len; + else + *eoc = 0; + return TRUE; +} + +/** + * gnet_snmp_ber_is_eoc: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * + * Checks if decoding is at end of contents. + * + * Returns: a gboolean indicating whether we have reached the end of + * contents. + */ + +gboolean +gnet_snmp_ber_is_eoc(GNetSnmpBer *asn1, guchar *eoc) +{ + g_assert(asn1); + + if (eoc == 0) { + return (asn1->pointer [0] == 0x00 && asn1->pointer [1] == 0x00); + } else { + return (asn1->pointer >= eoc); + } +} + +/** + * gnet_snmp_ber_enc_eoc: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer used to store the end of encoding pointer. + * @error: the error object used to report errors. + * + * If eoc is 0 it encodes an ASN1 end of contents (0x00 0x00), so it + * produces an indefinite length encoding. If eoc points to a + * character pointer, eoc is filled with the pointer to the last + * encoded octet. This pointer can be used in the next + * asn1_header_encode to determine the length of the encoding. This + * produces a definite length encoding. + * + * Returns: a gboolean indicating success. + */ + +gboolean +gnet_snmp_ber_enc_eoc(GNetSnmpBer *asn1, guchar **eoc, GError **error) +{ + g_assert(asn1); + + if (eoc == 0) { + if (!enc_octet(asn1, 0x00, error)) { + return FALSE; + } + if (!enc_octet(asn1, 0x00, error)) { + return FALSE; + } + } else { + *eoc = asn1->pointer; + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_eoc: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @error: the error object used to report errors. + * + * If eoc is 0 it decodes an ASN1 end of contents (0x00 0x00), so it + * has to be an indefinite length encoding. If eoc is a character + * pointer, it probably was filled by asn1_header_decode, and should + * point to the octet after the last of the encoding. It is checked if + * this pointer points to the octet to be decoded. This only takes + * place in decoding a definite length encoding. + * + * Returns: a gboolean indicating success. + */ + +gboolean +gnet_snmp_ber_dec_eoc(GNetSnmpBer *asn1, guchar *eoc, GError **error) +{ + guchar ch; + + g_assert(asn1); + + if (eoc == 0) { + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + if (ch != 0x00) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_EOC_MISMATCH, + "BER EOC mismatch"); + } + return FALSE; + } + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + if (ch != 0x00) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_EOC_MISMATCH, + "BER EOC mismatch"); + } + return FALSE; + } + } else { + if (asn1->pointer != eoc) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_LENGTH_MISMATCH, + "BER length mismatch"); + } + return FALSE; + } + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_null: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @error: the error object used to report errors. + * + * Encodes an ASN.1 NULL value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_null(GNetSnmpBer *asn1, guchar **eoc, GError **error) +{ + g_assert(asn1); + + *eoc = asn1->pointer; + return TRUE; +} + +/** + * gnet_snmp_ber_dec_null: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @error: the error object used to report errors. + * + * Decodes an ASN.1 NULL value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_null(GNetSnmpBer *asn1, guchar *eoc, GError **error) +{ + g_assert(asn1); + + asn1->pointer = eoc; + return TRUE; +} + +/** + * gnet_snmp_ber_enc_gint32: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @value: the gint32 value to encode. + * @error: the error object used to report errors. + * + * Encodes a gint32 value as an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_gint32(GNetSnmpBer *asn1, guchar **eoc, + const gint32 value, GError **error) +{ + guchar ch, sign; + int lim; + gint32 val = value; + + g_assert(asn1); + + *eoc = asn1->pointer; + if (val < 0) { + lim = -1; + sign = 0x80; + } else { + lim = 0; + sign = 0x00; + } + do { + ch = (guchar) val; + val >>= 8; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } while ((val != lim) || (guchar) (ch & 0x80) != sign); + return TRUE; +} + +/** + * gnet_snmp_ber_dec_gint32: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @value: the pointer used to store the gint32 value. + * @error: the error object used to report errors. + * + * Decodes a gint32 value from an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_gint32(GNetSnmpBer *asn1, guchar *eoc, + gint32 *value, GError **error) +{ + guchar ch; + guint len; + + g_assert(asn1); + + if (!dec_octet(asn1, &ch, error)) + return FALSE; + *value = (gchar) ch; + len = 1; + while (asn1->pointer < eoc) { + if (++len > sizeof (gint32)) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "BER gint32 value too big"); + } + return FALSE; + } + if (!dec_octet(asn1, &ch, error)) + return FALSE; + *value <<= 8; + *value |= ch; + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_gint64: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @value: the gint64 value to encode. + * @error: the error object used to report errors. + * + * Encodes a gint64 value as an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_gint64(GNetSnmpBer *asn1, guchar **eoc, + const gint64 value, GError **error) +{ + guchar ch, sign; + glong lim; + gint64 val = value; + + g_assert(asn1); + + *eoc = asn1->pointer; + if (val < 0) { + lim = -1; + sign = 0x80; + } else { + lim = 0; + sign = 0x00; + } + do { + ch = (guchar) val; + val >>= 8; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } while ((val != lim) || (guchar) (ch & 0x80) != sign); + return TRUE; +} + +/** + * gnet_snmp_ber_dec_gint64: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @value: the pointer used to store the gint64 value. + * @error: the error object used to report errors. + * + * Decodes a gint64 value from an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_gint64(GNetSnmpBer *asn1, guchar *eoc, + gint64 *value, GError **error) +{ + guchar ch; + guint len; + + g_assert(asn1); + + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value = (gchar) ch; + len = 1; + while (asn1->pointer < eoc) { + if (++len > sizeof (gint64)) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "BER gint64 value too big"); + } + return FALSE; + } + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value <<= 8; + *value |= ch; + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_guint32: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @value: the guint32 value to encode. + * @error: the error object used to report errors. + * + * Encodes a guint32 value as an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_guint32(GNetSnmpBer *asn1, guchar **eoc, + const guint32 value, GError **error) +{ + guchar ch; + guint32 val = value; + + g_assert(asn1); + + *eoc = asn1->pointer; + do { + ch = (guchar) val; + val >>= 8; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } while ((val != 0) || (ch & 0x80) != 0x00); + return TRUE; +} + +/** + * gnet_snmp_ber_dec_guint32: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @value: the pointer used to store the guint32 value. + * @error: the error object used to report errors. + * + * Decodes a guint32 value from an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_guint32(GNetSnmpBer *asn1, guchar *eoc, + guint32 *value, GError **error) +{ + guchar ch; + guint len; + + g_assert(asn1); + + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value = ch; + len = (ch == 0) ? 0 : 1; + while (asn1->pointer < eoc) { + if (++len > sizeof (guint32)) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "BER guint32 value too big"); + } + return FALSE; + } + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value <<= 8; + *value |= ch; + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_guint64: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @value: the guint64 value to encode. + * @error: the error object used to report errors. + * + * Encodes a guint64 value as an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_guint64(GNetSnmpBer *asn1, guchar **eoc, + const guint64 value, GError **error) +{ + guchar ch; + guint64 val = value; + + g_assert(asn1); + + *eoc = asn1->pointer; + do { + ch = (guchar) val; + val >>= 8; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } + while ((val != 0) || (ch & 0x80) != 0x00); + return TRUE; +} + +/** + * gnet_snmp_ber_dec_guint64: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @value: the pointer used to store the guint64 value. + * @error: the error object used to report errors. + * + * Decodes a guint64 value from an ASN.1 INTEGER value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_guint64(GNetSnmpBer *asn1, guchar *eoc, + guint64 *value, GError **error) +{ + guchar ch; + guint len; + + g_assert(asn1); + + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value = ch; + len = (ch == 0) ? 0 : 1; + while (asn1->pointer < eoc) { + if (++len > sizeof (guint64)) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "BER guint64 value too big"); + } + return FALSE; + } + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *value <<= 8; + *value |= ch; + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_octets: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @octets: the pointer to the octets to encode. + * @len: the number of octets to encode. + * @error: the error object used to report errors. + * + * Encodes a buffer of octets (bytes) as an ASN.1 OCTET STRING value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_octets(GNetSnmpBer *asn1, guchar **eoc, + const guchar *octets, const gsize len, GError **error) +{ + const guchar *ptr; + gint i; + + g_assert(asn1); + + *eoc = asn1->pointer; + ptr = octets + len; + + for (i = 0; i < len; i++) { + if (!enc_octet(asn1, *--ptr, error)) + return FALSE; + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_octets: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @octets: pointer to a dynamically allocated buffer holding the value. + * @len: the pointer used to store the number of octets. + * @error: the error object used to report errors. + * + * Decodes a buffer of octets (bytes) from an ASN.1 OCTET STRING value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_octets(GNetSnmpBer *asn1, guchar *eoc, + guchar **octets, gsize *len, GError **error) +{ + guchar *ptr; + + g_assert(asn1); + + *octets = NULL; + *len = 0; + *octets = g_new(guchar, eoc - asn1->pointer + 1); + ptr = *octets; + while (asn1->pointer < eoc) { + if (!dec_octet(asn1, (guchar *)ptr++, error)) { + g_free(*octets); + *octets = NULL; + return FALSE; + } + (*len)++; + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_oid: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the pointer to the end of encoding pointer. + * @oid: the sub-identifier vector to encode. + * @len: the number of sub-identifier to encode. + * @error: the error object used to report errors. + * + * Encodes a sub-identifier vector as an ASN.1 OBJECT IDENTIFIER value. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +enc_subid(GNetSnmpBer *asn1, guint32 subid, GError **error) +{ + guchar ch; + + g_assert(asn1); + + ch = (guchar) (subid & 0x7F); + subid >>= 7; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + while (subid > 0) { + ch = (guchar) (subid | 0x80); + subid >>= 7; + if (!enc_octet(asn1, ch, error)) { + return FALSE; + } + } + return TRUE; +} + +gboolean +gnet_snmp_ber_enc_oid(GNetSnmpBer *asn1, guchar **eoc, + const guint32 *oid, const gsize len, GError **error) +{ + gulong subid; + guint l = len; + + g_assert(asn1); + + *eoc = asn1->pointer; + if (len < 2) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "BER object identifier too short"); + } + return FALSE; + } + subid = oid [1] + oid [0] * 40; + oid += len; + while (l-- > 2) { + if (!enc_subid(asn1, *--oid, error)) { + return FALSE; + } + } + if (!enc_subid (asn1, subid, error)) { + return FALSE; + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_oid: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @eoc: the end of encoding pointer. + * @oid: pointer to a dynamically allocated sub-identifiers vector. + * @len: the pointer used to store the number of sub-identifier. + * @error: the error object used to report errors. + * + * Decodes a sub-identifier vector from an ASN.1 OBJECT IDENTIFIER value. + * + * Returns: a gboolean value indicating success. + */ + +static inline gboolean +dec_subid(GNetSnmpBer *asn1, guint32 *subid, GError **error) +{ + guchar ch; + + g_assert(asn1); + + *subid = 0; + do { + if (!dec_octet(asn1, &ch, error)) { + return FALSE; + } + *subid <<= 7; + *subid |= ch & 0x7F; + } + while ((ch & 0x80) == 0x80); + return TRUE; +} + +gboolean +gnet_snmp_ber_dec_oid(GNetSnmpBer *asn1, guchar *eoc, + guint32 **oid, gsize *len, GError **error) +{ + guint32 subid; + guint size; + guint32 *optr; + + g_assert(asn1); + + size = eoc - asn1->pointer + 1; + *oid = g_new(guint32, size); + optr = *oid; + + if (!dec_subid(asn1, &subid, error)) { + g_free(*oid); + *oid = NULL; + return FALSE; + } + if (subid < 40) { + optr [0] = 0; + optr [1] = subid; + } else if (subid < 80) { + optr [0] = 1; + optr [1] = subid - 40; + } else { + optr [0] = 2; + optr [1] = subid - 80; + } + *len = 2; + optr += 2; + while (asn1->pointer < eoc) { + if (++(*len) > size) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "BER object identifier value too long"); + } + g_free(*oid); + *oid = NULL; + return FALSE; + } + if (!dec_subid (asn1, optr++, error)) { + g_free(*oid); + *oid = NULL; + return FALSE; + } + } + + return TRUE; +} diff --git a/src/ber.h b/src/ber.h new file mode 100644 index 0000000..3eddf45 --- /dev/null +++ b/src/ber.h @@ -0,0 +1,153 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * Copyright (c) 1990 Dirk Wisse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_BER_H__ +#define __GNET_SNMP_BER_H__ + +#include + +/* This module implements a subset of an ASN.1/BER encoder/decoder. + * Encoding takes place from the end to the beginning in order to + * provide compact encodings without memory copies. Note that reverse + * encoding may not work for other protocols. + * + * The encoding and decoding API functions are also tailored to handle + * just the subset of ASN.1 data types actually used by SNMP. Note + * that ASN.1 for example allows uncontrained INTEGER values while + * this library has several API functions for various concrete size + * constrained types of INTEGER values. + */ + +/* ASN.1 classes */ + +#define GNET_SNMP_ASN1_UNI 0 /* Universal */ +#define GNET_SNMP_ASN1_APL 1 /* Application */ +#define GNET_SNMP_ASN1_CTX 2 /* Context */ +#define GNET_SNMP_ASN1_PRV 3 /* Private */ + +/* ASN.1 tags */ + +#define GNET_SNMP_ASN1_EOC 0 /* End Of Contents */ +#define GNET_SNMP_ASN1_BOL 1 /* Boolean */ +#define GNET_SNMP_ASN1_INT 2 /* Integer */ +#define GNET_SNMP_ASN1_BTS 3 /* Bit String */ +#define GNET_SNMP_ASN1_OTS 4 /* Octet String */ +#define GNET_SNMP_ASN1_NUL 5 /* Null */ +#define GNET_SNMP_ASN1_OJI 6 /* Object Identifier */ +#define GNET_SNMP_ASN1_OJD 7 /* Object Description */ +#define GNET_SNMP_ASN1_EXT 8 /* External */ +#define GNET_SNMP_ASN1_SEQ 16 /* Sequence */ +#define GNET_SNMP_ASN1_SET 17 /* Set */ +#define GNET_SNMP_ASN1_NUMSTR 18 /* Numerical String */ +#define GNET_SNMP_ASN1_PRNSTR 19 /* Printable String */ +#define GNET_SNMP_ASN1_TEXSTR 20 /* Teletext String */ +#define GNET_SNMP_ASN1_VIDSTR 21 /* Video String */ +#define GNET_SNMP_ASN1_IA5STR 22 /* IA5 String */ +#define GNET_SNMP_ASN1_UNITIM 23 /* Universal Time */ +#define GNET_SNMP_ASN1_GENTIM 24 /* General Time */ +#define GNET_SNMP_ASN1_GRASTR 25 /* Graphical String */ +#define GNET_SNMP_ASN1_VISSTR 26 /* Visible String */ +#define GNET_SNMP_ASN1_GENSTR 27 /* General String */ + +/* ASN.1 primitive / constructed */ + +#define GNET_SNMP_ASN1_PRI 0 /* Primitive */ +#define GNET_SNMP_ASN1_CON 1 /* Constructed */ + +/* BER encoding / decoding error codes */ + +typedef enum +{ + GNET_SNMP_BER_ERROR_ENC_FULL, + GNET_SNMP_BER_ERROR_DEC_EMPTY, + GNET_SNMP_BER_ERROR_DEC_EOC_MISMATCH, + GNET_SNMP_BER_ERROR_DEC_LENGTH_MISMATCH, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + GNET_SNMP_BER_ERROR_ENC_BADVALUE +} GNetSnmpBerError; + +#define GNET_SNMP_BER_ERROR gnet_snmp_ber_error_quark() + +typedef struct _GNetSnmpBer GNetSnmpBer; + +GQuark gnet_snmp_ber_error_quark(); + +GNetSnmpBer* gnet_snmp_ber_enc_new (guchar *buf, gsize buf_len); + +GNetSnmpBer* gnet_snmp_ber_dec_new (guchar *buf, gsize buf_len); + +void gnet_snmp_ber_enc_delete (GNetSnmpBer *asn1, guchar **buf, + gsize *buf_len); +void gnet_snmp_ber_dec_delete (GNetSnmpBer *asn1, guchar **buf, + gsize *buf_len); +gboolean gnet_snmp_ber_enc_length (GNetSnmpBer *asn1, guint def, + gsize len, GError **error); +gboolean gnet_snmp_ber_dec_length (GNetSnmpBer *asn1, guint *def, + gsize *len, GError **error); +gboolean gnet_snmp_ber_enc_header (GNetSnmpBer *asn1, guchar *eoc, + guint cls, guint con, guint tag, + GError **error); +gboolean gnet_snmp_ber_dec_header (GNetSnmpBer *asn1, guchar **eoc, + guint *cls, guint *con, guint *tag, + GError **error); +gboolean gnet_snmp_ber_is_eoc (GNetSnmpBer *asn1, guchar *eoc); + +gboolean gnet_snmp_ber_enc_eoc (GNetSnmpBer *asn1, guchar **eoc, + GError **error); +gboolean gnet_snmp_ber_dec_eoc (GNetSnmpBer *asn1, guchar *eoc, + GError **error); +gboolean gnet_snmp_ber_enc_null (GNetSnmpBer *asn1, guchar **eoc, + GError **error); +gboolean gnet_snmp_ber_dec_null (GNetSnmpBer *asn1, guchar *eoc, + GError **error); +gboolean gnet_snmp_ber_enc_gint32 (GNetSnmpBer *asn1, guchar **eoc, + const gint32 value, GError **error); +gboolean gnet_snmp_ber_dec_gint32 (GNetSnmpBer *asn1, guchar *eoc, + gint32 *value, GError **error); +gboolean gnet_snmp_ber_enc_gint64 (GNetSnmpBer *asn1, guchar **eoc, + const gint64 value, GError **error); +gboolean gnet_snmp_ber_dec_gint64 (GNetSnmpBer *asn1, guchar *eoc, + gint64 *value, GError **error); +gboolean gnet_snmp_ber_enc_guint32 (GNetSnmpBer *asn1, guchar **eoc, + const guint32 value, GError **error); +gboolean gnet_snmp_ber_dec_guint32 (GNetSnmpBer *asn1, guchar *eoc, + guint32 *value, GError **error); +gboolean gnet_snmp_ber_enc_guint64 (GNetSnmpBer *asn1, guchar **eoc, + const guint64 value, GError **error); +gboolean gnet_snmp_ber_dec_guint64 (GNetSnmpBer *asn1, guchar *eoc, + guint64 *integer, GError **error); +gboolean gnet_snmp_ber_enc_octets (GNetSnmpBer *asn1, guchar **eoc, + const guchar *octs, const gsize len, + GError **error); +gboolean gnet_snmp_ber_dec_octets (GNetSnmpBer *asn1, guchar *eoc, + guchar **octs, gsize *len, + GError **error); +gboolean gnet_snmp_ber_enc_oid (GNetSnmpBer *asn1, guchar **eoc, + const guint32 *oid, const gsize len, + GError **error); +gboolean gnet_snmp_ber_dec_oid (GNetSnmpBer *asn1, guchar *eoc, + guint32 **oid, gsize *len, + GError **error); + +#endif /* __GNET_SNMP_BER_H__ */ diff --git a/src/dispatch.c b/src/dispatch.c new file mode 100644 index 0000000..0fd8ea4 --- /dev/null +++ b/src/dispatch.c @@ -0,0 +1,744 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + +#include /* for printf xxx should not be used here xxx */ + +/* This module defines the API to the SNMP RFC layer. Requests are routed + * to the appropriate transport (e.g. IPv4 or IPv6 or IPX) by using the + * message processing compatible with the given PDU version (V1, V2C, + * or V3). Applications will prefer to use the sync or async event loop + * API presented by the g_session layer. + */ + +/* RFC2271 defines some dispatcher primitives as standard SNMPv3 API. + * These names do not match GNU conventions. RFC2272 defines what exactly + * these primitives are supposed to do. + * + * It appears to me these primitives are mainly designed to describe + * interfaces between objects. I.e. the "modules" of RFC2271 translate + * to "objects" and the "primitives" translate to "public methods". + * In this case there should be a global registry (IR?) which keeps track + * of all known "modules" and loads them at init time. The dispatcher + * "module" (which should be guaranteed to exist only once -> singleton) + * must be constructed first, so the other "modules" can register themselves. + * + * statusInformation = + * sendPdu( + * IN transportDomain (guint) + * IN transportAddress (struct sockaddr *) + * IN messageProcessingModel INTEGER (0..2147483647) + * IN securityModel INTEGER (0..2147483647) + * IN securityName (gpointer) + * IN securityLevel INTEGER (1,2,3) + * IN contextEngineID OCTET STRING (SIZE(1..32)) + * IN contextName SnmpAdminString (SIZE(0..32)) + * IN pduVersion (guint) + * IN PDU (SNMP_PDU *) + * IN expectResponse (gboolean) + * ) + * + * returnResponsePdu( + * messageProcessingModel INTEGER (0..2147483647) + * securityModel INTEGER (0..2147483647) + * securityName (gpointer) + * securityLevel INTEGER (1,2,3) + * contextEngineID OCTET STRING (SIZE(1..32)) + * contextName SnmpAdminString (SIZE(0..32)) + * pduVersion (guint) + * PDU (SNMP_PDU *) + * maxSizeResponseScopedPDU INTEGER (0..2147483647) + * stateReference (gpointer) + * statusInformation (gint) + * ) + * + * statusInformation = + * registerContextEngineID( + * contextEngineID OCTET STRING (SIZE(1..32)) + * pduType INTEGER (1,2,3,4,5,6,7) + * ) + * + * unregisterContextID( + * contextEngineID OCTET STRING (SIZE(1..32)) + * pduType INTEGER (1,2,3,4,5,6,7) + * ) + * + * Callback Functions. These must be provided by the application: + * + * processPdu( + * messageProcessingModel INTEGER (0..2147483647) + * securityModel INTEGER (0..2147483647) + * securityName (gpointer) + * securityLevel INTEGER (1,2,3) + * contextEngineID OCTET STRING (SIZE(1..32)) + * contextName SnmpAdminString (SIZE(0..32)) + * pduVersion (guint) + * PDU (SNMP_PDU *) + * maxSizeResponseScopedPDU INTEGER (0..2147483647) + * stateReference (gpointer) + * ) + * + * processResponsePdu( + * messageProcessingModel INTEGER (0..2147483647) + * securityModel INTEGER (0..2147483647) + * securityName (gpointer) + * securityLevel INTEGER (1,2,3) + * contextEngineID OCTET STRING (SIZE(1..32)) + * contextName SnmpAdminString (SIZE(0..32)) + * pduVersion (guint) + * PDU (SNMP_PDU *) + * statusInformation (gint) + * sendPduHandle (int) + * ) + */ + +/* FIXME: Should be moved into a transport module with an init function + * For this it would be nice, if glib already had the event loop :) + */ + +/* static id field for SNMP id */ + +static guint32 id = 1; + +/* static registration hash tables. */ + +static GHashTable *message_models = NULL; +static GHashTable *security_models = NULL; +static GHashTable *access_models = NULL; + +/* 4.1.1. Sending a Request or Notification + * + * The following procedures are followed by the Dispatcher when an + * application wants to send an SNMP PDU to another (remote) + * application, i.e., to initiate a communication by originating a + * message, such as one containing a request or a trap. + * + * 1) The application requests this using the abstract service + * primitive: + * + * statusInformation = -- sendPduHandle if success + * -- errorIndication if failure + * sendPdu( + * IN transportDomain -- transport domain to be used + * IN transportAddress -- destination network address + * IN messageProcessingModel -- typically, SNMP version + * IN securityModel -- Security Model to use + * IN securityName -- on behalf of this principal + * IN securityLevel -- Level of Security requested + * IN contextEngineID -- data from/at this entity + * IN contextName -- data from/in this context + * IN pduVersion -- the version of the PDU + * IN PDU -- SNMP Protocol Data Unit + * IN expectResponse -- TRUE or FALSE + * ) + * + * 2) If the messageProcessingModel value does not represent a Message + * Processing Model known to the Dispatcher, then an errorIndication + * (implementation-dependent) is returned to the calling application. + * No further processing is performed. + * + * 3) The Dispatcher generates a sendPduHandle to coordinate + * subsequent processing. + * + * 4) The Message Dispatcher sends the request to the version-specific + * Message Processing module identified by messageProcessingModel + * using the abstract service primitive: + * + * statusInformation = - success or error indication + * prepareOutgoingMessage( + * IN transportDomain -- as specified by application + * IN transportAddress -- as specified by application + * IN messageProcessingModel -- as specified by application + * IN securityModel -- as specified by application + * IN securityName -- as specified by application + * IN securityLevel -- as specified by application + * IN contextEngineID -- as specified by application + * IN contextName -- as specified by application + * IN pduVersion -- the version of the PDU + * IN PDU -- as specified by application + * IN expectResponse -- as specified by application + * IN sendPduHandle -- as determined in step 3. + * OUT destTransportDomain -- destination transport domain + * OUT destTransportAddress -- destination transport address + * OUT outgoingMessage -- the message to send + * OUT outgoingMessageLength -- the message length + * ) + * + * 5) If the statusInformation indicates an error, the errorIndication + * is returned to the calling application. No further processing is + * performed. + * + * 6) If the statusInformation indicates success, the sendPduHandle is + * returned to the application, and the outgoingMessage is sent via + * the transport specified by the transportDomain to the address + * specified by the transportAddress. + * + * Outgoing Message Processing is complete. + */ + +int +sendPdu(GNetSnmpTDomain transportDomain, GInetAddr *transportAddress, + guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, gboolean expectResponse, + GError **error) +{ + gboolean result; + GNetSnmpTDomain destTransportDomain; + GInetAddr *destTransportAddress; + gpointer outgoingMessage; + guint outgoingMessageLength; + guint sendPduHandle; + struct g_message *msg_model; + +/* Currently, we return 0 for error and the handle if everything worked OK. + It might be a bit better to make the return code a struct to return a + better error code */ + +/* Search for message processing model */ + + if (!message_models || !(msg_model = g_hash_table_lookup(message_models, + &messageProcessingModel))) + { + printf("No message model found!\n"); + return 0; + /* Error reason: message processing model unknown */ + } + +/* Generate a handle of -1, if SNMPv1 or SNMPv2 is used. This way, the + application knows there might be duplicate responses. + TODO: Check interop draft/RFC, if this is allowed. */ + + if (messageProcessingModel < PMODEL_SNMPV3) sendPduHandle=-1; + else sendPduHandle=id++; + + result = msg_model->prepareOutgoingMessage(transportDomain, transportAddress, + messageProcessingModel, securityModel, securityName, + securityLevel, contextEngineID, contextName, + pduVersion, PDU, expectResponse, sendPduHandle, + &destTransportDomain, &destTransportAddress, + &outgoingMessage, &outgoingMessageLength, error); + + if (!result) + { + return -1; + } + + gnet_snmp_transport_send(destTransportDomain, destTransportAddress, + outgoingMessage, outgoingMessageLength, error); + if (error) { + g_free(outgoingMessage); + return 0; + } + + g_free(outgoingMessage); + return sendPduHandle; +} + +/* 4.1.2. Sending a Response to the Network + * + * The following procedure is followed when an application wants to + * return a response back to the originator of an SNMP Request. + * + * 1) An application can request this using the abstract service + * primitive: + * + * returnResponsePDU( + * IN messageProcessingModel -- typically, SNMP version + * IN securityModel -- Security Model in use + * IN securityName -- on behalf of this principal + * IN securityLevel -- same as on incoming request + * IN contextEngineID -- data from/at this SNMP entity + * IN contextName -- data from/in this context + * IN pduVersion -- the version of the PDU + * IN PDU -- SNMP Protocol Data Unit + * IN maxSizeResponseScopedPDU -- maximum size of Response PDU + * IN stateReference -- reference to state information + * -- as presented with the request + * IN statusInformation -- success or errorIndication + * ) -- (error counter OID and value + * -- when errorIndication) + * + * 2) The Message Dispatcher sends the request to the appropriate + * Message Processing Model indicated by the received value of + * messageProcessingModel using the abstract service primitive: + * + * result = -- SUCCESS or errorIndication + * prepareResponseMessage( + * IN messageProcessingModel -- specified by application + * IN securityModel -- specified by application + * IN securityName -- specified by application + * IN securityLevel -- specified by application + * IN contextEngineID -- specified by application + * IN contextName -- specified by application + * IN pduVersion -- specified by application + * IN PDU -- specified by application + * IN maxSizeResponseScopedPDU -- specified by application + * IN stateReference -- specified by application + * IN statusInformation -- specified by application + * OUT destTransportDomain -- destination transport domain + * OUT destTransportAddress -- destination transport address + * OUT outgoingMessage -- the message to send + * OUT outgoingMessageLength -- the message length + * ) + * + * 3) If the result is an errorIndication, the errorIndication is + * returned to the calling application. No further processing is + * performed. + * + * 4) If the result is success, the outgoingMessage is sent over the + * transport specified by the transportDomain to the address + * specified by the transportAddress. + * + * Message Processing is complete. + */ + +gboolean +returnResponsePdu(guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, int maxSizeResponseScopedPDU, + gpointer stateReference, int statusInformation, + GError **error) +{ + gboolean result; + GNetSnmpTDomain destTransportDomain; + GInetAddr *destTransportAddress; + gpointer outgoingMessage; + guint outgoingMessageLength; + struct g_message *msg_model; + + if (!message_models || !(msg_model = g_hash_table_lookup(message_models, + &messageProcessingModel))) + return FALSE; + + result = msg_model->prepareResponseMessage(messageProcessingModel, + securityModel, securityName, securityLevel, contextEngineID, + contextName, pduVersion, PDU, maxSizeResponseScopedPDU, + stateReference, statusInformation, + &destTransportDomain, &destTransportAddress, + &outgoingMessage, &outgoingMessageLength); + + if (!result) return FALSE; + + gnet_snmp_transport_send(destTransportDomain, destTransportAddress, + outgoingMessage, outgoingMessageLength, error); + if (error) { + g_free(outgoingMessage); + return FALSE; + } + + g_free(outgoingMessage); + return TRUE; +} + +gboolean +g_register_message(guint model_nr, struct g_message *msg) +{ + guint *ptr; + + if (g_hash_table_lookup(message_models, &model_nr)) return FALSE; + ptr = g_malloc(sizeof(guint)); + *ptr = model_nr; + g_hash_table_insert(message_models, ptr, msg); + return TRUE; +} + +gboolean +g_register_security(guint model_nr, struct g_security *sec) +{ + guint *ptr; + + if (g_hash_table_lookup(security_models, &model_nr)) return FALSE; + ptr = g_malloc(sizeof(guint)); + *ptr = model_nr; + g_hash_table_insert(security_models, ptr, sec); + return TRUE; +} + +/* 4.2.1. Message Dispatching of received SNMP Messages + * + * 1) The snmpInPkts counter [RFC1907] is incremented. + * + * 2) The version of the SNMP message is determined in an + * implementation-dependent manner. If the packet cannot be + * sufficiently parsed to determine the version of the SNMP message, + * then the snmpInASNParseErrs [RFC1907] counter is incremented, and + * the message is discarded without further processing. If the + * version is not supported, then the snmpInBadVersions [RFC1907] + * counter is incremented, and the message is discarded without + * further processing. + * + * 3) The origin transportDomain and origin transportAddress are + * determined. + * + * 4) The message is passed to the version-specific Message Processing + * Model which returns the abstract data elements required by the + * Dispatcher. This is performed using the abstract service + * primitive: + * + * result = -- SUCCESS or errorIndication + * prepareDataElements( + * IN transportDomain -- origin as determined in step 3. + * IN transportAddress -- origin as determined in step 3. + * IN wholeMsg -- as received from the network + * IN wholeMsgLength -- as received from the network + * OUT messageProcessingModel -- typically, SNMP version + * OUT securityModel -- Security Model to use + * OUT securityName -- on behalf of this principal + * OUT securityLevel -- Level of Security requested + * OUT contextEngineID -- data from/at this entity + * OUT contextName -- data from/in this context + * OUT pduVersion -- the version of the PDU + * OUT PDU -- SNMP Protocol Data Unit + * OUT pduType -- SNMP PDU type + * OUT sendPduHandle -- handle for a matched request + * OUT maxSizeResponseScopedPDU -- maximum size of Response PDU + * OUT statusInformation -- success or errorIndication + * -- (error counter OID and value + * -- when errorIndication) + * OUT stateReference -- reference to state information + * -- to be used for a possible + * ) -- Response + * + * 5) If the result is a FAILURE errorIndication, the message is + * discarded without further processing. + * + * 6) At this point, the abstract data elements have been prepared and + * processing continues as described in Section 4.2.2, PDU + * Dispatching for Incoming Messages. + */ + +void +g_receive_message(GNetSnmpTDomain transportDomain, GInetAddr *transportAddress, + gpointer wholeMsg, guint wholeMsgLength) +{ + GNetSnmpBer *asn1; + guint cls, con, tag; + gint32 version; + guchar *eoc, *end; + struct g_message *msg_model; + guint messageProcessingModel; + guint securityModel; + GString *securityName; + int securityLevel; + GString *contextEngineID; + GString *contextName; + guint pduVersion; + GNetSnmpPdu PDU; + guint pduType; + int sendPduHandle; + guint maxSizeResponseScopedPDU; + guint statusInformation; + gpointer stateReference; + gint result; + + GError *error = NULL; + +/* + * snmpInPkts ++; + */ + + asn1 = gnet_snmp_ber_dec_new(wholeMsg, wholeMsgLength); + if (! asn1) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, NULL)) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_CON || tag != GNET_SNMP_ASN1_SEQ) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, NULL)) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_INT) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + if (!gnet_snmp_ber_dec_gint32(asn1, end, &version, NULL)) { + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + return; + } + gnet_snmp_ber_dec_delete(asn1, NULL, NULL); + + if (!message_models) + return; + + if (!(msg_model = g_hash_table_lookup(message_models, + &version))) + return; + + result = msg_model->prepareDataElements(transportDomain, transportAddress, + wholeMsg, wholeMsgLength, &messageProcessingModel, &securityModel, + &securityName, &securityLevel, &contextEngineID, &contextName, + &pduVersion, &PDU, &pduType, &sendPduHandle, + &maxSizeResponseScopedPDU, &statusInformation, &stateReference, + &error); + if (!result) { + g_warning("message processing failed: %s", error->message); + return; + } + +/* 4.2.2. PDU Dispatching for Incoming Messages + * + * The elements of procedure for the dispatching of PDUs depends on the + * value of sendPduHandle. If the value of sendPduHandle is , + * then this is a request or notification and the procedures specified + * in Section 4.2.2.1 apply. If the value of snmpPduHandle is not + * , then this is a response and the procedures specified in + * Section 4.2.2.2 apply. + */ + + if (sendPduHandle) + { + +/* 4.2.2.2. Incoming Responses + * + * The following procedures are followed for the dispatching of PDUs + * when the value of sendPduHandle is not , indicating this is a + * response. + * + * 1) The value of sendPduHandle is used to determine, in an + * implementation-defined manner, which application is waiting for + * a response PDU associated with this sendPduHandle. + * + * 2) If no waiting application is found, the message is discarded + * without further processing, and the stateReference is released. + * The snmpUnknownPDUHandlers counter is incremented. Message + * Processing is complete for this message. + * + * 3) Any cached information, including stateReference, about the + * message is discarded. + * + * 4) The response is dispatched to the application using the + * abstract service primitive: + * + * processResponsePdu( -- process Response PDU + * IN messageProcessingModel -- provided by the MP module + * IN securityModel -- provided by the MP module + * IN securityName -- provided by the MP module + * IN securityLevel -- provided by the MP module + * IN contextEngineID -- provided by the MP module + * IN contextName -- provided by the MP module + * IN pduVersion -- provided by the MP module + * IN PDU -- provided by the MP module + * IN statusInformation -- provided by the MP module + * IN sendPduHandle -- provided by the MP module + * ) + * + * Message Processing is complete for this message. + */ + +/* FIXME: This should be handled through a hash table instead of sending + all to g_session_response_pdu */ + + g_session_response_pdu(messageProcessingModel, securityModel, + securityName, securityLevel, contextEngineID, contextName, + pduVersion, &PDU); + g_free(securityName->str); + g_free(securityName); + } + else + { + +/* 4.2.2.1. Incoming Requests and Notifications + * + * The following procedures are followed for the dispatching of PDUs + * when the value of sendPduHandle is , indicating this is a + * request or notification. + * + * 1) The combination of contextEngineID and pduType is used to + * determine which application has registered for this request or + * notification. + * + * 2) If no application has registered for the combination, then + * + * a) The snmpUnknownPDUHandlers counter is incremented. + * + * b) A Response message is generated using the abstract service + * primitive: + * + * result = -- SUCCESS or FAILURE + * prepareResponseMessage( + * IN messageProcessingModel -- as provided by MP module + * IN securityModel -- as provided by MP module + * IN securityName -- as provided by MP module + * IN securityLevel -- as provided by MP module + * IN contextEngineID -- as provided by MP module + * IN contextName -- as provided by MP module + * IN pduVersion -- as provided by MP module + * IN PDU -- as provided by MP module + * IN maxSizeResponseScopedPDU -- as provided by MP module + * IN stateReference -- as provided by MP module + * IN statusInformation -- errorIndication plus + * -- snmpUnknownPDUHandlers OID + * -- value pair. + * OUT transportDomain -- destination transportDomain + * OUT transportAddress -- destination transportAddress + * OUT outgoingMessage -- the message to send + * OUT outgoingMessageLength -- its length + * ) + * + * c) If the result is SUCCESS, then the prepared message is sent to + * the originator of the request as identified by the + * transportDomain and transportAddress. + * + * d) The incoming message is discarded without further processing. + * Message Processing for this message is complete. + * + * 3) The PDU is dispatched to the application, using the abstract + * service primitive: + * + * processPdu( -- process Request/Notification + * IN messageProcessingModel -- as provided by MP module + * IN securityModel -- as provided by MP module + * IN securityName -- as provided by MP module + * IN securityLevel -- as provided by MP module + * IN contextEngineID -- as provided by MP module + * IN contextName -- as provided by MP module + * IN pduVersion -- as provided by MP module + * IN PDU -- as provided by MP module + * IN maxSizeResponseScopedPDU -- as provided by MP module + * IN stateReference -- as provided by MP module + * -- needed when sending response + * ) + * + * Message processing for this message is complete. + */ + + /* + * snmpUnknownPDUHandlers ++; + */ + + /* + result = prepareResponseMessage(messageProcessingModel, securityModel, + securityName, securityLevel, contextEngineID, contextName, + pduVersion, PDU, maxSizeResponseScopedPDU, stateReference, + ERROR-???, &transportDomain, &transportAddress, + &outgoingMessage, &outgoingMessageLength); + if (result) + { + if (!transport_models) + return; + + if (!(trp_model = g_hash_table_lookup(transport_models, + &destTransportDomain))) + return; + + trp_model->sendMessage(destTransportAddress, outgoingMessage, + outgoingMessageLength); + g_free(outgoingMessage); + } + return; + */; + } +} + +/* 4.3. Application Registration for Handling PDU types + * + * Applications that want to process certain PDUs must register with the + * PDU Dispatcher. Applications specify the combination of + * contextEngineID and pduType(s) for which they want to take + * responsibility + * + * 1) An application registers according to the abstract interface + * primitive: + * + * statusInformation = -- success or errorIndication + * registerContextEngineID( + * IN contextEngineID -- take responsibility for this one + * IN pduType -- the pduType(s) to be registered + * ) + * + * Note: implementations may provide a means of requesting + * registration for simultaneous multiple contextEngineID values, + * e.g., all contextEngineID values, and may also provide means for + * requesting simultaneous registration for multiple values of + * pduType. + * + * 2) The parameters may be checked for validity; if they are not, then + * an errorIndication (invalidParameter) is returned to the + * application. + * + * 3) Each combination of contextEngineID and pduType can be registered + * only once. If another application has already registered for the + * specified combination, then an errorIndication (alreadyRegistered) + * is returned to the application. + * + * 4) Otherwise, the registration is saved so that SNMP PDUs can be + * dispatched to this application. + */ + +/* 4.4. Application Unregistration for Handling PDU Types + * + * Applications that no longer want to process certain PDUs must + * unregister with the PDU Dispatcher. + * + * 1) An application unregisters using the abstract service primitive: + * + * unregisterContextEngineID( + * IN contextEngineID -- give up responsibility for this + * IN pduType -- the pduType(s) to be unregistered + * ) + * Note: implementations may provide means for requesting + * unregistration for simultaneous multiple contextEngineID values, + * e.g., all contextEngineID values, and may also provide means for + * requesting simultaneous unregistration for multiple values of + * pduType. + * + * 2) If the contextEngineID and pduType combination has been + * registered, then the registration is deleted. + * + * If no such registration exists, then the request is ignored. + */ + +gboolean +gnet_snmp_init(gboolean dobind) +{ + message_models = g_hash_table_new (g_int_hash, g_int_equal); + security_models = g_hash_table_new (g_int_hash, g_int_equal); + access_models = g_hash_table_new (g_int_hash, g_int_equal); + + /* Init all required models by RFC 2571. Any private model should + * be initialized after calling snmp_init(). */ + + if (!g_message_init()) + return FALSE; + +#if 0 + g_security_init() && + g_access_init(); +#endif + + g_timeout_add(100, g_snmp_timeout_cb, NULL); + return TRUE; +} + +/* EOF */ diff --git a/src/dispatch.h b/src/dispatch.h new file mode 100644 index 0000000..4c3aae5 --- /dev/null +++ b/src/dispatch.h @@ -0,0 +1,59 @@ +/* + * $Id$ + * GXSNMP -- An snmp management application + * Copyright (C) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * Implementation of a SNMP dispatcher as of RFC2271 + */ + +#ifndef _G_DISPATCH_H_ +#define _G_DISPATCH_H_ + +#include "gsnmp.h" + +/* This module defines the API to the SNMP RFC layer. Requests are routed + * to the appropriate transport (e.g. IPv4 or IPv6 or IPX) by using the + * message processing compatible with the given PDU version (V1, V2C, + * or V3). Applications will prefer to use the sync or async event loop + * API presented by the g_session layer. + */ + +typedef void (*GXINITCB) (guint r_socket, void (*receiveMessage) ()); + +int sendPdu(GNetSnmpTDomain transportDomain, GInetAddr *transportAddress, + guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, gboolean expectResponse, + GError **error); + +gboolean returnResponsePdu(guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, int maxSizeResponseScopedPDU, + gpointer stateReference, int statusInformation, GError **error); + +void g_receive_message(GNetSnmpTDomain transportDomain, GInetAddr *transportAddress, + gpointer wholeMsg, guint wholeMsgLength); + +gboolean g_register_message (guint model_nr, struct g_message *msg); +gboolean g_register_security (guint model_nr, struct g_security *sec); + +#define PDUV1 1 +#define PDUV2 2 + +#endif /* _G_DISPATCH_H_ */ diff --git a/src/gsnmp.h b/src/gsnmp.h new file mode 100644 index 0000000..d3aae2a --- /dev/null +++ b/src/gsnmp.h @@ -0,0 +1,64 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_H__ +#define __GNET_SNMP_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +typedef enum +{ + GNET_SNMP_DEBUG_REQUESTS = 1 << 0, + GNET_SNMP_DEBUG_SESSION = 1 << 1, + GNET_SNMP_DEBUG_TRANSPORT = 1 << 2, + GNET_SNMP_DEBUG_PACKET = 1 << 3, + GNET_SNMP_DEBUG_BER = 1 << 4, + GNET_SNMP_DEBUG_ALL = GNET_SNMP_DEBUG_REQUESTS + | GNET_SNMP_DEBUG_SESSION + | GNET_SNMP_DEBUG_TRANSPORT + | GNET_SNMP_DEBUG_PACKET + | GNET_SNMP_DEBUG_BER, + GNET_SNMP_DEBUG_MASK = 0x1f +} GNetSnmpDebugFlags; + +extern GNetSnmpDebugFlags gnet_snmp_debug_flags; + +#include "ber.h" +#include "pdu.h" +#include "transport.h" +#include "message.h" +#include "security.h" +#include "session.h" +#include "dispatch.h" +#include "utils.h" + +gboolean gnet_snmp_init(gboolean dobind); + +G_END_DECLS + +#endif /* __GNET_SNMP_H__ */ diff --git a/src/message.c b/src/message.c new file mode 100644 index 0000000..fa56c5b --- /dev/null +++ b/src/message.c @@ -0,0 +1,680 @@ +/* + * GSNMP -- glib-based SNMP library + * + * Copyright (C) 2003 Juergen Schoenwaelder + * Copyright (C) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + */ + +#include "gsnmp.h" + +GNetSnmpDebugFlags gnet_snmp_debug_flags = 0; + +/* This modules implements the formatting of the different SNMP versions. + * The interface is documented in RFC2271. + */ + +/* RFC2271 defines some message processing primitives as standard SNMPv3 API. + * These names do not match GNU conventions. RFC2272 defines what exactly + * these primitives are supposed to do. + * + * Application Interface: + * + * statusInformation = + * prepareOutgoingMessage( + * IN transportDomain (guint) + * IN transportAddress (struct sockaddr *) + * IN messageProcessingModel INTEGER (0..2147483647) + * IN securityModel INTEGER (0..2147483647) + * IN securityName (GString *) + * IN securityLevel INTEGER (1,2,3) + * IN contextEngineID OCTET STRING (SIZE(1..32)) + * IN contextName SnmpAdminString (SIZE(0..32)) + * IN pduVersion (guint) + * IN PDU (SNMP_PDU *) + * IN expectResponse (gboolean) + * IN sendPduHandle (int) + * OUT destTransportDomain (guint) + * OUT destTransportAddress (struct sockaddr) + * OUT outgoingMessage (gpointer) + * OUT outgoingMessageLength (int) + * ) + * + * result = + * prepareResponseMessage( + * IN messageProcessingModel INTEGER (0..2147483647) + * IN securityModel INTEGER (0..2147483647) + * IN securityName (GString *) + * IN securityLevel INTEGER (1,2,3) + * IN contextEngineID OCTET STRING (SIZE(1..32)) + * IN contextName SnmpAdminString (SIZE(0..32)) + * IN pduVersion (guint) + * IN PDU (SNMP_PDU *) + * IN maxSizeResponseScopedPDU (guint) + * IN stateReference (gpointer) + * IN statusInformation (guint) + * OUT destTransportDomain (guint) + * OUT destTransportAddress (struct sockaddr) + * OUT outgoingMessage (gpointer) + * OUT outgoingMessageLength (int) + * ) + * + * prepareDataElements( + * IN transportDomain (guint) + * IN transportAddress (struct sockaddr *) + * IN wholeMsg (gpointer) + * IN wholeMsgLength (int) + * OUT messageProcessingModel INTEGER (0..2147483647) + * OUT securityModel INTEGER (0..2147483647) + * OUT securityName (GString *) + * OUT securityLevel INTEGER (1,2,3) + * OUT contextEngineID OCTET STRING (SIZE(1..32)) + * OUT contextName SnmpAdminString (SIZE(0..32)) + * OUT pduVersion (guint) + * OUT PDU (SNMP_PDU *) + * OUT pduType (guint) + * OUT sendPduHandle (int) + * OUT maxSizeResponseScopedPDU (guint) + * OUT statusInformation (guint) + * OUT stateReference (gpointer) + * ) + * + * releaseState( + * IN stateReference (gpointer) + * ) + */ + +/* ---------------------------------------------------------------------------- + * SNMP V1 Message Processing Model + * ---------------------------------------------------------------------------- + */ + +static gboolean +snmpv1_prepare_outgoing_message(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, + gboolean expectResponse, int sendPduHandle, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength, + GError **error) +{ + GNetSnmpBer *asn1; + guchar *eoc, *end; + guchar buffer[65536], *ptr; + + ptr = buffer; + *outgoingMessageLength = 65536; + + if (messageProcessingModel != PMODEL_SNMPV1) + return FALSE; /* This should never happen. Something fishy going on? */ + if ((securityModel != SMODEL_ANY) && (securityModel != SMODEL_SNMPV1)) + return FALSE; + if (securityLevel != SLEVEL_NANP) + return FALSE; + if (pduVersion != PDUV1) + return FALSE; + +/* FIXME: Currently, i'm pretty much cheating here. I probably *should* call + * the community security model to map the security name (principal) + * to the community name he has configured for a given router/PDU + * type (might be different for PUT, GET(NEXT) and TRAP). Should also + * check for invalid PDU, however, this should as well never happen as + * the PDU version matches with what we expect. + * + * Depending on the meaning of PDU (struct or ANS.1 encoded), the + * security model might have to decode the PDU again to get to the + * PDU type (PUT/GET/TRAP). This seems very odd and backward to me + * in some way. + */ + +/* RFC1157 + * Message ::= SEQUENCE { + * version INTEGER { version(0) }, + * community OCTET STRING, + * data ANY + * } + */ + + asn1 = gnet_snmp_ber_enc_new(ptr, *outgoingMessageLength); + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + + if (!gnet_snmp_ber_enc_pdu_v1(asn1, PDU, error)) + return FALSE; + if (!gnet_snmp_ber_enc_octets (asn1, &end, (guchar *) securityName->str, securityName->len, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_guint32(asn1, &end, 0, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, error)) + return FALSE; + + gnet_snmp_ber_enc_delete(asn1, &ptr, outgoingMessageLength); + +/* FIXME: we currently don't implement proxy support. In this case + * outTransportDomain and outTransportAddress are always + * the same as transportAddress and transportDomain. + * + * "Rule #1: If there's something you don't understand, it must be + * related to proxies" -- Juergen Schoenwaelder + */ + + *outTransportDomain = transportDomain; + *outTransportAddress = transportAddress; + + *outgoingMessage = g_malloc(*outgoingMessageLength); + g_memmove(*outgoingMessage, ptr, *outgoingMessageLength); + + return TRUE; +} + +static gboolean +snmpv1_prepare_response_message(guint messageProcessingModel, + guint securityModel, GString *securityName, + int securityLevel, GString *contextEngineID, + GString *contextName, guint pduVersion, GNetSnmpPdu *PDU, + guint maxSizeResponseScopedPDU, + gpointer stateReference, guint statusInformation, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength) +{ + if (messageProcessingModel != PMODEL_SNMPV1) + return FALSE; /* This should never happen. Something fishy going on? */ + + return FALSE; +} + +static gboolean +snmpv1_prepare_data_elements(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + gpointer wholeMsg, int wholeMsgLength, + guint *messageProcessingModel, guint *securityModel, + GString **securityName, int *securityLevel, + GString **contextEngineID, GString **contextName, + guint *pduVersion, GNetSnmpPdu *PDU, guint *pduType, + int *sendPduHandle, guint *maxSizeResponseScopedPDU, + guint *statusInformation, gpointer *stateReference, + GError **error) +{ + GNetSnmpBer *asn1; + guint cls, con, tag; + guchar *eoc, *end; + + *securityModel = SMODEL_SNMPV1; + *securityLevel = SLEVEL_NANP; + *contextEngineID = NULL; + *contextName = NULL; + *pduVersion = PDUV1; + + *securityName = g_malloc(sizeof(GString)); + + asn1 = gnet_snmp_ber_dec_new(wholeMsg, wholeMsgLength); + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_CON || tag != GNET_SNMP_ASN1_SEQ) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_INT) + return FALSE; + if (!gnet_snmp_ber_dec_guint32(asn1, end, messageProcessingModel, error)) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_OTS) + return FALSE; + if (!gnet_snmp_ber_dec_octets(asn1, end, (guchar **)&((*securityName)->str), + (guint *) &((*securityName)->len), error)) + return FALSE; + if (!gnet_snmp_ber_dec_pdu_v1(asn1, PDU, error)) + return FALSE; + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) + return FALSE; + gnet_snmp_ber_dec_delete(asn1, wholeMsg, (guint *) &wholeMsgLength); + + if (PDU->type == GNET_SNMP_PDU_RESPONSE) + *sendPduHandle = -1; + else + *sendPduHandle = 0; + return TRUE; +} + +static gboolean +snmpv1_release_state( gpointer stateReference) +{ +/* free whatever structures are in stateReference */ + if (stateReference) g_free(stateReference); + return TRUE; +} + +/* ---------------------------------------------------------------------------- + * SNMP V2c Message Processing Model + * ---------------------------------------------------------------------------- + */ + +static gboolean +snmpv2c_prepare_outgoing_message(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, + gboolean expectResponse, int sendPduHandle, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength, + GError **error) +{ + GNetSnmpBer *asn1; + guchar *eoc, *end; + guchar buffer[65536], *ptr; + + ptr = buffer; + *outgoingMessageLength = 65536; + + + if (messageProcessingModel != PMODEL_SNMPV2C) + return FALSE; /* This should never happen. Something fishy going on? */ + +/* We allow both SNMPV1 and SNMPV2C security models here. There currently + * is a discussion in the SNMPv3 mailing list to rename SNMPV1 security to + * SNMP_COMMUNITY and dump the SNMPV2C model (declaring it reserved). + * Allowing both SNMPV1 and SNMPV2C here should make this library compatible + * with both cases. + */ + + if ((securityModel != SMODEL_ANY) && (securityModel != SMODEL_SNMPV1) + && (securityModel != SMODEL_SNMPV2C)) + return FALSE; + if (securityLevel != SLEVEL_NANP) + return FALSE; + if (pduVersion != PDUV2) + return FALSE; + +/* FIXME: Currently, i'm pretty much cheating here. I probably *should* call + * the community security model to map the security name (principal) + * to the community name he has configured for a given router/PDU + * type (might be different for PUT, GET(NEXT) and TRAP). Should also + * check for invalid PDU, however, this should as well never happen as + * the PDU version matches with what we expect. + */ + +/* RFC1901 + * Message ::= SEQUENCE { + * version INTEGER { version(1) }, + * community OCTET STRING, + * data ANY + * } + */ + + asn1 = gnet_snmp_ber_enc_new(ptr, *outgoingMessageLength); + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_pdu_v2(asn1, PDU, error)) + return FALSE; + if (!gnet_snmp_ber_enc_octets (asn1, &end, (guchar *) securityName->str, securityName->len, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_guint32(asn1, &end, 1, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, error)) + return FALSE; + + gnet_snmp_ber_enc_delete(asn1, &ptr, outgoingMessageLength); + +/* FIXME: we currently don't implement proxy support. In this case + * outTransportDomain and outTransportAddress are always + * the same as transportAddress and transportDomain. + * + * "Rule #1: If there's something you don't understand, it must be + * related to proxies" -- Juergen Schoenwaelder + */ + + *outTransportDomain = transportDomain; + *outTransportAddress = transportAddress; + + *outgoingMessage = g_malloc(*outgoingMessageLength); + g_memmove(*outgoingMessage, ptr, *outgoingMessageLength); + + return TRUE; +} + +static gboolean +snmpv2c_prepare_response_message(guint messageProcessingModel, + guint securityModel, GString *securityName, + int securityLevel, GString *contextEngineID, + GString *contextName, guint pduVersion, GNetSnmpPdu *PDU, + guint maxSizeResponseScopedPDU, + gpointer stateReference, guint statusInformation, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength) +{ + return FALSE; +} + +static gboolean +snmpv2c_prepare_data_elements(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + gpointer wholeMsg, int wholeMsgLength, + guint *messageProcessingModel, guint *securityModel, + GString **securityName, int *securityLevel, + GString **contextEngineID, GString **contextName, + guint *pduVersion, GNetSnmpPdu *PDU, guint *pduType, + int *sendPduHandle, guint *maxSizeResponseScopedPDU, + guint *statusInformation, gpointer *stateReference, + GError **error) +{ + GNetSnmpBer *asn1; + guint cls, con, tag; + guchar *eoc, *end; + + *securityModel = SMODEL_SNMPV2C; /* might combine with SMODEL_SNMPV1 */ + *securityLevel = SLEVEL_NANP; + *contextEngineID = NULL; + *contextName = NULL; + *pduVersion = PDUV2; + + *securityName = g_malloc(sizeof(GString)); + + asn1 = gnet_snmp_ber_dec_new(wholeMsg, wholeMsgLength); + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_CON || tag != GNET_SNMP_ASN1_SEQ) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_INT) + return FALSE; + if (!gnet_snmp_ber_dec_guint32(asn1, end, messageProcessingModel, error)) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_OTS) + return FALSE; + if (!gnet_snmp_ber_dec_octets (asn1, end, (guchar **)&((*securityName)->str), + (guint *) &((*securityName)->len), error)) + return FALSE; + if (!gnet_snmp_ber_dec_pdu_v2(asn1, PDU, error)) + return FALSE; + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) + return FALSE; + gnet_snmp_ber_dec_delete(asn1, wholeMsg, (guint *) &wholeMsgLength); + + if (PDU->type == GNET_SNMP_PDU_RESPONSE) + *sendPduHandle = -1; + else + *sendPduHandle = 0; + return TRUE; +} + +static gboolean +snmpv2c_release_state( gpointer stateReference) +{ + return TRUE; +} + +/* ---------------------------------------------------------------------------- + * SNMP V3 Message Processing Model + * ---------------------------------------------------------------------------- + */ + +static gboolean +snmpv3_prepare_outgoing_message(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + guint messageProcessingModel, guint securityModel, + GString *securityName, int securityLevel, + GString *contextEngineID, GString *contextName, + guint pduVersion, GNetSnmpPdu *PDU, + gboolean expectResponse, int sendPduHandle, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength, + GError **error) +{ + GNetSnmpBer *asn1; + guchar *eoc, *eoc1, *end, flags; + guchar buffer[65536], *ptr; + + ptr = buffer; + *outgoingMessageLength = 65536; + flags = expectResponse?4+securityLevel:securityLevel; + + if (messageProcessingModel != PMODEL_SNMPV3) + return FALSE; /* This should never happen. Something fishy going on? */ + + if ((securityModel == SMODEL_SNMPV1) || (securityModel == SMODEL_SNMPV2C)) + return FALSE; + if (pduVersion != PDUV2) + return FALSE; + + if (securityModel == SMODEL_ANY) + securityModel = SMODEL_USM; + +/* RFC2272 + * SNMPv3Message ::= SEQUENCE { + * -- identify the layout of the SNMPv3Message + * -- this element is in same position as in SNMPv1 + * -- and SNMPv2c, allowing recognition + * msgVersion INTEGER { snmpv3 (3) }, + * -- administrative parameters + * msgGlobalData HeaderData, + * -- security model-specific parameters + * -- format defined by Security Model + * msgSecurityParameters OCTET STRING, + * msgData ScopedPduData + * } + */ + + asn1 = gnet_snmp_ber_enc_new(ptr, *outgoingMessageLength); + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + if (contextEngineID) { + PDU->context_engineid = contextEngineID->str; + PDU->context_engineid_len = contextEngineID->len; + } + if (contextName) { + PDU->context_name = contextName->str; + PDU->context_name_len = contextName->len; + } + + if (!gnet_snmp_ber_enc_pdu_v3(asn1, PDU, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_octets(asn1, &end, (guchar *) securityName->str, securityName->len, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc1, error)) + return FALSE; + if (!gnet_snmp_ber_enc_guint32(asn1, &end, securityModel, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + if (!gnet_snmp_ber_enc_octets(asn1, &end, &flags, 1, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, error)) + return FALSE; + if (!gnet_snmp_ber_enc_guint32(asn1, &end, 65536, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + if (!gnet_snmp_ber_enc_guint32(asn1, &end, sendPduHandle, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, eoc1, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_guint32(asn1, &end, 3, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, error)) + return FALSE; + + gnet_snmp_ber_enc_delete(asn1, &ptr, outgoingMessageLength); + +/* FIXME: we currently don't implement proxy support. In this case + * outTransportDomain and outTransportAddress are always + * the same as transportAddress and transportDomain. + * + * "Rule #1: If there's something you don't understand, it must be + * related to proxies" -- Juergen Schoenwaelder + */ + + *outTransportDomain = transportDomain; + *outTransportAddress = transportAddress; + + *outgoingMessage = g_malloc(*outgoingMessageLength); + g_memmove(*outgoingMessage, ptr, *outgoingMessageLength); + g_free(buffer); + + return TRUE; +} + +static gboolean +snmpv3_prepare_response_message(guint messageProcessingModel, + guint securityModel, GString *securityName, + int securityLevel, GString *contextEngineID, + GString *contextName, guint pduVersion, GNetSnmpPdu *PDU, + guint maxSizeResponseScopedPDU, + gpointer stateReference, guint statusInformation, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength) +{ + return FALSE; +} + +static gboolean +snmpv3_prepare_data_elements(GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + gpointer wholeMsg, int wholeMsgLength, + guint *messageProcessingModel, guint *securityModel, + GString **securityName, int *securityLevel, + GString **contextEngineID, GString **contextName, + guint *pduVersion, GNetSnmpPdu *PDU, guint *pduType, + int *sendPduHandle, guint *maxSizeResponseScopedPDU, + guint *statusInformation, gpointer *stateReference, + GError **error) +{ + GNetSnmpBer *asn1; + guint cls, con, tag; + guchar *eoc, *end; + + /* FIXME: This is horribly broken */ + + *securityName = g_malloc(sizeof(GString)); + + asn1 = gnet_snmp_ber_dec_new(wholeMsg, wholeMsgLength); + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_CON || tag != GNET_SNMP_ASN1_SEQ) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_INT) + return FALSE; + if (!gnet_snmp_ber_dec_guint32(asn1, end, messageProcessingModel, error)) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI || con != GNET_SNMP_ASN1_PRI || tag != GNET_SNMP_ASN1_OTS) + return FALSE; + if (!gnet_snmp_ber_dec_octets(asn1, end, (guchar **)&((*securityName)->str), + (guint *) &((*securityName)->len), error)) + return FALSE; + if (!gnet_snmp_ber_dec_pdu_v2(asn1, PDU, error)) + return FALSE; + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) + return FALSE; + gnet_snmp_ber_dec_delete(asn1, wholeMsg, (guint *) &wholeMsgLength); + + if (PDU->type == GNET_SNMP_PDU_RESPONSE) + *sendPduHandle = -1; + else + *sendPduHandle = 0; + return TRUE; +} + +static gboolean +snmpv3_release_state( gpointer stateReference) +{ + return TRUE; +} + + +gboolean +g_message_init() +{ + struct g_message *my_message; + + my_message = g_malloc(sizeof(struct g_message)); + + my_message->prepareOutgoingMessage = snmpv1_prepare_outgoing_message; + my_message->prepareResponseMessage = snmpv1_prepare_response_message; + my_message->prepareDataElements = snmpv1_prepare_data_elements; + my_message->releaseState = snmpv1_release_state; + + g_register_message(PMODEL_SNMPV1, my_message); + + my_message = g_malloc(sizeof(struct g_message)); + + my_message->prepareOutgoingMessage = snmpv2c_prepare_outgoing_message; + my_message->prepareResponseMessage = snmpv2c_prepare_response_message; + my_message->prepareDataElements = snmpv2c_prepare_data_elements; + my_message->releaseState = snmpv2c_release_state; + + g_register_message(PMODEL_SNMPV2C, my_message); + + my_message = g_malloc(sizeof(struct g_message)); + + my_message->prepareOutgoingMessage = snmpv3_prepare_outgoing_message; + my_message->prepareResponseMessage = snmpv3_prepare_response_message; + my_message->prepareDataElements = snmpv3_prepare_data_elements; + my_message->releaseState = snmpv3_release_state; + + g_register_message(PMODEL_SNMPV3, my_message); + return TRUE; +} diff --git a/src/message.h b/src/message.h new file mode 100644 index 0000000..b62f86c --- /dev/null +++ b/src/message.h @@ -0,0 +1,122 @@ +/* + * GSNMP -- glib-based SNMP library + * + * Copyright (C) 2003 Juergen Schoenwaelder + * Copyright (C) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_MSG_H__ +#define __GNET_SNMP_MSG_H__ + +#include "gsnmp.h" + +typedef enum { + GNET_SNMP_V1 = 0, + GNET_SNMP_V2C = 1, + GNET_SNMP_V3 = 3 +} GNetSnmpVersion; + +#if 0 +typedef struct _GNetSnmpMessage GNetSnmpMsg; + +struct _GNetSnmpMsg { + gint32 version; /* SNMPv1 / SNMPv2c / SNMPv3 */ + guchar *community; /* SNMPv1 / SNMPv2c */ + gsize community_len; /* SNMPv1 / SNMPv2c */ + gint32 msgid; /* SNMPv3 */ + gint32 msg_max_size; /* SNMPv3 */ + guint8 msg_flags; /* SNMPv3 */ + gint32 msg_security_model; /* SNMPv3 */ +}; + +gboolean gnet_snmp_ber_enc_msg (GNetSnmpBer *asn1, GNetSnmpMsg *msg, + GError **error); +gboolean gnet_snmp_ber_dec_msg (GNetSnmpBer *asn1, GNetSnmpMsg *msg, + GError **error); +#endif + +/* Processing Models as in RFC2271, page 40 */ + +#define PMODEL_SNMPV1 0 +#define PMODEL_SNMPV2C 1 +#define PMODEL_SNMPV2 2 +#define PMODEL_SNMPV3 3 + +struct g_message + { + gboolean (*prepareOutgoingMessage) ( + GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + guint messageProcessingModel, + guint securityModel, + GString *securityName, + int securityLevel, + GString *contextEngineID, + GString *contextName, + guint pduVersion, + GNetSnmpPdu *PDU, + gboolean expectResponse, + int sendPduHandle, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength, + GError **error); + gboolean (*prepareResponseMessage) ( + guint messageProcessingModel, + guint securityModel, + GString *securityName, + int securityLevel, + GString *contextEngineID, + GString *contextName, + guint pduVersion, + GNetSnmpPdu *PDU, + guint maxSizeResponseScopedPDU, + gpointer stateReference, + guint statusInformation, + GNetSnmpTDomain *outTransportDomain, + GInetAddr **outTransportAddress, + gpointer *outgoingMessage, + guint *outgoingMessageLength); + gboolean (*prepareDataElements) ( + GNetSnmpTDomain transportDomain, + GInetAddr *transportAddress, + gpointer wholeMsg, + int wholeMsgLength, + guint *messageProcessingModel, + guint *securityModel, + GString **securityName, + int *securityLevel, + GString **contextEngineID, + GString **contextName, + guint *pduVersion, + GNetSnmpPdu *PDU, + guint *pduType, + int *sendPduHandle, + guint *maxSizeResponseScopedPDU, + guint *statusInformation, + gpointer *stateReference, + GError **error); + gboolean (*releaseState) ( + gpointer stateReference); + }; + +gboolean g_message_init(void); + +#endif /* _G_MESSAGE_H_ */ diff --git a/src/pdu.c b/src/pdu.c new file mode 100644 index 0000000..934407b --- /dev/null +++ b/src/pdu.c @@ -0,0 +1,1467 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * Copyright (c) 1990 Dirk Wisse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include +#include "pdu.h" + +/* + * Constants used internally for encoding/decoding traps. + */ + +static const guint32 sysUpTime0[] + = { 1, 3, 6, 1, 2, 1, 1, 3, 0 }; +static const guint32 snmpTrapOID0[] + = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; +static const guint32 snmpTrapAddress0[] + = { 1, 3, 6, 1, 6, 3, 18, 1, 3, 0 }; +static const guint32 snmpTrapCommunity0[] + = { 1, 3, 6, 1, 6, 3, 18, 1, 4, 0 }; +static const guint32 snmpTrapEnterprise0[] + = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 3, 0 }; +static const guint32 snmpTraps[] + = { 1, 3, 6, 1, 6, 3, 1, 1, 5 }; + +/* + * Application specific ASN.1 tags as defined in RFC 3416. + */ + +#define GNET_SNMP_ATAG_IPA 0 +#define GNET_SNMP_ATAG_CNT 1 +#define GNET_SNMP_ATAG_GGE 2 +#define GNET_SNMP_ATAG_TIT 3 +#define GNET_SNMP_ATAG_OPQ 4 +#define GNET_SNMP_ATAG_C64 6 + +#define GNET_SNMP_ATAG_NSO 0 +#define GNET_SNMP_ATAG_NSI 1 +#define GNET_SNMP_ATAG_EOM 2 + +static struct { + guint klass; + guint tag; + GNetSnmpVarBindType type; +} class_tag_type_table[] = { + + { GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_NUL, GNET_SNMP_VARBIND_TYPE_NULL}, + { GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_INT, GNET_SNMP_VARBIND_TYPE_INTEGER32}, + { GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_OTS, GNET_SNMP_VARBIND_TYPE_OCTETSTRING}, + { GNET_SNMP_ASN1_UNI, GNET_SNMP_ASN1_OJI, GNET_SNMP_VARBIND_TYPE_OBJECTID}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_IPA, GNET_SNMP_VARBIND_TYPE_IPADDRESS}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_CNT, GNET_SNMP_VARBIND_TYPE_COUNTER32}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_GGE, GNET_SNMP_VARBIND_TYPE_UNSIGNED32}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_TIT, GNET_SNMP_VARBIND_TYPE_TIMETICKS}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_OPQ, GNET_SNMP_VARBIND_TYPE_OPAQUE}, + { GNET_SNMP_ASN1_APL, GNET_SNMP_ATAG_C64, GNET_SNMP_VARBIND_TYPE_COUNTER64}, + { GNET_SNMP_ASN1_CTX, GNET_SNMP_ATAG_NSO, GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT}, + { GNET_SNMP_ASN1_CTX, GNET_SNMP_ATAG_NSI, GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE}, + { GNET_SNMP_ASN1_CTX, GNET_SNMP_ATAG_EOM, GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW}, + + { -1, -1, -1 } +}; + +static inline gboolean +type_to_tag_and_class(guint *tag, guint *cls, GNetSnmpVarBindType type) +{ + int i; + + for (i = 0; class_tag_type_table[i].klass != -1; i++) { + if (class_tag_type_table[i].type == type) { + *tag = class_tag_type_table[i].tag; + *cls = class_tag_type_table[i].klass; + return TRUE; + } + } + return FALSE; +} + +static inline gboolean +tag_and_class_to_type(guint tag, guint klass, GNetSnmpVarBindType *type) +{ + int i; + + for (i = 0; class_tag_type_table[i].klass != -1; i++) { + if (class_tag_type_table[i].tag == tag + && class_tag_type_table[i].klass == klass) { + *type = class_tag_type_table[i].type; + return TRUE; + } + } + return FALSE; +} + + +/** + * varbind_new: + * + * Internal function to allocate and initialize a new GNetSnmpVarBind. + * + * Returns: a pointer to a new GNetSnmpVarBind. + */ + +static GNetSnmpVarBind* +varbind_new(const guint32 *oid, const gsize oid_len, + const GNetSnmpVarBindType type, + const gpointer value, const gsize value_len, + const int flags) +{ + GNetSnmpVarBind *vb; + + vb = g_new(GNetSnmpVarBind, 1); + + vb->oid_len = oid_len; + vb->oid = flags ? (guint32 *)oid + : (guint32 *) g_memdup(oid, oid_len * sizeof(guint32)); + + vb->type = type; + + vb->value_len = 0; + switch (type) { + case GNET_SNMP_VARBIND_TYPE_NULL: + case GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT: + case GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE: + case GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW: + vb->value.i32 = 0; + break; + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + g_assert(value); + vb->value.i32 = *((gint32 *) value); + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + g_assert(value); + vb->value.ui32 = *((guint32 *) value); + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + g_assert(value); + vb->value.ui64 = *((guint64 *) value); + break; + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + vb->value_len = value_len; + vb->value.ui8v = flags ? (guchar *) value + : (guchar *) g_memdup(value, vb->value_len); + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + vb->value_len = value_len; + vb->value.ui32v = flags ? (guint32 *) value + : (guint32 *) g_memdup(value, vb->value_len * sizeof(guint32)); + break; + } + + return vb; +} + +/** + * gnet_snmp_varbind_new: + * + * Allocate and initialize a new GNetSnmpVarBind. + * + * Returns: a pointer to a new GNetSnmpVarBind. + */ + +GNetSnmpVarBind* +gnet_snmp_varbind_new(const guint32 *oid, const gsize oid_len, + const GNetSnmpVarBindType type, + const gpointer value, const gsize value_len) +{ + return varbind_new(oid, oid_len, type, value, value_len, 0); +} + +/** + * gnet_snmp_varbind_delete: + * @vb: the pointer to the #GNetSnmpVarBind to free + * + * Deallocate a GNetSnmpVarBind by freeing all associated memory. + */ + +void +gnet_snmp_varbind_delete(GNetSnmpVarBind *vb) +{ + if (vb) { + g_free(vb->oid); + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + g_free(vb->value.ui8v); + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + g_free(vb->value.ui32v); + break; + default: + break; + } + g_free(vb); + } +} + +/** + * gnet_snmp_ber_enc_varbind: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vb: the pointer to the #GNetSnmpVarBind to encode + * @error: the error object used to report errors. + * + * Encodes an SNMP varbind as an ASN.1 SEQUENCE. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_varbind(GNetSnmpBer *asn1, GNetSnmpVarBind *vb, + GError **error) +{ + guint cls, tag; + guchar *eoc, *end; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + if (!gnet_snmp_ber_enc_gint32(asn1, &end, vb->value.i32, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + if (!gnet_snmp_ber_enc_octets(asn1, &end, vb->value.ui8v, + vb->value_len, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_NULL: + case GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT: + case GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE: + case GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW: + if (!gnet_snmp_ber_enc_null(asn1, &end, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + if (!gnet_snmp_ber_enc_oid(asn1, &end, vb->value.ui32v, + vb->value_len, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + if (!gnet_snmp_ber_enc_octets(asn1, &end, vb->value.ui8v, + vb->value_len, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + if (!gnet_snmp_ber_enc_guint32(asn1, &end, vb->value.ui32, error)) + return FALSE; + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + if (!gnet_snmp_ber_enc_guint64(asn1, &end, vb->value.ui64, error)) + return FALSE; + break; + default: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "unknown varbind type %d", vb->type); + } + return FALSE; + } + + g_assert(type_to_tag_and_class(&tag, &cls, vb->type)); + + if (!gnet_snmp_ber_enc_header(asn1, end, cls, GNET_SNMP_ASN1_PRI, tag, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_oid(asn1, &end, vb->oid, vb->oid_len, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OJI, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, + error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_enc_varbind_null: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vb: the pointer to the #GNetSnmpVarBind to encode + * @error: the error object used to report errors. + * + * Encodes an SNMP varbind as an ASN.1 SEQUENCE. This function always + * encodes an ASN.1 NULL value, regardless what the varbind actually + * contains. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_varbind_null(GNetSnmpBer *asn1, GNetSnmpVarBind *vb, + GError **error) +{ + GNetSnmpVarBindType t; + gboolean b; + + t = vb->type; + vb->type = GNET_SNMP_VARBIND_TYPE_NULL; + b = gnet_snmp_ber_enc_varbind(asn1, vb, error); + vb->type = t; + return b; +} + +/** + * gnet_snmp_ber_dec_varbind: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vb: the pointer used to store the new #GNetSnmpVarBind. + * @error: the error object used to report errors. + * + * Decodes an SNMP varbind from an ASN.1 SEQUENCE. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_varbind(GNetSnmpBer *asn1, GNetSnmpVarBind **vb, + GError **error) +{ + guint cls, con, tag, len, idlen; + GNetSnmpVarBindType type; + guchar *eoc, *end, *p = NULL; + guint32 *lp = NULL; + guint32 *id; + gint32 l; + guint32 ul; + guint64 ull; + gpointer value = NULL; + gsize value_len = 0; + + g_assert(vb); + + *vb = NULL; + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_CON + || tag != GNET_SNMP_ASN1_SEQ) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "varbind sequence with unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_OJI) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "varbind name with unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_oid(asn1, end, &id, &idlen, error)) + return FALSE; + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) { + g_free(id); + return FALSE; + } + if (con != GNET_SNMP_ASN1_PRI + || ! tag_and_class_to_type(tag, cls, &type)) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "varbind value with unexpected tag %d", tag); + } + g_free(id); + return FALSE; + } + + switch (type) { + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + if (!gnet_snmp_ber_dec_gint32(asn1, end, &l, error)) { + g_free(id); + return FALSE; + } + value = &l; + break; + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + if (!gnet_snmp_ber_dec_octets(asn1, end, &p, &len, error)) { + g_free(id); + return FALSE; + } + value = p; + value_len = len; + break; + case GNET_SNMP_VARBIND_TYPE_NULL: + case GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT: + case GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE: + case GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW: + if (!gnet_snmp_ber_dec_null(asn1, end, error)) { + g_free(id); + return FALSE; + } + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + if (!gnet_snmp_ber_dec_oid(asn1, end, (guint32 **)&lp, &len, error)) { + g_free(id); + return FALSE; + } + value = lp; + value_len = len; + break; + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + if (!gnet_snmp_ber_dec_octets(asn1, end, &p, &len, error)) { + g_free(id); + return FALSE; + } + if (len != 4) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "varbind value has unexpected length %d", len); + } + g_free(p); + g_free(id); + return FALSE; + } + value = p; + value_len = len; + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + if (!gnet_snmp_ber_dec_guint32(asn1, end, &ul, error)) { + g_free(id); + return FALSE; + } + value = &ul; + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + if (!gnet_snmp_ber_dec_guint64(asn1, end, &ull, error)) { + g_free(id); + return FALSE; + } + value = &ull; + break; + default: + g_assert_not_reached(); + } + + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) { + g_free(id); + return FALSE; + } + + *vb = varbind_new(id, idlen, type, value, value_len, 1); + return TRUE; +} + +/** + * gnet_snmp_ber_enc_varbind_list: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vbl: the list of #GNetSnmpVarBind to encode + * @error: the error object used to report errors. + * + * Encodes an SNMP varbind list as an ASN.1 SEQUENCE OF. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_varbind_list(GNetSnmpBer *asn1, GList *vbl, GError **error) +{ + guchar *eoc; + GList *elem; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + for (elem = g_list_last(vbl); elem; elem = g_list_previous(elem)) { + if (!gnet_snmp_ber_enc_varbind(asn1, + (GNetSnmpVarBind *) elem->data, error)) + return FALSE; + } + + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, + error)) + return FALSE; + + if (g_snmp_list_encode_hook) { + g_snmp_list_encode_hook(vbl); + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_varbind_list_null: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vbl: the list of #GNetSnmpVarBind to encode + * @error: the error object used to report errors. + * + * Encodes an SNMP varbind list as an ASN.1 SEQUENCE OF. This function + * always encodes an ASN.1 NULL values, regardless what the varbinds + * actually contain. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_varbind_list_null(GNetSnmpBer *asn1, GList *vbl, + GError **error) +{ + guchar *eoc; + GList *elem; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + for (elem = g_list_last(vbl); elem; elem = g_list_previous(elem)) { + if (!gnet_snmp_ber_enc_varbind_null(asn1, + (GNetSnmpVarBind *) elem->data, error)) + return FALSE; + } + + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, + error)) + return FALSE; + + if (g_snmp_list_encode_hook) { + g_snmp_list_encode_hook(vbl); + } + return TRUE; +} + +/** + * gnet_snmp_ber_dec_varbind_list: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @vbl: the pointer used to store the new list of #GNetSnmpVarBinds. + * @error: the error object used to report errors. + * + * Decodes an SNMP varbind list from an ASN.1 SEQUENCE OF. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_varbind_list(GNetSnmpBer *asn1, GList **vbl, GError **error) +{ + guint cls, con, tag; + guchar *eoc; + GNetSnmpVarBind *vb; + + g_assert(vbl); + + *vbl = NULL; + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_CON + || tag != GNET_SNMP_ASN1_SEQ) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "varbind list starts with unexpected tag %d", tag); + } + return FALSE; + } + + while (!gnet_snmp_ber_is_eoc(asn1, eoc)) { + if (!gnet_snmp_ber_dec_varbind(asn1, &vb, error)) { + g_list_foreach(*vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(*vbl); + *vbl = NULL; + return FALSE; + } + *vbl = g_list_prepend(*vbl, vb); + } + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) { + g_list_foreach(*vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(*vbl); + *vbl = NULL; + return FALSE; + } + *vbl = g_list_reverse(*vbl); + if (g_snmp_list_decode_hook) { + g_snmp_list_decode_hook(*vbl); + } + return TRUE; +} + +/** + * gnet_snmp_ber_enc_standard_pdu: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &pdu: the @GNetSnmpPdu to encode. + * @error: the error object used to report errors. + * + * Encodes a standard SNMP PDU as defined in RFC 3416. Suppresses + * values on read class PDUs. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_standard_pdu(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error) +{ + guchar *end; + + if (GNET_SNMP_PDU_CLASS_READ(pdu->type)) { + if (!gnet_snmp_ber_enc_varbind_list_null(asn1, pdu->varbind_list, error)) + return FALSE; + } else { + if (!gnet_snmp_ber_enc_varbind_list(asn1, pdu->varbind_list, error)) + return FALSE; + } + + if (!gnet_snmp_ber_enc_gint32(asn1, &end, pdu->error_index, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + error)) + return FALSE; + + if (!gnet_snmp_ber_enc_gint32(asn1, &end, pdu->error_status, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + error)) + return FALSE; + + if (!gnet_snmp_ber_enc_gint32(asn1, &end, pdu->request_id, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_dec_standard_pdu: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &pdu: the @GNetSnmpPdu to decode. + * @error: the error object used to report errors. + * + * Decodes a standard SNMP PDU as defined in RFC 3416. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_standard_pdu(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error) +{ + guint cls, con, tag; + guchar *end; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_INT) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "request-id has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_gint32(asn1, end, (guint32 *) &pdu->request_id, + error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_INT) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "error-status has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_guint32(asn1, end, + (guint32 *) &pdu->error_status, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_INT) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "error-index has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_guint32(asn1, end, &pdu->error_index, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_varbind_list(asn1, &pdu->varbind_list, error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_enc_trap_pdu: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &pdu: the @GNetSnmpPdu to encode. + * @error: the error object used to report errors. + * + * Encodes an SNMPv1 trap PDU as defined in RFC 1157. This function + * also implements the notification parameter translation defined in + * RFC 2576 section 3. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_trap_pdu(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guchar *end; + + const guint32 *enterprise = NULL; + gsize enterprise_len = 0; + guchar ip_address[] = { 0x00, 0x00, 0x00, 0x00 }; + gsize ip_address_len = 4; + gint32 generic = 0; + gint32 specific = 0; + guint32 timestamp = 0; + guint32 last = 0; + + GNetSnmpVarBind *vb, *vb_address = NULL, + *vb_community = NULL, *vb_enterprise = NULL; + GList *elem, *new_varbind_list = NULL; + + /* The first varbind has to be sysUpTime.0 ... */ + + vb = g_list_nth_data(pdu->varbind_list, 0); + if (! vb || vb->type != GNET_SNMP_VARBIND_TYPE_TIMETICKS + || gnet_snmp_compare_oids(sysUpTime0, G_N_ELEMENTS(sysUpTime0), + vb->oid, vb->oid_len) != 0) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "first trap varbind must be sysUpTime.0"); + } + return FALSE; + } + timestamp = vb->value.ui32; + + /* ... and the following varbind must be snmpTrapOID.0. */ + + vb = g_list_nth_data(pdu->varbind_list, 1); + if (!vb || !pdu->varbind_list->data) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "second trap varbind must be snmpTrapOID.0"); + } + return FALSE; + } + + if (! vb || vb->type != GNET_SNMP_VARBIND_TYPE_OBJECTID + || gnet_snmp_compare_oids(snmpTrapOID0, G_N_ELEMENTS(snmpTrapOID0), + vb->oid, vb->oid_len) != 0) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "second trap varbind must be snmpTrapOID.0"); + } + return FALSE; + } + + /* Next, see whether we can extract essential trap parameters if + the prefix conforms to SNMPv2-MIB::snmpTraps. */ + + last = vb->value.ui32v[G_N_ELEMENTS(snmpTraps)]; + generic = 6; + specific = last; + if (vb->value_len > G_N_ELEMENTS(snmpTraps) + && memcmp(vb->value.ui32v, snmpTraps, sizeof(snmpTraps)) == 0 + && (last > 0 || last < 7)) { + generic = last - 1; + specific = 0; + enterprise = snmpTraps; + enterprise_len = G_N_ELEMENTS(snmpTraps); + } + + /* Skip the first two varbinds and build a new varbind list which + * excludes any magic proxy varbinds. */ + + for (elem = g_list_nth(pdu->varbind_list, 2); + elem; elem = g_list_next(elem)) { + vb = elem->data; + if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapAddress0, G_N_ELEMENTS(snmpTrapAddress0))) { + vb_address = vb; + continue; + } else if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapCommunity0, G_N_ELEMENTS(snmpTrapCommunity0))) { + vb_community = vb; + continue; + } else if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapEnterprise0, G_N_ELEMENTS(snmpTrapEnterprise0))) { + vb_enterprise = vb; + continue; + } + new_varbind_list = g_list_append(new_varbind_list, vb); + } + + if (!gnet_snmp_ber_enc_varbind_list(asn1, new_varbind_list, error)) { + g_list_free(new_varbind_list); + return FALSE; + } + g_list_free(new_varbind_list); + + if (!gnet_snmp_ber_enc_guint32(asn1, &end, timestamp, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_APL, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ATAG_TIT, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_gint32(asn1, &end, specific, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_gint32(asn1, &end, generic, error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_octets(asn1, &end, ip_address, ip_address_len, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_APL, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ATAG_IPA, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_oid(asn1, &end, enterprise, enterprise_len, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OJI, + error)) + return FALSE; + + return TRUE; +} + +/** + * gnet_snmp_ber_dec_trap_pdu: + * &asn1: the handle for the #GNetSnmpBer buffer. + * &pdu: the @GNetSnmpPdu to decode. + * @error: the error object used to report errors. + * + * Decodes an SNMPv1 trap PDU as defined in RFC 1157. This function + * also implements the notification parameter translation defined in + * RFC 2576 section 3. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_trap_pdu(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guint cls, con, tag; + guchar *end; + GNetSnmpVarBind *vb, *vb_address = NULL, + *vb_community = NULL, *vb_enterprise = NULL; + GList *elem; + + guint32 *enterprise = NULL; + gsize enterprise_len; + guchar *ip_address = NULL; + gsize ip_address_len; + gint32 generic; + gint32 specific; + guint32 timestamp; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_OJI) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "enterprise has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_oid(asn1, end, &enterprise, &enterprise_len, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (!((cls == GNET_SNMP_ASN1_APL + && con == GNET_SNMP_ASN1_PRI + && tag == GNET_SNMP_ATAG_IPA) + || (cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI + && tag == GNET_SNMP_ASN1_OTS))) { /* needed for Banyan */ + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "ip-address has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_octets(asn1, end, &ip_address, &ip_address_len, + error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_INT) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "generic trap number has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_gint32(asn1, end, &generic, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_INT) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "specific trap number has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_gint32(asn1, end, &specific, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (!((cls == GNET_SNMP_ASN1_APL + && con == GNET_SNMP_ASN1_PRI + && tag == GNET_SNMP_ATAG_TIT) + || (cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI + && tag == GNET_SNMP_ASN1_INT))) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "timestamp has unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_guint32(asn1, end, ×tamp, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_varbind_list(asn1, &pdu->varbind_list, error)) + return FALSE; + + /* + * Add varbinds as described in RFC 2576 section 3.1. + */ + + if (generic >= 0 && generic < 6) { + guint32 base[] = { 1, 3, 6, 1, 6, 3, 1, 1, 0, 1 }; + base[8] = generic + 1; + vb = gnet_snmp_varbind_new(snmpTrapOID0, G_N_ELEMENTS(snmpTrapOID0), + GNET_SNMP_VARBIND_TYPE_OBJECTID, + base, G_N_ELEMENTS(base)); + pdu->varbind_list = g_list_prepend(pdu->varbind_list, vb); + } else if (generic == 6) { + guint32 *base = g_new0(guint32, enterprise_len + 2); + g_memmove(base, enterprise, enterprise_len * sizeof(guint32)); + base[enterprise_len + 1] = specific; + vb = gnet_snmp_varbind_new(snmpTrapOID0, G_N_ELEMENTS(snmpTrapOID0), + GNET_SNMP_VARBIND_TYPE_OBJECTID, + base, G_N_ELEMENTS(base)); + pdu->varbind_list = g_list_prepend(pdu->varbind_list, vb); + } else { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "illegal generic value %d", generic); + } + return FALSE; + } + + vb = gnet_snmp_varbind_new(sysUpTime0, G_N_ELEMENTS(sysUpTime0), + GNET_SNMP_VARBIND_TYPE_TIMETICKS, + ×tamp, 0); + pdu->varbind_list = g_list_prepend(pdu->varbind_list, vb); + + /* Search for any magic varbinds potentially inserted by a proxy + * as described in RFC 2576 section 3. If the proxy varbinds are + * not present, we claim to be proxy and insert them according to + * RFC 2576 section 3.1 paragraph (4). */ + + for (elem = pdu->varbind_list; elem; elem = g_list_next(elem)) { + vb = elem->data; + if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapAddress0, G_N_ELEMENTS(snmpTrapAddress0))) { + vb_address = vb; + } else if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapCommunity0, G_N_ELEMENTS(snmpTrapCommunity0))) { + vb_community = vb; + } else if (0 == gnet_snmp_compare_oids(vb->oid, vb->oid_len, + snmpTrapEnterprise0, G_N_ELEMENTS(snmpTrapEnterprise0))) { + vb_enterprise = vb; + } + } + + if (! vb_address) { + vb = gnet_snmp_varbind_new(snmpTrapAddress0, + G_N_ELEMENTS(snmpTrapAddress0), + GNET_SNMP_VARBIND_TYPE_IPADDRESS, + ip_address, ip_address_len); + pdu->varbind_list = g_list_append(pdu->varbind_list, vb); + } + + if (! vb_community) { + /* xxx gee, we do not have the community handy - solve this via + * context pdu field? does not really work - any other ideas? */ + vb = gnet_snmp_varbind_new(snmpTrapCommunity0, + G_N_ELEMENTS(snmpTrapCommunity0), + GNET_SNMP_VARBIND_TYPE_OCTETSTRING, + NULL, 0); + pdu->varbind_list = g_list_append(pdu->varbind_list, vb); + } + + if (! vb_enterprise) { + vb = gnet_snmp_varbind_new(snmpTrapEnterprise0, + G_N_ELEMENTS(snmpTrapEnterprise0), + GNET_SNMP_VARBIND_TYPE_OBJECTID, + enterprise, enterprise_len); + pdu->varbind_list = g_list_append(pdu->varbind_list, vb); + } + + if (enterprise) g_free(enterprise); + if (ip_address) g_free(ip_address); + + return TRUE; +} + +/** + * gnet_snmp_ber_enc_pdu_v1: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 1157 SNMP PDU to encode. + * @error: the error object used to report errors. + * + * Encodes an RFC 1157 SNMP PDU as an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_pdu_v1(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guchar *eoc; + GList *elem; + + /* xxx need to ensure that non SNMPv1 types in the varbind cause + * an error and that exceptions are treated as errors and NULL + * values */ + + for (elem = pdu->varbind_list; elem; elem = g_list_next(elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + /* better be explicit ... */ + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_NULL: + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "PDU does not support Counter64"); + } + return FALSE; + case GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT: + case GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE: + case GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "PDU does not support exceptions"); + } + return FALSE; + } + } + + /* xxx check for a valid message type, converting silently (?) + * where possible */ + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + switch (pdu->type) { + case GNET_SNMP_PDU_GET: + case GNET_SNMP_PDU_NEXT: + case GNET_SNMP_PDU_RESPONSE: + case GNET_SNMP_PDU_SET: + if (!gnet_snmp_ber_enc_standard_pdu(asn1, pdu, error)) + return FALSE; + break; + case GNET_SNMP_PDU_TRAP: + if (!gnet_snmp_ber_enc_trap_pdu(asn1, pdu, error)) + return FALSE; + break; + default: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "illegal PDU type %d", pdu->type); + } + return FALSE; + } + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_CTX, + GNET_SNMP_ASN1_CON, pdu->type, error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_dec_pdu_v1: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 1157 SNMP PDU to encode. + * @error: the error object used to report errors. + * + * Decodes an RFC 1157 SNMP PDU from an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_pdu_v1(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guint cls, con; + guchar *eoc; + + /* xxx need to ensure that non SNMPv1 types in the varbind cause + * an error and that exceptions are treated as errors and NULL + * values */ + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, + &cls, &con, (guint32 *) &pdu->type, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_CTX || con != GNET_SNMP_ASN1_CON) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "PDU starts with unexpected tag %d", pdu->type); + } + return FALSE; + } + switch (pdu->type) { + case GNET_SNMP_PDU_GET: + case GNET_SNMP_PDU_NEXT: + case GNET_SNMP_PDU_RESPONSE: + case GNET_SNMP_PDU_SET: + if (!gnet_snmp_ber_dec_standard_pdu(asn1, pdu, error)) + return FALSE; + break; + case GNET_SNMP_PDU_TRAP: + if (!gnet_snmp_ber_dec_trap_pdu(asn1, pdu, error)) + return FALSE; + break; + default: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "illegal PDU type %d", pdu->type); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_enc_pdu_v2: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 3416 SNMP PDU to encode. + * @error: the error object used to report errors. + * + * Encodes an RFC 3416 SNMP PDU as an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_pdu_v2(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guchar *eoc; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + switch (pdu->type) { + case GNET_SNMP_PDU_GET: + case GNET_SNMP_PDU_NEXT: + case GNET_SNMP_PDU_RESPONSE: + case GNET_SNMP_PDU_SET: + case GNET_SNMP_PDU_BULK: + case GNET_SNMP_PDU_INFORM: + case GNET_SNMP_PDU_TRAP: + if (!gnet_snmp_ber_enc_standard_pdu(asn1, pdu, error)) + return FALSE; + break; + default: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_ENC_BADVALUE, + "illegal PDU type %d", pdu->type); + } + return FALSE; + } + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_CTX, + GNET_SNMP_ASN1_CON, pdu->type, error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_dec_pdu_v2: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 3416 SNMP PDU to encode. + * @error: the error object used to report errors. + * + * Decodes an RFC 3416 SNMP PDU from an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_pdu_v2(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guint cls, con; + guchar *eoc; + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, + &cls, &con, (guint32 *) &pdu->type, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_CTX || con != GNET_SNMP_ASN1_CON) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "PDU starts with unexpected tag %d", pdu->type); + } + return FALSE; + } + switch (pdu->type) { + case GNET_SNMP_PDU_GET: + case GNET_SNMP_PDU_NEXT: + case GNET_SNMP_PDU_RESPONSE: + case GNET_SNMP_PDU_SET: + case GNET_SNMP_PDU_BULK: + case GNET_SNMP_PDU_INFORM: + case GNET_SNMP_PDU_TRAP: + if (!gnet_snmp_ber_dec_standard_pdu(asn1, pdu, error)) + return FALSE; + break; + default: + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "illegal PDU type %d", pdu->type); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_eoc(asn1, eoc, error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_enc_pdu_v3: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 3416 SNMP PDU to encode. + * @error: the error object used to report errors. + * + * Encodes an RFC 3412 scoped PDU as an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_enc_pdu_v3(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guchar *eoc, *end; + + if (!gnet_snmp_ber_enc_eoc(asn1, &eoc, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_pdu_v2(asn1, pdu, error)) + return FALSE; + + if (!gnet_snmp_ber_enc_octets(asn1, &end, + pdu->context_name, pdu->context_name_len, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_octets(asn1, &end, + pdu->context_engineid, pdu->context_engineid_len, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, end, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, + error)) + return FALSE; + if (!gnet_snmp_ber_enc_header(asn1, eoc, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_CON, GNET_SNMP_ASN1_SEQ, + error)) + return FALSE; + return TRUE; +} + +/** + * gnet_snmp_ber_dec_pdu_v3: + * @asn1: the handle for the #GNetSnmpBer buffer. + * @pdu: the RFC 3416 SNMP PDU to decode. + * @error: the error object used to report errors. + * + * Decodes an RFC 3412 scoped PDU from an ASN.1 value. + * + * Returns: a gboolean value indicating success. + */ + +gboolean +gnet_snmp_ber_dec_pdu_v3(GNetSnmpBer *asn1, GNetSnmpPdu *pdu, GError **error) +{ + guint cls, con, tag; + guchar *eoc, *end; + + if (!gnet_snmp_ber_dec_header(asn1, &eoc, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_CON + || tag != GNET_SNMP_ASN1_SEQ) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "Scoped PDU starts with unexpected tag %d", tag); + } + return FALSE; + } + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_OTS) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "contextEngineID starts with unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_octets(asn1, end, &pdu->context_engineid, + &pdu->context_engineid_len, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_header(asn1, &end, &cls, &con, &tag, error)) + return FALSE; + if (cls != GNET_SNMP_ASN1_UNI + || con != GNET_SNMP_ASN1_PRI + || tag != GNET_SNMP_ASN1_OTS) { + if (error) { + g_set_error(error, + GNET_SNMP_BER_ERROR, + GNET_SNMP_BER_ERROR_DEC_BADVALUE, + "contextName starts with unexpected tag %d", tag); + } + return FALSE; + } + if (!gnet_snmp_ber_dec_octets(asn1, end, &pdu->context_name, + &pdu->context_name_len, error)) + return FALSE; + + if (!gnet_snmp_ber_dec_pdu_v2(asn1, pdu, error)) + return FALSE; + + return TRUE; +} + + + +/* ------------------------ stuff we should get rid off ----------------- */ + +void (*g_snmp_list_decode_hook)(GList *list) = NULL; +void (*g_snmp_list_encode_hook)(GList *list) = NULL; diff --git a/src/pdu.h b/src/pdu.h new file mode 100644 index 0000000..98b942b --- /dev/null +++ b/src/pdu.h @@ -0,0 +1,225 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * Copyright (c) 1990 Dirk Wisse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_PDU_H__ +#define __GNET_SNMP_PDU_H__ + +#include "ber.h" + +#define GNET_SNMP_SIZE_OBJECTID (128) + +/* + * Distinguished SNMP varbind types as defined in RFC 3416. + */ + +typedef enum { + GNET_SNMP_VARBIND_TYPE_NULL = 0, + GNET_SNMP_VARBIND_TYPE_OCTETSTRING = 1, + GNET_SNMP_VARBIND_TYPE_OBJECTID = 2, + GNET_SNMP_VARBIND_TYPE_IPADDRESS = 3, + GNET_SNMP_VARBIND_TYPE_INTEGER32 = 4, + GNET_SNMP_VARBIND_TYPE_UNSIGNED32 = 5, /* also Gauge32 */ + GNET_SNMP_VARBIND_TYPE_COUNTER32 = 6, + GNET_SNMP_VARBIND_TYPE_TIMETICKS = 7, + GNET_SNMP_VARBIND_TYPE_OPAQUE = 8, + GNET_SNMP_VARBIND_TYPE_COUNTER64 = 9, + GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT = 10, + GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE = 11, + GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW = 12 +} GNetSnmpVarBindType; + +typedef struct _GNetSnmpVarBind GNetSnmpVarBind; + +struct _GNetSnmpVarBind +{ + guint32 *oid; /* name of the variable */ + gsize oid_len; /* length of the name */ + GNetSnmpVarBindType type; /* variable type / exception */ + union { + gint32 i32; /* 32 bit signed */ + guint32 ui32; /* 32 bit unsigned */ + gint64 i64; /* 64 bit signed */ + guint64 ui64; /* 64 bit unsigned */ + guint8 *ui8v; /* 8 bit unsigned vector */ + guint32 *ui32v; /* 32 bit unsigned vector */ + } value; /* value of the variable */ + gsize value_len; /* length of a vector in byte */ +}; + +GNetSnmpVarBind* gnet_snmp_varbind_new (const guint32 *oid, + const gsize oid_len, + const GNetSnmpVarBindType type, + const gpointer value, + const gsize value_len); +void gnet_snmp_varbind_delete (GNetSnmpVarBind *vb); + +gboolean gnet_snmp_ber_enc_varbind (GNetSnmpBer *asn1, + GNetSnmpVarBind *vb, + GError **error); +gboolean gnet_snmp_ber_enc_varbind_null (GNetSnmpBer *asn1, + GNetSnmpVarBind *vb, + GError **error); +gboolean gnet_snmp_ber_dec_varbind (GNetSnmpBer *asn1, + GNetSnmpVarBind **vb, + GError **error); + +/* + * SNMP VarBindLists are represented as GLists of GNetSnmpVarBinds. + * This allows us to use all the nice GList functions to manipulate + * and navigate SNMP VarBindLists. + */ + +gboolean gnet_snmp_ber_enc_varbind_list (GNetSnmpBer *asn1, + GList *list, + GError **error); + +gboolean gnet_snmp_ber_enc_varbind_list_null(GNetSnmpBer *asn1, + GList *list, + GError **error); + +gboolean gnet_snmp_ber_dec_varbind_list (GNetSnmpBer *asn1, + GList **list, + GError **error); + +/* + * SNMP protocol operations as defined in RFC 3416. + */ + +typedef enum { + GNET_SNMP_PDU_GET = 0, + GNET_SNMP_PDU_NEXT = 1, + GNET_SNMP_PDU_RESPONSE = 2, + GNET_SNMP_PDU_SET = 3, + GNET_SNMP_PDU_TRAP = 4, + GNET_SNMP_PDU_BULK = 5, + GNET_SNMP_PDU_INFORM = 6, +} GNetSnmpPduType; + +/* + * SNMP protocol operation classes as defined in RFC 3411. + */ + +#define GNET_SNMP_PDU_CLASS_READ(p) \ + (p == GNET_SNMP_PDU_GET || \ + p == GNET_SNMP_PDU_NEXT || \ + p == GNET_SNMP_PDU_BULK) + +#define GNET_SNMP_PDU_CLASS_WRITE(p) \ + (p == GNET_SNMP_PDU_SET) + +#define GNET_SNMP_PDU_CLASS_RESPONSE(p) \ + (p == GNET_SNMP_PDU_RESPONSE) + +#define GNET_SNMP_PDU_CLASS_NOTIFICATION(p) \ + (p == GNET_SNMP_PDU_TRAP || p == GNET_SNMP_PDU_INFORM) + +/* + * SNMP protocol error codes as defined in RFC 3416. + * Negative error codes are GNET-SNMP internal codes. + */ + +typedef enum { + GNET_SNMP_ERR_DONE = -4, + GNET_SNMP_ERR_PROCEDURE = -3, + GNET_SNMP_ERR_INTERNAL = -2, + GNET_SNMP_ERR_NORESPONSE = -1, + GNET_SNMP_ERR_NOERROR = 0, + GNET_SNMP_ERR_TOOBIG = 1, + GNET_SNMP_ERR_NOSUCHNAME = 2, + GNET_SNMP_ERR_BADVALUE = 3, + GNET_SNMP_ERR_READONLY = 4, + GNET_SNMP_ERR_GENERROR = 5, + GNET_SNMP_ERR_NOACCESS = 6, + GNET_SNMP_ERR_WRONGTYPE = 7, + GNET_SNMP_ERR_WRONGLENGTH = 8, + GNET_SNMP_ERR_WRONGENCODING = 9, + GNET_SNMP_ERR_WRONGVALUE = 10, + GNET_SNMP_ERR_NOCREATION = 11, + GNET_SNMP_ERR_INCONSISTENTVALUE = 12, + GNET_SNMP_ERR_RESOURCEUNAVAILABLE = 13, + GNET_SNMP_ERR_COMMITFAILED = 14, + GNET_SNMP_ERR_UNDOFAILED = 15, + GNET_SNMP_ERR_AUTHORIZATIONERROR = 16, + GNET_SNMP_ERR_NOTWRITABLE = 17, + GNET_SNMP_ERR_INCONSISTENTNAME = 18 +} GNetSnmpError; + +/* + * SNMPv1 trap PDUs have a slightly different format. This library + * implements the notification mappings defined in RFC 2576 so that + * applications will always see the SNMPv2c/SNMPv3 notification PDU + * format. Also note that the GNetSnmpPdu represents a scoped PDU as + * defined in RFC 3411 and RFC 3412. + */ + +typedef struct _GNetSnmpPdu GNetSnmpPdu; + +struct _GNetSnmpPdu { + guchar *context_engineid; + gsize context_engineid_len; + guchar *context_name; + gsize context_name_len; + GNetSnmpPduType type; + gint32 request_id; + gint32 error_status; /* should be GNetSnmpError */ + gint32 error_index; + GList *varbind_list; +}; + +/* + * The following encoding/decoding functions are for the different SNMP + * protocol versions supported by this library. + */ + +gboolean gnet_snmp_ber_enc_standard_pdu (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_dec_standard_pdu (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_enc_trap_pdu (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_dec_trap_pdu (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); + +gboolean gnet_snmp_ber_enc_pdu_v1 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_dec_pdu_v1 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_enc_pdu_v2 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_dec_pdu_v2 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_enc_pdu_v3 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); +gboolean gnet_snmp_ber_dec_pdu_v3 (GNetSnmpBer *asn1, GNetSnmpPdu *pdu, + GError **error); + +/* ------------------------ stuff we should get rid off ----------------- */ + + +/* SNMP hooks for debugging, profiling, statistics, ... */ + +extern void (*g_snmp_list_decode_hook)(GList *list); +extern void (*g_snmp_list_encode_hook)(GList *list); + +#endif /* __GNET_SNMP_PDU_H__ */ diff --git a/src/security.c b/src/security.c new file mode 100644 index 0000000..452b3ad --- /dev/null +++ b/src/security.c @@ -0,0 +1,289 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + +#include + +/* This module defines the API to the SNMP RFC layer. Requests are routed + * to the appropriate transport (e.g. IPv4 or IPv6 or IPX) by using the + * message processing compatible with the given PDU version (V1, V2C, + * or V3). Applications will prefer to use the sync or async event loop + * API presented by the g_session layer. + */ + +/* + statusInformation = + authenticateOutgoingMsg( + IN authKey -- secret key for authentication + IN wholeMsg -- unauthenticated complete message + OUT authenticatedWholeMsg -- complete authenticated message + ) + + statusInformation = + authenticateIncomingMsg( + IN authKey -- secret key for authentication + IN authParameters -- as received on the wire + IN wholeMsg -- as received on the wire + OUT authenticatedWholeMsg -- complete authenticated message + ) + + statusInformation = + encryptData( + IN encryptKey -- secret key for encryption + IN dataToEncrypt -- data to encrypt (scopedPDU) + OUT encryptedData -- encrypted data (encryptedPDU) + OUT privParameters -- filled in by service provider + ) + + statusInformation = + decryptData( + IN decryptKey -- secret key for decrypting + IN privParameters -- as received on the wire + IN encryptedData -- encrypted data (encryptedPDU) + OUT decryptedData -- decrypted data (scopedPDU) + ) + + statusInformation = -- success or errorIndication + generateRequestMsg( + IN messageProcessingModel -- typically, SNMP version + IN globalData -- message header, admin data + IN maxMessageSize -- of the sending SNMP entity + IN securityModel -- for the outgoing message + IN securityEngineID -- authoritative SNMP entity + IN securityName -- on behalf of this principal + IN securityLevel -- Level of Security requested + IN scopedPDU -- message (plaintext) payload + OUT securityParameters -- filled in by Security Module + OUT wholeMsg -- complete generated message + OUT wholeMsgLength -- length of generated message + ) + + statusInformation = -- success or errorIndication + generateResponseMsg( + IN messageProcessingModel -- typically, SNMP version + IN globalData -- message header, admin data + IN maxMessageSize -- of the sending SNMP entity + IN securityModel -- for the outgoing message + IN securityEngineID -- authoritative SNMP entity + IN securityName -- on behalf of this principal + IN securityLevel -- Level of Security requested + IN scopedPDU -- message (plaintext) payload + IN securityStateReference -- reference to security state + -- information from original + -- request + OUT securityParameters -- filled in by Security Module + OUT wholeMsg -- complete generated message + OUT wholeMsgLength -- length of generated message + ) + + statusInformation = -- errorIndication or success + -- error counter OID/value if error + processIncomingMsg( + IN messageProcessingModel -- typically, SNMP version + IN maxMessageSize -- of the sending SNMP entity + IN securityParameters -- for the received message + IN securityModel -- for the received message + IN securityLevel -- Level of Security + IN wholeMsg -- as received on the wire + IN wholeMsgLength -- length as received on the wire + OUT securityEngineID -- authoritative SNMP entity + OUT securityName -- identification of the principal + OUT scopedPDU, -- message (plaintext) payload + OUT maxSizeResponseScopedPDU -- maximum size of the Response PDU + OUT securityStateReference -- reference to security state + ) -- information, needed for response + +*/ + +/* + * USMSecurityParametersSyntax DEFINITIONS IMPLICIT TAGS ::= BEGIN + * + * UsmSecurityParameters ::= + * SEQUENCE { + * -- global User-based security parameters + * msgAuthoritativeEngineID OCTET STRING, + * msgAuthoritativeEngineBoots INTEGER (0..2147483647), + * msgAuthoritativeEngineTime INTEGER (0..2147483647), + * msgUserName OCTET STRING (SIZE(1..32)), + * -- authentication protocol specific parameters + * msgAuthenticationParameters OCTET STRING, + * -- privacy protocol specific parameters + * msgPrivacyParameters OCTET STRING + * } + * END + */ + +/* ******************************* */ + +/** + * gnet_snmp_password_to_key_md5 + * @password: Password (not necessarily NUL terminated). + * @password_len: Length of the password (must be positive). + * @key: Pointer to memory large enough to hold the key. + * + * Convert the password into a key by implementing the algorithm + * defined in RFC 3414 appendix A.2.1 using MD5 as the oneway hash + * function. + * + **/ + +void +gnet_snmp_password_to_key_md5(guchar *password, gsize password_len, + guchar *key) +{ + GMD5 *gmd5; + guchar *cp, password_buf[64]; + gulong password_index = 0; + gulong count = 0, i; + + g_assert(password_len); + + gmd5 = gnet_md5_new_incremental(); + + /**********************************************/ + /* Use while loop until we've done 1 Megabyte */ + /**********************************************/ + + while (count < 1048576) { + cp = password_buf; + for(i = 0; i < 64; i++) { + /*************************************************/ + /* Take the next octet of the password, wrapping */ + /* to the beginning of the password as necessary.*/ + /*************************************************/ + *cp++ = password[ password_index++ % password_len ]; + } + gnet_md5_update(gmd5, password_buf, 64); + count += 64; + } + gnet_md5_final(gmd5); + + g_memmove(key, gnet_md5_get_digest(gmd5), GNET_MD5_HASH_LENGTH); + gnet_md5_delete(gmd5); +} + +/** + * gnet_snmp_localize_key_md5 + * @key: Pointer to memory which holds a key. + * @engineID: Pointer to memory which holds an SNMP engine ID. + * @engineID_len: Length of the engine ID (between 5 and 32 inclusive). + * + * Localize a key for a specific engine by implementing the algorithm + * defined in RFC 3414 appendix A.2.1 using MD5 as the oneway hash + * function. + * + **/ + +void +gnet_snmp_localize_key_md5(guchar *key, guchar *engineID, gsize engineID_len) +{ + GMD5 *gmd5; + guchar password_buf[64]; + + g_assert(engineID_len > 4 && engineID_len < 33); + + g_memmove(password_buf, key, 16); + g_memmove(password_buf+16, engineID, engineID_len); + g_memmove(password_buf+16+engineID_len, key, 16); + + gmd5 = gnet_md5_new(password_buf, 32+engineID_len); + g_memmove(key, gnet_md5_get_digest(gmd5), GNET_MD5_HASH_LENGTH); + gnet_md5_delete(gmd5); +} + +/** + * gnet_snmp_password_to_key_sha + * @password: Password (not necessarily NUL terminated) + * @password_len: Length of the password (must be positive) + * @key: Pointer to memory large enough to hold the key + * + * Convert the password into a key by implementing the algorithm + * defined in RFC 3414 appendix A.2.1 using SHA as the oneway hash + * function. + * + **/ + +void +gnet_snmp_password_to_key_sha(guchar *password, gsize password_len, + guchar *key) +{ + GSHA *gsha; + guchar *cp, password_buf[64]; + gulong password_index = 0; + gulong count = 0, i; + + g_assert(password_len); + + gsha = gnet_sha_new_incremental(); + + /**********************************************/ + /* Use while loop until we've done 1 Megabyte */ + /**********************************************/ + + while (count < 1048576) { + cp = password_buf; + for(i = 0; i < 64; i++) { + /*************************************************/ + /* Take the next octet of the password, wrapping */ + /* to the beginning of the password as necessary.*/ + /*************************************************/ + *cp++ = password[ password_index++ % password_len ]; + } + gnet_sha_update(gsha, password_buf, 64); + count += 64; + } + gnet_sha_final(gsha); + + g_memmove(key, gnet_sha_get_digest(gsha), GNET_SHA_HASH_LENGTH); + gnet_sha_delete(gsha); +} + +/** + * gnet_snmp_localize_key_sha + * @key: Pointer to memory which holds a key + * @engineID: Pointer to memory which holds an SNMP engine ID + * @engineID_len: Length of the engine ID (between 5 and 32 inclusive) + * + * Localize a key for a specific engine by implementing the algorithm + * defined in RFC 3414 appendix A.2.1 using SHA as the oneway hash + * function. + * + **/ + +void +gnet_snmp_localize_key_sha(guchar *key, guchar *engineID, gsize engineID_len) +{ + GSHA *gsha; + guchar password_buf[72]; + + g_assert(engineID_len > 4 && engineID_len < 33); + + g_memmove(password_buf, key, 20); + g_memmove(password_buf+20, engineID, engineID_len); + g_memmove(password_buf+20+engineID_len, key, 20); + + gsha = gnet_sha_new(password_buf, 40+engineID_len); + g_memmove(key, gnet_sha_get_digest(gsha), GNET_SHA_HASH_LENGTH); + gnet_sha_delete(gsha); +} diff --git a/src/security.h b/src/security.h new file mode 100644 index 0000000..20d6030 --- /dev/null +++ b/src/security.h @@ -0,0 +1,81 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_USM_H__ +#define __GNET_SNMP_USM_H__ + +#include "gsnmp.h" + +/* Security models as in RFC2271, page 39 */ + +#define SMODEL_ANY 0 +#define SMODEL_SNMPV1 1 +#define SMODEL_SNMPV2C 2 +#define SMODEL_USM 3 + +#define SLEVEL_NANP 0 +#define SLEVEL_ANP 1 +#define SLEVEL_AP 3 + +struct g_security + { + gboolean (*generateRequestMsg) (); + gboolean (*processIncomingMsg) (); + gboolean (*generateResponseMsg) (); + }; + +/* Authentification types */ +#define AUTH_COMMUNITY 1 +#define AUTH_USEC 2 + +#define AUTH_COMLEN 255 + +/* Typedefs */ + +typedef struct _SNMP_AUTH SNMP_AUTH; + +/* Authentication */ + +struct _SNMP_AUTH +{ + guint type; + guchar name[AUTH_COMLEN]; + guint nlen; + guchar ahash[20]; + guint alen; + guchar phash[20]; + guint plen; +}; + + +void gnet_snmp_password_to_key_md5 (guchar *password, gsize password_len, + guchar *key); +void gnet_snmp_localize_key_md5 (guchar *key, + guchar *engineID, gsize engineID_len); + +void gnet_snmp_password_to_key_sha (guchar *password, gsize password_len, + guchar *key); +void gnet_snmp_localize_key_sha (guchar *key, + guchar *engineID, gsize engineID_len); + +#endif /* __GNET_SNMP_USM_H__ */ diff --git a/src/session.c b/src/session.c new file mode 100644 index 0000000..95348fa --- /dev/null +++ b/src/session.c @@ -0,0 +1,801 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + +#include +#include +#include +#include +#include + +static GSList *request_queue = NULL; /* queue of active requests */ + +/* + * Allocate a new session data structure. + */ + +GNetSnmp* +gnet_snmp_new() +{ + GNetSnmp *session; + + session = g_malloc0(sizeof(GNetSnmp)); + session->tdomain = GNET_SNMP_TDOMAIN_NONE; + session->taddress = NULL; + session->retries = GNET_SNMP_DEFAULT_RETRIES; + session->timeout = GNET_SNMP_DEFAULT_TIMEOUT; + session->version = GNET_SNMP_V2C; + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: new\n", session); + } + return session; +} + +/** + * gnet_snmp_new_uri: + * @uri: the snmp: uri + * + * Allocate and initialize a new GNetSnmp session. + * + * Returns: a pointer to a new GNetSnmp session. + */ + +/* XXX must use the glib error handling mechanism here (and in other + XXX session related functions) */ + +/* XXX what about TCP/UDP selection? probing? should we pass some flags? */ + +GNetSnmp* +gnet_snmp_new_uri(const GURI *uri) +{ + GNetSnmp *snmp = NULL; + GInetAddr *taddress = NULL; + GNetSnmpTDomain tdomain = GNET_SNMP_TDOMAIN_NONE; + int ipv6; + + g_return_val_if_fail(uri, NULL); + + taddress = gnet_inetaddr_new(uri->hostname, uri->port); + if (taddress) { + ipv6 = gnet_inetaddr_is_ipv6(taddress); + tdomain = + ipv6 ? GNET_SNMP_TDOMAIN_UDP_IPV6 : GNET_SNMP_TDOMAIN_UDP_IPV4; + + snmp = gnet_snmp_new(); + if (snmp) { + gnet_snmp_set_transport(snmp, tdomain, taddress); + gnet_snmp_set_community(snmp, uri->userinfo); + } + gnet_inetaddr_delete(taddress); + } + + return snmp; +} + +/* + * Clone a session data structure. + */ + +GNetSnmp* +gnet_snmp_clone(GNetSnmp *session) +{ + GNetSnmp *clone; + + g_return_val_if_fail(session, NULL); + + clone = gnet_snmp_new(); + gnet_snmp_set_transport(clone, session->tdomain, session->taddress); + gnet_snmp_set_community(clone, session->community); + gnet_snmp_set_timeout(clone, session->timeout); + gnet_snmp_set_retries(clone, session->retries); + gnet_snmp_set_version(clone, session->version); + + return clone; +} + +/* + * Destroy a session data structure. + */ + +void +gnet_snmp_delete(GNetSnmp *snmp) +{ + g_return_if_fail(snmp); + + /* XXX delete all requests that refer to this session first */ + + if (snmp->taddress) gnet_inetaddr_delete(snmp->taddress); + if (snmp->uri) gnet_uri_delete(snmp->uri); + if (snmp->community) g_free(snmp->community); + g_free(snmp); + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: deleted\n", snmp); + } +} + +void +gnet_snmp_set_transport(GNetSnmp *snmp, + GNetSnmpTDomain tdomain, GInetAddr *taddress) +{ + g_return_if_fail(snmp); + + if (snmp->taddress) gnet_inetaddr_delete(snmp->taddress); + snmp->tdomain = GNET_SNMP_TDOMAIN_NONE; + snmp->taddress = NULL; + if (taddress) { + snmp->tdomain = tdomain; + snmp->taddress = gnet_inetaddr_clone(taddress); + } + (void) gnet_snmp_get_uri(snmp); +} + +void +gnet_snmp_set_community(GNetSnmp *snmp, gchar *community) +{ + g_return_if_fail(snmp); + + if (snmp->community) g_free(snmp->community); + snmp->community = NULL; + if (community) snmp->community = g_strdup(community); + (void) gnet_snmp_get_uri(snmp); +} + +const gchar* +gnet_snmp_get_community(const GNetSnmp *snmp) +{ + g_return_val_if_fail(snmp, NULL); + + return snmp->community; +} + +void +gnet_snmp_set_timeout(GNetSnmp *snmp, guint timeout) +{ + g_return_if_fail(snmp); + + snmp->timeout = timeout; +} + +guint +gnet_snmp_get_timeout(const GNetSnmp *snmp) +{ + g_return_val_if_fail(snmp, 0); + + return snmp->timeout; +} + +void +gnet_snmp_set_retries(GNetSnmp *snmp, guint retries) +{ + g_return_if_fail(snmp); + + snmp->retries = retries; +} + +guint +gnet_snmp_get_retries(const GNetSnmp *snmp) +{ + g_return_val_if_fail(snmp, 0); + + return snmp->retries; +} + +void +gnet_snmp_set_version(GNetSnmp *snmp, GNetSnmpVersion version) +{ + g_return_if_fail(snmp); + + snmp->version = version; +} + +GNetSnmpVersion +gnet_snmp_get_version(const GNetSnmp *snmp) +{ + g_return_val_if_fail(snmp, 0); + + return snmp->version; +} + +/* + * Allocate a new request data structure. + */ + +GNetSnmpRequest* +gnet_snmp_request_new() +{ + GNetSnmpRequest *request; + + request = g_malloc0(sizeof(GNetSnmpRequest)); + request->auth = g_string_new(NULL); + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: new\n", request); + } + + return request; +} + +/* + * Destroy a request data structure. + */ + +void +gnet_snmp_request_delete(GNetSnmpRequest *request) +{ + g_return_if_fail(request); + + if (request->auth) { + g_string_free(request->auth, 1); + } + g_free(request); + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: deleted\n", request); + } +} + +/* + * Add a request to the global queue of outstanding requests. + * XXX This is not thread-safe. + */ + +void +gnet_snmp_request_queue(GNetSnmpRequest *request) +{ + g_return_if_fail(request); + + request_queue = g_slist_append(request_queue, request); + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: queued\n", request); + } +} + +/* + * Remove a request from the global queue of outstanding requests. + * XXX This is not thread-safe. + */ + +void +gnet_snmp_request_dequeue(GNetSnmpRequest *request) +{ + g_return_if_fail(request); + + request_queue = g_slist_remove(request_queue, request); + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: dequeued\n", request); + } +} + +/* + * Find the request with a given request id in the global queue of + * outstanding requests. + * XXX This is not thread-safe. + */ + +GNetSnmpRequest* +gnet_snmp_request_find(gint32 id) +{ + GSList *elem; + + for (elem = request_queue; elem; elem = g_slist_next(elem)) { + GNetSnmpRequest *request = (GNetSnmpRequest *) elem->data; + if (request->pdu.request_id == id) { + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: found\n", request); + } + return request; + } + } + + return NULL; +} + +/* + * + */ + +void +gnet_snmp_request_timeout(GNetSnmpRequest *request) +{ + if (request->timeout) { + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: timeout callback invoked\n", request); + } + request->timeout(request->session, request->magic); + } +} + + +/* + * query/set one mib from a snmp host + * + * host -- Host info in question + * callback-- Pointer to function that will handle the reply + * + */ + +/* Asynchronous SNMP functions */ + +static gpointer +g_async_send(GNetSnmp *session, GNetSnmpPduType type, + GList *vbl, guint32 arg1, guint32 arg2) +{ + GError *error = NULL; + GNetSnmpRequest *request; + GTimeVal now; + int model = 0, pduv = 0; + static gint32 id = -1; + + if (id < 0) { + id = random(); + } + + g_get_current_time(&now); + + session->error_status = GNET_SNMP_ERR_NOERROR; + session->error_index = 0; + + request = gnet_snmp_request_new(); + request->callback = session->done_callback; + request->timeout = session->time_callback; + request->pdu.request_id = id++; + request->pdu.error_status = arg1; + request->pdu.error_index = arg2; + request->pdu.varbind_list = vbl; + request->auth = g_string_append(request->auth, session->community); + request->pdu.type = type; + request->retries = session->retries; + request->timeoutval = session->timeout; + request->magic = session->magic; + request->version = session->version; + request->tdomain = session->tdomain; + request->taddress = session->taddress; + request->session = session; + request->timer = now; + request->timer.tv_sec += request->timeoutval / 1000; + request->timer.tv_usec += (request->timeoutval % 1000) * 1000; + + switch (request->version) { + case 0: + model = PMODEL_SNMPV1; + pduv = PDUV1; + break; + case 1: + model = PMODEL_SNMPV2C; + pduv = PDUV2; + break; + case 3: + model = PMODEL_SNMPV3; + pduv = PDUV2; + break; + default: + g_assert_not_reached(); + } + + sendPdu(request->tdomain, request->taddress, model, SMODEL_ANY, + request->auth, SLEVEL_NANP, NULL, NULL, pduv, &request->pdu, TRUE, + &error); + + if (error) { + gnet_snmp_request_timeout(request); + gnet_snmp_request_delete(request); + g_error_free(error); + return NULL; + } + + gnet_snmp_request_queue(request); + + return request; +} + +gpointer +gnet_snmp_async_set(GNetSnmp *snmp, GList *vbl) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_async_set pdu %p\n", snmp, vbl); + } + return g_async_send(snmp, GNET_SNMP_PDU_SET, vbl, 0, 0); +} + +gpointer +gnet_snmp_async_get(GNetSnmp *snmp, GList *vbl) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_async_get pdu %p\n", snmp, vbl); + } + return g_async_send(snmp, GNET_SNMP_PDU_GET, vbl, 0, 0); +} + +gpointer +gnet_snmp_async_getnext(GNetSnmp *snmp, GList *vbl) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_async_getnext pdu %p\n", snmp, vbl); + } + return g_async_send(snmp, GNET_SNMP_PDU_NEXT, vbl, 0, 0); +} + +gpointer +gnet_snmp_async_getbulk(GNetSnmp *snmp, GList *vbl, + guint32 nonrep, guint32 maxrep) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_async_getbulk pdu %p\n", snmp, vbl); + } + return g_async_send(snmp, GNET_SNMP_PDU_BULK, vbl, nonrep, maxrep); +} + +/* Synchronous SNMP functions */ + +struct inputcb { + int sock_nr; + void (*receiveMessage)(); +}; + +struct syncmagic { + GMainLoop *loop; + GList *result; +}; + +static void +cb_time(GNetSnmp *session, void *magic) +{ + struct syncmagic *sm = (struct syncmagic *) magic; + sm->result = NULL; + session->error_index = 0; + session->error_status = GNET_SNMP_ERR_NORESPONSE; + + g_main_quit(sm->loop); +} + +static gboolean +cb_done(GNetSnmp *session, GNetSnmpPdu *spdu, GList *objs, gpointer magic) +{ + struct syncmagic *sm = (struct syncmagic *) magic; + sm->result = objs; + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: error-status = %d, error-index = %d\n", + session, session->error_status, session->error_index); + } + g_main_quit(sm->loop); + return FALSE; +} + +static GList * +g_sync_send(GNetSnmp *session, GNetSnmpPduType type, + GList *objs, guint32 arg1, guint32 arg2) +{ + struct syncmagic * magic; + GList *result; + + magic = (struct syncmagic *) g_malloc(sizeof(struct syncmagic)); + magic->loop = g_main_new(TRUE); + + session->done_callback = cb_done; + session->time_callback = cb_time; + session->magic = magic; + if (! g_async_send(session, type, objs, arg1, arg2)) { + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_sync_send failed to send PDU\n", session); + } + g_main_destroy(magic->loop); + g_free(magic); + return NULL; + } + + while(g_main_is_running(magic->loop)) { + g_main_run(magic->loop); + } + g_main_destroy(magic->loop); + result = magic->result; + g_free(magic); + return result; +} + +GList * +gnet_snmp_sync_set(GNetSnmp *snmp, GList *pdu) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_sync_set pdu %p\n", snmp, pdu); + } + return g_sync_send(snmp, GNET_SNMP_PDU_SET, pdu, 0, 0); +} + +GList * +gnet_snmp_sync_get(GNetSnmp *snmp, GList *pdu) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_sync_get pdu %p\n", snmp, pdu); + } + return g_sync_send(snmp, GNET_SNMP_PDU_GET, pdu, 0, 0); +} + +GList * +gnet_snmp_sync_getnext(GNetSnmp *snmp, GList *pdu) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_sync_getnext pdu %p\n", snmp, pdu); + } + return g_sync_send(snmp, GNET_SNMP_PDU_NEXT, pdu, 0, 0); +} + +GList * +gnet_snmp_sync_getbulk(GNetSnmp *snmp, GList *pdu, + guint32 nonrep, guint32 maxrep) +{ + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: g_sync_getbulk pdu %p\n", snmp, pdu); + } + return g_sync_send(snmp, GNET_SNMP_PDU_BULK, pdu, nonrep, maxrep); +} + +#if 0 +gboolean +g_pdu_add_oid(GList **pdu, guint32 *myoid, guint mylength, + GSnmpVarBindType type, gpointer value) +{ + GSnmpVarBind *obj; + + obj = g_snmp_varbind_new(myoid, mylength, type, value, -1); + if (! obj) { + return FALSE; + } + *pdu = g_list_append(*pdu, obj); + return TRUE; +} +#endif + +#if 0 +/* This should be nuked once the new parser and mib module are available. + For now, either use this or the print function in struct tree */ + +void +g_snmp_printf(char *buf, int buflen, GSnmpVarBind *obj) +{ + int i; + /* + * Changed all the sprintf's to snprintf, paranoid I know but + * I'd rather not get caught with any buffer overflows.. + */ + switch(obj->type) + { + case G_SNMP_INTEGER32: + g_snprintf(buf, buflen, "%d", obj->syntax.i32[0]); + break; + case G_SNMP_COUNTER32: + case G_SNMP_UNSIGNED32: + g_snprintf(buf, buflen, "%u", obj->syntax.ui32[0]); + break; + case G_SNMP_TIMETICKS: + /* replaced this duplicated code with a call to existing code */ + /* timetick_string (obj->syntax.ul[0], buf); */ + g_snprintf(buf, buflen, "%u", obj->syntax.ui32[0]); + break; + case G_SNMP_OCTET_STRING: + case G_SNMP_OPAQUE: + /* xxx fix this (data is not necessarily printable) */ + memcpy(buf, obj->syntax.uc, + obj->syntax_len > buflen ? buflen: obj->syntax_len); + buf[obj->syntax_len > buflen ? buflen: obj->syntax_len] = '\0'; + break; + case G_SNMP_IPADDRESS: + if (obj->syntax_len == 4) /* IPv4 */ + g_snprintf(buf, buflen, "%d.%d.%d.%d", obj->syntax.uc[0], + obj->syntax.uc[1], + obj->syntax.uc[2], + obj->syntax.uc[3]); + break; + case G_SNMP_OBJECT_ID: + g_snprintf(buf, buflen, "%u", obj->syntax.ui32[0]); + i=1; + while(i < obj->syntax_len / sizeof(guint32)) + g_snprintf(buf+strlen(buf), buflen-strlen(buf), ".%u", + obj->syntax.ui32[i++]); + break; + case G_SNMP_COUNTER64: + g_snprintf(buf, buflen, "%llu", obj->syntax.ui64[0]); + break; + case G_SNMP_NULL: + g_snprintf(buf, buflen, ""); + break; + case G_SNMP_NOSUCHOBJECT: + g_snprintf(buf, buflen, ""); + break; + case G_SNMP_NOSUCHINSTANCE: + g_snprintf(buf, buflen, ""); + break; + case G_SNMP_ENDOFMIBVIEW: + g_snprintf(buf, buflen, ""); + break; + } +} +#endif + +/* + * The low level callbacks + */ + +int +g_snmp_timeout_cb (gpointer data) +{ + GSList *mylist; + GTimeVal now; + GNetSnmpRequest *request; + int model = 0, pduv = 0; + + again: + g_get_current_time(&now); + mylist = request_queue; + + while (mylist) { + request = (GNetSnmpRequest *) mylist->data; + mylist = mylist->next; + if (request->timer.tv_sec < now.tv_sec + || (request->timer.tv_sec == now.tv_sec + && request->timer.tv_usec <= now.tv_usec)) { + if (request->retries) { + request->retries--; + + request->timer = now; + request->timer.tv_sec += request->timeoutval / 1000; + request->timer.tv_usec += (request->timeoutval % 1000) * 1000; + + /* + * Again what happens on a -1 return to sendto + */ + switch (request->version) { + case GNET_SNMP_V1: + model = PMODEL_SNMPV1; + pduv = PDUV1; + break; + case GNET_SNMP_V2C: + model = PMODEL_SNMPV2C; + pduv = PDUV2; + break; + case GNET_SNMP_V3: + model = PMODEL_SNMPV3; + pduv = PDUV2; + break; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: timeout ...\n", request); + } + + { + GError *error = NULL; + + sendPdu(request->tdomain, request->taddress, model, SMODEL_ANY, + request->auth, SLEVEL_NANP, NULL, NULL, pduv, + &request->pdu, TRUE, &error); + if (error) { + g_error_free(error); + gnet_snmp_request_timeout(request); + gnet_snmp_request_dequeue(request); + gnet_snmp_request_delete(request); + goto again; + } + } +#if 0 + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_warning("request %p: timeout, retry shipped", request); + } +#endif + } else { + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: final timeout ...\n", request); + } + + gnet_snmp_request_timeout(request); + gnet_snmp_request_dequeue(request); + gnet_snmp_request_delete(request); + goto again; + } + } + } + return TRUE; +} + +void +g_session_response_pdu(guint messageProcessingModel, + guint securityModel, + GString *securityName, + guint securityLevel, + GString *contextEngineID, + GString *contextName, + guint pduVersion, + GNetSnmpPdu *PDU) +{ + GList *vbl; + GNetSnmpRequest *request; + + vbl = PDU->varbind_list; + + request = gnet_snmp_request_find(PDU->request_id); + if (! request) { + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + return; + } + + /* XXX this needs to be generalized I think */ + + if (memcmp(securityName->str, request->auth->str, securityName->len)) { + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + return; + } + + gnet_snmp_request_dequeue(request); + request->session->error_status = PDU->error_status; + request->session->error_index = PDU->error_index; + if (! request->callback) { + g_list_foreach(vbl, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(vbl); + gnet_snmp_request_delete(request); + return; + } + + if (request->callback(request->session, PDU, vbl, request->magic)) { + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_REQUESTS) { + g_printerr("request %p: callback invoked\n", request); + } + /* g_snmp_vbl_free(vbl); */ + } + gnet_snmp_request_delete(request); +} + +GURI* +gnet_snmp_get_uri(GNetSnmp *snmp) +{ + gchar *host, *name = NULL, *context = ""; + gint port; + + g_return_val_if_fail(snmp, NULL); + + if (snmp->uri) gnet_uri_delete(snmp->uri); + + host = gnet_inetaddr_get_canonical_name(snmp->taddress); + port = gnet_inetaddr_get_port(snmp->taddress); + + if (snmp->version == GNET_SNMP_V1 || snmp->version == GNET_SNMP_V2C) { + if (snmp->community) { + char *p; + name = g_strdup(snmp->community); + p = strchr(name, '@'); + if (p) { + *p = 0; + context = ++p; + } + } + } + + snmp->uri = gnet_uri_new_fields_all("snmp", name, host, port, + context, NULL, NULL); + g_free(name); + + return snmp->uri; +} diff --git a/src/session.h b/src/session.h new file mode 100644 index 0000000..2e2f21e --- /dev/null +++ b/src/session.h @@ -0,0 +1,185 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_SESSION_H__ +#define __GNET_SNMP_SESSION_H__ + +/* + * Basic snmp info on a per session basis. Note that status + * information of the last SNMP interaction is returned to the + * application as part of the session structure. (!) + */ + +typedef struct _GNetSnmp GNetSnmp; + +/* XXX there should only be a single callback (for everything) with + the condition signalled as part of the session state / error + code XXX */ + +typedef gboolean (*GNetSnmpDoneFunc) (GNetSnmp *snmp, + GNetSnmpPdu *pdu, + GList *vbl, + gpointer data); +typedef void (*GNetSnmpTimeFunc) (GNetSnmp *snmp, + gpointer data); + +/* XXX this structure should be completely private XXX */ + +struct _GNetSnmp { + GNetSnmpTDomain tdomain; + GInetAddr *taddress; + GURI *uri; + gchar *community; + gint32 error_status; + guint32 error_index; + guint retries; /* number of retries */ + guint timeout; /* timeout in milliseconds */ + GNetSnmpVersion version; + GNetSnmpDoneFunc done_callback; /* what to call when complete */ + GNetSnmpTimeFunc time_callback; /* what to call on a timeout */ + gpointer magic; /* additional data for callbacks */ +}; + +#define GNET_SNMP_DEFAULT_RETRIES 3 +#define GNET_SNMP_DEFAULT_TIMEOUT 200 + +GNetSnmp* gnet_snmp_new (void); +GNetSnmp* gnet_snmp_new_uri (const GURI *uri); +GNetSnmp* gnet_snmp_clone (GNetSnmp *snmp); +void gnet_snmp_delete (GNetSnmp *snmp); + +void gnet_snmp_set_transport (GNetSnmp *snmp, + GNetSnmpTDomain tdomain, + GInetAddr *taddress); +void gnet_snmp_set_community (GNetSnmp *snmp, + gchar *community); +void gnet_snmp_set_timeout (GNetSnmp *snmp, + guint timeout); +void gnet_snmp_set_retries (GNetSnmp *snmp, + guint retries); +void gnet_snmp_set_version (GNetSnmp *snmp, + GNetSnmpVersion version); + +const gchar* gnet_snmp_get_community (const GNetSnmp *snmp); +guint gnet_snmp_get_timeout (const GNetSnmp *snmp); +guint gnet_snmp_get_retries (const GNetSnmp *snmp); +GNetSnmpVersion gnet_snmp_get_version (const GNetSnmp *snmp); +GURI* gnet_snmp_get_uri (GNetSnmp *snmp); + +gpointer gnet_snmp_async_set (GNetSnmp *snmp, + GList *vbl); +gpointer gnet_snmp_async_set (GNetSnmp *snmp, + GList *vbl); +gpointer gnet_snmp_async_get (GNetSnmp *snmp, + GList *vbl); +gpointer gnet_snmp_async_getnext (GNetSnmp *snmp, + GList *vbl); +gpointer gnet_snmp_async_getbulk (GNetSnmp *snmp, + GList *vbl, + guint32 nonrep, + guint32 maxrep); + +GList* gnet_snmp_sync_set (GNetSnmp *snmp, + GList *vbl); +GList* gnet_snmp_sync_get (GNetSnmp *snmp, + GList *vbl); +GList* gnet_snmp_sync_getnext (GNetSnmp *snmp, + GList *vbl); +GList* gnet_snmp_sync_getbulk (GNetSnmp *snmp, + GList *vbl, + guint32 nonrep, + guint32 maxrep); + +/* Is it necessary to support multiple walks per session (with shared + callbacks anyway)? If we drop this feature, we could merge the walk + state into the session itself and simplify the API. */ + +typedef struct _GNetSnmpWalk GNetSnmpWalk; + +GNetSnmpWalk* gnet_snmp_walk_new (GNetSnmp *snmp, + GList *vbl, + void (* cb_error)(), + void (* cb_row)(), + void (* cb_finish)(), + gpointer data); +void gnet_snmp_walk_delete (GNetSnmpWalk *walk); + +void gnet_snmp_async_walk (GNetSnmpWalk *walk); +GList* gnet_snmp_sync_walk (GNetSnmp *snmp, + GList *vbl); + +/* Is it necessary to support multiple takes per session (with shared + callbacks anyway)? If we drop this feature, we could merge the table + state into the session itself and simplify the API. */ + +typedef struct _GNetSnmpTable GNetSnmpTable; + +GNetSnmpTable* gnet_snmp_table_new (GNetSnmp *snmp, + GList *vbl, + void (* cb_error)(), + void (* cb_row)(), + void (* cb_finish)(), + gpointer data); +void gnet_snmp_table_delete (GNetSnmpTable *table); + +void gnet_snmp_async_table (GNetSnmpTable *table); +GList* gnet_snmp_sync_table (GNetSnmp *snmp, + GList *vbl); + +typedef struct _GNetSnmpRequest { + GNetSnmpDoneFunc callback; + GNetSnmpTimeFunc timeout; + GNetSnmp *session; + GString *auth; + GNetSnmpPdu pdu; + struct sockaddr *address; + GNetSnmpTDomain tdomain; + GInetAddr *taddress; + GTimeVal timer; + guint retries; + guint timeoutval; + GNetSnmpVersion version; + gpointer magic; +} GNetSnmpRequest; + + +GNetSnmpRequest* gnet_snmp_request_new (void); +void gnet_snmp_request_delete (GNetSnmpRequest *request); + +void gnet_snmp_request_queue (GNetSnmpRequest *request); +void gnet_snmp_request_dequeue(GNetSnmpRequest *request); +GNetSnmpRequest* gnet_snmp_request_find (gint32 request_id); +void gnet_snmp_request_timeout(GNetSnmpRequest *request); + +/* + * Session API - the stuff below needs to be cleaned up. XXX + */ + +int g_snmp_timeout_cb (gpointer data); + +void g_session_response_pdu (guint messageProcessingModel, + guint securityModel, GString *securityName, guint securityLevel, + GString *contextEngineID, GString *contextName, guint pduVersion, + GNetSnmpPdu *PDU); + +#endif /* __GNET_SNMP_SESSION_H__ */ diff --git a/src/table.c b/src/table.c new file mode 100644 index 0000000..dfb4264 --- /dev/null +++ b/src/table.c @@ -0,0 +1,311 @@ +/* + * GNET-SNMP -- glib-based SNMP implementation + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + + +struct _GNetSnmpTable { + GNetSnmp *snmp; + GList *orig_objs; + GList *prev_objs; + gpointer data; + gpointer request; + void (* cb_error)(GNetSnmp *snmp, gpointer data); + void (* cb_row)(GNetSnmp *snmp, GList *vbl, int indexlen, gpointer data); + void (* cb_finish)(GNetSnmp *snmp, gpointer data); +}; + + +static gboolean +g_snmp_table_done_callback(GNetSnmp *snmp, + GNetSnmpPdu *spdu, GList *objs, gpointer data) +{ + GNetSnmpTable *table; + GList *nobjs; /* New varbind list for next query */ + GNetSnmpVarBind *cobj; /* Current object being processed */ + GNetSnmpVarBind *obj; /* Base object being processed */ + int cols; /* Number of columns we expect */ + int i, j, eov = 0; + guint32 index[GNET_SNMP_SIZE_OBJECTID]; + int index_len; + GList *cb_vbl = NULL; + + snmp->error_status = spdu->error_status; + snmp->error_index = spdu->error_index; + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: error-status = %d, error-index = %d\n", + snmp, snmp->error_status, snmp->error_index); + } + + table = (GNetSnmpTable *) data; + table->request = 0; + + /* Check whether we reached the end of the MIB view... */ + + cols = g_list_length(table->orig_objs); + if (spdu->error_status == GNET_SNMP_ERR_NOSUCHNAME) { + if (table->cb_finish) { + table->cb_finish(snmp, table->data); + } else { + gnet_snmp_table_delete(table); + } + return TRUE; + } + + /* Check whether we got an error back... */ + + if (spdu->error_status) { + if (table->cb_error) { + table->cb_error(snmp, table->data); + } else { + gnet_snmp_table_delete(table); + } + return TRUE; + } + + /* Check if the number of requested variables matches the number + of returned variables */ + + if (g_list_length(objs) != cols) { + if (table->cb_error) { + table->cb_error(snmp, table->data); + } else { + gnet_snmp_table_delete(table); + } + return TRUE; + } + + /* Search smallest index in all valid returned columns. */ + + index_len = 0; + for (i = 0; i < cols; i++) { + obj = (GNetSnmpVarBind *) g_list_nth_data(table->orig_objs, i); + cobj = (GNetSnmpVarBind *) g_list_nth_data(objs, i); + if (cobj->oid_len >= obj->oid_len + && !memcmp (cobj->oid, obj->oid, obj->oid_len * sizeof (guint32))) { + if (!index_len) { + index_len = cobj->oid_len - obj->oid_len; + g_memmove(index, cobj->oid + obj->oid_len, + index_len * sizeof (guint32)); + } else { + if ((j=memcmp(index, cobj->oid + obj->oid_len, + MIN(index_len, cobj->oid_len - obj->oid_len) + * sizeof (guint32)))) { + /* g_warning("Non-regular SNMP table"); (js) */ + if (j>0) { + index_len = cobj->oid_len - obj->oid_len; + g_memmove(index, cobj->oid + obj->oid_len, + index_len * sizeof (guint32)); + } + } + if (cobj->oid_len - obj->oid_len < index_len) { + g_warning("SNMP table index length changed"); + index_len = cobj->oid_len - obj->oid_len; + } + } + } + if (cobj->type == GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW) { + eov++; + } + } + + /* If no valid columns found, table query must be finished. */ + + if (! index_len || eov) { + if (table->cb_finish) { + table->cb_finish(snmp, table->data); + } else { + gnet_snmp_table_delete(table); + } + return TRUE; + } + + /* Build varbind list for the callback and construct a new varbind + list for next row. */ + + nobjs = NULL; + for (i = 0; i < cols; i++) { + obj = (GNetSnmpVarBind *) g_list_nth_data(table->orig_objs, i); + cobj = (GNetSnmpVarBind *) g_list_nth_data(objs, i); + if (!memcmp (cobj->oid, obj->oid, obj->oid_len * sizeof (guint32))) { + if (cobj->oid_len - obj->oid_len == index_len) + if (!memcmp(cobj->oid + obj->oid_len, index, + index_len * sizeof (guint32))) { + cb_vbl = g_list_append(cb_vbl, cobj); + } + } + if (obj->oid_len + index_len < GNET_SNMP_SIZE_OBJECTID) { + GNetSnmpVarBind *vb; + guint32 oid[GNET_SNMP_SIZE_OBJECTID]; + g_memmove(oid, obj->oid, obj->oid_len * sizeof(guint32)); + g_memmove(oid + obj->oid_len, index, index_len * sizeof(guint32)); + vb = gnet_snmp_varbind_new(oid, obj->oid_len + index_len, + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + nobjs = g_list_append(nobjs, vb); + } + } + + table->prev_objs = cb_vbl; + + if (table->cb_row) { + table->cb_row(snmp, cb_vbl, index_len, table->data); + } + /* g_list_free(cb_vbl); ?? */ + + table->request = gnet_snmp_async_getnext(table->snmp, nobjs); +#if 0 + g_list_foreach(nobjs, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(nobjs); +#endif + return TRUE; +} + + +static void +g_snmp_table_time_callback(GNetSnmp *snmp, gpointer data) +{ + GNetSnmpTable *table; + + table = (GNetSnmpTable *) data; + table->request = 0; + if (table->cb_error) { + table->cb_error(snmp, table->data); + } else { + gnet_snmp_table_delete(table); + } + + snmp->error_index = 0; + snmp->error_status = GNET_SNMP_ERR_NORESPONSE; +} + + +GNetSnmpTable * +gnet_snmp_table_new(GNetSnmp *snmp, + GList *vbl, + void (* cb_error)(), + void (* cb_row)(), + void (* cb_finish)(), + gpointer data) +{ + GList *elem; + GNetSnmpTable *table; + + table = g_malloc0(sizeof(GNetSnmpTable)); + + table->snmp = gnet_snmp_clone(snmp); + table->snmp->magic = table; + table->snmp->done_callback = g_snmp_table_done_callback; + table->snmp->time_callback = g_snmp_table_time_callback; + + for (elem = vbl; elem; elem = g_list_next(elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + GNetSnmpVarBind *nvb; + nvb = gnet_snmp_varbind_new(vb->oid, vb->oid_len, + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + table->orig_objs = g_list_append(table->orig_objs, nvb); + } + table->data = data; + + table->cb_error = cb_error; + table->cb_row = cb_row; + table->cb_finish = cb_finish; + + return table; +} + + +void +gnet_snmp_table_delete(GNetSnmpTable *table) +{ + if (table->request) { + gnet_snmp_request_dequeue(table->request); + gnet_snmp_request_delete(table->request); + } + gnet_snmp_delete(table->snmp); + g_list_foreach(table->orig_objs, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(table->orig_objs); + g_free(table); +} + + +void +gnet_snmp_async_table(GNetSnmpTable *table) +{ + table->request = gnet_snmp_async_getnext(table->snmp, table->orig_objs); +} + + +/* + * Another entry point which is used by the scli package. + */ + +static GMainLoop *loop = NULL; + + +static void +cb_finish(GNetSnmp *snmp, gpointer *data) +{ + if (loop) g_main_quit(loop); +} + +static void +cb_error(GNetSnmp *snmp, gpointer *data) +{ + if (loop) g_main_quit(loop); +} + +static void +cb_row(GNetSnmp *snmp, GList *rowlist, int index_len, gpointer *data) +{ + GList **tablelist = (GList **) data; + + *tablelist = g_list_append(*tablelist, rowlist); +} + + +GList * +gnet_snmp_sync_table(GNetSnmp *s, GList *in) +{ + GNetSnmpTable *table; + GList *tablelist = NULL; + + table = gnet_snmp_table_new(s, in, cb_error, cb_row, cb_finish, &tablelist); + + gnet_snmp_async_table(table); + + loop = g_main_new(TRUE); + while (loop && g_main_is_running(loop)) { + g_main_run(loop); + } + g_main_destroy(loop); + loop = NULL; + + s->error_status = table->snmp->error_status; + s->error_index = table->snmp->error_index; + + gnet_snmp_table_delete(table); + + return tablelist; +} + diff --git a/src/transport.c b/src/transport.c new file mode 100644 index 0000000..705658b --- /dev/null +++ b/src/transport.c @@ -0,0 +1,393 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include +#include +#include +#include + +#include + +#include "transport.h" +#include "dispatch.h" +#include "pdu.h" /* xxx only needed for debugging flags... */ + + +static GUdpSocket *udp_ipv4_socket = NULL; +static GUdpSocket *udp_ipv6_socket = NULL; + +static GTcpSocket *tcp_ipv4_socket = NULL; /* this should be a pool */ + +GQuark +gnet_snmp_transport_error_quark(void) +{ + static GQuark quark = 0; + if (quark == 0) { + quark = g_quark_from_static_string("gnet-snmp-transport-error-quark"); + } + return quark; +} + +/* + * Subroutine to dump packet contents to the screen - jms + */ + +static void +dump_packet(guchar *data, guint len) +{ + guint i; + g_printerr("packet %p: ", data); + for (i = 0; i < len; i++) { + g_printerr("%2.2x", data[i]); + if (i+1 < len) { + if (i % 16 == 15) { + g_printerr("\npacket %p: ", data); + } else { + g_printerr(":"); + } + } + } + // if (i % 16 != 15) + g_printerr("\n"); +} + +static gboolean +gaga(GIOChannel *source, GIOCondition condition, gpointer data) +{ + void (*func)(void); + func = data; + func(); + return TRUE; +} + +/* + * xxx - first approximation handles just one established tcp session + */ + +static void +tcp_ipv4_receive_message() +{ + guchar buffer[MAX_DGRAM_SIZE]; + GIOChannel *channel; + GInetAddr* addr; + gsize len; + + addr = gnet_tcp_socket_get_remote_inetaddr(tcp_ipv4_socket); + channel = gnet_tcp_socket_get_io_channel(tcp_ipv4_socket); + if (! channel) { + g_error("retrieving snmp over tcp/ipv4 socket failed"); + return; + } + + if (g_io_channel_read(channel, buffer, sizeof(buffer), &len)) { + return; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. tcp/ipv4: received %d bytes from %s:%d\n", len, + gnet_inetaddr_get_name(addr), + gnet_inetaddr_get_port(addr)); + } + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(buffer, len); + } + g_receive_message(GNET_SNMP_TDOMAIN_TCP_IPV4, addr, buffer, len); + gnet_inetaddr_delete(addr); +} + +static gboolean +tcp_ipv4_send_message(GInetAddr *taddress, + guchar *outgoingMessage, + guint outgoingMessageLength, + GError **error) +{ + GIOChannel *channel; + guint len; + + if (! tcp_ipv4_socket + || ! gnet_inetaddr_equal(taddress, gnet_tcp_socket_get_remote_inetaddr(tcp_ipv4_socket))) { + if (tcp_ipv4_socket) { + gnet_tcp_socket_delete(tcp_ipv4_socket); + } + tcp_ipv4_socket = gnet_tcp_socket_new(taddress); + if (! tcp_ipv4_socket) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_CONNECT, + "failed to connect tcp/ipv4 socket"); + } + return FALSE; + } + } + + channel = gnet_tcp_socket_get_io_channel(tcp_ipv4_socket); + if (! channel) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_REGISTER, + "failed to register tcp/ipv4 socket"); + } + return FALSE; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. tcp/ipv4: send %d bytes to %s:%d\n", len, + gnet_inetaddr_get_name(taddress), + gnet_inetaddr_get_port(taddress)); + } + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(outgoingMessage, outgoingMessageLength); + } + + g_io_add_watch(channel, (G_IO_IN | G_IO_PRI), + gaga, tcp_ipv4_receive_message); + if (G_IO_ERROR_NONE != gnet_io_channel_writen(channel, outgoingMessage, + outgoingMessageLength, + &len)) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_SEND, + "failed to send over tcp/ipv4 socket"); + } + gnet_tcp_socket_delete(tcp_ipv4_socket); + tcp_ipv4_socket = NULL; + return FALSE; + } + return TRUE; +} + +static gboolean +tcp_ipv4_init(gboolean dobind) /* xxx dobind is not used */ +{ + tcp_ipv4_socket = NULL; + return TRUE; +} + +static gboolean +udp_ipv4_send_message(GInetAddr *taddress, + guchar *outgoingMessage, + guint outgoingMessageLength, + GError **error) +{ + gint rv; + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(outgoingMessage, outgoingMessageLength); + } + + rv = gnet_udp_socket_send(udp_ipv4_socket, outgoingMessage, + outgoingMessageLength, taddress); + if (rv) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_SEND, + "failed to send over udp/ipv4 socket"); + } + return FALSE; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. udp/ipv4: send %d bytes to %s:%d\n", + outgoingMessageLength, + gnet_inetaddr_get_name(taddress), + gnet_inetaddr_get_port(taddress)); + } + return TRUE; +} + +static void +udp_ipv4_receive_message(GError **error) +{ + guchar buffer[MAX_DGRAM_SIZE]; + GInetAddr* addr; + int len; + + len = gnet_udp_socket_receive(udp_ipv4_socket, buffer, sizeof(buffer), &addr); + if (! len) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_RECV, + "failed to receive from udp/ipv4 socket"); + } + return; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. udp/ipv4: received %d bytes from %s:%d\n", len, + gnet_inetaddr_get_name(addr), + gnet_inetaddr_get_port(addr)); + } + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(buffer, len); + } + g_receive_message(GNET_SNMP_TDOMAIN_UDP_IPV4, addr, buffer, len); + gnet_inetaddr_delete(addr); +} + +static gboolean +upd_ipv4_init(gboolean dobind) /* xxx dobind is not used */ +{ + GIOChannel *channel; + + udp_ipv4_socket = gnet_udp_socket_new(); + if (! udp_ipv4_socket) { + g_error("opening snmp over udp/ipv4 socket failed"); + return FALSE; + } + + channel = gnet_udp_socket_get_io_channel(udp_ipv4_socket); + if (! channel) { + g_error("registering snmp over udp/ipv4 socket failed"); + return FALSE; + } + g_io_add_watch(channel, (G_IO_IN | G_IO_PRI), + gaga, udp_ipv4_receive_message); + + return TRUE; +} + +static gboolean +udp_ipv6_send_message(GInetAddr *taddress, + guchar *outgoingMessage, + guint outgoingMessageLength, + GError **error) +{ + gint rv; + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(outgoingMessage, outgoingMessageLength); + } + + rv = gnet_udp_socket_send(udp_ipv6_socket, outgoingMessage, + outgoingMessageLength, taddress); + if (rv) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_SEND, + "failed to send over udp/ipv6 socket"); + } + return FALSE; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. udp/ipv6: send %d bytes to %s:%d\n", + outgoingMessageLength, + gnet_inetaddr_get_name(taddress), + gnet_inetaddr_get_port(taddress)); + } + return TRUE; +} + +static void +udp_ipv6_receive_message(GError **error) +{ + guchar buffer[MAX_DGRAM_SIZE]; + GInetAddr* addr; + int len; + + len = gnet_udp_socket_receive(udp_ipv6_socket, buffer, sizeof(buffer), &addr); + if (! len) { + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_RECV, + "failed to receive from udp/ipv6 socket"); + } + return; + } + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_TRANSPORT) { + g_printerr("transp. udp/ipv6: received %d bytes from %s:%d\n", len, + gnet_inetaddr_get_name(addr), + gnet_inetaddr_get_port(addr)); + } + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_PACKET) { + dump_packet(buffer, len); + } + g_receive_message(GNET_SNMP_TDOMAIN_UDP_IPV6, addr, buffer, len); + gnet_inetaddr_delete(addr); +} + +static gboolean +udp_ipv6_init(gboolean dobind) +{ + GIOChannel *channel; + GInetAddr *addr = gnet_inetaddr_new("::", 0); + + udp_ipv6_socket = gnet_udp_socket_new_full(addr, 0); + if (! udp_ipv6_socket) { + g_error("opening snmp over udp/ipv6 socket failed"); + return FALSE; + } + + channel = gnet_udp_socket_get_io_channel(udp_ipv6_socket); + if (! channel) { + g_error("registering snmp over udp/ipv6 socket failed"); + return FALSE; + } + g_io_add_watch(channel, (G_IO_IN | G_IO_PRI), + gaga, udp_ipv6_receive_message); + + return TRUE; +} + +gboolean +gnet_snmp_transport_send(GNetSnmpTDomain tdomain, GInetAddr *taddress, + guchar *msg, guint msg_len, GError **error) +{ + static int initialized = 0; + + if (! initialized) { /* xxx race condition xxx */ + initialized = 1; + upd_ipv4_init(0); + tcp_ipv4_init(0); + udp_ipv6_init(0); + } + + switch (tdomain) { + case GNET_SNMP_TDOMAIN_UDP_IPV4: + return udp_ipv4_send_message(taddress, msg, msg_len, error); + case GNET_SNMP_TDOMAIN_TCP_IPV4: + return tcp_ipv4_send_message(taddress, msg, msg_len, error); + case GNET_SNMP_TDOMAIN_UDP_IPV6: + return udp_ipv6_send_message(taddress, msg, msg_len, error); + default: + if (error) { + g_set_error(error, + GNET_SNMP_TRANSPORT_ERROR, + GNET_SNMP_TRANSPORT_ERROR_UNSUPPORTED, + "unsupported transport domain"); + } + break; + } + + return FALSE; +} + + diff --git a/src/transport.h b/src/transport.h new file mode 100644 index 0000000..a3bf6b5 --- /dev/null +++ b/src/transport.h @@ -0,0 +1,73 @@ +/* + * GNET-SNMP -- glib-based SNMP library + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_TRANSPORT_H__ +#define __GNET_SNMP_TRANSPORT_H__ + +/* + * Enumeration for the SNMP transport domains we care of. + */ + +typedef enum { + GNET_SNMP_TDOMAIN_NONE = 0, + GNET_SNMP_TDOMAIN_UDP_IPV4 = 1, /* RFC 3417 */ + GNET_SNMP_TDOMAIN_UDP_IPV6 = 2, + GNET_SNMP_TDOMAIN_IPX = 3, /* RFC 3417 */ + GNET_SNMP_TDOMAIN_TCP_IPV4 = 4, /* RFC 3430 */ + GNET_SNMP_TDOMAIN_TCP_IPV6 = 5 /* RFC 3430 */ +} GNetSnmpTDomain; + +/* + * The maximum datagram size we are prepared to deal with. + */ + +#define MAX_DGRAM_SIZE 32768 + +/* + * Transport related runtime error handling. + */ + +typedef enum +{ + GNET_SNMP_TRANSPORT_ERROR_SEND, + GNET_SNMP_TRANSPORT_ERROR_RECV, + GNET_SNMP_TRANSPORT_ERROR_CONNECT, + GNET_SNMP_TRANSPORT_ERROR_REGISTER, + GNET_SNMP_TRANSPORT_ERROR_UNSUPPORTED, +} GNetSnmpTransportError; + +#define GNET_SNMP_TRANSPORT_ERROR gnet_snmp_transport_error_quark() + +GQuark gnet_snmp_transport_error_quark(); + +/* + * The entrance into the transport module. + */ + +gboolean gnet_snmp_transport_send (GNetSnmpTDomain tdomain, + GInetAddr *taddress, + guchar *msg, + guint msg_len, + GError **error); + +#endif /* __GNET_SNMP_TRANSPORT_H__ */ diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..fc93555 --- /dev/null +++ b/src/utils.c @@ -0,0 +1,480 @@ +/* + * GNET-SNMP -- glib-based SNMP implementation + * + * Copyright (C) 2003 Juergen Schoenwaelder + * Copyright (C) 1998 Gregory McLean & Jochen Friedrich + * Copyright (C) 1993 DNPAP Beholder Group + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + +#include + + +GNetSnmpEnum const gnet_snmp_enum_version_table[] = { + { GNET_SNMP_V1, "SNMPv1" }, + { GNET_SNMP_V2C, "SNMPv2c" }, + { GNET_SNMP_V3, "SNMPv3" }, + { 0, 0 } +}; + + + +GNetSnmpEnum const gnet_snmp_enum_error_table[] = { + { GNET_SNMP_ERR_DONE, "done" }, + { GNET_SNMP_ERR_PROCEDURE, "procedureError" }, + { GNET_SNMP_ERR_INTERNAL, "internalError" }, + { GNET_SNMP_ERR_NORESPONSE, "noResponse" }, + { GNET_SNMP_ERR_NOERROR, "noError" }, + { GNET_SNMP_ERR_TOOBIG, "tooBig" }, + { GNET_SNMP_ERR_NOSUCHNAME, "noSuchName"}, + { GNET_SNMP_ERR_BADVALUE, "badValue" }, + { GNET_SNMP_ERR_READONLY, "readOnly" }, + { GNET_SNMP_ERR_GENERROR, "genErr" }, + { GNET_SNMP_ERR_NOACCESS, "noAccess" }, + { GNET_SNMP_ERR_WRONGTYPE, "wrongType" }, + { GNET_SNMP_ERR_WRONGLENGTH, "wrongLength" }, + { GNET_SNMP_ERR_WRONGENCODING, "wrongEncoding" }, + { GNET_SNMP_ERR_WRONGVALUE, "wrongValue" }, + { GNET_SNMP_ERR_NOCREATION, "noCreation" }, + { GNET_SNMP_ERR_INCONSISTENTVALUE, "inconsistentValue" }, + { GNET_SNMP_ERR_RESOURCEUNAVAILABLE,"resourceUnavailable" }, + { GNET_SNMP_ERR_COMMITFAILED, "commitFailed" }, + { GNET_SNMP_ERR_UNDOFAILED, "undoFailed" }, + { GNET_SNMP_ERR_AUTHORIZATIONERROR, "authorizationError" }, + { GNET_SNMP_ERR_NOTWRITABLE, "notWritable" }, + { GNET_SNMP_ERR_INCONSISTENTNAME, "inconsistentName" }, + { 0, 0 } +}; + + + +GNetSnmpEnum const gnet_snmp_enum_type_table[] = { + { GNET_SNMP_VARBIND_TYPE_NULL, "NULL" }, + { GNET_SNMP_VARBIND_TYPE_OCTETSTRING, "OctetString" }, + { GNET_SNMP_VARBIND_TYPE_OBJECTID, "ObjectIdentifier" }, + { GNET_SNMP_VARBIND_TYPE_IPADDRESS, "IpAddress" }, + { GNET_SNMP_VARBIND_TYPE_INTEGER32, "Integer32" }, + { GNET_SNMP_VARBIND_TYPE_UNSIGNED32, "Unsigned32" }, + { GNET_SNMP_VARBIND_TYPE_COUNTER32, "Counter32" }, + { GNET_SNMP_VARBIND_TYPE_TIMETICKS, "TimeTicks" }, + { GNET_SNMP_VARBIND_TYPE_OPAQUE, "Opaque" }, + { GNET_SNMP_VARBIND_TYPE_COUNTER64, "Counter64" }, + { GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT, "NoSuchObject" }, + { GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE, "NoSuchInstance" }, + { GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW, "EndOfMibView" }, + { 0, 0 } +}; + + + +GNetSnmpEnum const gnet_snmp_enum_pdu_table[] = { + { GNET_SNMP_PDU_GET, "get" }, + { GNET_SNMP_PDU_NEXT, "getnext" }, + { GNET_SNMP_PDU_RESPONSE, "response" }, + { GNET_SNMP_PDU_SET, "set" }, + { GNET_SNMP_PDU_TRAP, "trap" }, + { GNET_SNMP_PDU_BULK, "getbulk" }, + { GNET_SNMP_PDU_INFORM, "inform" }, + { 0, 0 } +}; + + + +GNetSnmpEnum const gnet_snmp_enum_debug_table[] = { + { GNET_SNMP_DEBUG_REQUESTS, "request" }, + { GNET_SNMP_DEBUG_SESSION, "session" }, + { GNET_SNMP_DEBUG_TRANSPORT,"transport" }, + { GNET_SNMP_DEBUG_PACKET, "packet" }, + { GNET_SNMP_DEBUG_BER, "ber" }, + { 0, 0 } +}; + + + +GNetSnmpEnum const gnet_snmp_enum_tdomain_table[] = { + { GNET_SNMP_TDOMAIN_NONE, "none" }, + { GNET_SNMP_TDOMAIN_UDP_IPV4, "udp/ipv4" }, + { GNET_SNMP_TDOMAIN_UDP_IPV6, "udp/ipv6" }, + { GNET_SNMP_TDOMAIN_IPX, "ipx" }, + { GNET_SNMP_TDOMAIN_TCP_IPV4, "tcp/ipv4" }, + { GNET_SNMP_TDOMAIN_TCP_IPV6, "tcp/ipv6" }, + { 0, 0 } +}; + + + +gchar const * +gnet_snmp_enum_get_label(GNetSnmpEnum const *table, gint32 const id) +{ + int i; + + for (i = 0; table[i].label; i++) { + if (id == table[i].number) { + return table[i].label; + } + } + + return NULL; +} + + + +gboolean +gnet_snmp_enum_get_number(GNetSnmpEnum const *table, + gchar const *str, gint32 *number) +{ + int i; + + for (i = 0; table[i].label; i++) { + if (strcmp(str, table[i].label) == 0) { + if (number) *number = table[i].number; + return TRUE; + } + } + + return FALSE; +} + + + +gchar const * +gnet_snmp_identity_get_label(GNetSnmpIdentity const *table, + guint32 const *oid, gsize oidlen) +{ + int i; + + if (! oid || oidlen <= 0) { + return NULL; + } + + for (i = 0; table[i].label; i++) { + if (table[i].oidlen == oidlen + && memcmp(table[i].oid, oid, oidlen * sizeof(guint32)) == 0) { + return table[i].label; + } + } + + return NULL; +} + + + +int +gnet_snmp_attr_assign(GList *vbl, + guint32 const *base, size_t const len, + const GNetSnmpAttribute *attributes, + const gpointer p) +{ + GList *elem; + int i, n = 0; + gpointer **gp; + + if (!p) { + return 0; + } + + for (elem = vbl; elem; elem = g_list_next(elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + + if (vb->type == GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW + || (vb->type == GNET_SNMP_VARBIND_TYPE_NOSUCHOBJECT) + || (vb->type == GNET_SNMP_VARBIND_TYPE_NOSUCHINSTANCE)) { + continue; + } + + if (memcmp(vb->oid, base, len * sizeof(guint32)) != 0) { + continue; + } + + for (i = 0; attributes[i].label; i++) { + if (vb->oid_len > len && vb->oid[len] == attributes[i].subid) { + break; + } + } + + if (! attributes[i].label) { + continue; + } + +#define CLASS_INT(x) (x == GNET_SNMP_VARBIND_TYPE_INTEGER32 || x == GNET_SNMP_VARBIND_TYPE_UNSIGNED32 || x == GNET_SNMP_VARBIND_TYPE_COUNTER32 || x == GNET_SNMP_VARBIND_TYPE_TIMETICKS) + + #define CLASS_STRING(x) (x == GNET_SNMP_VARBIND_TYPE_OCTETSTRING || x == GNET_SNMP_VARBIND_TYPE_IPADDRESS || x == GNET_SNMP_VARBIND_TYPE_OPAQUE) + + if (vb->type != attributes[i].type) { + const char *a = gnet_snmp_enum_get_label(gnet_snmp_enum_type_table, + vb->type); + const char *b = gnet_snmp_enum_get_label(gnet_snmp_enum_type_table, + attributes[i].type); + if ((a && b) + && ((CLASS_INT(vb->type) + && CLASS_INT(attributes[i].type)) + || (CLASS_STRING(vb->type) + && CLASS_STRING(attributes[i].type)))) { + g_warning("%s: type mismatch: converting %s to %s", + attributes[i].label, a, b); + } else { + if (a && b) { + g_warning("%s: type mismatch: cannot convert %s to %s", + attributes[i].label, a, b); + } else { + g_warning("%s: type mismatch", attributes[i].label); + } + continue; + } + } + + if (attributes[i].val_offset < 0) { + continue; + } + gp = G_STRUCT_MEMBER_P(p, attributes[i].val_offset); + switch (vb->type) { + case GNET_SNMP_VARBIND_TYPE_INTEGER32: + if (attributes[i].constraints) { + gint32 *range = (gint32 *) attributes[i].constraints; + while (range[0] != 0 || range[1] != 0) { + if (vb->value.i32 >= range[0] + && vb->value.i32 <= range[1]) { + break; + } + range += 2; + } + if (range[0] == 0 && range[1] == 0) { + g_warning("%s: value not within range contraints", + attributes[i].label); + gp = NULL; + } + } + if (gp) *gp = (gpointer) &(vb->value.i32); + break; + case GNET_SNMP_VARBIND_TYPE_UNSIGNED32: + case GNET_SNMP_VARBIND_TYPE_COUNTER32: + case GNET_SNMP_VARBIND_TYPE_TIMETICKS: + if (attributes[i].constraints) { + guint32 *range = (guint32 *) attributes[i].constraints; + while (range[0] != 0 || range[1] != 0) { + if (vb->value.i32 >= range[0] + && vb->value.i32 <= range[1]) { + break; + } + range += 2; + } + if (range[0] == 0 && range[1] == 0) { + g_warning("%s: value not within range contraints", + attributes[i].label); + gp = NULL; + } + } + if (gp) *gp = (gpointer) &(vb->value.ui32); + break; + case GNET_SNMP_VARBIND_TYPE_OCTETSTRING: + if (attributes[i].constraints) { + guint16 *size = (guint16 *) attributes[i].constraints; + while (size[0] != 0 || size[1] != 0) { + if (vb->value_len >= size[0] + && vb->value_len <= size[1]) { + break; + } + size += 2; + } + if (size[0] == 0 && size[1] == 0) { + g_warning("%s: value not within size contraints", + attributes[i].label); + gp = NULL; + } + } + if (gp) *gp = (gpointer) vb->value.ui8v; + break; + case GNET_SNMP_VARBIND_TYPE_OBJECTID: + case GNET_SNMP_VARBIND_TYPE_IPADDRESS: + case GNET_SNMP_VARBIND_TYPE_OPAQUE: + *gp = (gpointer) vb->value.ui32; + break; + case GNET_SNMP_VARBIND_TYPE_COUNTER64: + if (gp) *gp = (gpointer) &(vb->value.ui64); + break; + default: + break; + } + if (gp && attributes[i].len_offset) { + guint16 *lp; + lp = (guint16 *) G_STRUCT_MEMBER_P(p, attributes[i].len_offset); + *lp = vb->value_len; + } + n++; + } + + return n; +} + + + +void +gnet_snmp_attr_get(const GNetSnmp *s, GList **vbl, + guint32 *base, size_t const len, + guint const idx, + const GNetSnmpAttribute *attributes, + const gint64 mask) +{ + GNetSnmpVarBind *vb; + int i; + + for (i = 0; attributes[i].label; i++) { + if (mask && !(mask & attributes[i].tag)) { + continue; + } + if (attributes[i].type == GNET_SNMP_VARBIND_TYPE_COUNTER64 + && s->version == GNET_SNMP_V1) { + continue; + } + base[idx] = attributes[i].subid; + vb = gnet_snmp_varbind_new(base, len, + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + *vbl = g_list_prepend(*vbl, vb); + } + *vbl = g_list_reverse(*vbl); +} + + + +void +gnet_snmp_attr_set(const GNetSnmp *s, GList **vbl, + guint32 *base, size_t const len, + guint const idx, + const GNetSnmpAttribute *attributes, + const gint64 mask, + const gpointer p) +{ + GNetSnmpVarBind *vb; + gpointer **gp; + guint16 *lp; + int i; + + if (!p) { + return; + } + + for (i = 0; attributes[i].label; i++) { + if (mask && !(mask & attributes[i].tag)) { + continue; + } + if ((attributes[i].type == GNET_SNMP_VARBIND_TYPE_COUNTER64 + && s->version == GNET_SNMP_V1)) { + continue; + } + if (! (attributes[i].flags & GSNMP_ATTR_FLAG_WRITABLE)) { + continue; + } + gp = G_STRUCT_MEMBER_P(p, attributes[i].val_offset); + if (attributes[i].len_offset) { + lp = (guint16 *) G_STRUCT_MEMBER_P(p, attributes[i].len_offset); + } else { + lp = 0; + } + base[idx] = attributes[i].subid; + vb = gnet_snmp_varbind_new(base, len, attributes[i].type, + *gp, lp ? *lp : 0); + *vbl = g_list_prepend(*vbl, vb); + } + *vbl = g_list_reverse(*vbl); +} + +gint +gnet_snmp_compare_oids(guint32 *oid1, gsize len1, guint32 *oid2, gsize len2) +{ + int i, j, len; + + /* implement lexicographic ordering */ + len = len1 < len2 ? len1 : len2; + for (i = 0, j = 0; i < len; i++, j++) { + if (oid1[i] < oid2[i]) return -1; + if (oid1[i] > oid2[i]) return 1; + } + + if (len1 < len2) return -1; + if (len2 < len1) return 1; + return 0; + +} + +GURI* +gnet_snmp_parse_uri(const gchar *string) +{ + GURI *uri; + + g_return_val_if_fail(string, NULL); + + string = g_strdup(string); + + /* First, try to treat the string as a fully specified SNMP + URI. If that fails, try to treat the string as something + that looks like [name@]host. Note that simply prepending + "snmp://" does not work well with IPv6 addresses such as "::1" + (which still would have to be written as "[::1]"). */ + + uri = gnet_uri_new(string); + if (uri && !uri->scheme && !uri->hostname) { + gnet_uri_delete(uri); + uri = NULL; + } + if (uri && strcmp(uri->scheme, "snmp") != 0) { + if (uri->hostname) { + gnet_uri_delete(uri); + goto done; + } else { + gnet_uri_delete(uri); + uri = NULL; + } + } + + if (! uri) { + gchar *hostname = NULL, *userinfo = NULL, *port = NULL; + + hostname = strchr(string, '@'); + if (hostname) { + userinfo = string; + *hostname = 0; + hostname++; + } else { + hostname = string; + } + port = strchr(hostname, ':'); + if (port) { + *port = 0; + port++; + /* check that port is numeric? */ + } + + uri = gnet_uri_new_fields_all("snmp", userinfo, hostname, + port ? atoi(port) : 161, + "", NULL, NULL); + } + + if (uri && !uri->userinfo) { + gnet_uri_set_userinfo(uri, "public"); + } + + if (uri && uri->port == 0) { + gnet_uri_set_port(uri, 161); + } + + done: + g_free(string); + return uri; +} diff --git a/src/utils.h b/src/utils.h new file mode 100644 index 0000000..d348057 --- /dev/null +++ b/src/utils.h @@ -0,0 +1,126 @@ +/* + * GNET-SNMP -- glib-based SNMP implementation + * + * Copyright (C) 2003 Juergen Schoenwaelder + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#ifndef __GNET_SNMP_UTILS_H__ +#define __GNET_SNMP_UTILS_H__ + +/* + * Lexicographically compare two object identifiers oid1 and oid2 with + * length len1 and len2 and return -1, 0 or 1 if oid1 is found to be + * less than, to match or be greater than oid2. + */ + +gint gnet_snmp_compare_oids (guint32 *oid1, gsize len1, + guint32 *oid2, gsize len2); + +/* + * Parse a string into an SNMP URI. This function also handles + * abbreviated URIs. + */ + +GURI* gnet_snmp_parse_uri (const gchar *string); + +/* + * The following types and the associated functions are used to + * map enumerated numbers to labels and vice versa. + */ + +typedef struct _GNetSnmpEnum GNetSnmpEnum; +typedef struct _GNetSnmpIdentity GNetSnmpIdentity; + +struct _GNetSnmpEnum { + gint32 const number; + gchar const *label; +}; + +gchar const * +gnet_snmp_enum_get_label(GNetSnmpEnum const *table, gint32 const id); + +gboolean +gnet_snmp_enum_get_number(GNetSnmpEnum const *table, gchar const *str, + gint32 *number); + +struct _GNetSnmpIdentity { + guint32 const *oid; + gsize const oidlen; + gchar const *label; +}; + +gchar const * +gnet_snmp_identity_get_label(GNetSnmpIdentity const *table, + guint32 const *oid, gsize oidlen); +guint32 * +gnet_snmp_identity_get_identity(GNetSnmpIdentity const *table, + gchar const *str, gsize *oidlen); + +/* + * SNMP specific enumerations + */ + +extern GNetSnmpEnum const gnet_snmp_enum_version_table[]; +extern GNetSnmpEnum const gnet_snmp_enum_error_table[]; +extern GNetSnmpEnum const gnet_snmp_enum_debug_table[]; +extern GNetSnmpEnum const gnet_snmp_enum_tdomain_table[]; +extern GNetSnmpEnum const gnet_snmp_enum_type_table[]; +extern GNetSnmpEnum const gnet_snmp_enum_pdu_table[]; + +/* + * The following utilities are used by the scli stubs generated by the + * smidump MIB compiler. + */ + +typedef enum +{ + GSNMP_ATTR_FLAG_WRITABLE = 1 << 0, + GSNMP_ATTR_FLAG_MASK = 0x01 +} GNetSnmpAttrFlags; + +typedef struct { + const guint32 subid; /* column/scalar subid */ + const GNetSnmpVarBindType type; /* SNMP type of the value */ + const gint tag; /* internal identification tag */ + const gchar *label; /* label (used for error reports) */ + const gpointer constraints;/* range or size contraints */ + const gint val_offset; /* offset for the value pointer */ + const gint len_offset; /* offset for the length pointer */ + const GNetSnmpAttrFlags flags; /* various flags, see above */ +} GNetSnmpAttribute; + +extern int gnet_snmp_attr_assign(GList *vbl, + guint32 const *base, size_t const len, + const GNetSnmpAttribute *attributes, + const gpointer p); + +extern void gnet_snmp_attr_get(const GNetSnmp *s, GList **vbl, + guint32 *base, size_t const len, + guint const idx, + const GNetSnmpAttribute *attributes, + const gint64 mask); + +extern void gnet_snmp_attr_set(const GNetSnmp *s, GList **vbl, + guint32 *base, size_t len, + guint const idx, + const GNetSnmpAttribute *attributes, + const gint64 mask, + const gpointer p); + +#endif /* __GNET_SNMP_UTILS_H__ */ diff --git a/src/walk.c b/src/walk.c new file mode 100644 index 0000000..d0ab690 --- /dev/null +++ b/src/walk.c @@ -0,0 +1,302 @@ +/* + * GNET-SNMP -- glib-based SNMP implementation + * + * Copyright (c) 2003 Juergen Schoenwaelder + * Copyright (c) 1998 Gregory McLean & Jochen Friedrich + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +#include "gsnmp.h" + + +struct _GNetSnmpWalk { + GNetSnmp *snmp; + GList *orig_objs; + GList *prev_objs; + gpointer data; + gpointer request; + void (* cb_error)(GNetSnmp *snmp, gpointer data); + void (* cb_row)(GNetSnmp *snmp, GList *vbl, gpointer data); + void (* cb_finish)(GNetSnmp *snmp, gpointer data); +}; + + + +static gboolean +g_snmp_walk_done_callback(GNetSnmp *snmp, + GNetSnmpPdu *pdu, GList *objs, gpointer data) +{ + GNetSnmpWalk *walk; + GList *elem, *orig_elem, *prev_elem; + int endofviews = 0; + + snmp->error_status = pdu->error_status; + snmp->error_index = pdu->error_index; + + if (gnet_snmp_debug_flags & GNET_SNMP_DEBUG_SESSION) { + g_printerr("session %p: error-status = %d, error-index = %d\n", + snmp, snmp->error_status, snmp->error_index); + } + + walk = (GNetSnmpWalk *) data; + walk->request = 0; + + /* + * Check whether we got an error or reached the end of the MIB view. + */ + + if (pdu->error_status == GNET_SNMP_ERR_NOSUCHNAME) { + if (walk->cb_finish) { + walk->cb_finish(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + return TRUE; + } + if (pdu->error_status) { + if (walk->cb_error) { + walk->cb_error(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + return TRUE; + } + + /* + * Check whether we got end of mib view exceptions for all varbinds. + */ + + for (elem = objs; elem; elem = elem = g_list_next(elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + if (vb->type == GNET_SNMP_VARBIND_TYPE_ENDOFMIBVIEW) { + endofviews++; + } + } + if (endofviews == g_list_length(objs)) { + if (walk->cb_finish) { + walk->cb_finish(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + return TRUE; + } + +#if 1 + /* sanity check whether the new oid is larger than the previous */ + + for (elem = objs, prev_elem = walk->prev_objs; + elem && prev_elem; + elem = g_list_next(elem), prev_elem = g_list_next(prev_elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + GNetSnmpVarBind *prev_vb = (GNetSnmpVarBind *) prev_elem->data; + int x; + + x = gnet_snmp_compare_oids(prev_vb->oid, prev_vb->oid_len, + vb->oid, vb->oid_len); + if (x >= 0) { + if (walk->cb_error) { + walk->cb_error(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + return TRUE; + } + } +#endif + + /* Check whether the new oid is within the scope of the walk. */ + + for (elem = objs, orig_elem = walk->orig_objs; + elem && orig_elem; + elem = g_list_next(elem), orig_elem = g_list_next(orig_elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + GNetSnmpVarBind *orig_vb = (GNetSnmpVarBind *) orig_elem->data; + + if (vb->oid_len < orig_vb->oid_len + || memcmp(vb->oid, orig_vb->oid, orig_vb->oid_len * sizeof(guint32))) { + if (walk->cb_finish) { + walk->cb_finish(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + g_list_foreach(objs, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(objs); + return TRUE; + } + } + +#if 0 + if (walk->prev_objs) { + g_list_foreach(walk->prev_objs, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(walk->prev_objs); + } +#endif + + walk->prev_objs = objs; + + if (walk->cb_row) { + walk->cb_row(snmp, objs, walk->data); + } + + walk->request = gnet_snmp_async_getnext(snmp, objs); + + return TRUE; +} + + + +static void +g_snmp_walk_time_callback(GNetSnmp *snmp, gpointer data) +{ + GNetSnmpWalk *walk; + + walk = (GNetSnmpWalk *) data; + walk->request = 0; + if (walk->cb_error) { + walk->cb_error(snmp, walk->data); + } else { + gnet_snmp_walk_delete(walk); + } + + snmp->error_index = 0; + snmp->error_status = GNET_SNMP_ERR_NORESPONSE; +} + + + +GNetSnmpWalk * +gnet_snmp_walk_new(GNetSnmp *session, + GList *vbl, + void (* cb_error)(), + void (* cb_row)(), + void (* cb_finish)(), + gpointer data) +{ + GList *elem; + GNetSnmpWalk *walk; + + walk = g_malloc0(sizeof(GNetSnmpWalk)); + + walk->snmp = gnet_snmp_clone(session); + walk->snmp->magic = walk; + walk->snmp->done_callback = g_snmp_walk_done_callback; + walk->snmp->time_callback = g_snmp_walk_time_callback; + + for (elem = vbl; elem; elem = g_list_next(elem)) { + GNetSnmpVarBind *vb = (GNetSnmpVarBind *) elem->data; + GNetSnmpVarBind *nvb; + nvb = gnet_snmp_varbind_new(vb->oid, vb->oid_len, + GNET_SNMP_VARBIND_TYPE_NULL, NULL, 0); + walk->orig_objs = g_list_append(walk->orig_objs, nvb); + } + walk->data = data; + + walk->cb_error = cb_error; + walk->cb_row = cb_row; + walk->cb_finish = cb_finish; + + return walk; +} + + + +void +gnet_snmp_walk_delete(GNetSnmpWalk *walk) +{ + if (walk->request) { + gnet_snmp_request_dequeue(walk->request); + gnet_snmp_request_delete(walk->request); + } + g_list_foreach(walk->orig_objs, (GFunc) gnet_snmp_varbind_delete, NULL); + g_list_free(walk->orig_objs); + gnet_snmp_delete(walk->snmp); + g_free(walk); +} + + + +void +gnet_snmp_async_walk(GNetSnmpWalk *walk) +{ + walk->request = gnet_snmp_async_getnext(walk->snmp, + walk->orig_objs); +} + + + +/* + * Another entry point which is used by the scli package. + */ + +static GMainLoop *loop = NULL; + + +static void +cb_finish(GNetSnmp *snmp, gpointer *data) +{ + if (loop) g_main_quit(loop); +} + + + +static void +cb_error(GNetSnmp *snmp, gpointer *data) +{ + if (loop) g_main_quit(loop); +} + + + +static void +cb_row(GNetSnmp *snmp, GList *vbl, gpointer *data) +{ + GList **walklist = (GList **) data; + GList *elem; + + for (elem = vbl; elem; elem = g_list_next(elem)) { + *walklist = g_list_append(*walklist, elem->data); + } +} + + + +GList* +gnet_snmp_sync_walk(GNetSnmp *s, GList *in) +{ + GNetSnmpWalk *walk; + GList *walklist = NULL; + + walk = gnet_snmp_walk_new(s, in, cb_error, cb_row, cb_finish, &walklist); + + gnet_snmp_async_walk(walk); + + loop = g_main_new(TRUE); + while (loop && g_main_is_running(loop)) { + g_main_run(loop); + } + g_main_destroy(loop); + loop = NULL; + + s->error_status = walk->snmp->error_status; + s->error_index = walk->snmp->error_index; + + gnet_snmp_walk_delete(walk); + + return walklist; +} + diff --git a/stamp-h.in b/stamp-h.in new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/stamp-h.in @@ -0,0 +1 @@ +timestamp diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..aee6203 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,7 @@ +INCLUDES = $(GNET_CFLAGS) -I$(top_builddir)/src + +bin_PROGRAMS = gsnmp-test + +gsnmp_test_SOURCES = gsnmp-test.c +gsnmp_test_LDADD = $(top_builddir)/src/libgsnmp.la \ + $(GNET_LIBS) diff --git a/tests/Makefile.in b/tests/Makefile.in new file mode 100644 index 0000000..6b84f9c --- /dev/null +++ b/tests/Makefile.in @@ -0,0 +1,373 @@ +# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AR = @AR@ +AS = @AS@ +CC = @CC@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +GCJ = @GCJ@ +GCJFLAGS = @GCJFLAGS@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GNET_CFLAGS = @GNET_CFLAGS@ +GNET_LIBS = @GNET_LIBS@ +GOBJECT_QUERY = @GOBJECT_QUERY@ +HAVE_LIB = @HAVE_LIB@ +ISODATE = @ISODATE@ +LIB = @LIB@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIB = @LTLIB@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RC = @RC@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +INCLUDES = $(GNET_CFLAGS) -I$(top_builddir)/src + +bin_PROGRAMS = gsnmp-test + +gsnmp_test_SOURCES = gsnmp-test.c +gsnmp_test_LDADD = $(top_builddir)/src/libgsnmp.la $(GNET_LIBS) + +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = gsnmp-test$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +gsnmp_test_OBJECTS = gsnmp-test.$(OBJEXT) +gsnmp_test_DEPENDENCIES = $(top_builddir)/src/libgsnmp.la +gsnmp_test_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/gsnmp-test.P +SOURCES = $(gsnmp_test_SOURCES) +OBJECTS = $(gsnmp_test_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .obj .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +gsnmp-test$(EXEEXT): $(gsnmp_test_OBJECTS) $(gsnmp_test_DEPENDENCIES) + @rm -f gsnmp-test$(EXEEXT) + $(LINK) $(gsnmp_test_LDFLAGS) $(gsnmp_test_OBJECTS) $(gsnmp_test_LDADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags -o $$here/TAGS $(ETAGS_ARGS) $$tags $$unique $(LISP)) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = tests + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu tests/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-libtool \ + distclean-tags distclean-depend distclean-generic \ + clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tests/gsnmp-test.c b/tests/gsnmp-test.c new file mode 100644 index 0000000..314af98 --- /dev/null +++ b/tests/gsnmp-test.c @@ -0,0 +1,673 @@ +#include "gsnmp.h" + +void +dump(guchar *bytes, gsize len) +{ + int i; + + for (i = 0; i < len; i++) { + g_print("%02x%c", bytes[i], (i % 16) == 15 ? '\n': ':'); + } +} + +/* + * Check the password to key algorithm and the key localization as + * described in RFC 3414 section A.3.1. + */ + +static void +test_md5_key_localization() +{ + char *password = "maplesyrup"; + guchar key[GNET_MD5_HASH_LENGTH]; + + guchar engineid[] = + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; + + guchar digest1[] = + { 0x9f, 0xaf, 0x32, 0x83, 0x88, 0x4e, 0x92, 0x83, + 0x4e, 0xbc, 0x98, 0x47, 0xd8, 0xed, 0xd9, 0x63 }; + + guchar digest2[] = + { 0x52, 0x6f, 0x5e, 0xed, 0x9f, 0xcc, 0xe2, 0x6f, + 0x89, 0x64, 0xc2, 0x93, 0x07, 0x87, 0xd8, 0x2b }; + + gnet_snmp_password_to_key_md5(password, strlen(password), key); + g_assert(memcmp(key, digest1, GNET_MD5_HASH_LENGTH) == 0); + + gnet_snmp_localize_key_md5(key, engineid, G_N_ELEMENTS(engineid)); + g_assert(memcmp(key, digest2, GNET_MD5_HASH_LENGTH) == 0); +} + +/* + * Check the password to key algorithm and the key localization as + * described in RFC 3414 section A.3.2. + */ + +static void +test_sha_key_localization() +{ + char *password = "maplesyrup"; + guchar key[GNET_SHA_HASH_LENGTH]; + + guchar engineid[] = + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; + + guchar digest1[] = + { 0x9f, 0xb5, 0xcc, 0x03, 0x81, 0x49, 0x7b, 0x37, 0x93, 0x52, + 0x89, 0x39, 0xff, 0x78, 0x8d, 0x5d, 0x79, 0x14, 0x52, 0x11 }; + + guchar digest2[] = + { 0x66, 0x95, 0xfe, 0xbc, 0x92, 0x88, 0xe3, 0x62, 0x82, 0x23, + 0x5f, 0xc7, 0x15, 0x1f, 0x12, 0x84, 0x97, 0xb3, 0x8f, 0x3f }; + + gnet_snmp_password_to_key_sha(password, strlen(password), key); + g_assert(memcmp(key, digest1, GNET_SHA_HASH_LENGTH) == 0); + + gnet_snmp_localize_key_sha(key, engineid, G_N_ELEMENTS(engineid)); + g_assert(memcmp(key, digest2, GNET_SHA_HASH_LENGTH) == 0); +} + +/* + * + */ + +static void +test_ber_std_pdu() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + GNetSnmpPdu pdu1, pdu2; + guchar buf[1234], *start; + gint len; + + guchar x[] = { + 0xA1, 0x0B, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x30, 0x00 + }; + + guchar y[] = { + 0x30, 0x1c, + 0x04, 0x08, 0x80, 0x00, 0x02, 0xb8, 0x04, 0x61, 0x62, 0x63, + 0x04, 0x03, 0x64, 0x65, 0x66, + 0xa1, 0x0b, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x30, 0x00, + }; + + guchar eid[] = { + 0x80, 0x00, 0x02, 0xb8, 0x04, 0x61, 0x62, 0x63, + }; + + memset(&pdu1, 0, sizeof(pdu1)); + pdu1.type = GNET_SNMP_PDU_NEXT; + pdu1.context_name = "def"; + pdu1.context_name_len = strlen(pdu1.context_name); + pdu1.context_engineid = eid; + pdu1.context_engineid_len = sizeof(eid); + + memset(&pdu2, 0, sizeof(pdu2)); + + /* SNMPv1 PDU */ + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_pdu_v1(asn1, &pdu1, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_pdu_v1(asn1, &pdu2, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(pdu2.type == pdu1.type); + g_assert(pdu2.request_id == pdu1.request_id); + g_assert(pdu2.error_status == pdu1.error_status); + g_assert(pdu2.error_index == pdu1.error_index); + + /* SNMPv2 PDU */ + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_pdu_v2(asn1, &pdu1, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_pdu_v2(asn1, &pdu2, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(pdu2.type == pdu1.type); + g_assert(pdu2.request_id == pdu1.request_id); + g_assert(pdu2.error_status == pdu1.error_status); + g_assert(pdu2.error_index == pdu1.error_index); + + /* SNMPv3 PDU */ + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_pdu_v3(asn1, &pdu1, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(y)); + g_assert(memcmp(start, y, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_pdu_v3(asn1, &pdu2, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(pdu2.type == pdu1.type); + g_assert(pdu2.request_id == pdu1.request_id); + g_assert(pdu2.error_status == pdu1.error_status); + g_assert(pdu2.error_index == pdu1.error_index); + g_assert(pdu2.context_name_len == pdu1.context_name_len); + g_assert(memcmp(pdu2.context_name, pdu1.context_name, + pdu1.context_name_len) == 0); + g_assert(pdu2.context_engineid_len == pdu1.context_engineid_len); + g_assert(memcmp(pdu2.context_engineid, pdu1.context_engineid, + pdu1.context_engineid_len) == 0); +} + +/* + * + */ + +static void +test_ber_trap_pdu() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + GNetSnmpPdu pdu1, pdu2; + GNetSnmpVarBind *vb; + guchar buf[1234], *start; + gsize len; + guint32 time = 42; + + guchar x[] = { + 0xa4, 0x1b, + 0x06, 0x08, 0x2b, 0x06, 0x01, 0x06, 0x03, 0x01, 0x01, 0x05, + 0x40, 0x04, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x43, 0x01, 0x2a, + 0x30, 0x00 + }; + + guchar y[] = { + 0xa4, 0x33, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x00, + 0x30, 0x28, + 0x30, 0x0d, + 0x06, 0x08, 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x03, 0x00, + 0x43, 0x01, 0x2a, + 0x30, 0x17, + 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x06, 0x03, 0x01, 0x01, 0x04, 0x01, 0x00, + 0x06, 0x09, 0x2b, 0x06, 0x01, 0x06, 0x03, 0x01, 0x01, 0x05, 0x01 + }; + + static const guint32 sysUpTime0[] + = { 1, 3, 6, 1, 2, 1, 1, 3, 0 }; + + static const guint32 snmpTrapOID0[] + = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; + + static guint32 coldStart[] + = { 1, 3, 6, 1, 6, 3, 1, 1, 5, 1 }; + + memset(&pdu1, 0, sizeof(pdu1)); + pdu1.type = GNET_SNMP_PDU_TRAP; + + vb = gnet_snmp_varbind_new(sysUpTime0, G_N_ELEMENTS(sysUpTime0), + GNET_SNMP_VARBIND_TYPE_TIMETICKS, + &time, 0); + pdu1.varbind_list = g_list_append(pdu1.varbind_list, vb); + + vb = gnet_snmp_varbind_new(snmpTrapOID0, G_N_ELEMENTS(snmpTrapOID0), + GNET_SNMP_VARBIND_TYPE_OBJECTID, + coldStart, G_N_ELEMENTS(coldStart)); + pdu1.varbind_list = g_list_append(pdu1.varbind_list, vb); + + /* encode and decode the notification following the RFC 1157 + * protocol operations format */ + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_pdu_v1(asn1, &pdu1, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + memset(&pdu2, 0, sizeof(pdu2)); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_pdu_v1(asn1, &pdu2, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(pdu2.type == pdu1.type); + + vb = g_list_nth_data(pdu2.varbind_list, 0); + g_assert(vb); + g_assert(vb->type == GNET_SNMP_VARBIND_TYPE_TIMETICKS); + g_assert(vb->value.ui32 == time); + + vb = g_list_nth_data(pdu2.varbind_list, 1); + g_assert(vb); + g_assert(vb->type == GNET_SNMP_VARBIND_TYPE_OBJECTID); + g_assert(vb->value_len == G_N_ELEMENTS(coldStart)); + g_assert(memcmp(vb->value.ui32v, coldStart, vb->value_len) == 0); + + /* now do the same with the RFC 3416 protocol operations format */ + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_pdu_v2(asn1, &pdu1, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(y)); + g_assert(memcmp(start, y, len) == 0); + + memset(&pdu2, 0, sizeof(pdu2)); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_pdu_v2(asn1, &pdu2, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(pdu2.type == pdu1.type); + g_assert(pdu2.request_id == pdu1.request_id); + g_assert(pdu2.error_status == pdu1.error_status); + g_assert(pdu2.error_index == pdu1.error_index); + + vb = g_list_nth_data(pdu2.varbind_list, 0); + g_assert(vb); + g_assert(vb->type == GNET_SNMP_VARBIND_TYPE_TIMETICKS); + g_assert(vb->value.ui32 == time); + + vb = g_list_nth_data(pdu2.varbind_list, 1); + g_assert(vb); + g_assert(vb->type == GNET_SNMP_VARBIND_TYPE_OBJECTID); + g_assert(vb->value_len == G_N_ELEMENTS(coldStart)); + g_assert(memcmp(vb->value.ui32v, coldStart, vb->value_len) == 0); +} + +static void +test_ber_null() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gsize len; + guint cls, con, tag; + + guchar x[] = { + 0x05, 0x00, + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + gnet_snmp_ber_enc_null(asn1, &eoi, &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_NUL, &error); + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_NUL); + gnet_snmp_ber_dec_null(asn1, eoi, &error); + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_ber_gint32() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gint i, len; + guint cls, con, tag; + + gint32 a, v[] = { + -2147483648L, -2147483647L, -1, 0, 1, 2147483646L, 2147483647L + }; + + guchar x[] = { + 0x02, 0x04, 0x80, 0x00, 0x00, 0x00, + 0x02, 0x04, 0x80, 0x00, 0x00, 0x01, + 0x02, 0x01, 0xFF, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x01, + 0x02, 0x04, 0x7F, 0xFF, 0xFF, 0xFE, + 0x02, 0x04, 0x7F, 0xFF, 0xFF, 0xFF + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + for (i = G_N_ELEMENTS(v) - 1; i >= 0; i--) { + gnet_snmp_ber_enc_gint32(asn1, &eoi, v[i], &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + &error); + } + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + for (i = 0; i < G_N_ELEMENTS(v); i++) { + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_INT); + gnet_snmp_ber_dec_gint32(asn1, eoi, &a, &error); + g_assert(a == v[i]); + } + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_ber_gint64() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gint i, len; + guint cls, con, tag; + + gint64 a, v[] = { + -9223372036854775808LL, -2147483648LL, -2147483647LL, + -1, 0, 1, + 2147483646LL, 2147483647LL, 9223372036854775807LL + }; + + guchar x[] = { + 0x02, 0x08, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x04, 0x80, 0x00, 0x00, 0x00, + 0x02, 0x04, 0x80, 0x00, 0x00, 0x01, + 0x02, 0x01, 0xFF, + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x01, + 0x02, 0x04, 0x7F, 0xFF, 0xFF, 0xFE, + 0x02, 0x04, 0x7F, 0xFF, 0xFF, 0xFF, + 0x02, 0x08, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + for (i = G_N_ELEMENTS(v) - 1; i >= 0; i--) { + gnet_snmp_ber_enc_gint64(asn1, &eoi, v[i], &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + &error); + } + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + for (i = 0; i < G_N_ELEMENTS(v); i++) { + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_INT); + gnet_snmp_ber_dec_gint64(asn1, eoi, &a, &error); + g_assert(a == v[i]); + } + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_ber_guint32() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gint i, len; + guint cls, con, tag; + + guint32 a, v[] = { + 0, 1, 4294967294UL, 4294967295UL + }; + + guchar x[] = { + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x01, + 0x02, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFE, + 0x02, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFF + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + for (i = G_N_ELEMENTS(v) - 1; i >= 0; i--) { + gnet_snmp_ber_enc_guint32(asn1, &eoi, v[i], &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + &error); + } + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + for (i = 0; i < G_N_ELEMENTS(v); i++) { + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_INT); + gnet_snmp_ber_dec_guint32(asn1, eoi, &a, &error); + g_assert(a == v[i]); + } + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_ber_guint64() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gint i, len; + guint cls, con, tag; + + guint64 a, v[] = { + 0, 1, 4294967295UL, 4294967296ULL, 18446744073709551615ULL + }; + + guchar x[] = { + 0x02, 0x01, 0x00, + 0x02, 0x01, 0x01, + 0x02, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0x02, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x09, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + for (i = G_N_ELEMENTS(v) - 1; i >= 0; i--) { + gnet_snmp_ber_enc_guint64(asn1, &eoi, v[i], &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_INT, + &error); + } + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + for (i = 0; i < G_N_ELEMENTS(v); i++) { + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_INT); + gnet_snmp_ber_dec_guint64(asn1, eoi, &a, &error); + g_assert(a == v[i]); + } + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_ber_octets() +{ + GError *error = NULL; + GNetSnmpBer *asn1; + guchar buf[1234], *start, *eoi; + gint i, len; + guint cls, con, tag; + gsize a_len; + + guchar *a, *v[] = { + "", "a", "abcdefghijklmnopqrstuvwxyz" + }; + + guchar x[] = { + 0x04, 0x00, + 0x04, 0x01, 0x61, + 0x04, 0x1a, 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 + }; + + asn1 = gnet_snmp_ber_enc_new(buf, sizeof(buf)); + for (i = G_N_ELEMENTS(v) - 1; i >= 0; i--) { + gnet_snmp_ber_enc_octets(asn1, &eoi, v[i], strlen(v[i]), &error); + gnet_snmp_ber_enc_header(asn1, eoi, GNET_SNMP_ASN1_UNI, + GNET_SNMP_ASN1_PRI, GNET_SNMP_ASN1_OTS, + &error); + } + gnet_snmp_ber_enc_delete(asn1, &start, &len); + + g_assert(error == NULL); + g_assert(len == G_N_ELEMENTS(x)); + g_assert(memcmp(start, x, len) == 0); + + asn1 = gnet_snmp_ber_dec_new(start, len); + for (i = 0; i < G_N_ELEMENTS(v); i++) { + gnet_snmp_ber_dec_header(asn1, &eoi, &cls, &con, &tag, &error); + g_assert(cls == GNET_SNMP_ASN1_UNI + && con == GNET_SNMP_ASN1_PRI && tag == GNET_SNMP_ASN1_OTS); + gnet_snmp_ber_dec_octets(asn1, eoi, &a, &a_len, &error); + g_assert(a_len == strlen(v[i])); + g_assert(memcmp(a, v[i], a_len) == 0); + } + gnet_snmp_ber_dec_delete(asn1, &start, &len); + g_assert(error == NULL); +} + +static void +test_snmp_uri_parser() +{ + GURI *uri; + int i; + + const gchar *testcases[] = { + + /* fully qualified service URIs which we accept */ + + "snmp://localhost/", "snmp://public@localhost:161/", + "snmp://public@localhost/", "snmp://public@localhost:161/", + "snmp://localhost:162/", "snmp://public@localhost:162/", + "snmp://public@localhost:163/", "snmp://public@localhost:163/", + + "snmp://127.0.0.1/", "snmp://public@127.0.0.1:161/", + "snmp://public@127.0.0.1/", "snmp://public@127.0.0.1:161/", + "snmp://127.0.0.1:162/", "snmp://public@127.0.0.1:162/", + "snmp://public@127.0.0.1:163/", "snmp://public@127.0.0.1:163/", + + "snmp://[::1]/", "snmp://public@[::1]:161/", + "snmp://public@[::1]/", "snmp://public@[::1]:161/", + "snmp://[::1]:162/", "snmp://public@[::1]:162/", + "snmp://public@[::1]:163/", "snmp://public@[::1]:163/", + + /* abbreviated URIs which we also accept for convenience */ + + "localhost", "snmp://public@localhost:161/", + "public@localhost", "snmp://public@localhost:161/", + "localhost:161", "snmp://public@localhost:161/", + + "127.0.0.1", "snmp://public@127.0.0.1:161/", + "public@127.0.0.1", "snmp://public@127.0.0.1:161/", + "127.0.0.1:161", "snmp://public@127.0.0.1:161/", + +// "::1", "snmp://public@[::1]:161/", +// "public@::1", "snmp://public@[::1]:161/", + +// "[::1]", "snmp://public@[::1]:161/", +// "public@[::1]", "snmp://public@[::1]:161/", +// "[::1]:161", "snmp://public@[::1]:161/", +// "public@[::1]:161", "snmp://public@[::1]:161/", + + NULL, NULL + }; + + for (i = 0; testcases[i]; i++) { + uri = gnet_snmp_parse_uri(testcases[i++]); + if (uri) { + gchar *s = gnet_uri_get_string(uri); + // g_printerr("%s-> %s\n", testcases[i], s); + g_assert(strcmp(s, testcases[i]) == 0); + g_free(s); + } else { + g_assert(testcases[i] == NULL); + } + if (uri) { + gnet_uri_delete(uri); + } + } +} + +int +main(void) +{ + gint i; + + static struct { + void (*func)(void); + const gchar *desc; + } tests[] = { + { test_ber_null, "ASN.1/BER null encoding/decoding test" }, + { test_ber_gint32, "ASN.1/BER gint32 encoding/decoding test" }, + { test_ber_gint64, "ASN.1/BER gint64 encoding/decoding test" }, + { test_ber_guint32, "ASN.1/BER guint32 encoding/decoding test" }, + { test_ber_guint64, "ASN.1/BER guint64 encoding/decoding test" }, + { test_ber_octets, "ASN.1/BER octet string encoding/decoding test" }, + { test_ber_std_pdu, "ASN.1/BER standard pdu encoding/decoding test" }, + { test_ber_trap_pdu, "ASN.1/BER trap pdu encoding/decoding test" }, + { test_md5_key_localization, "MD5 key localization test" }, + { test_sha_key_localization, "SHA key localization test" }, + { test_snmp_uri_parser, "SNMP URI parser test" }, + { NULL, NULL } + }; + + for (i = 0; tests[i].func && tests[i].desc; i++) { + g_print("%3d: %s\n", i, tests[i].desc); + tests[i].func(); + } + + return 0; +}