Adding Max Kastanas's fwknop client app code for Android
git-svn-id: file:///home/mbr/svn/fwknop/trunk@309 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
33
Makefile.am
33
Makefile.am
@@ -15,6 +15,39 @@ SUBDIRS = \
|
||||
doc
|
||||
|
||||
EXTRA_DIST = \
|
||||
android/COPYING \
|
||||
android/Application.mk \
|
||||
android/README \
|
||||
android/project/src/com/max2idea/android/fwknop/R.java \
|
||||
android/project/src/com/max2idea/android/fwknop/Fwknop.java \
|
||||
android/project/build.xml \
|
||||
android/project/default.properties \
|
||||
android/project/res/values/strings.xml \
|
||||
android/project/res/drawable-hdpi/icon.png \
|
||||
android/project/res/drawable-mdpi/icon.png \
|
||||
android/project/res/drawable-ldpi/icon.png \
|
||||
android/project/res/drawable/lock_64x64.png \
|
||||
android/project/res/drawable/lock_32x32.png \
|
||||
android/project/res/drawable/lock_128x128.png \
|
||||
android/project/res/layout/main.xml \
|
||||
android/project/nbproject/project.properties \
|
||||
android/project/nbproject/project.xml \
|
||||
android/project/nbproject/build-impl.xml \
|
||||
android/project/nbproject/private/private.properties \
|
||||
android/project/nbproject/private/private.xml \
|
||||
android/project/nbproject/private/config.properties \
|
||||
android/project/nbproject/genfiles.properties \
|
||||
android/project/build.properties \
|
||||
android/project/assets \
|
||||
android/project/AndroidManifest.xml \
|
||||
android/project/jni/fwknop/fwknop_client.c \
|
||||
android/project/jni/fwknop/fwknop_client.h \
|
||||
android/project/jni/fwknop/send_spa_packet.c \
|
||||
android/project/jni/config.h \
|
||||
android/project/jni/libfwknop/README \
|
||||
android/project/jni/libfwknop/get_libfko_files.sh \
|
||||
android/project/jni/logutils.h \
|
||||
android/project/jni/Android.mk \
|
||||
extras/fwknop.init.debian \
|
||||
extras/fwknop.init.openwrt \
|
||||
extras/fwknop.init.redhat \
|
||||
|
||||
2
android/Application.mk
Normal file
2
android/Application.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
APP_PROJECT_PATH := $(call my-dir)/project
|
||||
APP_MODULES := libfwknop
|
||||
674
android/COPYING
Normal file
674
android/COPYING
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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) <year> <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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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 Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
142
android/README
Normal file
142
android/README
Normal file
@@ -0,0 +1,142 @@
|
||||
===============================================================================
|
||||
FWKNOP for Android
|
||||
|
||||
Max Kastanas <max2idea@users.sourceforge.net>
|
||||
|
||||
Based on fwknop C implementation by Damien Stuart
|
||||
===============================================================================
|
||||
|
||||
1. Requirements:
|
||||
|
||||
a. Apache Ant (1.7.1)
|
||||
http://ant.apache.org/bindownload.cgi
|
||||
|
||||
b. Android NDK (Android r5-linux)
|
||||
http://developer.android.com/sdk/ndk/index.html
|
||||
Unzip the contents under a directory ie:
|
||||
/home/yourname/tools/android-sdk-linux_86
|
||||
|
||||
c. Android SDK (Android r08-linux)
|
||||
http://developer.android.com/sdk/index.html
|
||||
Unzip the contents under a directory ie:
|
||||
/home/yourname/tools/android-ndk-r5
|
||||
|
||||
d. Include the Android SDK tools directory in your user PATH variable:
|
||||
export PATH=$PATH:/home/dev/tools/android-sdk-linux_86/tools:/home/yourname/tools/android-ndk-r5
|
||||
|
||||
e. Download an SDK Android platform, in a command shell type: "android &"
|
||||
to start up the "Android SDK and AVD Manager". Download an SDK
|
||||
platform (Android 2.1 and above is recommended) under the
|
||||
"Available Packages" section.
|
||||
|
||||
f. Java SDK (1.6 and above)
|
||||
http://www.oracle.com/technetwork/java/javase/downloads/index.html
|
||||
|
||||
g. Netbeans (6.9 and above) - Optional if you want to use Netbeans as
|
||||
the IDE:
|
||||
http://netbeans.org/downloads/
|
||||
|
||||
h. Netbeans Android plugin (0.11 and above) - Optional if you are using
|
||||
the Netbeans IDE:
|
||||
http://kenai.com/projects/nbandroid/pages/Install
|
||||
|
||||
===============================================================================
|
||||
2. Setup
|
||||
|
||||
a. Untar the tar.gz file:
|
||||
tar -zxf Fwknop-0.9.tar.gz
|
||||
|
||||
b. Update the properties files with the path to the sdk and ndk tools:
|
||||
.../fwknop-android/project/build.properties
|
||||
sdk.dir=/home/yourname/tools/android-sdk-linux_86
|
||||
ndk.dir=/home/yourname/tools/android-ndk-r5
|
||||
|
||||
c. Include the Android SDK platform directory in your user PATH variable
|
||||
export PATH=$PATH:/home/dev/tools/android-sdk-linux_86/platforms-tools
|
||||
|
||||
d. Create a new Android device, in a command shell type: "android".
|
||||
This will start the android SDK and AVD Manager
|
||||
Under Virtual Devices create an AVD device and name it as "Android2.1"
|
||||
|
||||
e. Update (if needed) project file with the right virtual device as above:
|
||||
.../fwknop-android/project/nbproject/project.properties
|
||||
platform.active=Android2.1
|
||||
|
||||
f. The relevant fwknop android C code can be found under the
|
||||
".../project/jni" directory:
|
||||
1. The ".../project/jni/libfwknop" directory should contain all of
|
||||
the .c and .h files from the main fwknop/lib/ directory (the
|
||||
libfko source files. You can copy all of the *.[ch] files from
|
||||
.../fwknop.../lib manually, or use the "get_libfko_files.sh"
|
||||
script.
|
||||
|
||||
2. The ".../project/jni/fwknop" directory contains the code for
|
||||
the android-specific client code (with the Java Native Interface
|
||||
hooks).
|
||||
|
||||
===============================================================================
|
||||
3. Build
|
||||
|
||||
a. To build the app make sure you're under the project directory:
|
||||
$> cd /home/yourname/.../fwknop-android/project
|
||||
|
||||
b. To build the application type:
|
||||
$> ant jar
|
||||
|
||||
===============================================================================
|
||||
4. Run
|
||||
|
||||
a. Now search under the .../fwknop-android/dist directory for a .apk
|
||||
file. You can copy the .apk file to your SD card by typing (make
|
||||
sure the Android Emulator is on):
|
||||
$> adb push Fwknop.apk /sdcard/
|
||||
|
||||
Then you can open it and install it from within your Android device
|
||||
using a Filemanager like Astro. Make sure that you have turned on the
|
||||
"Unknown Sources" Option under Application settings.
|
||||
|
||||
===============================================================================
|
||||
5. Android Emulator
|
||||
|
||||
If you don't have a device you can install and run Fwknop in the Android
|
||||
emulator. To do so follow these steps:
|
||||
$> android
|
||||
|
||||
Under the virtual devices find your device "Android2.1" and start it up
|
||||
|
||||
In a command line type:
|
||||
$> adb install Fwknop.apk
|
||||
|
||||
You can now find the Firewall Knock Operator app under the menu tap on
|
||||
the icon to get started.
|
||||
|
||||
===============================================================================
|
||||
6. Developing with Netbeans
|
||||
|
||||
To develop and build with Netbeans make sure you have installed the nbandroid
|
||||
plugin (see requirements. Once you have that install a new Java platform under
|
||||
the Tool -> Java Platforms and choose a Google Android platform, navigate
|
||||
under the SDK platform directory you downloaded under step 1e. Finally, just
|
||||
open the .../fwknop-android/project directory as a Netbeans project.
|
||||
|
||||
===============================================================================
|
||||
7. Debugging
|
||||
|
||||
You can use gdb to debug the app. Before you do so make sure you have the
|
||||
following attribute in your AndroidManifest.xml file:
|
||||
android:debuggable="true"
|
||||
Now rebuild the application and start the Android Emulator, then in a command
|
||||
shell type:
|
||||
$> ndk-gdb --project=<path-to>/android/project
|
||||
|
||||
This will start gdb in remote debugging, similarly you can follow the same
|
||||
steps to debug a physical device
|
||||
|
||||
===============================================================================
|
||||
Changelog
|
||||
v0.9 Dec 28 2010
|
||||
1) Rijndael client support
|
||||
2) Local and External IP resolution
|
||||
2) Automatically start ConnectBot
|
||||
|
||||
|
||||
19
android/project/AndroidManifest.xml
Normal file
19
android/project/AndroidManifest.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.max2idea.android.fwknop"
|
||||
android:versionCode="2"
|
||||
android:versionName="1.0">
|
||||
<application android:label="@string/app_name" android:icon="@drawable/lock_64x64"
|
||||
android:debuggable="true">
|
||||
<activity android:name=".Fwknop"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="8"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
||||
16
android/project/build.properties
Normal file
16
android/project/build.properties
Normal file
@@ -0,0 +1,16 @@
|
||||
# SDK paths
|
||||
sdk.dir=/home/dstuart/android-sdk-linux_86
|
||||
ndk.dir=/home/dstuart/android-ndk-r5
|
||||
|
||||
# if you want to deploy to a website#
|
||||
#deploy.dir=/home/yourname/public_html
|
||||
|
||||
# Currently platform supported is Android 7 (2.1)
|
||||
platforms.Android2.1.aapt=${platforms.Android2.1.home}/tools/aapt
|
||||
platforms.Android2.1.adb=${sdk.dir}/tools/adb
|
||||
platforms.Android2.1.apkbuilder=${sdk.dir}/tools/apkbuilder
|
||||
platforms.Android2.1.bootclasspath=${platforms.Android2.1.home}/android.jar
|
||||
platforms.Android2.1.bootclasspath0=${platforms.Android2.1.home}/android.jar
|
||||
platforms.Android2.1.dx=${platforms.Android2.1.home}/tools/dx
|
||||
platforms.Android2.1.emulator=${sdk.dir}/tools/emulator
|
||||
platforms.Android2.1.home=${sdk.dir}/platforms/android-7
|
||||
67
android/project/build.xml
Normal file
67
android/project/build.xml
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="fwknop-android" default="jar">
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked in in Version
|
||||
Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The build.properties file can be created by you and is never touched
|
||||
by the 'android' tool. This is the place to change some of the default property values
|
||||
used by the Ant rules.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
application.package
|
||||
the name of your application package as defined in the manifest. Used by the
|
||||
'uninstall' rule.
|
||||
source.dir
|
||||
the name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
the name of the output directory. Default is 'bin'.
|
||||
|
||||
Properties related to the SDK location or the project target should be updated
|
||||
using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your application and
|
||||
should be checked in in Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="build.properties" />
|
||||
|
||||
<!-- The default.properties file is created and updated by the 'android' tool, as well
|
||||
as ADT.
|
||||
This file is an integral part of the build system for your application and
|
||||
should be checked in in Version Control Systems. -->
|
||||
<property file="default.properties" />
|
||||
|
||||
<!-- Custom Android task to deal with the project target, and import the proper rules.
|
||||
This requires ant 1.6.0 or above. -->
|
||||
<path id="android.antlibs">
|
||||
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
|
||||
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
|
||||
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
|
||||
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
|
||||
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
|
||||
</path>
|
||||
|
||||
<!-- <taskdef name="setup"
|
||||
classname="com.android.ant.SetupTask"
|
||||
classpathref="android.antlibs" />-->
|
||||
|
||||
<!-- Execute the Android Setup task that will setup some properties specific to the target,
|
||||
and import the build rules files.
|
||||
|
||||
The rules file is imported from
|
||||
<SDK>/platforms/<target_platform>/templates/android_rules.xml
|
||||
|
||||
To customize some build steps for your project:
|
||||
- copy the content of the main node <project> from android_rules.xml
|
||||
- paste it in this build.xml below the <setup /> task.
|
||||
- disable the import by changing the setup task below to <setup import="false" />
|
||||
|
||||
This will ensure that the properties are setup correctly but that your customized
|
||||
build steps are used.
|
||||
-->
|
||||
<!--<setup />-->
|
||||
|
||||
</project>
|
||||
11
android/project/default.properties
Normal file
11
android/project/default.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# "build.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=Google Inc.:Google APIs:7
|
||||
36
android/project/jni/Android.mk
Normal file
36
android/project/jni/Android.mk
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2009 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
# libfwknop module
|
||||
#
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libfwknop
|
||||
LOCAL_CFLAGS := -W -g -DHAVE_CONFIG_H \
|
||||
-I$(LOCAL_PATH) \
|
||||
-I$(LOCAL_PATH)/fwknop \
|
||||
-I$(LOCAL_PATH)/libfwknop
|
||||
|
||||
LOCAL_SRC_FILES := $(shell cd $(LOCAL_PATH); \
|
||||
find ./fwknop/ -type f -name '*.c'; \
|
||||
find ./libfwknop/ -type f -name '*.c'; \
|
||||
)
|
||||
|
||||
LOCAL_LDLIBS := \
|
||||
-L$(LOCAL_PATH)/libs \
|
||||
-llog
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
350
android/project/jni/config.h
Normal file
350
android/project/jni/config.h
Normal file
@@ -0,0 +1,350 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File: config.h (Hard-coded for Android development environment)
|
||||
*
|
||||
* Author: Max Kastanas <max2idea@users.sourceforge.net>
|
||||
*
|
||||
* Purpose: General config.h modified for Android env
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef FWKNOP_CONFIG_H
|
||||
#define FWKNOP_CONFIG_H
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
|
||||
/* Path to firewall command executable (it should match the firewall type). */
|
||||
#define FIREWALL_EXE "/sbin/iptables"
|
||||
|
||||
/* The firewall type: ipf. */
|
||||
/* #undef FIREWALL_IPF */
|
||||
|
||||
/* The firewall type: ipfw. */
|
||||
/* #undef FIREWALL_IPFW */
|
||||
|
||||
/* The firewall type: iptables. */
|
||||
#define FIREWALL_IPTABLES 1
|
||||
|
||||
/* Path to gpg executable */
|
||||
#define GPG_EXE "/usr/bin/gpg"
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the <arpa/nameser.h> header file. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define to 1 if you have the `bzero' function. */
|
||||
#define HAVE_BZERO 1
|
||||
|
||||
/* Define to 1 if you have the <ctype.h> header file. */
|
||||
#define HAVE_CTYPE_H 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#define HAVE_ENDIAN_H 1
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define if you have libgdbm */
|
||||
#define HAVE_LIBGDBM 1
|
||||
|
||||
/* Define if you have libgpgme */
|
||||
/* #undef HAVE_LIBGPGME */
|
||||
|
||||
/* Define if you have libndbm */
|
||||
/* #undef HAVE_LIBNDBM */
|
||||
|
||||
/* Define if you have libpcap */
|
||||
#define HAVE_LIBPCAP 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#define HAVE_NETDB_H 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the <net/ethernet.h> header file. */
|
||||
/* #undef HAVE_NET_ETHERNET_H */
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
|
||||
and to 0 otherwise. */
|
||||
#define HAVE_REALLOC 1
|
||||
|
||||
/* Define to 1 if you have the <resolv.h> header file. */
|
||||
#define HAVE_RESOLV_H 1
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
/* #undef HAVE_STAT_EMPTY_STRING_BUG */
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#define HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strcspn' function. */
|
||||
#define HAVE_STRCSPN 1
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strncasecmp' function. */
|
||||
#define HAVE_STRNCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strndup' function. */
|
||||
#define HAVE_STRNDUP 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#define HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strspn' function. */
|
||||
#define HAVE_STRSPN 1
|
||||
|
||||
/* Define to 1 if you have the <sys/byteorder.h> header file. */
|
||||
/* #undef HAVE_SYS_BYTEORDER_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
/* #undef HAVE_SYS_ENDIAN_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/ethernet.h> header file. */
|
||||
/* #undef HAVE_SYS_ETHERNET_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#define HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/wait.h> header file. */
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <time.h> header file. */
|
||||
#define HAVE_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "fwknop"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "dstuart@dstuart.org"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "fwknop"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "fwknop 2.0.0rc2"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "fwknop"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.0.0rc2"
|
||||
|
||||
/* The size of `unsigned int', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_INT 4
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# define _ALL_SOURCE 1
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE 1
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# define _TANDEM_SOURCE 1
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# define __EXTENSIONS__ 1
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "2.0.0rc2"
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
/* #undef _LARGE_FILES */
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
/* #undef _MINIX */
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
/* #undef _POSIX_1_SOURCE */
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
/* #undef _POSIX_SOURCE */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT32_T */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT64_T */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT8_T */
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int16_t */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int32_t */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef int64_t */
|
||||
|
||||
/* Define to the type of a signed integer type of width exactly 8 bits if such
|
||||
a type exists and the standard includes do not define it. */
|
||||
/* #undef int8_t */
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
/* #undef malloc */
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to rpl_realloc if the replacement function should be used. */
|
||||
/* #undef realloc */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 16 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint16_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint32_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint64_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 8 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint8_t */
|
||||
|
||||
|
||||
#endif /* FWKNOP_CONFIG_H */
|
||||
|
||||
186
android/project/jni/fwknop/fwknop_client.c
Normal file
186
android/project/jni/fwknop/fwknop_client.c
Normal file
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
*
|
||||
* File: fwknop_client.c
|
||||
*
|
||||
* Author: Damien S. Stuart
|
||||
*
|
||||
* Purpose: An implementation of an fwknop client for Android.
|
||||
*
|
||||
* Copyright (C) 2010 Damien Stuart (dstuart@dstuart.org)
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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 <jni.h>
|
||||
|
||||
#include "fwknop_client.h"
|
||||
#include "fko.h"
|
||||
|
||||
/* Format error message.
|
||||
*/
|
||||
char *
|
||||
fko_errmsg(char *msg, int res) {
|
||||
static char err_msg[MSG_BUFSIZE+1] = {0};
|
||||
snprintf(err_msg, MSG_BUFSIZE, "Error: %s: %i", msg, fko_errstr(res));
|
||||
return(err_msg);
|
||||
}
|
||||
|
||||
/* JNI interface: constructs arguments and calls main function
|
||||
*/
|
||||
jstring Java_com_max2idea_android_fwknop_Fwknop_sendSPAPacket(JNIEnv* env,
|
||||
jobject thiz)
|
||||
{
|
||||
fko_ctx_t ctx;
|
||||
fwknop_options_t opts;
|
||||
|
||||
int res;
|
||||
char res_msg[MSG_BUFSIZE+1] = {0};
|
||||
char spa_msg[MSG_BUFSIZE+1] = {0};
|
||||
|
||||
LOGV("**** Init fwknop ****");
|
||||
|
||||
memset(&opts, 0, sizeof(fwknop_options_t));
|
||||
|
||||
/* Read the member values from the Java Object that called sendSPAPacket() method
|
||||
*/
|
||||
jclass c = (*env)->GetObjectClass(env, thiz);
|
||||
jfieldID fid = (*env)->GetFieldID(env, c, "access_str", "Ljava/lang/String;");
|
||||
jstring jaccess = (*env)->GetObjectField(env, thiz, fid);
|
||||
const char *access_str = (*env)->GetStringUTFChars(env, jaccess, 0);
|
||||
|
||||
fid = (*env)->GetFieldID(env, c, "allowip_str", "Ljava/lang/String;");
|
||||
jstring jallowip = (*env)->GetObjectField(env, thiz, fid);
|
||||
const char *allowip_str = (*env)->GetStringUTFChars(env, jallowip, 0);
|
||||
|
||||
fid = (*env)->GetFieldID(env, c, "destip_str", "Ljava/lang/String;");
|
||||
jstring jdestip = (*env)->GetObjectField(env, thiz, fid);
|
||||
const char *destip_str = (*env)->GetStringUTFChars(env, jdestip, 0);
|
||||
|
||||
fid = (*env)->GetFieldID(env, c, "passwd_str", "Ljava/lang/String;");
|
||||
jstring jpasswd = (*env)->GetObjectField(env, thiz, fid);
|
||||
const char *passwd_str = (*env)->GetStringUTFChars(env, jpasswd, 0);
|
||||
|
||||
fid = (*env)->GetFieldID(env, c, "fw_timeout_str", "Ljava/lang/String;");
|
||||
jstring jfwtimeout = (*env)->GetObjectField(env, thiz, fid);
|
||||
const char *fw_timeout_str = (*env)->GetStringUTFChars(env, jfwtimeout, 0);
|
||||
|
||||
/* Sanity checks
|
||||
*/
|
||||
if(access_str == NULL) {
|
||||
sprintf(res_msg, "Error: Invalid or missing access string");
|
||||
goto cleanup2;
|
||||
}
|
||||
if(allowip_str == NULL) {
|
||||
sprintf(res_msg, "Error: Invalid or missing allow IP");
|
||||
goto cleanup2;
|
||||
}
|
||||
if(destip_str == NULL) {
|
||||
sprintf(res_msg, "Error: Invalid or missing destination IP");
|
||||
goto cleanup2;
|
||||
}
|
||||
if(passwd_str == NULL) {
|
||||
sprintf(res_msg, "Error: Invalid or missing password");
|
||||
goto cleanup2;
|
||||
}
|
||||
if(fw_timeout_str == NULL) {
|
||||
sprintf(res_msg, "Error: Invalid or missing firewall timeout value");
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
/* Set our spa server info
|
||||
*/
|
||||
opts.spa_server_str = (char*)destip_str;
|
||||
opts.spa_dst_port = FKO_DEFAULT_PORT; /* Until we make this settable. */
|
||||
|
||||
/* Intialize the context
|
||||
*/
|
||||
res = fko_new(&ctx);
|
||||
if (res != FKO_SUCCESS) {
|
||||
strcpy(res_msg, fko_errmsg("Unable to create FKO context", res));
|
||||
goto cleanup2;
|
||||
}
|
||||
|
||||
/* Set client timeout
|
||||
*/
|
||||
res = fko_set_spa_client_timeout(ctx, atoi(fw_timeout_str));
|
||||
if (res != FKO_SUCCESS) {
|
||||
strcpy(res_msg, fko_errmsg("Error setting FW timeout", res));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Set the spa message string
|
||||
*/
|
||||
snprintf(spa_msg, MSG_BUFSIZE, "%s,%s", allowip_str, access_str);
|
||||
|
||||
res = fko_set_spa_message(ctx, spa_msg);
|
||||
if (res != FKO_SUCCESS) {
|
||||
strcpy(res_msg, fko_errmsg("Error setting SPA request message", res));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Finalize the context data (Encrypt and encode).
|
||||
*/
|
||||
res = fko_spa_data_final(ctx, (char*)passwd_str);
|
||||
if (res != FKO_SUCCESS) {
|
||||
strcpy(res_msg, fko_errmsg("Error generating SPA data", res));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
res = fko_get_spa_data(ctx, &opts.spa_data);
|
||||
if (res != FKO_SUCCESS) {
|
||||
strcpy(res_msg, fko_errmsg("Error getting SPA data", res));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* --DSS NOTE: At this point, we could just return the SPA data
|
||||
* to the caller and use the Java network libs to send
|
||||
* the packet and eliminate the spa_comm code altogether.
|
||||
*/
|
||||
|
||||
/* Send the spa data packet
|
||||
*/
|
||||
res = send_spa_packet(&opts);
|
||||
|
||||
if (res < 0) {
|
||||
sprintf(res_msg, "Error: send_spa_packet: packet not sent.");
|
||||
} else if (res == 0) {
|
||||
sprintf(res_msg, "Error: send_spa_packet: Empty packet sent.");
|
||||
} else {
|
||||
sprintf(res_msg, "SPA Packet sent successfully.");
|
||||
}
|
||||
|
||||
cleanup:
|
||||
/* Release the resources used by the fko context.
|
||||
*/
|
||||
fko_destroy(ctx);
|
||||
|
||||
cleanup2:
|
||||
/* Release mem
|
||||
*/
|
||||
(*env)->ReleaseStringUTFChars(env, jaccess, access_str);
|
||||
(*env)->ReleaseStringUTFChars(env, jallowip, allowip_str);
|
||||
(*env)->ReleaseStringUTFChars(env, jdestip, destip_str);
|
||||
(*env)->ReleaseStringUTFChars(env, jpasswd, passwd_str);
|
||||
(*env)->ReleaseStringUTFChars(env, jfwtimeout, fw_timeout_str);
|
||||
|
||||
/* Log and return a string of success or error message.
|
||||
* This can be enhanced semantically with codes.
|
||||
*/
|
||||
LOGV(res_msg);
|
||||
|
||||
return (*env)->NewStringUTF(env, res_msg);
|
||||
}
|
||||
|
||||
/***EOF***/
|
||||
56
android/project/jni/fwknop/fwknop_client.h
Normal file
56
android/project/jni/fwknop/fwknop_client.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
*
|
||||
* File: fwknop_client.h
|
||||
*
|
||||
* Author: Damien Stuart (dstuart@dstuart.org)
|
||||
*
|
||||
* Purpose: Header file for fwknop_client.c fwknop client for Android.
|
||||
*
|
||||
* Copyright (C) 2010 Damien Stuart (dstuart@dstuart.org)
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
#ifndef FWKNOP_CLIENT_H
|
||||
#define FWKNOP_CLIENT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "logutils.h"
|
||||
|
||||
#define FKO_DEFAULT_PORT 62201
|
||||
#define MAX_PORT_STR_LEN 6
|
||||
#define MAX_SERVER_STR_LEN 50
|
||||
#define MSG_BUFSIZE 255
|
||||
|
||||
typedef struct fwknop_options
|
||||
{
|
||||
char *spa_server_str;
|
||||
unsigned int spa_dst_port;
|
||||
char *spa_data;
|
||||
} fwknop_options_t;
|
||||
|
||||
/* Function Prototypes
|
||||
*/
|
||||
int send_spa_packet(fwknop_options_t *options);
|
||||
|
||||
#endif /* FWKNOP_CLIENT_H */
|
||||
94
android/project/jni/fwknop/send_spa_packet.c
Normal file
94
android/project/jni/fwknop/send_spa_packet.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
*
|
||||
* File: send_spa_packet.c
|
||||
*
|
||||
* Author: Damien S. Stuart (dstuart@dstuart.org)
|
||||
*
|
||||
* Purpose: Function to send a SPA data packet out onto the network.
|
||||
*
|
||||
* Copyright (C) 2010 Damien Stuart (dstuart@dstuart.org)
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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 "fwknop_client.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
/* Send the SPA data via UDP packet.
|
||||
*/
|
||||
int
|
||||
send_spa_packet(fwknop_options_t *options)
|
||||
{
|
||||
int sock, res=0, sd_len, error;
|
||||
struct addrinfo *result, *rp, hints;
|
||||
char port_str[MAX_PORT_STR_LEN];
|
||||
|
||||
memset(&hints, 0, sizeof(struct addrinfo));
|
||||
|
||||
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
sprintf(port_str, "%d", options->spa_dst_port);
|
||||
|
||||
error = getaddrinfo(options->spa_server_str, port_str, &hints, &result);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOGV("Error in getaddrinfo: %s\n", gai_strerror(error));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (rp = result; rp != NULL; rp = rp->ai_next) {
|
||||
sock = socket(rp->ai_family, rp->ai_socktype,
|
||||
rp->ai_protocol);
|
||||
if (sock < 0)
|
||||
continue;
|
||||
|
||||
if ((error = (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1)))
|
||||
break; /* made it */
|
||||
|
||||
close(sock);
|
||||
}
|
||||
|
||||
if (rp == NULL)
|
||||
{
|
||||
LOGV("Error: Unable to create socket.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
sd_len = strlen(options->spa_data);
|
||||
|
||||
res = send(sock, options->spa_data, sd_len, 0);
|
||||
|
||||
if(res < 0)
|
||||
LOGV("send_spa_packet: write error: ");
|
||||
else if(res != sd_len)
|
||||
LOGV("Warning: bytes sent (%i) not spa data length (%i).\n",
|
||||
res, sd_len
|
||||
);
|
||||
|
||||
close(sock);
|
||||
|
||||
return(res);
|
||||
}
|
||||
|
||||
/***EOF***/
|
||||
10
android/project/jni/libfwknop/README
Normal file
10
android/project/jni/libfwknop/README
Normal file
@@ -0,0 +1,10 @@
|
||||
README for the libfwknop directory (android/project/jni/libfwknop)
|
||||
===============================================================================
|
||||
|
||||
This directory should contain all of the .c and .h files from the fwknop
|
||||
main distribution "lib" directory. These are the source files for libfko.
|
||||
You can either copy or link to the libfko source files. Either way, they
|
||||
need to exist in this directory before you attempt to build the Android
|
||||
fwknop client.
|
||||
|
||||
|
||||
37
android/project/jni/libfwknop/get_libfko_files.sh
Executable file
37
android/project/jni/libfwknop/get_libfko_files.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# get_libfko_files.sh
|
||||
#
|
||||
# Copy each of the libfko source files in the fwknop source tree into this
|
||||
# directory.
|
||||
#
|
||||
# Usage: ./get_libfko_files.sh [libfko-dir]
|
||||
#
|
||||
# Note: You should run this script only from this directory (libfwknop).
|
||||
#
|
||||
# If the libfko-dir argument is not given, this script will assume
|
||||
# ../../../../lib (which will work if this directory is still part
|
||||
# of the original fwknop source distribution.
|
||||
#
|
||||
###############################################################################
|
||||
#
|
||||
LIBFKO_DIR=${1:-"../../../../lib"} # Default relative path to libfko files.
|
||||
|
||||
# Simple sanity checks. See if the LIBFKO_DIR directory exists and see if
|
||||
# thi "fko_context.h" is found there as well.
|
||||
#
|
||||
if [ ! -d "$LIBFKO_DIR" ] ; then
|
||||
echo "Libfko directory: '$LIBFKO_DIR' was not found! Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${LIBFKO_DIR}/fko_context.h" ] ; then
|
||||
echo "'$LIBFKO_DIR' does not seem to contain the required files! Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy the files.
|
||||
#
|
||||
/bin/cp ${LIBFKO_DIR}/*.[ch] .
|
||||
|
||||
###EOF###
|
||||
38
android/project/jni/logutils.h
Normal file
38
android/project/jni/logutils.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File: Fwknop.java
|
||||
*
|
||||
* Author: Max Kastanas <max2idea@users.sourceforge.net>
|
||||
*
|
||||
* Purpose: Simple wrapper for Android logging
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
#ifndef _LOGUTILS_H
|
||||
#define _LOGUTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <android/log.h>
|
||||
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "libfwknop",__VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LOGUTILS_H */
|
||||
|
||||
744
android/project/nbproject/build-impl.xml
Normal file
744
android/project/nbproject/build-impl.xml
Normal file
@@ -0,0 +1,744 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project xmlns:androidproject1="http://www.netbeans.org/ns/android-project/1" basedir=".." default="default" name="fwknop-android-impl">
|
||||
<target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="-pre-init" name="-init-private">
|
||||
<property file="nbproject/private/config.properties"/>
|
||||
<property file="nbproject/private/configs/${config}.properties"/>
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private" name="-init-user">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user" name="-init-project">
|
||||
<property file="nbproject/configs/${config}.properties"/>
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
|
||||
<androidproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
|
||||
<androidproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
|
||||
<androidproject1:property name="platform.bootcp0" value="platforms.${platform.active}.bootclasspath0"/>
|
||||
<androidproject1:property name="platform.bootcp1" value="platforms.${platform.active}.bootclasspath1"/>
|
||||
<androidproject1:property name="aapt" value="platforms.${platform.active}.aapt"/>
|
||||
<androidproject1:property name="adb" value="platforms.${platform.active}.adb"/>
|
||||
<androidproject1:property name="dx" value="platforms.${platform.active}.dx"/>
|
||||
<androidproject1:property name="emulator" value="platforms.${platform.active}.emulator"/>
|
||||
<androidproject1:property name="apkbuilder" value="platforms.${platform.active}.apkbuilder"/>
|
||||
<condition property="bootclasspath1.available">
|
||||
<and>
|
||||
<isset property="platforms.${platform.active}.bootclasspath1"/>
|
||||
<not>
|
||||
<equals arg1="${platform.bootcp1}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.bootclasspath1.available">
|
||||
<not>
|
||||
<isset property="bootclasspath1.available"/>
|
||||
</not>
|
||||
</condition>
|
||||
<condition property="assets.available">
|
||||
<and>
|
||||
<isset property="${assets.dir}"/>
|
||||
<not>
|
||||
<equals arg1="${assets.dir}" arg2="" trim="true"/>
|
||||
</not>
|
||||
<available file="${assets.dir}" property="assets.available"/>
|
||||
</and>
|
||||
</condition>
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<and>
|
||||
<isset property="javadoc.preview"/>
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
<property name="application.args" value=""/>
|
||||
<property name="source.encoding" value="${file.encoding}"/>
|
||||
<condition property="javadoc.encoding.used" value="${javadoc.encoding}">
|
||||
<and>
|
||||
<isset property="javadoc.encoding"/>
|
||||
<not>
|
||||
<equals arg1="${javadoc.encoding}" arg2=""/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javadoc.encoding.used" value="${source.encoding}"/>
|
||||
<property name="includes" value="**"/>
|
||||
<property name="excludes" value=""/>
|
||||
<property name="do.depend" value="false"/>
|
||||
<condition property="do.depend.true">
|
||||
<istrue value="${do.depend}"/>
|
||||
</condition>
|
||||
<condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
|
||||
<and>
|
||||
<isset property="jaxws.endorsed.dir"/>
|
||||
<available file="nbproject/jaxws-build.xml"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="screen.skin" value="HVGA"/>
|
||||
<property name="emulator.options" value=""/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.apk">Must set dist.apk</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${src.dir}" name="srcdir"/>
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<attribute default="${javac.classpath}" name="classpath"/>
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="${javac.debug}" name="debug"/>
|
||||
<attribute default="" name="sourcepath"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac bootclasspath="${platform.bootcp}" debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="depend" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${src.dir}" name="srcdir"/>
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<attribute default="${javac.classpath}" name="classpath"/>
|
||||
<sequential>
|
||||
<depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</depend>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="force-recompile" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${build.classes.dir}" name="destdir"/>
|
||||
<sequential>
|
||||
<fail unless="javac.includes">Must set javac.includes</fail>
|
||||
<pathconvert pathsep="," property="javac.includes.binary">
|
||||
<path>
|
||||
<filelist dir="@{destdir}" files="${javac.includes}"/>
|
||||
</path>
|
||||
<globmapper from="*.java" to="*.class"/>
|
||||
</pathconvert>
|
||||
<delete>
|
||||
<files includes="${javac.includes.binary}"/>
|
||||
</delete>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${includes}" name="includes"/>
|
||||
<attribute default="${excludes}" name="excludes"/>
|
||||
<attribute default="**" name="testincludes"/>
|
||||
<sequential>
|
||||
<junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
|
||||
<filename name="@{testincludes}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${main.class}" name="name"/>
|
||||
<attribute default="${debug.classpath}" name="classpath"/>
|
||||
<attribute default="" name="stopclassname"/>
|
||||
<sequential>
|
||||
<nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<bootclasspath>
|
||||
<path path="${platform.bootcp}"/>
|
||||
</bootclasspath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdaconnect" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${main.class}" name="name"/>
|
||||
<attribute default="${debug.classpath}" name="classpath"/>
|
||||
<sequential>
|
||||
<nbjpdaconnect address="${local.debug.port}" name="@{name}" transport="dt_socket">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<bootclasspath>
|
||||
<path path="${platform.bootcp}"/>
|
||||
</bootclasspath>
|
||||
</nbjpdaconnect>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${build.classes.dir}" name="dir"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset dir="@{dir}" includes="${fix.includes}*.class"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-debug-args">
|
||||
<property name="version-output" value="java version "${ant.java.version}"/>
|
||||
<condition property="have-jdk-older-than-1.4">
|
||||
<or>
|
||||
<contains string="${version-output}" substring="java version "1.0"/>
|
||||
<contains string="${version-output}" substring="java version "1.1"/>
|
||||
<contains string="${version-output}" substring="java version "1.2"/>
|
||||
<contains string="${version-output}" substring="java version "1.3"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
|
||||
<istrue value="${have-jdk-older-than-1.4}"/>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="-init-debug-args" name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${main.class}" name="classname"/>
|
||||
<attribute default="${debug.classpath}" name="classpath"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java classname="@{classname}" dir="${work.dir}" fork="true">
|
||||
<jvmarg line="${debug-args-line}"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper from="run-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/android-project/1">
|
||||
<attribute default="${main.class}" name="classname"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java classname="@{classname}" dir="${work.dir}" fork="true">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper from="run-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java" name="init"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target depends="init" name="deps-jar" unless="no.deps"/>
|
||||
<target depends="init,deps-jar" name="-pre-pre-compile">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target if="do.depend.true" name="-compile-depend">
|
||||
<androidproject1:depend/>
|
||||
</target>
|
||||
<target depends="init,-pre-pre-compile,-pre-compile" name="-res-compile" unless="bootclasspath1.available">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-m"/>
|
||||
<arg value="-J"/>
|
||||
<arg value="${src.dir}"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,-pre-pre-compile,-pre-compile" if="bootclasspath1.available" name="-res-compile1">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-m"/>
|
||||
<arg value="-J"/>
|
||||
<arg value="${src.dir}"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp0}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp1}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile" name="-idl-compile"/>
|
||||
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
|
||||
<androidproject1:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-res-compile,-res-compile1,-idl-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<androidproject1:force-recompile/>
|
||||
<androidproject1:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target depends="init" name="-pre-pre-jar">
|
||||
<dirname file="${dist.apk}" property="dist.apk.dir"/>
|
||||
<mkdir dir="${dist.apk.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
|
||||
<exec executable="./ndk-build" dir="${ndk.dir}">
|
||||
<env key="NDK_PROJECT_PATH" path="${basedir}"/>
|
||||
</exec>
|
||||
<copy todir="${basedir}/lib/lib/armeabi">
|
||||
<fileset dir="./libs/armeabi">
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" name="-dex">
|
||||
<exec executable="${dx}" failonerror="true">
|
||||
<arg value="--dex"/>
|
||||
<arg value="--output=${basedir}/${intermediate.dex}"/>
|
||||
<arg value="--positions=lines"/>
|
||||
<arg path="${build.classes.dir}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="assets.available" name="-package-res-and-assets" unless="bootclasspath1.available">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-f"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp}"/>
|
||||
<arg value="-F"/>
|
||||
<arg value="${dist.apk}_"/>
|
||||
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="assets.available" name="-package-res-and-assets1" unless="no.bootclasspath1.available">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-f"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp0}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp1}"/>
|
||||
<arg value="-F"/>
|
||||
<arg value="${dist.apk}_"/>
|
||||
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="no.bootclasspath1.available" name="-package-res-no-assets" unless="assets.available">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-f"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp}"/>
|
||||
<arg value="-F"/>
|
||||
<arg value="${dist.apk}_"/>
|
||||
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar" if="bootclasspath1.available" name="-package-res-no-assets1" unless="assets.available">
|
||||
<exec executable="${aapt}" failonerror="true">
|
||||
<arg value="package"/>
|
||||
<arg value="-f"/>
|
||||
<arg value="-M"/>
|
||||
<arg value="AndroidManifest.xml"/>
|
||||
<arg value="-S"/>
|
||||
<arg value="${resource.dir}"/>
|
||||
<arg value="-A"/>
|
||||
<arg value="${assets.dir}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp0}"/>
|
||||
<arg value="-I"/>
|
||||
<arg value="${platform.bootcp1}"/>
|
||||
<arg value="-F"/>
|
||||
<arg value="${dist.apk}_"/>
|
||||
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-res-and-assets1,-package-res-no-assets1" name="-package-add-ndk">
|
||||
<!-- <exec executable="zip" failonerror="true">
|
||||
<arg value="${dist.apk}_"/>
|
||||
<arg value="lib/armeabi/\*"/>
|
||||
</exec>-->
|
||||
<zip update="true" destfile="${dist.apk}_" basedir="${basedir}/lib">
|
||||
<fileset dir="lib/">
|
||||
</fileset>
|
||||
</zip>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-jar,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-res-and-assets1,-package-res-no-assets1,-package-add-ndk" name="-package-dex">
|
||||
<dirname file="${intermediate.dex}" property="package-dex.dex.folder"/>
|
||||
<basename file="${intermediate.dex}" property="package-dex.dex.file"/>
|
||||
<zip destfile="${dist.apk}_" update="true">
|
||||
<fileset dir="${package-dex.dex.folder}" includes="${package-dex.dex.file}"/>
|
||||
</zip>
|
||||
</target>
|
||||
<target depends="init,-package-res-and-assets,-package-res-no-assets,-package-dex" name="-sign">
|
||||
<exec executable="${apkbuilder}" failonerror="true">
|
||||
<arg value="${dist.apk}"/>
|
||||
<arg value="-z"/>
|
||||
<arg value="${dist.apk}_"/>
|
||||
</exec>
|
||||
<delete file="${dist.apk}_"/>
|
||||
<!-- <copy file="${dist.apk}" todir="${deploy.dir}"/> -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-jar,-dex,-package-res-and-assets,-package-res-no-assets,-package-dex,-sign,-post-jar" description="Build JAR." name="jar"/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="init,compile,jar,-start-emulator,-wait-for-emulator,-install-app" description="Run a main activity." name="run">
|
||||
<exec executable="${adb}">
|
||||
<arg value="shell"/>
|
||||
<arg value="am start -n ${main.component}/${main.class}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,jar" name="-emulator-running">
|
||||
<exec executable="${adb}" outputproperty="emulator-running.out" resultproperty="is.emulator.running.tmp">
|
||||
<arg value="shell"/>
|
||||
<arg value="date"/>
|
||||
</exec>
|
||||
<condition property="is.emulator.running">
|
||||
<not>
|
||||
<isfailure code="${is.emulator.running.tmp}"/>
|
||||
</not>
|
||||
</condition>
|
||||
</target>
|
||||
<target depends="init,compile,jar,-emulator-running" name="-start-emulator" unless="is.emulator.running">
|
||||
<exec executable="${adb}">
|
||||
<arg value="kill-server"/>
|
||||
</exec>
|
||||
<exec executable="${emulator}" spawn="true">
|
||||
<arg value="-skin"/>
|
||||
<arg value="${screen.skin}"/>
|
||||
<arg line="${emulator.options}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target depends="init,compile,jar,-start-emulator" name="-wait-for-emulator">
|
||||
<!--<taskdef classname="org.netbeans.modules.android.ant.AdbPackageManagerWait" classpath="${libs.AndroidForwardDebugger.classpath}" name="adb-pm-wait"/>
|
||||
<adb-pm-wait adb="${adb}"/>-->
|
||||
</target>
|
||||
<target depends="init,compile,jar,-start-emulator,-wait-for-emulator" name="-install-app">
|
||||
<exec executable="${adb}">
|
||||
<arg value="install"/>
|
||||
<arg value="-r"/>
|
||||
<arg value="${dist.apk}"/>
|
||||
</exec>
|
||||
</target>
|
||||
<target name="-do-not-recompile">
|
||||
<property name="javac.includes.binary" value=""/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target depends="init,-debug-start-debuggee" if="netbeans.home" name="-debug-start-debugger">
|
||||
<androidproject1:nbjpdaconnect/>
|
||||
</target>
|
||||
<target depends="init,compile,-start-emulator,-wait-for-emulator,-install-app" name="-debug-start-debuggee">
|
||||
<exec executable="${adb}">
|
||||
<arg value="shell"/>
|
||||
<arg value="am start -D -n ${main.component}/${main.class}"/>
|
||||
</exec>
|
||||
<taskdef classname="org.netbeans.modules.android.ant.ForwardDebugger" classpath="${libs.AndroidForwardDebugger.classpath}" name="forwarddebugger"/>
|
||||
<forwarddebugger adb="${adb}" addressProperty="local.debug.port" app="${main.component}"/>
|
||||
</target>
|
||||
<target depends="init,compile,-debug-start-debuggee,-debug-start-debugger" description="Debug project in IDE." if="netbeans.home" name="debug"/>
|
||||
<target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
|
||||
<androidproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target depends="init" name="-javadoc-build">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target if="do.depend.true" name="-compile-test-depend">
|
||||
<androidproject1:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
|
||||
<androidproject1:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<androidproject1:force-recompile destdir="${build.test.classes.dir}"/>
|
||||
<androidproject1:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init" if="have.tests" name="-pre-test-run">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
|
||||
<androidproject1:junit testincludes="**/*Test.java"/>
|
||||
</target>
|
||||
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init" if="have.tests" name="test-report"/>
|
||||
<target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
|
||||
<target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
|
||||
<target depends="init" if="have.tests" name="-pre-test-run-single">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<androidproject1:junit excludes="" includes="${test.includes}"/>
|
||||
</target>
|
||||
<target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
|
||||
<delete file="${test.report.file}"/>
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
<androidproject1:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
|
||||
<customize>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||
</syspropertyset>
|
||||
<arg value="${test.class}"/>
|
||||
<arg value="showoutput=true"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
|
||||
<arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
|
||||
</customize>
|
||||
</androidproject1:debug>
|
||||
</target>
|
||||
<target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
|
||||
<androidproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
|
||||
</target>
|
||||
<target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target depends="init" name="deps-clean" unless="no.deps"/>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
<delete dir="${obj.dir}"/>
|
||||
<delete dir="${armlibs.dir}"/>
|
||||
<delete dir="${armlib.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
|
||||
</project>
|
||||
8
android/project/nbproject/genfiles.properties
Normal file
8
android/project/nbproject/genfiles.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
build.xml.data.CRC32=04a1f81f
|
||||
build.xml.script.CRC32=051b2fac
|
||||
build.xml.stylesheet.CRC32=0cfbaa1e@0.3.1
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=34ee6a0c
|
||||
nbproject/build-impl.xml.script.CRC32=cce23c74
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=fed06522@0.11
|
||||
0
android/project/nbproject/private/config.properties
Normal file
0
android/project/nbproject/private/config.properties
Normal file
5
android/project/nbproject/private/private.properties
Normal file
5
android/project/nbproject/private/private.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
android.target.mode=manual
|
||||
do.depend=false
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
#user.properties.file=/home/yourname/.netbeans/6.8/build.properties
|
||||
4
android/project/nbproject/private/private.xml
Normal file
4
android/project/nbproject/private/private.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
||||
67
android/project/nbproject/project.properties
Normal file
67
android/project/nbproject/project.properties
Normal file
@@ -0,0 +1,67 @@
|
||||
application.title=Fwknop
|
||||
application.vendor=Max2idea
|
||||
assets.dir=assets
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
dist.apk=${dist.dir}/Fwknop.apk
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
obj.dir=obj
|
||||
armlibs.dir=libs/armeabi
|
||||
armlib.dir=lib/lib/armeabi
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
excludes=
|
||||
file.reference.libs-armeabi=libs/armeabi
|
||||
gen.source.dir=${src.dir}
|
||||
includes=**
|
||||
intermediate.dex=${build.dir}/classes.dex
|
||||
javac.classpath=\
|
||||
${file.reference.libs-armeabi}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}:\
|
||||
${libs.junit_4.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=com.max2idea.android.fwknop.Fwknop
|
||||
main.component=com.max2idea.android.fwknop
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=Android2.1
|
||||
resource.dir=res
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
source.encoding=UTF-8
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
17
android/project/nbproject/project.xml
Normal file
17
android/project/nbproject/project.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.android.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/android-project/1">
|
||||
<name>fwknop-android</name>
|
||||
<minimum-ant-version>1.7.0</minimum-ant-version>
|
||||
<explicit-platform explicit-source-supported="true"/>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
BIN
android/project/res/drawable-hdpi/icon.png
Normal file
BIN
android/project/res/drawable-hdpi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
BIN
android/project/res/drawable-ldpi/icon.png
Normal file
BIN
android/project/res/drawable-ldpi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
android/project/res/drawable-mdpi/icon.png
Normal file
BIN
android/project/res/drawable-mdpi/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
BIN
android/project/res/drawable/lock_128x128.png
Normal file
BIN
android/project/res/drawable/lock_128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
android/project/res/drawable/lock_32x32.png
Normal file
BIN
android/project/res/drawable/lock_32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
android/project/res/drawable/lock_64x64.png
Normal file
BIN
android/project/res/drawable/lock_64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.9 KiB |
180
android/project/res/layout/main.xml
Normal file
180
android/project/res/layout/main.xml
Normal file
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<LinearLayout android:id="@+id/allowipl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/allowipstr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Allow IP: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/allowip"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:singleLine="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/accessProtol"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/accessProtoStr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Access Protocol: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/accessProto"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:singleLine="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/accessPortl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/accessPortStr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Access Port: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/accessPort"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:inputType="numberDecimal"
|
||||
android:singleLine="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/destIPl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/destIPStr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Server Address: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/destIP"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:singleLine="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/fwTimeoutl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/fwTimeoutStr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Firewall Timeout: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/fwTimeout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="60"
|
||||
android:inputType="numberDecimal"
|
||||
android:singleLine="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:id="@+id/passwdl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/passwdStr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Rijndael Key: "
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/passwd"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:singleLine="true"
|
||||
android:password="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<RelativeLayout android:id="@+id/startAppl"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/startApp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Start ConnectBot"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<CheckBox
|
||||
android:id="@+id/startAppCheck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
<RelativeLayout android:id="@+id/startl"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/output"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="Tap the lock below to send SPA packet"
|
||||
android:textSize="20dip"
|
||||
/>
|
||||
<ImageButton
|
||||
android:id="@+id/unlock"
|
||||
android:background="@+drawable/lock_64x64"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
<!--test-->
|
||||
|
||||
5
android/project/res/values/strings.xml
Normal file
5
android/project/res/values/strings.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Firewall Knock Operator</string>
|
||||
<string name="app_short_name">Fwknop</string>
|
||||
</resources>
|
||||
531
android/project/src/com/max2idea/android/fwknop/Fwknop.java
Normal file
531
android/project/src/com/max2idea/android/fwknop/Fwknop.java
Normal file
@@ -0,0 +1,531 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File: Fwknop.java
|
||||
*
|
||||
* Author: Max Kastanas <max2idea@users.sourceforge.net>
|
||||
*
|
||||
* Purpose: A JNI wrapper for Damien Stuart's implementation of fwknop client
|
||||
*
|
||||
* License (GNU Public License):
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
package com.max2idea.android.fwknop;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.widget.TextView;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.AssetManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.URL;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.http.HttpConnection;
|
||||
|
||||
public class Fwknop extends Activity {
|
||||
|
||||
public View parent;
|
||||
public TextView mOutput;
|
||||
private boolean startApp = true;
|
||||
public Activity activity = this;
|
||||
|
||||
// Generic Dialog box
|
||||
public static void UIAlert(String title, String body, Activity activity) {
|
||||
AlertDialog ad;
|
||||
ad = new AlertDialog.Builder(activity).create();
|
||||
ad.setTitle(title);
|
||||
ad.setMessage(body);
|
||||
ad.setButton("OK", new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
}
|
||||
private String output;
|
||||
private Spinner mAllowip;
|
||||
private EditText mPasswd;
|
||||
private EditText mDestip;
|
||||
private Spinner mAccessProto;
|
||||
private EditText mAccessPort;
|
||||
private EditText mFwTimeout;
|
||||
private ImageButton mUnlock;
|
||||
private String access_str;
|
||||
private String allowip_str;
|
||||
private String passwd_str;
|
||||
private String destip_str;
|
||||
private String fw_timeout_str;
|
||||
private CheckBox mCheck;
|
||||
private String externalIP = "";
|
||||
private String localIP = "";
|
||||
private int IPS_RESOLVED = 1000;
|
||||
private int LOCALIP_NOTRESOLVED = 1001;
|
||||
private int EXTIP_NOTRESOLVED = 1002;
|
||||
private int SPA_SENT = 1003;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
//Installer
|
||||
installNativeLibs();
|
||||
|
||||
//Get IPs of client
|
||||
progDialog = ProgressDialog.show(activity, "Resolving External IP", "Please wait...", true);
|
||||
IPResolver p = new IPResolver();
|
||||
p.execute();
|
||||
|
||||
//Setup UI
|
||||
this.setContentView(R.layout.main);
|
||||
this.setupWidgets();
|
||||
|
||||
}
|
||||
|
||||
public void sendSPA() {
|
||||
startSPASend();
|
||||
}
|
||||
|
||||
// Intent for ConnectBot kickoff
|
||||
private void startApp() {
|
||||
Intent i = new Intent(Intent.ACTION_RUN);
|
||||
i.setComponent(new ComponentName("org.connectbot", "org.connectbot.HostListActivity"));
|
||||
PackageManager p = this.getPackageManager();
|
||||
List list = p.queryIntentActivities(i, p.COMPONENT_ENABLED_STATE_DEFAULT);
|
||||
if (list.isEmpty()) {
|
||||
Log.v("SPA", "ConnectBot is not installed");
|
||||
Toast.makeText(this, "ConnectBot is not installed", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Log.v("SPA", "Starting connectBot");
|
||||
Toast.makeText(this, "Starting ConnectBot", Toast.LENGTH_LONG);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
// Define the Handler that receives messages from the thread and update the progress
|
||||
public Handler handler = new Handler() {
|
||||
|
||||
@Override
|
||||
public synchronized void handleMessage(Message msg) {
|
||||
Bundle b = msg.getData();
|
||||
Integer messageType = (Integer) b.get("message_type");
|
||||
if (messageType != null && messageType == IPS_RESOLVED) {
|
||||
progDialog.dismiss();
|
||||
} else if (messageType != null && messageType == EXTIP_NOTRESOLVED) {
|
||||
progDialog.dismiss();
|
||||
UIAlert("Error", "Could not resolve your external IP. This means that "
|
||||
+ "you're not connected to the internet or ifconfig.me "
|
||||
+ "is not be accesible right now", activity);
|
||||
} else if (messageType != null && messageType == LOCALIP_NOTRESOLVED) {
|
||||
progDialog.dismiss();
|
||||
UIAlert("Error", "Could not find any IP, makes sure you have an internet connection", activity);
|
||||
} else if (messageType != null && messageType == SPA_SENT) {
|
||||
Toast.makeText(activity, output, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Get Local and External IPs
|
||||
private void getClientIPs() {
|
||||
localIP = getLocalIpAddress();
|
||||
externalIP = getExternalIP();
|
||||
sendHandlerMessage(handler, IPS_RESOLVED);
|
||||
}
|
||||
|
||||
// Generic Message to update UI
|
||||
public static void sendHandlerMessage(Handler handler, int message_type, String message_var, String message_value) {
|
||||
Message msg1 = handler.obtainMessage();
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("message_type", message_type);
|
||||
b.putString(message_var, message_value);
|
||||
msg1.setData(b);
|
||||
handler.sendMessage(msg1);
|
||||
}
|
||||
|
||||
// Sets member variables to IPs
|
||||
private void setIPs() {
|
||||
|
||||
String[] arraySpinner = {"Source IP", "", ""};
|
||||
if (this.localIP != null && !this.localIP.equals("")) {
|
||||
Log.v("setter", this.localIP);
|
||||
arraySpinner[1] = this.localIP;
|
||||
} else {
|
||||
sendHandlerMessage(handler, LOCALIP_NOTRESOLVED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.externalIP != null && !this.externalIP.equals("")) {
|
||||
arraySpinner[2] = this.externalIP;
|
||||
Log.v("setter", this.externalIP);
|
||||
} else {
|
||||
sendHandlerMessage(handler, EXTIP_NOTRESOLVED);
|
||||
}
|
||||
|
||||
ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
|
||||
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
this.mAllowip.setAdapter(adapter1);
|
||||
this.mAllowip.invalidate();
|
||||
}
|
||||
private ProgressDialog progDialog;
|
||||
|
||||
// Async task just in case things take a long time
|
||||
private class IPResolver extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
getClientIPs();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void test) {
|
||||
setIPs();
|
||||
}
|
||||
}
|
||||
|
||||
// Another Generic Messanger
|
||||
public static void sendHandlerMessage(Handler handler, int message_type) {
|
||||
Message msg1 = handler.obtainMessage();
|
||||
Bundle b = new Bundle();
|
||||
b.putInt("message_type", message_type);
|
||||
msg1.setData(b);
|
||||
handler.sendMessage(msg1);
|
||||
}
|
||||
|
||||
public class AutoScrollView extends ScrollView {
|
||||
|
||||
public AutoScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public AutoScrollView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
public AutoScrollView mLyricsScroll;
|
||||
|
||||
// Main event function
|
||||
// Retrives values from saved preferences
|
||||
private void onStartButton() {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
SharedPreferences.Editor edit = prefs.edit();
|
||||
//
|
||||
if (this.mAccessProto != null
|
||||
&& (this.mAccessProto.getSelectedItem().toString().trim().toLowerCase().equals("tcp")
|
||||
|| this.mAccessProto.getSelectedItem().toString().trim().toLowerCase().equals("udp"))) {
|
||||
this.access_str = mAccessProto.getSelectedItem().toString().toLowerCase() + "";
|
||||
edit.putString("accessProto_str", mAccessProto.getSelectedItem().toString());
|
||||
} else {
|
||||
this.UIAlert("Input error", "Please enter a valip protocol (tcp/udp)", this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mAccessPort != null) {
|
||||
int port;
|
||||
try {
|
||||
Integer.parseInt(this.mAccessPort.getText().toString());
|
||||
} catch (Exception e) {
|
||||
this.UIAlert("Input error", "Please enter a valid port number", this);
|
||||
return;
|
||||
}
|
||||
this.access_str = this.access_str + "/" + mAccessPort.getText();
|
||||
edit.putString("accessPort_str", mAccessPort.getText().toString());
|
||||
}
|
||||
|
||||
if (this.mAllowip != null && this.mAllowip.getSelectedItem() != null && !this.mAllowip.getSelectedItem().toString().trim().equals("")) {
|
||||
if(mAllowip.getSelectedItem().toString().trim().equals("Source IP")) {
|
||||
this.allowip_str = "0.0.0.0";
|
||||
} else {
|
||||
this.allowip_str = mAllowip.getSelectedItem().toString().trim();
|
||||
}
|
||||
|
||||
edit.putString("allowip_str", this.allowip_str);
|
||||
} else {
|
||||
UIAlert("Input error", "Please use a valid IP address", this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mPasswd != null && !this.mPasswd.getText().toString().trim().equals("")) {
|
||||
this.passwd_str = mPasswd.getText().toString();
|
||||
edit.putString("passwd_str", mPasswd.getText().toString());
|
||||
} else {
|
||||
this.UIAlert("Input error", "Please enter a key", this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mDestip != null && !this.mDestip.getText().toString().trim().equals("")) {
|
||||
this.destip_str = mDestip.getText().toString();
|
||||
edit.putString("destip_str", mDestip.getText().toString());
|
||||
} else {
|
||||
this.UIAlert("Input error", "Please enter a valid Server address", this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.mFwTimeout != null) {
|
||||
int fw_timeout;
|
||||
try {
|
||||
Integer.parseInt(this.mFwTimeout.getText().toString());
|
||||
} catch (Exception e) {
|
||||
this.UIAlert("Input error", "Please enter a valid timeout value", this);
|
||||
return;
|
||||
}
|
||||
this.fw_timeout_str = mFwTimeout.getText().toString();
|
||||
edit.putString("fw_timeout_str", mFwTimeout.getText().toString());
|
||||
}
|
||||
|
||||
if (this.mCheck != null && this.mCheck.isChecked()) {
|
||||
this.startApp = true;
|
||||
} else {
|
||||
this.startApp = false;
|
||||
}
|
||||
edit.putBoolean("app_start", startApp);
|
||||
edit.commit();
|
||||
|
||||
this.sendSPA();
|
||||
}
|
||||
|
||||
// Setting up the UI
|
||||
public void setupWidgets() {
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
this.mAccessPort = (EditText) findViewById(R.id.accessPort);
|
||||
this.mAccessPort.setText(prefs.getString("accessPort_str", "22"));
|
||||
|
||||
this.mAccessProto = (Spinner) findViewById(R.id.accessProto);
|
||||
String[] arraySpinner = new String[]{"tcp", "udp"};
|
||||
ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
this.mAccessProto.setAdapter(adapter);
|
||||
if (prefs.getString("accessProto_str", "tcp").equals("tcp")) {
|
||||
this.mAccessProto.setSelection(0);
|
||||
}
|
||||
if (prefs.getString("accessProto_str", "tcp").equals("udp")) {
|
||||
this.mAccessProto.setSelection(1);
|
||||
}
|
||||
|
||||
this.mAllowip = (Spinner) findViewById(R.id.allowip);
|
||||
|
||||
this.mDestip = (EditText) findViewById(R.id.destIP);
|
||||
this.mDestip.setText(prefs.getString("destip_str", ""));
|
||||
|
||||
this.mFwTimeout = (EditText) findViewById(R.id.fwTimeout);
|
||||
this.mFwTimeout.setText(prefs.getString("fw_timeout_str", "60"));
|
||||
|
||||
this.mCheck = (CheckBox) findViewById(R.id.startAppCheck);
|
||||
this.mCheck.setChecked(prefs.getBoolean("app_start", false));
|
||||
|
||||
this.mPasswd = (EditText) findViewById(R.id.passwd);
|
||||
this.mOutput = (TextView) findViewById(R.id.output);
|
||||
|
||||
mUnlock = (ImageButton) findViewById(R.id.unlock);
|
||||
mUnlock.setOnClickListener(new OnClickListener() {
|
||||
|
||||
public void onClick(View view) {
|
||||
onStartButton();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public native String sendSPAPacket();
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void installNativeLibs() {
|
||||
//Installation of C libs during apk installation, manual installation is not needed anymore
|
||||
// installNativeLib("libfwknop.so", "/data/data/com.max2idea.android.fwknop/lib");
|
||||
|
||||
//Load the C library
|
||||
loadNativeLib("libfwknop.so", "/data/data/com.max2idea.android.fwknop/lib");
|
||||
}
|
||||
|
||||
//This is not needed anymore, don't use
|
||||
private void installNativeLib(String lib, String destDir) {
|
||||
if (true) {
|
||||
try {
|
||||
String libLocation = destDir + "/" + lib;
|
||||
AssetManager am = this.getAssets();
|
||||
InputStream is = am.open(lib);
|
||||
OutputStream os = new FileOutputStream(libLocation);
|
||||
byte[] buf = new byte[8092];
|
||||
int n;
|
||||
while ((n = is.read(buf)) > 0) {
|
||||
os.write(buf, 0, n);
|
||||
}
|
||||
os.close();
|
||||
is.close();
|
||||
} catch (Exception ex) {
|
||||
Log.e("JNIExample", "failed to install native library: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Load the shared lib
|
||||
private void loadNativeLib(String lib, String destDir) {
|
||||
if (true) {
|
||||
String libLocation = destDir + "/" + lib;
|
||||
try {
|
||||
System.load(libLocation);
|
||||
} catch (Exception ex) {
|
||||
Log.e("JNIExample", "failed to load native library: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Start calling the JNI interface
|
||||
public synchronized void startSPASend() {
|
||||
output = sendSPAPacket();
|
||||
sendHandlerMessage(handler, SPA_SENT);
|
||||
if (startApp) {
|
||||
startApp();
|
||||
}
|
||||
}
|
||||
|
||||
// Not needed
|
||||
public static String sendHttpGet(String url) {
|
||||
HttpConnection hcon = null;
|
||||
DataInputStream dis = null;
|
||||
java.net.URL URL = null;
|
||||
try {
|
||||
URL = new java.net.URL(url);
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(Fwknop.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
StringBuffer responseMessage = new StringBuffer();
|
||||
|
||||
try {
|
||||
// obtain a DataInputStream from the HttpConnection
|
||||
dis = new DataInputStream(URL.openStream());
|
||||
|
||||
// retrieve the response from the server
|
||||
int ch;
|
||||
while ((ch = dis.read()) != -1) {
|
||||
responseMessage.append((char) ch);
|
||||
}//end while ( ( ch = dis.read() ) != -1 )
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
responseMessage.append(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (hcon != null) {
|
||||
hcon.close();
|
||||
}
|
||||
if (dis != null) {
|
||||
dis.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
}//end try/catch
|
||||
}//end try/catch/finally
|
||||
return responseMessage.toString();
|
||||
}//end sendHttpGet( String )
|
||||
|
||||
// Get the external IP from ifconfig.me
|
||||
// Other sites with similar services are whatismyip.com, whatismyip.org
|
||||
public static String getExternalIP() {
|
||||
URL Url = null;
|
||||
HttpURLConnection Conn = null;
|
||||
InputStream InStream = null;
|
||||
InputStreamReader Isr = null;
|
||||
String extIP = "";
|
||||
|
||||
try {
|
||||
Url = new java.net.URL("http://ifconfig.me/ip");
|
||||
Conn = (HttpURLConnection) Url.openConnection();
|
||||
InStream = Conn.getInputStream();
|
||||
Isr = new java.io.InputStreamReader(InStream);
|
||||
BufferedReader Br = new java.io.BufferedReader(Isr);
|
||||
extIP = Br.readLine();
|
||||
Log.v("External IP", "Your external IP address is " + extIP);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Fwknop.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
// Isr.close();
|
||||
// InStream.close();
|
||||
Conn.disconnect();
|
||||
}
|
||||
return extIP;
|
||||
|
||||
}
|
||||
|
||||
// This is easier: traverse the interfaces and get the local IPs
|
||||
public static String getLocalIpAddress() {
|
||||
try {
|
||||
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
||||
NetworkInterface intf = en.nextElement();
|
||||
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||
if (!inetAddress.isLoopbackAddress()) {
|
||||
Log.v("Internal ip", inetAddress.getHostAddress().toString());
|
||||
return inetAddress.getHostAddress().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException ex) {
|
||||
Log.e("Internal IP", ex.toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
52
android/project/src/com/max2idea/android/fwknop/R.java
Normal file
52
android/project/src/com/max2idea/android/fwknop/R.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.max2idea.android.fwknop;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int icon=0x7f020000;
|
||||
public static final int lock_128x128=0x7f020001;
|
||||
public static final int lock_32x32=0x7f020002;
|
||||
public static final int lock_64x64=0x7f020003;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int accessPort=0x7f050008;
|
||||
public static final int accessPortStr=0x7f050007;
|
||||
public static final int accessPortl=0x7f050006;
|
||||
public static final int accessProto=0x7f050005;
|
||||
public static final int accessProtoStr=0x7f050004;
|
||||
public static final int accessProtol=0x7f050003;
|
||||
public static final int allowip=0x7f050002;
|
||||
public static final int allowipl=0x7f050000;
|
||||
public static final int allowipstr=0x7f050001;
|
||||
public static final int destIP=0x7f05000b;
|
||||
public static final int destIPStr=0x7f05000a;
|
||||
public static final int destIPl=0x7f050009;
|
||||
public static final int fwTimeout=0x7f05000e;
|
||||
public static final int fwTimeoutStr=0x7f05000d;
|
||||
public static final int fwTimeoutl=0x7f05000c;
|
||||
public static final int output=0x7f050016;
|
||||
public static final int passwd=0x7f050011;
|
||||
public static final int passwdStr=0x7f050010;
|
||||
public static final int passwdl=0x7f05000f;
|
||||
public static final int startApp=0x7f050013;
|
||||
public static final int startAppCheck=0x7f050014;
|
||||
public static final int startAppl=0x7f050012;
|
||||
public static final int startl=0x7f050015;
|
||||
public static final int unlock=0x7f050017;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int main=0x7f030000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f040000;
|
||||
public static final int app_short_name=0x7f040001;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user