remove libopm
This commit is contained in:
parent
d43d276063
commit
28e917cf89
25 changed files with 0 additions and 4170 deletions
24
.gitattributes
vendored
24
.gitattributes
vendored
|
@ -11,30 +11,6 @@
|
|||
/configure.in -text
|
||||
/html.css -text
|
||||
/install-sh -text
|
||||
libopm/.cvsignore -text
|
||||
libopm/LICENSE -text
|
||||
libopm/Makefile.in -text
|
||||
libopm/README -text
|
||||
libopm/compat.c -text
|
||||
libopm/compat.h -text
|
||||
libopm/config.c -text
|
||||
libopm/config.h -text
|
||||
libopm/inet.c -text
|
||||
libopm/inet.h -text
|
||||
libopm/libopm.c -text
|
||||
libopm/libopm.h -text
|
||||
libopm/libopm.vcproj -text
|
||||
libopm/malloc.c -text
|
||||
libopm/malloc.h -text
|
||||
libopm/opm.h -text
|
||||
libopm/opm_common.h -text
|
||||
libopm/opm_error.h -text
|
||||
libopm/opm_types.h -text
|
||||
libopm/opmlist.c -text
|
||||
libopm/opmlist.h -text
|
||||
libopm/proxy.c -text
|
||||
libopm/proxy.h -text
|
||||
libopm/test.c -text
|
||||
/modconfig.h.in -text
|
||||
/modconfigwin32.h -text
|
||||
/opsb.Settings -text
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
*.sw[op]
|
||||
Makefile
|
||||
*.lo
|
||||
*.la
|
||||
setup.h
|
||||
stamp-h*
|
||||
.deps
|
||||
.libs
|
||||
test
|
||||
test_debug
|
339
libopm/LICENSE
339
libopm/LICENSE
|
@ -1,339 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, 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
|
||||
|
||||
Appendix: 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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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.
|
||||
|
||||
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) 19yy 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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
|
@ -1,45 +0,0 @@
|
|||
#Neostats Module Makefile!
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
DIRECTORY = @DIRINST@/dl/
|
||||
INCLUDES = -I. -I.. -I@DIRINST@/include/
|
||||
|
||||
SRCS= compat.c config.c inet.c libopm.c opmlist.c malloc.c proxy.c
|
||||
OBJS= ${SRCS:.c=.o}
|
||||
|
||||
TARGET= libopm.a
|
||||
DOCS=
|
||||
|
||||
all: libopm.a
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCLUDES) $<
|
||||
|
||||
|
||||
libopm.a: $(OBJS)
|
||||
ar cru $(TARGET) ${OBJS}
|
||||
ranlib $(TARGET)
|
||||
|
||||
clean:
|
||||
/bin/rm -rf $(TARGET) *.o Makefile
|
||||
|
||||
install:
|
||||
|
||||
dist:
|
||||
|
||||
$(OBJS): Makefile
|
||||
compat.o: compat.c ../modconfig.h compat.h opm.h opm_common.h
|
||||
config.o: config.c ../modconfig.h malloc.h config.h libopm.h inet.h \
|
||||
opm_common.h opm.h opm_error.h opm_types.h opmlist.h
|
||||
inet.o: inet.c ../modconfig.h inet.h opm.h opm_common.h
|
||||
libopm.o: libopm.c ../modconfig.h config.h libopm.h inet.h opm_common.h \
|
||||
opm.h malloc.h opm_error.h opm_types.h opmlist.h proxy.h
|
||||
list.o: opmlist.c ../modconfig.h opm_common.h opmlist.h malloc.h opm.h
|
||||
malloc.o: malloc.c ../modconfig.h malloc.h opm.h opm_common.h
|
||||
proxy.o: proxy.c ../modconfig.h inet.h compat.h config.h libopm.h \
|
||||
opm_common.h opm.h proxy.h opm_types.h opm_error.h
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
This is libopm, a open proxy detection library written by Erik Fears and the
|
||||
Blitzed team. (www.blitzed.org, strtok@blitzed.org)
|
||||
More information about this library can be found at www.blitzed.org (This
|
||||
library powers BOPM, blitzed version of the open proxy monitoring library.)
|
||||
|
||||
There are a few modifications to this library to enable it to plug in
|
||||
cleaning to OPSB, but the majority of credit must be given to them.
|
||||
|
||||
If your interested in using this library in your software, checked out the
|
||||
blitzed webpages for more informationa and documentation.
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/* vim: set shiftwidth=3 softtabstop=3 expandtab: */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Andy Smith
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
#ifndef WIN32
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
#include "opm.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
/*
|
||||
* An implementation of inet_aton for those systems that don't have it
|
||||
* (Solaris, ...)
|
||||
*/
|
||||
int libopm_inet_aton(const char *cp, struct in_addr *inp)
|
||||
{
|
||||
unsigned int a1, a2, a3, a4;
|
||||
unsigned long ret;
|
||||
|
||||
if (strcmp(cp, "255.255.255.255") == 0) {
|
||||
inp->s_addr = (unsigned) -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
|
||||
a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
|
||||
|
||||
inp->s_addr = htonl(ret);
|
||||
|
||||
if (inp->s_addr == (unsigned) -1) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef COMPAT_H
|
||||
#define COMPAT_H
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
#undef inet_aton
|
||||
#define inet_aton libopm_inet_aton
|
||||
extern int libopm_inet_aton(const char *cp, struct in_addr *inp);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
#undef snprintf
|
||||
#define snprintf ircsnprintf
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
#undef vsnprintf
|
||||
#define vsnprintf ircvsnprintf
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
#undef inet_pton
|
||||
#define inet_pton libopm_inet_pton
|
||||
#endif
|
||||
|
||||
#endif
|
268
libopm/config.c
268
libopm/config.c
|
@ -1,268 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2002 Erik Fears
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "config.h"
|
||||
#include "inet.h"
|
||||
#include "opm_error.h"
|
||||
#include "opm_types.h"
|
||||
#include "opm_common.h"
|
||||
#include "opmlist.h"
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
static OPM_CONFIG_HASH_T HASH[] = {
|
||||
{OPM_CONFIG_FD_LIMIT, OPM_TYPE_INT},
|
||||
{OPM_CONFIG_BIND_IP , OPM_TYPE_ADDRESS},
|
||||
{OPM_CONFIG_DNSBL_HOST, OPM_TYPE_STRING},
|
||||
{OPM_CONFIG_TARGET_STRING, OPM_TYPE_STRINGLIST},
|
||||
{OPM_CONFIG_SCAN_IP, OPM_TYPE_STRING},
|
||||
{OPM_CONFIG_SCAN_PORT, OPM_TYPE_INT},
|
||||
{OPM_CONFIG_MAX_READ, OPM_TYPE_INT},
|
||||
{OPM_CONFIG_TIMEOUT, OPM_TYPE_INT},
|
||||
};
|
||||
|
||||
|
||||
/* config_create
|
||||
*
|
||||
* Create an OPM_CONFIG_T struct, set default values and return it
|
||||
*
|
||||
* Parameters:
|
||||
* None;
|
||||
*
|
||||
* Return:
|
||||
* Pointer to allocated OPM_CONFIG_T struct
|
||||
*/
|
||||
|
||||
OPM_CONFIG_T *libopm_config_create()
|
||||
{
|
||||
int num, i;
|
||||
OPM_CONFIG_T *ret;
|
||||
|
||||
num = sizeof(HASH) / sizeof(OPM_CONFIG_HASH_T);
|
||||
|
||||
ret = MyMalloc(sizeof(OPM_CONFIG_T));
|
||||
ret->vars = MyMalloc(sizeof(void *) * num);
|
||||
|
||||
|
||||
/* Set default config items. This in the future would be much better
|
||||
if it could set realistic defaults for each individual config item.
|
||||
|
||||
OPM_TYPE_INT = 0
|
||||
OPM_TYPE_STRING = ""
|
||||
OPM_TYPE_ADDRESS = 0.0.0.0
|
||||
OPM_TYPE_STRINGLIST = empty list
|
||||
*/
|
||||
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
switch(libopm_config_gettype(i))
|
||||
{
|
||||
case OPM_TYPE_INT:
|
||||
ret->vars[i] = MyMalloc(sizeof(int));
|
||||
*(int *) ret->vars[i] = 0;
|
||||
break;
|
||||
|
||||
case OPM_TYPE_STRING:
|
||||
(char *) ret->vars[i] = strdup("");
|
||||
break;
|
||||
|
||||
case OPM_TYPE_ADDRESS:
|
||||
(opm_sockaddr *) ret->vars[i] = MyMalloc(sizeof(opm_sockaddr));
|
||||
memset((opm_sockaddr *) ret->vars[i], 0, sizeof(opm_sockaddr));
|
||||
break;
|
||||
|
||||
case OPM_TYPE_STRINGLIST:
|
||||
(OPM_LIST_T *) ret->vars[i] = libopm_list_create();
|
||||
break;
|
||||
default:
|
||||
ret->vars[i] = NULL;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* config_free
|
||||
*
|
||||
* Free config structure and clean up
|
||||
*
|
||||
* Parameters:
|
||||
* config: Structure to free/cleanup
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*/
|
||||
|
||||
void libopm_config_free(OPM_CONFIG_T *config)
|
||||
{
|
||||
int num, i;
|
||||
OPM_NODE_T *p, *next;
|
||||
OPM_LIST_T *list;
|
||||
|
||||
num = sizeof(HASH) / sizeof(OPM_CONFIG_HASH_T);
|
||||
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
if(config->vars[i] == NULL)
|
||||
continue;
|
||||
|
||||
switch(libopm_config_gettype(i))
|
||||
{
|
||||
case OPM_TYPE_STRINGLIST:
|
||||
list = (OPM_LIST_T *) config->vars[i];
|
||||
LIST_FOREACH_SAFE(p, next, list->head)
|
||||
{
|
||||
MyFree(p->data);
|
||||
MyFree(p);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
MyFree(config->vars[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MyFree(config->vars);
|
||||
MyFree(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* config_set
|
||||
*
|
||||
* Set configuration options on config struct.
|
||||
*
|
||||
* Parameters:
|
||||
* config: Config struct to set parameters on
|
||||
* key: Variable within the struct to set
|
||||
* value: Address of value to set
|
||||
*
|
||||
* Return:
|
||||
* 1: Variable was set
|
||||
* 0: Some error occured
|
||||
*/
|
||||
|
||||
OPM_ERR_T libopm_config_set(OPM_CONFIG_T *config, int key, void *value)
|
||||
{
|
||||
|
||||
int num;
|
||||
OPM_NODE_T *node;
|
||||
|
||||
num = sizeof(HASH) / sizeof(OPM_CONFIG_HASH_T);
|
||||
|
||||
if(key < 0 || key >= num)
|
||||
return OPM_ERR_BADKEY; /* Return appropriate error code eventually */
|
||||
|
||||
switch(libopm_config_gettype(key))
|
||||
{
|
||||
case OPM_TYPE_STRING:
|
||||
if((char *) config->vars[key] != NULL)
|
||||
MyFree(config->vars[key]);
|
||||
(char *) config->vars[key] = strdup((char *) value);
|
||||
break;
|
||||
|
||||
case OPM_TYPE_INT:
|
||||
*(int *) config->vars[key] = *(int *) value;
|
||||
break;
|
||||
|
||||
case OPM_TYPE_ADDRESS:
|
||||
if( inet_pton(AF_INET, (char *) value, &( ((opm_sockaddr *)config->vars[key])->sa4.sin_addr))
|
||||
<= 0)
|
||||
return OPM_ERR_BADVALUE; /* return appropriate err code */
|
||||
break;
|
||||
|
||||
case OPM_TYPE_STRINGLIST:
|
||||
node = libopm_node_create(strdup((char *) value));
|
||||
libopm_list_add((OPM_LIST_T *) config->vars[key], node);
|
||||
break;
|
||||
|
||||
default:
|
||||
return OPM_ERR_BADKEY; /* return appropriate err code */
|
||||
|
||||
}
|
||||
|
||||
return OPM_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* config_gettype
|
||||
*
|
||||
* Get type of key.
|
||||
*
|
||||
* Parameters:
|
||||
* key: Key to get type of.
|
||||
*
|
||||
* Return:
|
||||
* TYPE_? of key
|
||||
*/
|
||||
|
||||
int libopm_config_gettype(int key)
|
||||
{
|
||||
int num, i;
|
||||
|
||||
num = sizeof(HASH) / sizeof(OPM_CONFIG_HASH_T);
|
||||
|
||||
for(i = 0; i < num; i++)
|
||||
if(HASH[i].key == key)
|
||||
return HASH[i].type;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config
|
||||
*
|
||||
* Retrieve a specific config variable from
|
||||
* an OPM_CONFIG_T struct. This is basically a
|
||||
* wrapper to extracting the variable from the
|
||||
* array.
|
||||
*
|
||||
* Parameters:
|
||||
* config: Config struct to extract from
|
||||
* key: Value to extract
|
||||
*
|
||||
* Return:
|
||||
* -ADDRESS- to extracted value in array. This address
|
||||
* will have to be cast on the return end to be any use.
|
||||
*/
|
||||
|
||||
void *libopm_config(OPM_CONFIG_T *config, int key)
|
||||
{
|
||||
return config->vars[key];
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include "libopm.h"
|
||||
|
||||
typedef struct _opm_config_hash OPM_CONFIG_HASH_T;
|
||||
|
||||
struct _opm_config_hash {
|
||||
int key;
|
||||
int type;
|
||||
};
|
||||
|
||||
void libopm_config_free(OPM_CONFIG_T *);
|
||||
void *libopm_config(OPM_CONFIG_T *, int);
|
||||
int libopm_config_gettype(int);
|
||||
OPM_CONFIG_T *libopm_config_create(void);
|
||||
OPM_ERR_T libopm_config_set(OPM_CONFIG_T *, int , void *);
|
||||
|
||||
|
||||
#endif /* CONFIG_H */
|
542
libopm/inet.c
542
libopm/inet.c
|
@ -1,542 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2002 by the past and present ircd coders, and others.
|
||||
|
||||
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.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is borrowed from ircd-hybrid version 7
|
||||
* -TimeMr14C
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#if STDC_HEADERS
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "inet.h"
|
||||
#include "opm.h"
|
||||
|
||||
#ifndef INADDRSZ
|
||||
#define INADDRSZ 4
|
||||
#endif
|
||||
|
||||
#ifdef IPV6
|
||||
#ifndef IN6ADDRSZ
|
||||
#define IN6ADDRSZ 16
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INT16SZ
|
||||
#define INT16SZ 2
|
||||
#endif
|
||||
|
||||
#ifdef IPV6
|
||||
#define HOSTIPLEN 53
|
||||
#else
|
||||
#define HOSTIPLEN 15
|
||||
#endif
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
extern const unsigned char ToLowerTab[];
|
||||
#define ToLower(c) (ToLowerTab[(unsigned char)(c)])
|
||||
|
||||
/*
|
||||
* From: Thomas Helvey <tomh@inxpress.net>
|
||||
*/
|
||||
#if 0
|
||||
static const char *IpQuadTab[] = {
|
||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
|
||||
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
|
||||
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
|
||||
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
|
||||
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
|
||||
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
|
||||
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
|
||||
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
|
||||
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99",
|
||||
"100", "101", "102", "103", "104", "105", "106", "107", "108", "109",
|
||||
"110", "111", "112", "113", "114", "115", "116", "117", "118", "119",
|
||||
"120", "121", "122", "123", "124", "125", "126", "127", "128", "129",
|
||||
"130", "131", "132", "133", "134", "135", "136", "137", "138", "139",
|
||||
"140", "141", "142", "143", "144", "145", "146", "147", "148", "149",
|
||||
"150", "151", "152", "153", "154", "155", "156", "157", "158", "159",
|
||||
"160", "161", "162", "163", "164", "165", "166", "167", "168", "169",
|
||||
"170", "171", "172", "173", "174", "175", "176", "177", "178", "179",
|
||||
"180", "181", "182", "183", "184", "185", "186", "187", "188", "189",
|
||||
"190", "191", "192", "193", "194", "195", "196", "197", "198", "199",
|
||||
"200", "201", "202", "203", "204", "205", "206", "207", "208", "209",
|
||||
"210", "211", "212", "213", "214", "215", "216", "217", "218", "219",
|
||||
"220", "221", "222", "223", "224", "225", "226", "227", "228", "229",
|
||||
"230", "231", "232", "233", "234", "235", "236", "237", "238", "239",
|
||||
"240", "241", "242", "243", "244", "245", "246", "247", "248", "249",
|
||||
"250", "251", "252", "253", "254", "255"
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* inetntoa - in_addr to string
|
||||
* changed name to remove collision possibility and
|
||||
* so behaviour is guaranteed to take a pointer arg.
|
||||
* -avalon 23/11/92
|
||||
* inet_ntoa -- returned the dotted notation of a given
|
||||
* internet number
|
||||
* argv 11/90).
|
||||
* inet_ntoa -- its broken on some Ultrix/Dynix too. -avalon
|
||||
*
|
||||
* XXX - Again not used anywhere?
|
||||
* -grifferz
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static char *inetntoa(char *in)
|
||||
{
|
||||
static char buf[16];
|
||||
register char *bufptr = buf;
|
||||
register const unsigned char *a = (const unsigned char *) in;
|
||||
register const char *n;
|
||||
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a++];
|
||||
while (*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr++ = '.';
|
||||
n = IpQuadTab[*a];
|
||||
while (*n)
|
||||
*bufptr++ = *n++;
|
||||
*bufptr = '\0';
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX - this does not seem to be used anywhere currently.
|
||||
* -grifferz
|
||||
*/
|
||||
#if 0
|
||||
static const char *inet_ntop4(const u_char *src, char *dst, unsigned int size);
|
||||
#endif
|
||||
|
||||
#ifdef IPV6
|
||||
static const char *inet_ntop6(const u_char *src, char *dst, unsigned int size);
|
||||
#endif
|
||||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a u_char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*
|
||||
* XXX - this does not seem to be used anywhere currently.
|
||||
* -grifferz
|
||||
*/
|
||||
#if 0
|
||||
static const char *inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
|
||||
{
|
||||
if (size < 15)
|
||||
return NULL;
|
||||
return strcpy(dst, inetntoa((char *) src));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
#ifdef IPV6
|
||||
static const char *inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
|
||||
struct {
|
||||
int base, len;
|
||||
} best, cur;
|
||||
u_int words[IN6ADDRSZ / INT16SZ];
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof words);
|
||||
for (i = 0; i < IN6ADDRSZ; i += 2)
|
||||
words[i / 2] = (src[i] << 8) | src[i + 1];
|
||||
best.base = -1;
|
||||
cur.base = -1;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
|
||||
if (words[i] == 0) {
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
} else {
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
||||
/*
|
||||
* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base && i < (best.base + best.len)) {
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0)
|
||||
*tp++ = ':';
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 && (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
|
||||
if (!inet_ntop4(src + 12, tp, sizeof tmp - (tp - tmp)))
|
||||
return (NULL);
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
tp += sprintf(tp, "%x", words[i]);
|
||||
}
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
|
||||
*tp++ = ':';
|
||||
|
||||
*tp++ = '\0';
|
||||
|
||||
/*
|
||||
* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
|
||||
if ((tp - tmp) > size) {
|
||||
return (NULL);
|
||||
}
|
||||
return strcpy(dst, tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* This code doesn't seem to be used anywhere currently?
|
||||
* -grifferz
|
||||
*/
|
||||
|
||||
/* char *
|
||||
* inetntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *inetntop(int af, const void *src, char *dst, unsigned int size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_ntop4(src, dst, size));
|
||||
#ifdef IPV6
|
||||
case AF_INET6:
|
||||
if (IN6_IS_ADDR_V4MAPPED((const struct in6_addr *) src) ||
|
||||
IN6_IS_ADDR_V4COMPAT((const struct in6_addr *) src))
|
||||
return (inet_ntop4
|
||||
((unsigned char *) &((struct in6_addr *) src)->s6_addr[12], dst, size));
|
||||
else
|
||||
return (inet_ntop6(src, dst, size));
|
||||
|
||||
#endif
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
/* int
|
||||
* inet_pton(af, src, dst)
|
||||
* convert from presentation format (which usually means ASCII printable)
|
||||
* to network format (which is usually some kind of binary format).
|
||||
* return:
|
||||
* 1 if the address was valid for the specified address family
|
||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
|
||||
/* int
|
||||
* inet_pton4(src, dst)
|
||||
* like inet_aton() but without all the hexadecimal and shorthand.
|
||||
* return:
|
||||
* 1 if `src' is a valid dotted quad, else 0.
|
||||
* notice:
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
|
||||
static int inet_pton4(src, dst)
|
||||
const char *src;
|
||||
unsigned char *dst;
|
||||
{
|
||||
int saw_digit, octets, ch;
|
||||
unsigned char tmp[INADDRSZ], *tp;
|
||||
|
||||
saw_digit = 0;
|
||||
octets = 0;
|
||||
*(tp = tmp) = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
unsigned int new = *tp * 10 + (ch - '0');
|
||||
|
||||
if (new > 255)
|
||||
return (0);
|
||||
*tp = new;
|
||||
if (!saw_digit) {
|
||||
if (++octets > 4)
|
||||
return (0);
|
||||
saw_digit = 1;
|
||||
}
|
||||
} else if (ch == '.' && saw_digit) {
|
||||
if (octets == 4)
|
||||
return (0);
|
||||
*++tp = 0;
|
||||
saw_digit = 0;
|
||||
} else
|
||||
return (0);
|
||||
}
|
||||
if (octets < 4)
|
||||
return (0);
|
||||
memcpy(dst, tmp, INADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef IPV6
|
||||
/* int
|
||||
* inet_pton6(src, dst)
|
||||
* convert presentation level address to network order binary form.
|
||||
* return:
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* notice:
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* credit:
|
||||
* inspired by Mark Andrews.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
|
||||
static int inet_pton6(src, dst)
|
||||
const char *src;
|
||||
unsigned char *dst;
|
||||
{
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
|
||||
const char *curtok;
|
||||
int ch, saw_xdigit;
|
||||
unsigned int val;
|
||||
|
||||
tp = memset(tmp, '\0', IN6ADDRSZ);
|
||||
endp = tp + IN6ADDRSZ;
|
||||
colonp = NULL;
|
||||
/* Leading :: requires some special handling. */
|
||||
if (*src == ':')
|
||||
if (*++src != ':')
|
||||
return (0);
|
||||
curtok = src;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
while ((ch = ToLower(*src++)) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
pch = strchr(xdigits, ch);
|
||||
if (pch != NULL) {
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
if (ch == ':') {
|
||||
curtok = src;
|
||||
if (!saw_xdigit) {
|
||||
if (colonp)
|
||||
return (0);
|
||||
colonp = tp;
|
||||
continue;
|
||||
} else if (*src == '\0') {
|
||||
return (0);
|
||||
}
|
||||
if (tp + INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*src != '\0' && ch == '.') {
|
||||
if (((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) {
|
||||
tp += INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
} else
|
||||
continue;
|
||||
return (0);
|
||||
}
|
||||
if (saw_xdigit) {
|
||||
if (tp + INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
}
|
||||
if (colonp != NULL) {
|
||||
/*
|
||||
* Since some memmove()'s erroneously fail to handle
|
||||
* overlapping regions, we'll do the shift by hand.
|
||||
*/
|
||||
const int n = tp - colonp;
|
||||
int i;
|
||||
|
||||
if (tp == endp)
|
||||
return (0);
|
||||
for (i = 1; i <= n; i++) {
|
||||
endp[-i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
}
|
||||
tp = endp;
|
||||
}
|
||||
if (tp != endp)
|
||||
return (0);
|
||||
memcpy(dst, tmp, IN6ADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
#endif /* IPv6 */
|
||||
|
||||
int inet_pton(af, src, dst)
|
||||
int af;
|
||||
const char *src;
|
||||
void *dst;
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_pton4(src, dst));
|
||||
#ifdef IPV6
|
||||
case AF_INET6:
|
||||
/* Somebody might have passed as an IPv4 address this is sick but it works */
|
||||
if (inet_pton4(src, dst)) {
|
||||
char tmp[HOSTIPLEN];
|
||||
sprintf(tmp, "::ffff:%s", src);
|
||||
return (inet_pton6(tmp, dst));
|
||||
} else
|
||||
return (inet_pton6(src, dst));
|
||||
#endif /* IPv6 */
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,44 +0,0 @@
|
|||
#ifndef INET_H
|
||||
#define INET_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
#ifndef AF_INET6
|
||||
# define AF_INET6 10
|
||||
#endif
|
||||
|
||||
typedef struct _opm_sockaddr opm_sockaddr;
|
||||
typedef struct _opm_inaddr opm_inaddr;
|
||||
|
||||
struct _opm_sockaddr {
|
||||
struct sockaddr_in sa4;
|
||||
};
|
||||
|
||||
struct _opm_inaddr {
|
||||
struct in_addr in4;
|
||||
};
|
||||
|
||||
#ifndef HAVE_INET_PTON
|
||||
extern int inet_pton(int, const char *, void *);
|
||||
#endif
|
||||
extern const char *inetntop(int, const void *, char *, unsigned int);
|
||||
extern struct hostent *opm_gethostbyname(const char *);
|
||||
|
||||
|
||||
#endif /* INET_H */
|
1577
libopm/libopm.c
1577
libopm/libopm.c
File diff suppressed because it is too large
Load diff
|
@ -1,59 +0,0 @@
|
|||
#ifndef LIBOPM_H
|
||||
#define LIBOPM_H
|
||||
|
||||
#include <neostats.h>
|
||||
#include "config.h"
|
||||
#include "inet.h"
|
||||
#include "opm_common.h"
|
||||
#include "opm.h"
|
||||
|
||||
#define CBLEN 5 /* Number of callback functions */
|
||||
#define READBUFLEN 128 /* Size of conn->readbuf */
|
||||
#define SENDBUFLEN 512 /* Size of sendbuffer in proxy.c */
|
||||
|
||||
typedef struct _OPM_SCAN OPM_SCAN_T;
|
||||
typedef struct _OPM_CONNECTION OPM_CONNECTION_T;
|
||||
typedef struct _OPM_PROTOCOL_CONFIG OPM_PROTOCOL_CONFIG_T;
|
||||
typedef struct _OPM_PROTOCOL OPM_PROTOCOL_T;
|
||||
|
||||
/* Types of hard coded proxy READ/WRITE functions which are
|
||||
setup in a table in libopm.c */
|
||||
|
||||
typedef int OPM_PROXYWRITE_T (OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
typedef int OPM_PROXYREAD_T (OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
|
||||
struct _OPM_SCAN {
|
||||
opm_sockaddr addr; /* Address in byte order of remote client */
|
||||
OPM_REMOTE_T *remote; /* Pointed to the OPM_REMOTE_T for this scan, passed by client */
|
||||
OPM_LIST_T *connections; /* List of individual connections of this scan (1 for each protocol) */
|
||||
};
|
||||
|
||||
struct _OPM_CONNECTION {
|
||||
|
||||
OPM_PROTOCOL_T *protocol; /* Pointer to specific protocol this connection handles */
|
||||
unsigned short int port; /* Some protocols have multiple ports, eg. HTTP */
|
||||
Sock *Sock;
|
||||
int fd; /* Allocated file descriptor, 0 if not yet allocated */
|
||||
unsigned short int bytes_read; /* Bytes read so far in this connection */
|
||||
char readbuf[READBUFLEN + 1]; /* 128 byte read buffer, anything over 128 is probably not of use */
|
||||
unsigned short int readlen; /* Length of readbuf */
|
||||
unsigned short int state; /* State of connection */
|
||||
time_t creation; /* When this connection was established */
|
||||
};
|
||||
|
||||
struct _OPM_PROTOCOL_CONFIG
|
||||
{
|
||||
OPM_PROTOCOL_T *type; /* Protocol type */
|
||||
unsigned short int port; /* Port to connect on */
|
||||
|
||||
};
|
||||
|
||||
struct _OPM_PROTOCOL
|
||||
{
|
||||
int type; /* Protocol type */
|
||||
|
||||
OPM_PROXYWRITE_T *write_function; /* Write function handler for this protocol */
|
||||
OPM_PROXYREAD_T *read_function; /* Read function handler for this protocol */
|
||||
};
|
||||
|
||||
#endif /* LIBOPM_H */
|
|
@ -1,170 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="libopm"
|
||||
ProjectGUID="{C41CD6E3-30A4-4BB9-BA51-F97B2CD77D56}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/libopm.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="TRUE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/libopm.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\compat.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\config.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inet.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libopm.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\list.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\malloc.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\proxy.c">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\compat.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\config.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\inet.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\libopm.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\list.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\malloc.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\opm.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\opm_common.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\opm_error.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\opm_types.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\proxy.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2002 Erik Fears
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "opm.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
|
||||
/* MyMalloc
|
||||
*
|
||||
* A wrapper function for malloc(), for catching memory issues
|
||||
* and error handling.
|
||||
*
|
||||
* Parameters
|
||||
* bytes: amount in bytes to allocate
|
||||
*
|
||||
* Return:
|
||||
* Pointer to allocated memory
|
||||
*/
|
||||
|
||||
void *libopm_MyMalloc(size_t bytes)
|
||||
{
|
||||
void *ret = calloc(1, bytes);
|
||||
|
||||
assert(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* MyFree
|
||||
*
|
||||
* Free memory allocated with MyMalloc
|
||||
*
|
||||
* Parameters:
|
||||
* var: pointer to memory to free
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*/
|
||||
|
||||
void libopm_MyFree(void **var)
|
||||
{
|
||||
if(*var != NULL)
|
||||
free(*var);
|
||||
*var = NULL;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
#ifndef MALLOC_H
|
||||
#define MALLOC_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define MyMalloc(SIZE) libopm_MyMalloc(SIZE)
|
||||
#define MyFree(X) libopm_MyFree((void **) &X)
|
||||
|
||||
void *libopm_MyMalloc(size_t bytes);
|
||||
void libopm_MyFree(void **var);
|
||||
|
||||
#endif /* MALLOC_H */
|
88
libopm/opm.h
88
libopm/opm.h
|
@ -1,88 +0,0 @@
|
|||
/* vim: set shiftwidth=3 softtabstop=3 expandtab: */
|
||||
|
||||
/** \file opm.h
|
||||
* \brief Main header for libopm.
|
||||
* \author Erik Fears
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
#ifndef OPM_H
|
||||
#define OPM_H
|
||||
|
||||
#include "opm_common.h"
|
||||
#ifndef WIN32
|
||||
#include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Stuff to shut up warnings about rcsid being unused. */
|
||||
#define USE_VAR(var) static char sizeof##var = sizeof(sizeof##var) + sizeof(var)
|
||||
/* RCS tag. */
|
||||
#define RCSID(x) static char rcsid[] = x; USE_VAR(rcsid);
|
||||
|
||||
|
||||
typedef struct _OPM_CONFIG OPM_CONFIG_T;
|
||||
typedef struct _OPM OPM_T;
|
||||
typedef struct _OPM_REMOTE OPM_REMOTE_T;
|
||||
typedef struct _OPM_CALLBACK OPM_CALLBACK_T;
|
||||
|
||||
typedef int OPM_ERR_T;
|
||||
|
||||
typedef void OPM_CALLBACK_FUNC (OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
|
||||
struct _OPM_CALLBACK {
|
||||
OPM_CALLBACK_FUNC *func;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct _OPM_CONFIG {
|
||||
void **vars;
|
||||
};
|
||||
|
||||
struct _OPM {
|
||||
OPM_CONFIG_T *config; /* Individual scanner configuration */
|
||||
OPM_LIST_T *queue; /* List of scans in the queue (not yet established) */
|
||||
OPM_LIST_T *scans; /* List of scans (each scan containing a list of connections) */
|
||||
OPM_LIST_T *protocols; /* List of protocols this scanner handles */
|
||||
unsigned int fd_use; /* Number of file descriptors in use */
|
||||
|
||||
OPM_CALLBACK_T *callbacks; /* Scanner wide callbacks */
|
||||
};
|
||||
|
||||
struct _OPM_REMOTE {
|
||||
|
||||
char *ip; /* Readable IP address */
|
||||
|
||||
unsigned short int port; /* Port passed back on certain callbacks */
|
||||
unsigned short int protocol; /* Protocol passed back on certain callbacks */
|
||||
unsigned short int bytes_read; /* Bytes read passed back on certain callbacks */
|
||||
|
||||
OPM_LIST_T *protocols; /* Remote specific protocols */
|
||||
|
||||
void *data; /* Arbitrary data that the client can point to for any purpose*/
|
||||
};
|
||||
|
||||
OPM_T *opm_create(void);
|
||||
void opm_free(OPM_T *);
|
||||
|
||||
OPM_REMOTE_T *opm_remote_create(const char *);
|
||||
void opm_remote_free(OPM_REMOTE_T *);
|
||||
|
||||
OPM_ERR_T opm_config(OPM_T *, int, void *);
|
||||
OPM_ERR_T opm_scan(OPM_T *, OPM_REMOTE_T *);
|
||||
void opm_end(OPM_T *, OPM_REMOTE_T *);
|
||||
void opm_endscan(OPM_T *, OPM_REMOTE_T *);
|
||||
|
||||
OPM_ERR_T opm_addtype(OPM_T *, int, unsigned short int);
|
||||
OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *, int, unsigned short int);
|
||||
OPM_ERR_T opm_callback(OPM_T *, int, OPM_CALLBACK_FUNC *, void *);
|
||||
|
||||
void opm_cycle(OPM_T *);
|
||||
typedef struct pollfd pollfd;
|
||||
|
||||
void libopm_after_poll(OPM_T *, pollfd *, unsigned int );
|
||||
int libopm_before_poll(OPM_T *, pollfd *);
|
||||
|
||||
|
||||
size_t opm_active(OPM_T *);
|
||||
|
||||
#endif /* OPM_H */
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef OPM_COMMON_H
|
||||
#define OPM_COMMON_H
|
||||
|
||||
typedef struct _libopm_node OPM_NODE_T;
|
||||
typedef struct _libopm_list OPM_LIST_T;
|
||||
|
||||
|
||||
struct _libopm_list {
|
||||
|
||||
struct _libopm_node *head;
|
||||
struct _libopm_node *tail;
|
||||
|
||||
int elements;
|
||||
};
|
||||
|
||||
struct _libopm_node {
|
||||
|
||||
struct _libopm_node *next;
|
||||
struct _libopm_node *prev;
|
||||
|
||||
void *data;
|
||||
};
|
||||
|
||||
#endif /* OPM_COMMON_H */
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef LIBOPM_ERROR_H
|
||||
#define LIBOPM_ERROR_H
|
||||
|
||||
/* Success */
|
||||
#define OPM_SUCCESS 1
|
||||
|
||||
/* Configuration Errors */
|
||||
#define OPM_ERR_BADKEY 2 /* Unknown or bad key value */
|
||||
#define OPM_ERR_BADVALUE 3 /* Bad value matching key */
|
||||
#define OPM_ERR_BADPROTOCOL 4 /* Unknown protocol in config */
|
||||
|
||||
/* Read Errors */
|
||||
#define OPM_ERR_MAX_READ 5 /* Socket reached MAX_READ */
|
||||
|
||||
/* Callback Registration Errors */
|
||||
#define OPM_ERR_CBNOTFOUND 6 /* Callback is out of range */
|
||||
|
||||
/* opm_scan errors */
|
||||
#define OPM_ERR_BADADDR 7 /* IP in remote struct is bad */
|
||||
#define OPM_ERR_NOPROTOCOLS 8 /* No protocols to scan! */
|
||||
|
||||
/* bind/connect errors */
|
||||
#define OPM_ERR_BIND 9 /* Error binding to BIND_IP */
|
||||
#define OPM_ERR_NOFD 10/* Unable to allocate file descriptor */
|
||||
|
||||
#endif /* LIBOPM_ERROR_H */
|
|
@ -1,44 +0,0 @@
|
|||
#ifndef OPM_TYPES_H
|
||||
#define OPM_TYPES_H
|
||||
|
||||
/* Configuration Directives */
|
||||
#define OPM_CONFIG_FD_LIMIT 0
|
||||
#define OPM_CONFIG_BIND_IP 1
|
||||
#define OPM_CONFIG_DNSBL_HOST 2
|
||||
#define OPM_CONFIG_TARGET_STRING 3
|
||||
#define OPM_CONFIG_SCAN_IP 4
|
||||
#define OPM_CONFIG_SCAN_PORT 5
|
||||
#define OPM_CONFIG_MAX_READ 6
|
||||
#define OPM_CONFIG_TIMEOUT 7
|
||||
|
||||
/* Configuration Variable Types */
|
||||
#define OPM_TYPE_INT 1
|
||||
#define OPM_TYPE_STRING 2
|
||||
#define OPM_TYPE_ADDRESS 3
|
||||
#define OPM_TYPE_STRINGLIST 4
|
||||
|
||||
/* Protocols */
|
||||
#define OPM_TYPE_HTTP 1
|
||||
#define OPM_TYPE_SOCKS4 2
|
||||
#define OPM_TYPE_SOCKS5 3
|
||||
#define OPM_TYPE_WINGATE 4
|
||||
#define OPM_TYPE_ROUTER 5
|
||||
#define OPM_TYPE_HTTPPOST 6
|
||||
|
||||
/* States */
|
||||
#define OPM_STATE_UNESTABLISHED 1
|
||||
#define OPM_STATE_ESTABLISHED 2
|
||||
#define OPM_STATE_NEGSENT 3
|
||||
#define OPM_STATE_CLOSED 4
|
||||
|
||||
|
||||
/* Callbacks -- If more callback types are added,
|
||||
CBLEN will need to be changed in libopm.h accordingly */
|
||||
|
||||
#define OPM_CALLBACK_OPENPROXY 0 /* An open proxy has been found REMOTE/SCANNER */
|
||||
#define OPM_CALLBACK_NEGFAIL 1 /* Negotiation to a proxy has failed REMOTE/SCANNER */
|
||||
#define OPM_CALLBACK_END 2 /* A scan has ended REMOTE/SCANNER */
|
||||
#define OPM_CALLBACK_ERROR 3 /* An unrecoverable error has occured */
|
||||
#define OPM_CALLBACK_TIMEOUT 4 /* Specific scan (protocol) on host has timed out */
|
||||
|
||||
#endif /* OPM_TYPES_H */
|
123
libopm/opmlist.c
123
libopm/opmlist.c
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2002-2003 Erik Fears
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "opm_common.h"
|
||||
#include "opmlist.h"
|
||||
#include "malloc.h"
|
||||
#include "opm.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
OPM_NODE_T *libopm_node_create(void *data)
|
||||
{
|
||||
OPM_NODE_T *node = MyMalloc(sizeof *node);
|
||||
node->next = NULL;
|
||||
node->prev = NULL;
|
||||
node->data = (void *) data;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
OPM_LIST_T *libopm_list_create()
|
||||
{
|
||||
OPM_LIST_T *list = MyMalloc(sizeof *list);
|
||||
|
||||
list->head = NULL;
|
||||
list->tail = NULL;
|
||||
|
||||
list->elements = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
OPM_NODE_T *libopm_list_add(OPM_LIST_T *list, OPM_NODE_T *node)
|
||||
{
|
||||
|
||||
if(list == NULL || node == NULL)
|
||||
return NULL;
|
||||
|
||||
if(list->tail == NULL)
|
||||
{
|
||||
list->head = node;
|
||||
list->tail = node;
|
||||
|
||||
node->next = NULL;
|
||||
node->prev = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->prev = list->tail;
|
||||
list->tail->next = node;
|
||||
list->tail = node;
|
||||
node->next = NULL;
|
||||
}
|
||||
|
||||
list->elements++;
|
||||
return node;
|
||||
}
|
||||
|
||||
OPM_NODE_T *libopm_list_remove(OPM_LIST_T *list, OPM_NODE_T *node)
|
||||
{
|
||||
|
||||
if(list == NULL || node == NULL)
|
||||
return NULL;
|
||||
|
||||
if(node == list->head)
|
||||
{
|
||||
list->head = node->next;
|
||||
|
||||
if(node->next)
|
||||
node->next->prev = NULL;
|
||||
else
|
||||
list->tail = NULL;
|
||||
}
|
||||
else if(node == list->tail)
|
||||
{
|
||||
list->tail = list->tail->prev;
|
||||
list->tail->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
|
||||
list->elements--;
|
||||
return node;
|
||||
}
|
||||
|
||||
void libopm_list_free(OPM_LIST_T *list)
|
||||
{
|
||||
MyFree(list);
|
||||
}
|
||||
|
||||
void libopm_node_free(OPM_NODE_T *node)
|
||||
{
|
||||
MyFree(node);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef OPMLIST_H
|
||||
#define OPMLIST_H
|
||||
|
||||
|
||||
/* Copyright (C) 2002 by the past and present ircd coders, and others.
|
||||
* Adapted from Hybrid7 DLINK macros
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#define LIST_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next)
|
||||
#define LIST_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL)
|
||||
#define LIST_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev)
|
||||
#define LIST_SIZE(list) list->elements
|
||||
/* End Copyright */
|
||||
|
||||
OPM_NODE_T *libopm_node_create(void *);
|
||||
OPM_LIST_T *libopm_list_create(void);
|
||||
|
||||
OPM_NODE_T *libopm_list_add(OPM_LIST_T *, OPM_NODE_T *);
|
||||
OPM_NODE_T *libopm_list_remove(OPM_LIST_T *, OPM_NODE_T *);
|
||||
|
||||
void libopm_list_free(OPM_LIST_T *);
|
||||
void libopm_node_free(OPM_NODE_T *);
|
||||
|
||||
#endif /* LIST_H */
|
250
libopm/proxy.c
250
libopm/proxy.c
|
@ -1,250 +0,0 @@
|
|||
/* vim: set shiftwidth=3 softtabstop=3 expandtab: */
|
||||
|
||||
/* Copyright (C) 2002 Erik Fears
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "modconfigwin32.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#include "inet.h"
|
||||
#include "compat.h"
|
||||
#include "config.h"
|
||||
#include "proxy.h"
|
||||
#include "opm_common.h"
|
||||
#include "opm_types.h"
|
||||
#include "opm_error.h"
|
||||
#include "libopm.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
static char SENDBUF[SENDBUFLEN + 1];
|
||||
|
||||
int libopm_proxy_http_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
USE_VAR(scan);
|
||||
|
||||
snprintf(SENDBUF, SENDBUFLEN, "CONNECT %s:%d HTTP/1.0\r\n\r\n",
|
||||
(char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP),
|
||||
*(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT));
|
||||
|
||||
if(send(conn->fd, SENDBUF, strlen(SENDBUF), 0) == -1)
|
||||
return 0; /* Return error code ? */
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CONNECT request byte order for socks4
|
||||
*
|
||||
* +----+----+----+----+----+----+----+----+----+----+....+----+
|
||||
* | VN | CD | DSTPORT | DSTIP | USERID |NULL|
|
||||
* +----+----+----+----+----+----+----+----+----+----+....+----+
|
||||
* # of bytes: 1 1 2 4 variable 1
|
||||
*
|
||||
* VN = Version, CD = Command Code (1 is connect request)
|
||||
*/
|
||||
|
||||
int libopm_proxy_socks4_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
struct in_addr addr;
|
||||
unsigned long laddr;
|
||||
int len, scan_port;
|
||||
char *scan_ip;
|
||||
USE_VAR(scan);
|
||||
|
||||
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
|
||||
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
|
||||
|
||||
laddr = htonl(addr.s_addr);
|
||||
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c%c%c%c%c%c%c", 4, 1,
|
||||
(((unsigned short) scan_port) >> 8) & 0xFF,
|
||||
(((unsigned short) scan_port) & 0xFF),
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF, 0);
|
||||
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send version authentication selection message to socks5
|
||||
*
|
||||
* +----+----------+----------+
|
||||
* |VER | NMETHODS | METHODS |
|
||||
* +----+----------+----------+
|
||||
* | 1 | 1 | 1 to 255 |
|
||||
* +----+----------+----------+
|
||||
*
|
||||
* VER always contains 5, for socks version 5
|
||||
* Method 0 is 'No authentication required'
|
||||
*
|
||||
*
|
||||
*
|
||||
* The SOCKS request is formed as follows:
|
||||
*
|
||||
* +----+-----+-------+------+----------+----------+
|
||||
* |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |
|
||||
* +----+-----+-------+------+----------+----------+
|
||||
* | 1 | 1 | X'00' | 1 | Variable | 2 |
|
||||
* +----+-----+-------+------+----------+----------+
|
||||
*
|
||||
*
|
||||
* o VER protocol version: X'05'
|
||||
* o CMD
|
||||
* o CONNECT X'01'
|
||||
* o BIND X'02'
|
||||
* o UDP ASSOCIATE X'03'
|
||||
* o RSV RESERVED
|
||||
* o ATYP address type of following address
|
||||
* o IP V4 address: X'01'
|
||||
* o DOMAINNAME: X'03'
|
||||
* o IP V6 address: X'04'
|
||||
* o DST.ADDR desired destination address
|
||||
* o DST.PORT desired destination port in network octet
|
||||
* order
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
int libopm_proxy_socks5_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
struct in_addr addr;
|
||||
unsigned long laddr;
|
||||
int len, scan_port;
|
||||
char *scan_ip;
|
||||
USE_VAR(scan);
|
||||
|
||||
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
|
||||
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
|
||||
|
||||
if (inet_aton(scan_ip, &addr) == 0)
|
||||
; /* handle error */
|
||||
|
||||
laddr = htonl(addr.s_addr);
|
||||
|
||||
/* Form authentication string */
|
||||
/* Version 5, 1 number of methods, 0 method (no auth). */
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c", 5, 1, 0);
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
/* Form request string */
|
||||
|
||||
/* Will need to write ipv6 support here in future
|
||||
* as socks5 is ipv6 compatible
|
||||
*/
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "%c%c%c%c%c%c%c%c%c%c", 5, 1, 0, 1,
|
||||
(char) (laddr >> 24) & 0xFF, (char) (laddr >> 16) & 0xFF,
|
||||
(char) (laddr >> 8) & 0xFF, (char) laddr & 0xFF,
|
||||
(((unsigned short) scan_port) >> 8) & 0xFF,
|
||||
(((unsigned short) scan_port) & 0xFF));
|
||||
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Open wingates require no authentication, they will send a prompt when
|
||||
* connect.
|
||||
*/
|
||||
|
||||
int libopm_proxy_wingate_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
int scan_port, len;
|
||||
char *scan_ip;
|
||||
USE_VAR(scan);
|
||||
|
||||
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
|
||||
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
|
||||
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "%s:%d\r\n", scan_ip, scan_port);
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Cisco scanning
|
||||
*
|
||||
* Some cisco routers have 'cisco' set as password which allow open telnet
|
||||
* relay. Attempt to connect using cisco as a password, then give command for
|
||||
* telnet to the scanip/scanport
|
||||
*/
|
||||
|
||||
int libopm_proxy_router_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
int len, scan_port;
|
||||
char *scan_ip;
|
||||
USE_VAR(scan);
|
||||
|
||||
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
|
||||
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
|
||||
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "cisco\r\n");
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "telnet %s %d\r\n", scan_ip, scan_port);
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HTTP POST Scanning
|
||||
*
|
||||
*/
|
||||
|
||||
int libopm_proxy_httppost_write(OPM_T *scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
|
||||
{
|
||||
int len, scan_port;
|
||||
char *scan_ip;
|
||||
USE_VAR(scan);
|
||||
|
||||
scan_ip = (char *) libopm_config(scanner->config, OPM_CONFIG_SCAN_IP);
|
||||
scan_port = *(int *) libopm_config(scanner->config, OPM_CONFIG_SCAN_PORT);
|
||||
|
||||
len = snprintf(SENDBUF, SENDBUFLEN, "POST http://%s:%d/ HTTP/1.0\r\n"
|
||||
"Content-type: text/plain\r\n"
|
||||
"Content-length: 5\r\n\r\n"
|
||||
"quit\r\n\r\n",
|
||||
scan_ip, scan_port);
|
||||
|
||||
send(conn->fd, SENDBUF, (unsigned int)len, 0);
|
||||
|
||||
return OPM_SUCCESS;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef PROXY_H
|
||||
#define PROXY_H
|
||||
|
||||
#include "libopm.h"
|
||||
|
||||
int libopm_proxy_http_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
int libopm_proxy_socks4_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
int libopm_proxy_socks5_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
int libopm_proxy_wingate_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
int libopm_proxy_router_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
int libopm_proxy_httppost_write(OPM_T *, OPM_SCAN_T *, OPM_CONNECTION_T *);
|
||||
|
||||
|
||||
#endif /* PROXY_H */
|
248
libopm/test.c
248
libopm/test.c
|
@ -1,248 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2002 Erik Fears
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "opm.h"
|
||||
#include "opm_error.h"
|
||||
#include "opm_types.h"
|
||||
#include "compat.h"
|
||||
#include <sys/poll.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
RCSID("$Id: test.c,v 1.36 2003/06/20 04:55:14 andy Exp $");
|
||||
|
||||
#define ARRAY_SIZEOF(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
void open_proxy(OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
void negotiation_failed(OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
void timeout(OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
void end(OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
void handle_error(OPM_T *, OPM_REMOTE_T *, int, void *);
|
||||
|
||||
int complete = 0;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OPM_ERR_T err;
|
||||
int fdlimit = 1024;
|
||||
int scan_port = 6667;
|
||||
int max_read = 4096;
|
||||
int scantimeout = 10;
|
||||
struct pollfd *ufds;
|
||||
unsigned int size;
|
||||
unsigned int i, s;
|
||||
|
||||
unsigned short http_ports[] = {
|
||||
8000, 8080, 3128, 80
|
||||
};
|
||||
|
||||
unsigned short wingate_ports[] = {
|
||||
23
|
||||
};
|
||||
|
||||
unsigned short router_ports[] = {
|
||||
23
|
||||
};
|
||||
|
||||
unsigned short socks4_ports[] = {
|
||||
1080
|
||||
};
|
||||
|
||||
unsigned short socks5_ports[] = {
|
||||
1080
|
||||
};
|
||||
|
||||
unsigned short httppost_ports[] = {
|
||||
80, 8090, 3128
|
||||
};
|
||||
|
||||
OPM_T *scanner;
|
||||
OPM_REMOTE_T *remote;
|
||||
|
||||
scanner = opm_create();
|
||||
|
||||
if(argc >= 2)
|
||||
remote = opm_remote_create(argv[1]);
|
||||
else
|
||||
remote = opm_remote_create("127.0.0.1");
|
||||
|
||||
/* Setup callbacks */
|
||||
opm_callback(scanner, OPM_CALLBACK_OPENPROXY, &open_proxy, NULL);
|
||||
opm_callback(scanner, OPM_CALLBACK_NEGFAIL, &negotiation_failed, NULL);
|
||||
opm_callback(scanner, OPM_CALLBACK_TIMEOUT, &timeout, NULL);
|
||||
opm_callback(scanner, OPM_CALLBACK_END, &end, NULL);
|
||||
opm_callback(scanner, OPM_CALLBACK_ERROR, &handle_error, NULL);
|
||||
|
||||
|
||||
/* Setup the scanner configuration */
|
||||
opm_config(scanner, OPM_CONFIG_FD_LIMIT, &fdlimit);
|
||||
opm_config(scanner, OPM_CONFIG_SCAN_IP, "216.175.104.202");
|
||||
opm_config(scanner, OPM_CONFIG_SCAN_PORT, &scan_port);
|
||||
opm_config(scanner, OPM_CONFIG_TARGET_STRING, "*** Looking up your hostname...");
|
||||
opm_config(scanner, OPM_CONFIG_TARGET_STRING, "ERROR :Trying to reconnect too fast.");
|
||||
opm_config(scanner, OPM_CONFIG_TIMEOUT, &scantimeout);
|
||||
opm_config(scanner, OPM_CONFIG_MAX_READ, &max_read);
|
||||
|
||||
/* Setup the protocol configuration */
|
||||
for (s = ARRAY_SIZEOF(http_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_HTTP, http_ports[i]);
|
||||
}
|
||||
|
||||
for (s = ARRAY_SIZEOF(wingate_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_WINGATE, wingate_ports[i]);
|
||||
}
|
||||
|
||||
for (s = ARRAY_SIZEOF(router_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_ROUTER, router_ports[i]);
|
||||
}
|
||||
|
||||
for (s = ARRAY_SIZEOF(socks4_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_SOCKS4, socks4_ports[i]);
|
||||
}
|
||||
|
||||
for (s = ARRAY_SIZEOF(socks5_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_SOCKS5, socks5_ports[i]);
|
||||
}
|
||||
|
||||
for (s = ARRAY_SIZEOF(httppost_ports), i = 0; i < s; i++) {
|
||||
opm_addtype(scanner, OPM_TYPE_HTTPPOST, httppost_ports[i]);
|
||||
}
|
||||
|
||||
/* Remote structs can also have their own extended protocol configurations. For instance
|
||||
if the target hostname contains strings such as 'proxy' or 'www', extended ports could
|
||||
be scanned. */
|
||||
opm_remote_addtype(remote, OPM_TYPE_HTTP, 8001);
|
||||
opm_remote_addtype(remote, OPM_TYPE_HTTP, 8002);
|
||||
|
||||
switch(err = opm_scan(scanner, remote))
|
||||
{
|
||||
case OPM_SUCCESS:
|
||||
break;
|
||||
case OPM_ERR_BADADDR:
|
||||
printf("Bad address\n");
|
||||
opm_free(scanner);
|
||||
opm_remote_free(remote);
|
||||
return 0;
|
||||
default:
|
||||
printf("Unknown Error %d\n", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (!complete) {
|
||||
ufds = malloc((sizeof *ufds) * (*(unsigned int *) libopm_config(scanner->config, OPM_CONFIG_FD_LIMIT)));
|
||||
size = libopm_before_poll(scanner, ufds);
|
||||
|
||||
err = poll(ufds, size, 0);
|
||||
switch (err)
|
||||
{
|
||||
case -1:
|
||||
/* error in select/poll */
|
||||
printf("poll barked\n");
|
||||
return;
|
||||
case 0:
|
||||
/* Nothing to do */
|
||||
continue;
|
||||
default:
|
||||
libopm_after_poll(scanner, ufds, size);
|
||||
continue;
|
||||
|
||||
/* Pass pointer to connection to handler. */
|
||||
}
|
||||
}
|
||||
opm_free(scanner);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused,
|
||||
void *data)
|
||||
{
|
||||
USE_VAR(notused);
|
||||
USE_VAR(data);
|
||||
|
||||
printf("Open proxy on %s:%d [%d bytes read]\n", remote->ip,
|
||||
remote->port, remote->bytes_read);
|
||||
opm_end(scanner, remote);
|
||||
}
|
||||
|
||||
void negotiation_failed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused,
|
||||
void *data)
|
||||
{
|
||||
USE_VAR(scanner);
|
||||
USE_VAR(notused);
|
||||
USE_VAR(data);
|
||||
|
||||
printf("Negotiation on %s:%d failed [%d bytes read]\n", remote->ip,
|
||||
remote->port, remote->bytes_read);
|
||||
}
|
||||
|
||||
void timeout(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)
|
||||
{
|
||||
USE_VAR(scanner);
|
||||
USE_VAR(notused);
|
||||
USE_VAR(data);
|
||||
|
||||
printf("Negotiation timed out on %s:%d\n", remote->ip, remote->port);
|
||||
}
|
||||
|
||||
void end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *data)
|
||||
{
|
||||
USE_VAR(scanner);
|
||||
USE_VAR(notused);
|
||||
USE_VAR(data);
|
||||
|
||||
printf("Scan on %s has ended\n", remote->ip);
|
||||
opm_remote_free(remote);
|
||||
complete = 1;
|
||||
}
|
||||
|
||||
void handle_error(OPM_T *scanner, OPM_REMOTE_T *remote, int err, void *data)
|
||||
{
|
||||
USE_VAR(scanner);
|
||||
USE_VAR(data);
|
||||
|
||||
switch(err)
|
||||
{
|
||||
case OPM_ERR_MAX_READ:
|
||||
printf("Reached MAX READ on %s:%d\n", remote->ip, remote->port);
|
||||
break;
|
||||
case OPM_ERR_BIND:
|
||||
printf("Unable to bind for %s:%d\n", remote->ip, remote->port);
|
||||
break;
|
||||
case OPM_ERR_NOFD:
|
||||
printf("Unable to allocate file descriptor for %s:%d\n",
|
||||
remote->ip, remote->port);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown error on %s:%d, err = %d\n", remote->ip,
|
||||
remote->port, err);
|
||||
}
|
||||
}
|
Reference in a new issue