diff --git a/.gitignore b/.gitignore index 5ab0abeb..8b2d31fa 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ serval.c /directory_service /tfw_createfile /fakeradio +/config_test *.so test.*.log testlog diff --git a/Android.mk b/Android.mk index fb3fdd2a..92dfa9ad 100644 --- a/Android.mk +++ b/Android.mk @@ -6,7 +6,7 @@ SERVALD_SRC_FILES = $(SERVAL_SOURCES) $(ANDROIDONLY_SOURCES) SERVALD_LOCAL_CFLAGS = \ -g \ - -DSERVALD_VERSION="\"Android\"" \ + -DSERVALD_VERSION="\"Android\"" -DSERVALD_COPYRIGHT="\"Android\"" \ -DSHELL -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" \ -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" \ -DHAVE_LIBC=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \ @@ -17,7 +17,7 @@ SERVALD_LOCAL_CFLAGS = \ -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_POLL_H=1 -DHAVE_NETDB_H=1 \ -DHAVE_JNI_H=1 -DHAVE_STRUCT_UCRED=1 -DHAVE_CRYPTO_SIGN_NACL_GE25519_H=1 \ -DBYTE_ORDER=_BYTE_ORDER -DHAVE_LINUX_STRUCT_UCRED -DUSE_ABSTRACT_NAMESPACE \ - -DHAVE_BCOPY -DHAVE_BZERO \ + -DHAVE_BCOPY -DHAVE_BZERO -DHAVE_NETINET_IN_H \ -I$(NACL_INC) \ -I$(SQLITE3_INC) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..d6c7b857 --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,24 @@ +Serval DNA Contributors +======================= +[Serval Project][], December 2013 + +The following individuals have contributed to the [Serval DNA][] software. We +apologise for any omissions. If you know of a name that is missing, please +contact us. + +Serval Project team +------------------- + * Dr Paul Gardner-Stephen, Co-founder and Project Lead + * Jeremy Lakeman, Senior Software Engineer + * Andrew Bettison, Senior Software Engineer + * Daniel O'Connor, Senior Software Engineer + +Other contributors +------------------ + * Romain Vimont (®om) + * Dan Staples, Open Technology Institute + * Petter Reinholdtsen + + +[Serval Project]: http://www.servalproject.org/ +[Serval DNA]: https://github.com/servalproject/serval-dna diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt new file mode 100644 index 00000000..e8f65e12 --- /dev/null +++ b/COPYRIGHT.txt @@ -0,0 +1,7 @@ +Portions Copyright (C) 2010-2013 Serval Project Inc. +Portions Copyright (C) 2010-2013 Paul Gardner-Stephen +Portions Copyright (C) 2000-2001 Aaron D. Gifford +Portions Copyright (C) 2010-2012 Serval Project Pty Limited +Portions Copyright (C) 2006-2008 Linpro AS +Portions Copyright (C) 2012 Andrew Tridgell, All Rights Reserved +Portions Copyright (C) 2006 Verdens Gang AS diff --git a/GPL-2.0.txt b/GPL-2.0.txt new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/GPL-2.0.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/Makefile.in b/Makefile.in index 5b939b15..ee5f0e8e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,3 +1,8 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +sbindir=@sbindir@ + NACL_BASE= nacl/src include $(NACL_BASE)/nacl.mk SERVAL_BASE= @@ -23,6 +28,7 @@ MONITORCLIENTSRCS=conf.c \ conf_schema.c \ dataformats.c \ log.c \ + log_util.c \ xprintf.c \ os.c \ mem.c \ @@ -43,10 +49,12 @@ MDPCLIENTSRCS=conf.c \ os.c \ mem.c \ log.c \ + log_util.c \ xprintf.c \ mdp_client.c \ instance.c \ net.c \ + mdp_net.c \ socket.c \ str.c \ strbuf.c \ @@ -68,6 +76,11 @@ CFLAGS+=-Wall -Wno-unused-value CFLAGS+=-DSHA2_USE_INTTYPES_H -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1 # OSX magic to compensate for the Solaris magic CFLAGS+=-D_DARWIN_C_SOURCE + +INSTALL= install +INSTALL_PROGRAM=$(INSTALL) +INSTALL_DATA= $(INSTALL) -m 644 + -include Makefile.dbg # More warnings, discover problems that only happen on some archs @@ -82,16 +95,17 @@ DEFS= @DEFS@ all: servald libmonitorclient.so libmonitorclient.a test -test: tfw_createfile directory_service fakeradio +test: tfw_createfile directory_service fakeradio config_test sqlite-amalgamation-3070900/sqlite3.o: sqlite-amalgamation-3070900/sqlite3.c @echo CC $< @$(CC) $(CFLAGS) $(DEFS) -c $< -o sqlite-amalgamation-3070900/sqlite3.o -version.o: *.h *.c version_string.sh +version.o: *.h *.c version_string.sh COPYRIGHT.txt Makefile @echo CC version_servald.c @V=`./version_string.sh --ignore-untracked` \ - && $(CC) -c version_servald.c -o $@ -DSERVALD_VERSION="\"$$V\"" + && C="`sed -e :a -e N -e '$$!ba' -e 's/[\\\\"]/\\\\&/g' -e 's/\\n/\\\\n/g' COPYRIGHT.txt`" \ + && $(CC) -c version_servald.c -o $@ -DSERVALD_VERSION="\"$$V\"" -DSERVALD_COPYRIGHT="\"$$C\"" %.o: %.c @echo CC $< @@ -117,6 +131,18 @@ fakeradio: fakeradio.o @echo LINK $@ @$(CC) $(CFLAGS) -Wall -o $@ fakeradio.o +config_test: config_test.o conf_om.o conf_schema.o conf_parse.o str.o strbuf.o strbuf_helpers.o mem.o dataformats.o net.o log_util.o + @echo LINK $@ + @$(CC) $(CFLAGS) -Wall -o $@ config_test.o conf_om.o conf_schema.o conf_parse.o str.o strbuf.o strbuf_helpers.o mem.o dataformats.o net.o log_util.o $(LDFLAGS) + +copyright: COPYRIGHT.txt + +findPATH = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) +COPYRIGHT_TOOL := $(call findPATH,sp-copyright-tool) + +COPYRIGHT.txt: *.c *.h $(COPYRIGHT_TOOL) + $(COPYRIGHT_TOOL) -o $@ condense *.c *.h + # This does not build on 64 bit elf platforms as NaCL isn't built with -fPIC # DOC 20120615 libservald.so: $(OBJS) version.o @@ -131,8 +157,14 @@ libmonitorclient.a: $(MONITORCLIENTOBJS) version.o @echo AR $@ @$(AR) -cr $@ $(MONITORCLIENTOBJS) version.o +install: servald + $(INSTALL_PROGRAM) -D servald $(DESTDIR)$(sbindir)/servald + +uninstall: + $(RM) $(DESTDIR)$(sbindir)/servald + clean: - @rm -f $(OBJS) \ + @$(RM) $(OBJS) \ tfw_createfile.o version.o \ fakeradio.o fakeradio \ tfw_createfile servald \ diff --git a/README.md b/README.md index 3adc90bc..145651a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Serval DNA ========== -[Serval Project][], May 2013 +[Serval Project][], December 2013 This repository contains the source code for the “core” Serval components implemented in [GNU C][]: @@ -48,13 +48,12 @@ implemented in [GNU C][]: has two parts: a *manifest* that describes the content, and the *payload*, which is the content itself. Each bundle has its own unique cryptographic identifier that allows any recipient to verify that it has not been tampered - with. + with. A bundle's payload may be encrypted by the author so that only the + designated recipient can read it. - * The **[MeshMS][]** messaging service is implemented using Rhizome as its - transport, with each thread represented as a pair of bundles, one for each - direction. At present, the MeshMS logic is implemented in Java within the - [Serval Mesh][batphone] Android app, but is planned to be re-implemented in - C as part of Serval DNA (see [issue #28][]). + * The **[MeshMS][]** messaging service sends short text messages using Rhizome + as its transport. Each message thread is stored and carried in a pair of + journal bundles, one for each direction (ply). * **[Serval Infrastructure][]** services may optionally be deployed on any devices in the mesh to expose external services to mesh subscribers and vice versa @@ -77,26 +76,31 @@ Project's [serval-dna][] Git repository on [GitHub][]. The copyright in most of the source code in Serval DNA is held by [Serval Project Inc.][SPI], a not-for-profit association incorporated in the state of South Australia in the Commonwealth of Australia for the purpose of developing -the Serval mesh software. +the Serval mesh software. The [COPYRIGHT][] file contains a full list of all +those who hold copyright in portions of the Serval DNA source code. -The [Serval Project][] will accept contributions from individual developers who -have agreed to the [Serval Project Developer Agreement - Individual][individ], -and from organisations that have agreed to the [Serval Project Developer -Agreement - Entity][entity]. +The [Serval Project][] will accept contributions for which copyright has been +assigned to [Serval Project Inc.][SPI], or which are licensed to either [Serval +Project Inc.][SPI] or to the public on terms that allow the Serval Project to +freely redistribute and re-license the code under non-restrictive terms, for +example, to release Serval DNA as part of a product distributed through the +[Apple app store][]. + +Individual developers may assign copyright in their contributions by signing +the [Serval Project Developer Agreement - Individual][individ], and +organisations by signing the [Serval Project Developer Agreement - +Entity][entity]. Download, build and test ------------------------ Instructions for downloading, building and testing Serval DNA are in -[INSTALL.md](./INSTALL.md). (If that link is does not work, try -[INSTALL.md](/servalproject/serval-dna/blob/master/INSTALL.md).) +[INSTALL.md](./INSTALL.md). Configure --------- -See [doc/Servald-Configuration](./doc/Servald-Configuration.md) (alternative -link [doc/Servald-Configuration] -(/servalproject/serval-dna/blob/master/doc/Servald-Configuration.md)). +See [doc/Servald-Configuration](./doc/Servald-Configuration.md). More information ---------------- @@ -115,10 +119,12 @@ via a two-way [pipe][] called the *monitor interface*. For more documentation, see: * the [doc/](./doc/) directory - (alternative link [doc/](/servalproject/serval-dna/tree/master/doc/)) * the [Serval DNA][] page in the [Serval Project Wiki][] + * [CONTRIBUTORS.md](./CONTRIBUTORS.md) All individuals who have contributed + to the software. + [Serval Project]: http://www.servalproject.org/ [Serval Project Wiki]: http://developer.servalproject.org/ [Serval DNA]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:servaldna: @@ -129,9 +135,11 @@ For more documentation, see: [GNU C]: http://gcc.gnu.org/ [daemon]: http://en.wikipedia.org/wiki/Daemon_(computing) [free software]: http://www.gnu.org/philosophy/free-sw.html -[contributors]: /servalproject/serval-dna/blob/master/CONTRIBUTORS.md +[contributors]: /servalproject/serval-dna/blob/development/CONTRIBUTORS.md [GitHub]: https://github.com/servalproject -[GPL2]: http://www.gnu.org/licenses/gpl-2.0.html +[COPYRIGHT]: ./COPYRIGHT.txt +[GPL2]: ./GPL-2.0.txt +[Apple app store]: http://www.fsf.org/blogs/licensing/more-about-the-app-store-gpl-enforcement [individ]: http://developer.servalproject.org/files/serval_project_inc-individual.pdf [entity]: http://developer.servalproject.org/files/serval_project_inc-entity.pdf [DNA]: http://developer.servalproject.org/dokuwiki/doku.php?id=content:tech:dna diff --git a/check-in-out-return.c b/check-in-out-return.c index 8efee5fc..eaf57376 100644 --- a/check-in-out-return.c +++ b/check-in-out-return.c @@ -1,3 +1,22 @@ +/* +Serval DNA source code checker +Copyright 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include diff --git a/cli.c b/cli.c index 2013f262..87b0551d 100644 --- a/cli.c +++ b/cli.c @@ -1,6 +1,6 @@ /* Serval DNA command-line functions -Copyright (C) 2010-2013 Serval Project, Inc. +Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -340,17 +340,17 @@ int cli_optional_sid(const char *arg) int cli_optional_bundle_key(const char *arg) { - return !arg[0] || rhizome_str_is_bundle_key(arg); + return !arg[0] || str_to_rhizome_bk_t(NULL, arg) != -1; } int cli_manifestid(const char *arg) { - return rhizome_str_is_manifest_id(arg); + return str_to_rhizome_bid_t(NULL, arg) != -1; } int cli_fileid(const char *arg) { - return rhizome_str_is_file_hash(arg); + return str_to_rhizome_filehash_t(NULL, arg) != -1; } int cli_optional_bundle_crypt_key(const char *arg) diff --git a/cli.h b/cli.h index 4a340f22..1c139278 100644 --- a/cli.h +++ b/cli.h @@ -1,6 +1,6 @@ /* Serval command line parsing and processing. - Copyright (C) 2012,2013 Serval Project, Inc. + Copyright (C) 2012,2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_CLI_H -#define __SERVALD_CLI_H +#ifndef __SERVAL_DNA__CLI_H +#define __SERVAL_DNA__CLI_H #include "xprintf.h" #include "log.h" @@ -102,4 +102,4 @@ void cli_put_long(struct cli_context *context, int64_t value, const char *delim) void cli_put_string(struct cli_context *context, const char *value, const char *delim); void cli_put_hexvalue(struct cli_context *context, const unsigned char *value, int length, const char *delim); -#endif // __SERVALD_CLI_H +#endif // __SERVAL_DNA__CLI_H diff --git a/commandline.c b/commandline.c index 11be1a4a..bb9731d2 100644 --- a/commandline.c +++ b/commandline.c @@ -1,6 +1,6 @@ /* Serval DNA command-line functions -Copyright (C) 2010-2013 Serval Project, Inc. +Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -56,6 +56,17 @@ int commandline_usage(const struct cli_parsed *parsed, struct cli_context *conte return cli_usage_parsed(parsed, XPRINTF_STDIO(stdout)); } +int version_message(const struct cli_parsed *parsed, struct cli_context *context) +{ + printf("Serval DNA version %s\n%s\n", version_servald, copyright_servald); + printf("\ +License GPLv2+: GNU GPL version 2 or later .\n\ +This is free software: you are free to change and redistribute it.\n\ +There is NO WARRANTY, to the extent permitted by law.\n\ +"); + return 0; +} + /* Data structures for accumulating output of a single JNI call. */ @@ -2871,6 +2882,8 @@ int app_network_scan(const struct cli_parsed *parsed, struct cli_context *contex struct cli_schema command_line_options[]={ {commandline_usage,{"help|-h|--help","...",NULL},CLIFLAG_PERMISSIVE_CONFIG, "Display command usage."}, + {version_message,{"version|copyright"},CLIFLAG_PERMISSIVE_CONFIG, + "Display copyright information."}, {app_echo,{"echo","[-e]","[--]","...",NULL},CLIFLAG_PERMISSIVE_CONFIG, "Output the supplied string."}, {app_log,{"log","error|warn|hint|info|debug","",NULL},CLIFLAG_PERMISSIVE_CONFIG, diff --git a/conf.h b/conf.h index 2a3fbb7d..15310a07 100644 --- a/conf.h +++ b/conf.h @@ -222,8 +222,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * @author Andrew Bettison */ -#ifndef __SERVALDNA_CONFIG_H -#define __SERVALDNA_CONFIG_H +#ifndef __SERVAL_DNA__CONF_H +#define __SERVAL_DNA__CONF_H #include #include @@ -701,4 +701,4 @@ int cf_reload(); int cf_reload_strict(); int cf_reload_permissive(); -#endif //__SERVALDNA_CONFIG_H +#endif //__SERVAL_DNA__CONF_H diff --git a/conf_schema.c b/conf_schema.c index c53c74f5..bf7ee794 100644 --- a/conf_schema.c +++ b/conf_schema.c @@ -633,11 +633,7 @@ int cf_cmp_sid(const sid_t *a, const sid_t *b) int cf_opt_rhizome_bk(rhizome_bk_t *bkp, const char *text) { - if (!rhizome_str_is_bundle_key(text)) - return CFINVALID; - size_t n = fromhex(bkp->binary, text, RHIZOME_BUNDLE_KEY_BYTES); - assert(n == RHIZOME_BUNDLE_KEY_BYTES); - return CFOK; + return str_to_rhizome_bk_t(bkp, text) ? CFOK : CFINVALID; } int cf_fmt_rhizome_bk(const char **textp, const rhizome_bk_t *bkp) diff --git a/config_test.c b/config_test.c index 7cff08fc..87f8ec66 100644 --- a/config_test.c +++ b/config_test.c @@ -1,8 +1,28 @@ +/* +Serval DNA configuration stand-alone configuration check utility +Copyright 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include #include #include #include +#include #include #include "str.h" @@ -30,7 +50,7 @@ int main(int argc, char **argv) exit(1); } struct cf_om_node *root = NULL; - int ret = cf_parse_to_om(argv[i], buf, st.st_size, &root); + int ret = cf_om_parse(argv[i], buf, st.st_size, &root); close(fd); DEBUGF("ret = %s", strbuf_str(strbuf_cf_flags(strbuf_alloca(128), ret))); //cf_dump_node(root, 0); @@ -38,17 +58,17 @@ int main(int argc, char **argv) memset(&config, 0, sizeof config); cf_dfl_config_main(&config); int result = root ? cf_opt_config_main(&config, root) : CFEMPTY; - cf_free_node(&root); + cf_om_free_node(&root); free(buf); DEBUGF("result = %s", strbuf_str(strbuf_cf_flags(strbuf_alloca(128), result))); - DEBUGF("config.log.file = %s", alloca_str_toprint(config.log.file)); - DEBUGF("config.log.show_pid = %d", config.log.show_pid); - DEBUGF("config.log.show_time = %d", config.log.show_time); + DEBUGF("config.log.file.path = %s", alloca_str_toprint(config.log.file.path)); + DEBUGF("config.log.file.show_pid = %d", config.log.file.show_pid); + DEBUGF("config.log.file.show_time = %d", config.log.file.show_time); DEBUGF("config.server.chdir = %s", alloca_str_toprint(config.server.chdir)); - DEBUGF("config.debug = %"PRIx64, (uint64_t) config.debug); + DEBUGF("config.debug.verbose = %d", config.debug.verbose); DEBUGF("config.directory.service = %s", alloca_tohex_sid_t(config.directory.service)); DEBUGF("config.rhizome.api.addfile.allow_host = %s", inet_ntoa(config.rhizome.api.addfile.allow_host)); - int j; + unsigned j; for (j = 0; j < config.mdp.iftype.ac; ++j) { DEBUGF("config.mdp.iftype.%u", config.mdp.iftype.av[j].key); DEBUGF(" .tick_ms = %u", config.mdp.iftype.av[j].value.tick_ms); @@ -63,7 +83,7 @@ int main(int argc, char **argv) DEBUGF(" .port = %u", config.rhizome.direct.peer.av[j].value.port); } for (j = 0; j < config.interfaces.ac; ++j) { - DEBUGF("config.interfaces.%s", config.interfaces.av[j].key); + DEBUGF("config.interfaces.%u", config.interfaces.av[j].key); DEBUGF(" .exclude = %d", config.interfaces.av[j].value.exclude); DEBUGF(" .match = ["); int k; @@ -72,7 +92,9 @@ int main(int argc, char **argv) DEBUGF(" ]"); DEBUGF(" .type = %d", config.interfaces.av[j].value.type); DEBUGF(" .port = %u", config.interfaces.av[j].value.port); - DEBUGF(" .speed = %llu", (unsigned long long) config.interfaces.av[j].value.speed); + DEBUGF(" .drop_broadcasts = %llu", (unsigned long long) config.interfaces.av[j].value.drop_broadcasts); + DEBUGF(" .drop_unicasts = %llu", (unsigned long long) config.interfaces.av[j].value.drop_unicasts); + DEBUGF(" .drop_packets = %llu", (unsigned long long) config.interfaces.av[j].value.drop_packets); } for (j = 0; j < config.hosts.ac; ++j) { char sidhex[SID_STRLEN + 1]; @@ -129,37 +151,3 @@ void logMessage(int level, struct __sourceloc whence, const char *fmt, ...) va_end(ap); fputc('\n', stderr); } - -debugflags_t debugFlagMask(const char *flagname) -{ - if (!strcasecmp(flagname,"all")) return ~0; - else if (!strcasecmp(flagname,"interfaces")) return 1 << 0; - else if (!strcasecmp(flagname,"rx")) return 1 << 1; - else if (!strcasecmp(flagname,"tx")) return 1 << 2; - else if (!strcasecmp(flagname,"verbose")) return 1 << 3; - else if (!strcasecmp(flagname,"verbio")) return 1 << 4; - else if (!strcasecmp(flagname,"peers")) return 1 << 5; - else if (!strcasecmp(flagname,"dnaresponses")) return 1 << 6; - else if (!strcasecmp(flagname,"dnahelper")) return 1 << 7; - else if (!strcasecmp(flagname,"vomp")) return 1 << 8; - else if (!strcasecmp(flagname,"packetformats")) return 1 << 9; - else if (!strcasecmp(flagname,"packetconstruction")) return 1 << 10; - else if (!strcasecmp(flagname,"gateway")) return 1 << 11; - else if (!strcasecmp(flagname,"keyring")) return 1 << 12; - else if (!strcasecmp(flagname,"sockio")) return 1 << 13; - else if (!strcasecmp(flagname,"frames")) return 1 << 14; - else if (!strcasecmp(flagname,"abbreviations")) return 1 << 15; - else if (!strcasecmp(flagname,"routing")) return 1 << 16; - else if (!strcasecmp(flagname,"security")) return 1 << 17; - else if (!strcasecmp(flagname,"rhizome")) return 1 << 18; - else if (!strcasecmp(flagname,"rhizometx")) return 1 << 19; - else if (!strcasecmp(flagname,"rhizomerx")) return 1 << 20; - else if (!strcasecmp(flagname,"rhizomeads")) return 1 << 21; - else if (!strcasecmp(flagname,"monitorroutes")) return 1 << 22; - else if (!strcasecmp(flagname,"queues")) return 1 << 23; - else if (!strcasecmp(flagname,"broadcasts")) return 1 << 24; - else if (!strcasecmp(flagname,"manifests")) return 1 << 25; - else if (!strcasecmp(flagname,"mdprequests")) return 1 << 26; - else if (!strcasecmp(flagname,"timing")) return 1 << 27; - return 0; -} diff --git a/constants.h b/constants.h index cc8b4ffb..7af118b0 100644 --- a/constants.h +++ b/constants.h @@ -16,8 +16,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_CONSTANTS_H -#define __SERVALD_CONSTANTS_H +#ifndef __SERVAL_DNA__CONSTANTS_H +#define __SERVAL_DNA__CONSTANTS_H #define NELS(a) (sizeof (a) / sizeof *(a)) @@ -224,4 +224,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. typedef char bool_t; -#endif // __SERVALD_CONSTANTS_H +#endif // __SERVAL_DNA__CONSTANTS_H diff --git a/crypto.c b/crypto.c index 550a7aec..e2e9fe7b 100644 --- a/crypto.c +++ b/crypto.c @@ -1,3 +1,22 @@ +/* +Serval DNA internal cryptographic operations +Copyright 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "crypto_sign_edwards25519sha512batch.h" #include "nacl/src/crypto_sign_edwards25519sha512batch_ref/ge.h" #include "serval.h" diff --git a/crypto.h b/crypto.h index ec5c51e0..74190a7f 100644 --- a/crypto.h +++ b/crypto.h @@ -1,6 +1,24 @@ +/* +Serval DNA internal cryptographic operations +Copyright 2013 Serval Project Inc. -#ifndef __SERVALD_CRYPTO_H -#define __SERVALD_CRYPTO_H +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __SERVAL_DNA__CRYPTO_H +#define __SERVAL_DNA__CRYPTO_H #include "nacl.h" #define SIGNATURE_BYTES crypto_sign_edwards25519sha512batch_BYTES diff --git a/dataformats.c b/dataformats.c index ed841ca2..28238ef7 100644 --- a/dataformats.c +++ b/dataformats.c @@ -1,6 +1,6 @@ /* -Serval Distributed Numbering Architecture (DNA) -Copyright (C) 2010 Paul Gardner-Stephen +Serval DNA data interchange formats +Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,17 +28,20 @@ int cmp_sid_t(const sid_t *a, const sid_t *b) return memcmp(a, b, sizeof a->binary); } -int str_to_sid_t(sid_t *sid, const char *hex) { +int str_to_sid_t(sid_t *sid, const char *hex) +{ if (strcmp(hex, "broadcast") == 0) { - *sid = SID_BROADCAST; + if (sid) + *sid = SID_BROADCAST; return 0; } - return fromhexstr(sid->binary, hex, sizeof sid->binary); + return sid ? fromhexstr(sid->binary, hex, sizeof sid->binary) : is_xstring(hex, SID_STRLEN) ? 0 : -1; } int strn_to_sid_t(sid_t *sid, const char *hex, const char **endp) { if (str_startswith(hex, "broadcast", endp) == 0) { + if (sid) *sid = SID_BROADCAST; return 0; } @@ -80,7 +83,7 @@ int cmp_rhizome_bid_t(const rhizome_bid_t *a, const rhizome_bid_t *b) int str_to_rhizome_bid_t(rhizome_bid_t *bid, const char *hex) { - return fromhexstr(bid->binary, hex, sizeof bid->binary); + return bid ? fromhexstr(bid->binary, hex, sizeof bid->binary) : is_xstring(hex, RHIZOME_BUNDLE_ID_STRLEN) ? 0 : -1; } int strn_to_rhizome_bid_t(rhizome_bid_t *bid, const char *hex, const char **endp) @@ -102,7 +105,7 @@ int cmp_rhizome_filehash_t(const rhizome_filehash_t *a, const rhizome_filehash_t int str_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex) { - return fromhexstr(hashp->binary, hex, sizeof hashp->binary); + return hashp ? fromhexstr(hashp->binary, hex, sizeof hashp->binary) : is_xstring(hex, RHIZOME_FILEHASH_STRLEN) ? 0 : -1; } int strn_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex, const char **endp) @@ -119,27 +122,7 @@ int strn_to_rhizome_filehash_t(rhizome_filehash_t *hashp, const char *hex, const int str_to_rhizome_bk_t(rhizome_bk_t *bkp, const char *hex) { - return fromhexstr(bkp->binary, hex, sizeof bkp->binary); -} - -int rhizome_strn_is_manifest_id(const char *id) -{ - return is_xsubstring(id, RHIZOME_MANIFEST_ID_STRLEN); -} - -int rhizome_str_is_manifest_id(const char *id) -{ - return is_xstring(id, RHIZOME_MANIFEST_ID_STRLEN); -} - -int rhizome_strn_is_bundle_key(const char *key) -{ - return is_xsubstring(key, RHIZOME_BUNDLE_KEY_STRLEN); -} - -int rhizome_str_is_bundle_key(const char *key) -{ - return is_xstring(key, RHIZOME_BUNDLE_KEY_STRLEN); + return bkp ? fromhexstr(bkp->binary, hex, sizeof bkp->binary) : is_xstring(hex, RHIZOME_BUNDLE_KEY_STRLEN) ? 0 : -1; } int rhizome_strn_is_bundle_crypt_key(const char *key) @@ -152,16 +135,6 @@ int rhizome_str_is_bundle_crypt_key(const char *key) return is_xstring(key, RHIZOME_CRYPT_KEY_STRLEN); } -int rhizome_strn_is_file_hash(const char *hash) -{ - return is_xsubstring(hash, RHIZOME_FILEHASH_STRLEN); -} - -int rhizome_str_is_file_hash(const char *hash) -{ - return is_xstring(hash, RHIZOME_FILEHASH_STRLEN); -} - int rhizome_str_is_manifest_service(const char *text) { if (text[0] == '\0') @@ -171,6 +144,19 @@ int rhizome_str_is_manifest_service(const char *text) return *text == '\0'; } +/* A name cannot contain a LF because that is the Rhizome text manifest field terminator. For the + * time being, CR is not allowed either, because the Rhizome field terminator includes an optional + * CR. See rhizome_manifest_parse(). + * + * @author Andrew Bettison + */ +int rhizome_str_is_manifest_name(const char *text) +{ + while (*text && *text != '\n' && *text != '\r') + ++text; + return *text == '\0'; +} + int str_is_did(const char *did) { size_t len = 0; diff --git a/dataformats.h b/dataformats.h index 67afb746..26c9fb7c 100644 --- a/dataformats.h +++ b/dataformats.h @@ -1,5 +1,23 @@ -#ifndef __SERVALD_DATA_FORMATS_H -#define __SERVALD_DATA_FORMATS_H +/* +Serval DNA data interchange formats +Copyright (C) 2012-2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef __SERVAL_DNA___DATA_FORMATS_H +#define __SERVAL_DNA___DATA_FORMATS_H int str_is_subscriber_id(const char *sid); int strn_is_subscriber_id(const char *sid, size_t *lenp); @@ -15,6 +33,7 @@ int rhizome_str_is_bundle_crypt_key(const char *text); int rhizome_strn_is_file_hash(const char *text); int rhizome_str_is_file_hash(const char *text); int rhizome_str_is_manifest_service(const char *text); +int rhizome_str_is_manifest_name(const char *text); void write_uint64(unsigned char *o,uint64_t v); void write_uint16(unsigned char *o,uint16_t v); @@ -23,4 +42,4 @@ uint64_t read_uint64(const unsigned char *o); uint32_t read_uint32(const unsigned char *o); uint16_t read_uint16(const unsigned char *o); -#endif +#endif //__SERVAL_DNA___DATA_FORMATS_H diff --git a/directory_client.c b/directory_client.c index 1f542464..5ac3ac19 100644 --- a/directory_client.c +++ b/directory_client.c @@ -1,3 +1,21 @@ +/* +Serval DNA directory service client +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ /* diff --git a/directory_service.c b/directory_service.c index 6f09e32e..d89638a4 100644 --- a/directory_service.c +++ b/directory_service.c @@ -1,3 +1,21 @@ +/* +Serval DNA directory service +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ #ifdef HAVE_POLL_H #include diff --git a/fakeradio.c b/fakeradio.c index 2ed5441f..c0cb6a81 100644 --- a/fakeradio.c +++ b/fakeradio.c @@ -1,3 +1,22 @@ +/* +Serval DNA radio serial modem simulator +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include #include diff --git a/fdqueue.h b/fdqueue.h index df09e5b3..4a2adb29 100644 --- a/fdqueue.h +++ b/fdqueue.h @@ -1,6 +1,6 @@ /* Serval DNA file descriptor queue -Copyright (C) 2012-2013 Serval Project, Inc. +Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA__FDQUEUE_H -#define __SERVALDNA__FDQUEUE_H +#ifndef __SERVAL_DNA__FDQUEUE_H +#define __SERVAL_DNA__FDQUEUE_H #ifdef HAVE_POLL_H #include @@ -91,4 +91,4 @@ unsigned fd_depth(); #define RETURNNULL(X) do { X; OUT(); return (NULL); } while (0) #define RETURNVOID do { OUT(); return; } while (0) -#endif // __SERVALDNA__FDQUEUE_H +#endif // __SERVAL_DNA__FDQUEUE_H diff --git a/fifo.c b/fifo.c index 1b1530ce..8a8684c8 100644 --- a/fifo.c +++ b/fifo.c @@ -1,3 +1,22 @@ +/* +Serval DNA FIFO primitives +Copyright (C) 2012 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + /* * This is a simple FIFO implementation using a circular buffer. * diff --git a/fifo.h b/fifo.h index cb989921..40d63e88 100644 --- a/fifo.h +++ b/fifo.h @@ -1,3 +1,24 @@ +/* +Serval DNA FIFO primitives +Copyright (C) 2012 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +struct fifo; + struct fifo *fifo_alloc(unsigned int size); void fifo_free(struct fifo *fifo); void fifo_reset(struct fifo *fifo); @@ -6,8 +27,3 @@ unsigned int fifo_get(struct fifo *fifo, uint8_t *buffer, unsigned int len); unsigned int fifo_unget(struct fifo *fifo, uint8_t *buffer, unsigned int len); unsigned int fifo_avail(struct fifo *fifo); unsigned int fifo_space(struct fifo *fifo); - - - - - diff --git a/golay.c b/golay.c index 119cdae5..9599a497 100644 --- a/golay.c +++ b/golay.c @@ -1,3 +1,21 @@ +/* +Serval DNA Golay coding +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ #define POLY 0xAE3 /* or use the other polynomial, 0xC75 */ #include diff --git a/golay.h b/golay.h index 506eeacc..4d3641a9 100644 --- a/golay.h +++ b/golay.h @@ -1,8 +1,26 @@ +/* +Serval DNA Golay coding +Copyright (C) 2013 Serval Project Inc. -#ifndef __SERVALD_GOLAY_H -#define __SERVALD_GOLAY_H +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __SERVAL_DNA__GOLAY_H +#define __SERVAL_DNA__GOLAY_H int golay_encode(uint8_t *data); int golay_decode(int *errs, uint8_t *data); -#endif \ No newline at end of file +#endif diff --git a/http_server.c b/http_server.c index 814f0919..1a2193a2 100644 --- a/http_server.c +++ b/http_server.c @@ -1,6 +1,6 @@ /* Serval DNA - HTTP Server -Copyright (C) 2013 Serval Project, Inc. +Copyright (C) 2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/http_server.h b/http_server.h index baab6e75..86c88c32 100644 --- a/http_server.h +++ b/http_server.h @@ -1,6 +1,6 @@ /* Serval DNA - HTTP Server API -Copyright (C) 2013 Serval Project, Inc. +Copyright (C) 2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA__HTTP_SERVER_H -#define __SERVALDNA__HTTP_SERVER_H +#ifndef __SERVAL_DNA__HTTP_SERVER_H +#define __SERVAL_DNA__HTTP_SERVER_H #include #include "constants.h" @@ -207,4 +207,4 @@ struct http_request { char buffer[8 * 1024]; }; -#endif // __SERVALDNA__HTTP_SERVER_H +#endif // __SERVAL_DNA__HTTP_SERVER_H diff --git a/keyring.c b/keyring.c index 3182e6bb..1593d315 100644 --- a/keyring.c +++ b/keyring.c @@ -1,5 +1,7 @@ /* -Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project. +Serval DNA keyring +Copyright (C) 2013 Serval Project Inc. +Copyright (C) 2010-2012 Paul Gardner-Stephen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/keyring.h b/keyring.h index 85492447..f1368d91 100644 --- a/keyring.h +++ b/keyring.h @@ -1,5 +1,25 @@ -#ifndef __SERVALD_KEYRING_H -#define __SERVALD_KEYRING_H +/* +Serval DNA keyring +Copyright (C) 2013 Serval Project Inc. +Copyright (C) 2010-2012 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __SERVAL_DNA__KEYRING_H +#define __SERVAL_DNA__KEYRING_H typedef struct keypair { int type; @@ -106,4 +126,4 @@ int keyring_find_public_tag_value(const keyring_file *k, int *cn, int *in, int * int keyring_unpack_tag(const unsigned char *packed, size_t packed_len, const char **name, const unsigned char **value, size_t *length); int keyring_pack_tag(unsigned char *packed, size_t *packed_len, const char *name, const unsigned char *value, size_t length); -#endif // __SERVALD_KEYRING_H +#endif // __SERVAL_DNA__KEYRING_H diff --git a/log.c b/log.c index 85f7a99a..15a60733 100644 --- a/log.c +++ b/log.c @@ -1,5 +1,5 @@ /* -Serval DNA logging. +Serval DNA logging Copyright 2013 Serval Project Inc. This program is free software; you can redistribute it and/or @@ -717,30 +717,6 @@ void logConfigChanged() logFlush(); } -int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len) -{ - if (level != LOG_LEVEL_SILENT) { - char buf[100]; - size_t i; - if (name) - logMessage(level, whence, "Dump of %s", name); - for(i = 0; i < len; i += 16) { - strbuf b = strbuf_local(buf, sizeof buf); - strbuf_sprintf(b, " %04zx :", i); - int j; - for (j = 0; j < 16 && i + j < len; j++) - strbuf_sprintf(b, " %02x", addr[i + j]); - for (; j < 16; j++) - strbuf_puts(b, " "); - strbuf_puts(b, " "); - for (j = 0; j < 16 && i + j < len; j++) - strbuf_sprintf(b, "%c", addr[i+j] >= ' ' && addr[i+j] < 0x7f ? addr[i+j] : '.'); - logMessage(level, whence, "%s", strbuf_str(b)); - } - } - return 0; -} - ssize_t get_self_executable_path(char *buf, size_t len) { #if defined(linux) @@ -860,31 +836,3 @@ int log_backtrace(int level, struct __sourceloc whence) #endif return 0; } - -const char *log_level_as_string(int level) -{ - switch (level) { - case LOG_LEVEL_SILENT: return "silent"; - case LOG_LEVEL_DEBUG: return "debug"; - case LOG_LEVEL_INFO: return "info"; - case LOG_LEVEL_HINT: return "hint"; - case LOG_LEVEL_WARN: return "warn"; - case LOG_LEVEL_ERROR: return "error"; - case LOG_LEVEL_FATAL: return "fatal"; - case LOG_LEVEL_NONE: return "none"; - } - return NULL; -} - -int string_to_log_level(const char *text) -{ - if (strcasecmp(text, "none") == 0) return LOG_LEVEL_NONE; - if (strcasecmp(text, "fatal") == 0) return LOG_LEVEL_FATAL; - if (strcasecmp(text, "error") == 0) return LOG_LEVEL_ERROR; - if (strcasecmp(text, "warn") == 0) return LOG_LEVEL_WARN; - if (strcasecmp(text, "hint") == 0) return LOG_LEVEL_HINT; - if (strcasecmp(text, "info") == 0) return LOG_LEVEL_INFO; - if (strcasecmp(text, "debug") == 0) return LOG_LEVEL_DEBUG; - if (strcasecmp(text, "silent") == 0) return LOG_LEVEL_SILENT; - return LOG_LEVEL_INVALID; -} diff --git a/log.h b/log.h index 1d1b743f..bb27d124 100644 --- a/log.h +++ b/log.h @@ -16,8 +16,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_LOG_H -#define __SERVALD_LOG_H +#ifndef __SERVAL_DNA__LOG_H +#define __SERVAL_DNA__LOG_H #include #include @@ -161,4 +161,4 @@ struct strbuf; #define BACKTRACE log_backtrace(LOG_LEVEL_FATAL, __WHENCE__) -#endif // __SERVALD_LOG_H +#endif // __SERVAL_DNA__LOG_H diff --git a/log_util.c b/log_util.c new file mode 100644 index 00000000..4efbaafb --- /dev/null +++ b/log_util.c @@ -0,0 +1,73 @@ +/* +Serval DNA logging utility functions +Copyright 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "log.h" +#include "strbuf.h" + +int logDump(int level, struct __sourceloc whence, char *name, const unsigned char *addr, size_t len) +{ + if (level != LOG_LEVEL_SILENT) { + char buf[100]; + size_t i; + if (name) + logMessage(level, whence, "Dump of %s", name); + for(i = 0; i < len; i += 16) { + strbuf b = strbuf_local(buf, sizeof buf); + strbuf_sprintf(b, " %04zx :", i); + int j; + for (j = 0; j < 16 && i + j < len; j++) + strbuf_sprintf(b, " %02x", addr[i + j]); + for (; j < 16; j++) + strbuf_puts(b, " "); + strbuf_puts(b, " "); + for (j = 0; j < 16 && i + j < len; j++) + strbuf_sprintf(b, "%c", addr[i+j] >= ' ' && addr[i+j] < 0x7f ? addr[i+j] : '.'); + logMessage(level, whence, "%s", strbuf_str(b)); + } + } + return 0; +} + +const char *log_level_as_string(int level) +{ + switch (level) { + case LOG_LEVEL_SILENT: return "silent"; + case LOG_LEVEL_DEBUG: return "debug"; + case LOG_LEVEL_INFO: return "info"; + case LOG_LEVEL_HINT: return "hint"; + case LOG_LEVEL_WARN: return "warn"; + case LOG_LEVEL_ERROR: return "error"; + case LOG_LEVEL_FATAL: return "fatal"; + case LOG_LEVEL_NONE: return "none"; + } + return NULL; +} + +int string_to_log_level(const char *text) +{ + if (strcasecmp(text, "none") == 0) return LOG_LEVEL_NONE; + if (strcasecmp(text, "fatal") == 0) return LOG_LEVEL_FATAL; + if (strcasecmp(text, "error") == 0) return LOG_LEVEL_ERROR; + if (strcasecmp(text, "warn") == 0) return LOG_LEVEL_WARN; + if (strcasecmp(text, "hint") == 0) return LOG_LEVEL_HINT; + if (strcasecmp(text, "info") == 0) return LOG_LEVEL_INFO; + if (strcasecmp(text, "debug") == 0) return LOG_LEVEL_DEBUG; + if (strcasecmp(text, "silent") == 0) return LOG_LEVEL_SILENT; + return LOG_LEVEL_INVALID; +} diff --git a/main.c b/main.c index 38279a38..c0437063 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,6 @@ /* -Serval daemon -Copyright (C) 2012 The Serval Project +Serval DNA daemon +Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/mdp_client.c b/mdp_client.c index 0c4b6975..2cb7e0e1 100644 --- a/mdp_client.c +++ b/mdp_client.c @@ -1,5 +1,6 @@ /* - Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project. + Copyright (C) 2010-2012 Paul Gardner-Stephen + Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/mdp_client.h b/mdp_client.h index 47fbd33c..a93e0a3c 100644 --- a/mdp_client.h +++ b/mdp_client.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Serval Project. + Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -16,8 +16,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_MDP_CLIENT_H -#define __SERVALD_MDP_CLIENT_H +#ifndef __SERVAL_DNA__MDP_CLIENT_H +#define __SERVAL_DNA__MDP_CLIENT_H #include "serval.h" diff --git a/mdp_net.c b/mdp_net.c new file mode 100644 index 00000000..fa3e5131 --- /dev/null +++ b/mdp_net.c @@ -0,0 +1,74 @@ +/* +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "socket.h" +#include "conf.h" +#include "log.h" + +ssize_t recvwithttl(int sock,unsigned char *buffer, size_t bufferlen,int *ttl, struct socket_address *recvaddr) +{ + struct msghdr msg; + struct iovec iov[1]; + struct cmsghdr cmsgcmsg[16]; + iov[0].iov_base=buffer; + iov[0].iov_len=bufferlen; + bzero(&msg,sizeof(msg)); + msg.msg_name = &recvaddr->store; + msg.msg_namelen = recvaddr->addrlen; + msg.msg_iov = &iov[0]; + msg.msg_iovlen = 1; + msg.msg_control = cmsgcmsg; + msg.msg_controllen = sizeof cmsgcmsg; + msg.msg_flags = 0; + + ssize_t len = recvmsg(sock,&msg,0); + if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK) + return WHYF_perror("recvmsg(%d,%p,0)", sock, &msg); + +#if 0 + if (config.debug.packetrx) { + DEBUGF("recvmsg returned %d (flags=%d, msg_controllen=%d)", (int) len, msg.msg_flags, (int)msg.msg_controllen); + dump("received data", buffer, len); + } +#endif + + if (len > 0) { + struct cmsghdr *cmsg; + for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { + if ( cmsg->cmsg_level == IPPROTO_IP + && ((cmsg->cmsg_type == IP_RECVTTL) || (cmsg->cmsg_type == IP_TTL)) + && cmsg->cmsg_len + ) { + if (config.debug.packetrx) + DEBUGF(" TTL (%p) data location resolves to %p", ttl,CMSG_DATA(cmsg)); + if (CMSG_DATA(cmsg)) { + *ttl = *(unsigned char *) CMSG_DATA(cmsg); + if (config.debug.packetrx) + DEBUGF(" TTL of packet is %d", *ttl); + } + } else { + if (config.debug.packetrx) + DEBUGF("I didn't expect to see level=%02x, type=%02x", + cmsg->cmsg_level,cmsg->cmsg_type); + } + } + } + recvaddr->addrlen = msg.msg_namelen; + + return len; +} diff --git a/mem.h b/mem.h index e6f3cda9..498df4c4 100644 --- a/mem.h +++ b/mem.h @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA__MEM_H -#define __SERVALDNA__MEM_H +#ifndef __SERVAL_DNA__MEM_H +#define __SERVAL_DNA__MEM_H #include #include "log.h" @@ -69,4 +69,4 @@ char *_strn_edup(struct __sourceloc, const char *str, size_t len); #define str_edup(str) _str_edup(__HERE__, (str)) #define strn_edup(str, len) _strn_edup(__HERE__, (str), (len)) -#endif // __SERVALDNA__MEM_H +#endif // __SERVAL_DNA__MEM_H diff --git a/meshms.c b/meshms.c index 3c3d18ca..9c43f8b4 100644 --- a/meshms.c +++ b/meshms.c @@ -1,3 +1,22 @@ +/* +Serval DNA MeshMS +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include "serval.h" #include "rhizome.h" @@ -385,10 +404,6 @@ static int update_conversation(const sid_t *my_sid, struct conversations *conv){ if (config.debug.meshms) DEBUG("Locating their last message"); - // find the offset of their last message - if (rhizome_retrieve_manifest(&conv->their_ply.bundle_id, m_theirs)) - goto end; - if (ply_read_open(&ply, &conv->their_ply.bundle_id, m_theirs)) goto end; @@ -421,9 +436,6 @@ static int update_conversation(const sid_t *my_sid, struct conversations *conv){ m_ours = rhizome_new_manifest(); if (!m_ours) goto end; - if (rhizome_retrieve_manifest(&conv->my_ply.bundle_id, m_ours)) - goto end; - if (ply_read_open(&ply, &conv->my_ply.bundle_id, m_ours)) goto end; diff --git a/monitor-client.c b/monitor-client.c index 35ef276e..ad3afcb4 100644 --- a/monitor-client.c +++ b/monitor-client.c @@ -1,5 +1,6 @@ /* -Copyright (C) 2012 Paul Gardner-Stephen, Serval Project. +Copyright (C) 2012 Paul Gardner-Stephen +Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/monitor-client.h b/monitor-client.h index 810058a1..c40231c3 100644 --- a/monitor-client.h +++ b/monitor-client.h @@ -1,5 +1,6 @@ /* -Copyright (C) 2012 Paul Gardner-Stephen, Serval Project. +Copyright (C) 2012 Paul Gardner-Stephen +Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -16,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_MONITOR_CLIENT_H -#define __SERVALD_MONITOR_CLIENT_H +#ifndef __SERVAL_DNA__MONITOR_CLIENT_H +#define __SERVAL_DNA__MONITOR_CLIENT_H struct monitor_state; @@ -34,4 +35,4 @@ int monitor_client_read(int fd, struct monitor_state *res, struct monitor_comman int monitor_client_close(int fd, struct monitor_state *res); int monitor_socket_name(struct sockaddr_un *name); -#endif \ No newline at end of file +#endif diff --git a/monitor.c b/monitor.c index a27e4168..f60c370c 100644 --- a/monitor.c +++ b/monitor.c @@ -1,5 +1,6 @@ /* -Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project. +Copyright (C) 2010-2012 Paul Gardner-Stephen +Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -575,7 +576,7 @@ static int monitor_help(const struct cli_parsed *parsed, struct cli_context *con int monitor_announce_bundle(rhizome_manifest *m) { char msg[1024]; - int len = snprintf(msg,1024,"\n*%d:BUNDLE:%s\n", + int len = snprintf(msg,1024,"\n*%zd:BUNDLE:%s\n", m->manifest_all_bytes, alloca_tohex_rhizome_bid_t(m->cryptoSignPublic)); bcopy(m->manifestdata, &msg[len], m->manifest_all_bytes); diff --git a/net.c b/net.c index 73c744ca..8a3b7dfa 100644 --- a/net.c +++ b/net.c @@ -138,56 +138,3 @@ ssize_t _write_str_nonblock(int fd, const char *str, struct __sourceloc __whence { return _write_all_nonblock(fd, str, strlen(str), __whence); } - -ssize_t recvwithttl(int sock,unsigned char *buffer, size_t bufferlen,int *ttl, struct socket_address *recvaddr) -{ - struct msghdr msg; - struct iovec iov[1]; - struct cmsghdr cmsgcmsg[16]; - iov[0].iov_base=buffer; - iov[0].iov_len=bufferlen; - bzero(&msg,sizeof(msg)); - msg.msg_name = &recvaddr->store; - msg.msg_namelen = recvaddr->addrlen; - msg.msg_iov = &iov[0]; - msg.msg_iovlen = 1; - msg.msg_control = cmsgcmsg; - msg.msg_controllen = sizeof cmsgcmsg; - msg.msg_flags = 0; - - ssize_t len = recvmsg(sock,&msg,0); - if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK) - return WHYF_perror("recvmsg(%d,%p,0)", sock, &msg); - -#if 0 - if (config.debug.packetrx) { - DEBUGF("recvmsg returned %d (flags=%d, msg_controllen=%d)", (int) len, msg.msg_flags, (int)msg.msg_controllen); - dump("received data", buffer, len); - } -#endif - - if (len > 0) { - struct cmsghdr *cmsg; - for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) { - if ( cmsg->cmsg_level == IPPROTO_IP - && ((cmsg->cmsg_type == IP_RECVTTL) || (cmsg->cmsg_type == IP_TTL)) - && cmsg->cmsg_len - ) { - if (config.debug.packetrx) - DEBUGF(" TTL (%p) data location resolves to %p", ttl,CMSG_DATA(cmsg)); - if (CMSG_DATA(cmsg)) { - *ttl = *(unsigned char *) CMSG_DATA(cmsg); - if (config.debug.packetrx) - DEBUGF(" TTL of packet is %d", *ttl); - } - } else { - if (config.debug.packetrx) - DEBUGF("I didn't expect to see level=%02x, type=%02x", - cmsg->cmsg_level,cmsg->cmsg_type); - } - } - } - recvaddr->addrlen = msg.msg_namelen; - - return len; -} diff --git a/net.h b/net.h index 6ef3e1c0..baeadf31 100644 --- a/net.h +++ b/net.h @@ -16,8 +16,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_NET_H -#define __SERVALD_NET_H +#ifndef __SERVAL_DNA__NET_H +#define __SERVAL_DNA__NET_H #include // for size_t, ssize_t #include // for struct sockaddr, socklen_t @@ -53,7 +53,4 @@ ssize_t _writev_all(int fd, const struct iovec *iov, int iovcnt, struct __source ssize_t _write_str(int fd, const char *str, struct __sourceloc __whence); ssize_t _write_str_nonblock(int fd, const char *str, struct __sourceloc __whence); -struct socket_address; -ssize_t recvwithttl(int sock, unsigned char *buffer, size_t bufferlen, int *ttl, struct socket_address *); - -#endif // __SERVALD_NET_H +#endif // __SERVAL_DNA__NET_H diff --git a/nonce.c b/nonce.c index 06ab7bb2..00d2bab8 100644 --- a/nonce.c +++ b/nonce.c @@ -1,5 +1,6 @@ /* -Copyright (C) 2013 Paul Gardner-Stephen, Serval Project. +Copyright (C) 2013 Paul Gardner-Stephen +Copyright (C) 2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/os.c b/os.c index 84e49cb6..35d2e3de 100644 --- a/os.c +++ b/os.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define __SERVALDNA_OS_INLINE +#define __SERVAL_DNA__OS_INLINE #include "os.h" #include "str.h" #include "log.h" diff --git a/os.h b/os.h index f098518e..9de08d6e 100644 --- a/os.h +++ b/os.h @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA_OS_H -#define __SERVALDNA_OS_H +#ifndef __SERVAL_DNA__OS_H +#define __SERVAL_DNA__OS_H #include #include @@ -26,11 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include -#ifndef __SERVALDNA_OS_INLINE +#ifndef __SERVAL_DNA__OS_INLINE # if __GNUC__ && !__GNUC_STDC_INLINE__ -# define __SERVALDNA_OS_INLINE extern inline +# define __SERVAL_DNA__OS_INLINE extern inline # else -# define __SERVALDNA_OS_INLINE inline +# define __SERVAL_DNA__OS_INLINE inline # endif #endif @@ -60,19 +60,19 @@ time_ms_t gettime_ms(); time_ms_t sleep_ms(time_ms_t milliseconds); #ifndef HAVE_BZERO -__SERVALDNA_OS_INLINE void bzero(void *buf, size_t len) { +__SERVAL_DNA__OS_INLINE void bzero(void *buf, size_t len) { memset(buf, 0, len); } #endif #ifndef HAVE_BCOPY -__SERVALDNA_OS_INLINE void bcopy(const void *src, void *dst, size_t len) { +__SERVAL_DNA__OS_INLINE void bcopy(const void *src, void *dst, size_t len) { memcpy(dst, src, len); } #endif #ifndef HAVE_BCMP -__SERVALDNA_OS_INLINE int bcmp(const void *s1, const void *s2, size_t n) { +__SERVAL_DNA__OS_INLINE int bcmp(const void *s1, const void *s2, size_t n) { // bcmp() is only an equality test, not an order test, so its return value // is not specified as negative or positive, only non-zero. Hoewver // memcmp() is an order test. We deliberately discard negative return @@ -123,4 +123,4 @@ int urandombytes(unsigned char *buf, size_t len); */ ssize_t read_symlink(const char *path, char *buf, size_t len); -#endif //__SERVALDNA_OS_H +#endif //__SERVAL_DNA__OS_H diff --git a/overlay_address.c b/overlay_address.c index 399e147f..c8463764 100644 --- a/overlay_address.c +++ b/overlay_address.c @@ -1,6 +1,7 @@ /* -Serval Distributed Numbering Architecture (DNA) -Copyright (C) 2010 Paul Gardner-Stephen +Serval DNA MDP addressing +Copyright (C) 2012-2013 Serval Project Inc. +Copyright (C) 2012 Paul Gardner-Stephen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/overlay_address.h b/overlay_address.h index 1de7801b..82a9b3fa 100644 --- a/overlay_address.h +++ b/overlay_address.h @@ -1,24 +1,24 @@ /* - Serval Daemon - Copyright (C) 2012 Serval Project Inc. - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +Serval DNA MDP addressing +Copyright (C) 2012-2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _SERVALD_OVERLAY_ADDRESS_H -#define _SERVALD_OVERLAY_ADDRESS_H +#ifndef __SERVAL_DNA__OVERLAY_ADDRESS_H +#define __SERVAL_DNA__OVERLAY_ADDRESS_H #include "constants.h" @@ -130,4 +130,4 @@ int send_please_explain(struct decode_context *context, struct subscriber *sourc void free_subscribers(); -#endif +#endif //__SERVAL_DNA__OVERLAY_ADDRESS_H diff --git a/overlay_buffer.h b/overlay_buffer.h index cf69a4b9..7aa3c5e4 100644 --- a/overlay_buffer.h +++ b/overlay_buffer.h @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD__OVERLAY_BUFFER_H -#define __SERVALD__OVERLAY_BUFFER_H +#ifndef __SERVAL_DNA___OVERLAY_BUFFER_H +#define __SERVAL_DNA___OVERLAY_BUFFER_H struct overlay_buffer { unsigned char *bytes; @@ -118,4 +118,4 @@ unsigned char* ob_ptr(struct overlay_buffer *b); #define ob_overrun(b) _ob_overrun(__WHENCE__, b) -#endif //__SERVALD__OVERLAY_BUFFER_H +#endif //__SERVAL_DNA___OVERLAY_BUFFER_H diff --git a/overlay_link.c b/overlay_link.c index 781b456c..a622a03c 100644 --- a/overlay_link.c +++ b/overlay_link.c @@ -1,4 +1,23 @@ -#include +/* +Serval DNA MDP overlay network link tracking +Copyright (C) 2012-2013 Serval Project Inc. +Copyright (C) 2010-2012 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "serval.h" #include "conf.h" #include "str.h" diff --git a/overlay_mdp.c b/overlay_mdp.c index e6089cb4..9cec8e14 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -1,5 +1,7 @@ /* -Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project. +Serval DNA MDP overlay network +Copyright (C) 2012-2013 Serval Project Inc. +Copyright (C) 2010-2012 Paul Gardner-Stephen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/overlay_mdp_services.c b/overlay_mdp_services.c index 2abc30d4..a9088619 100644 --- a/overlay_mdp_services.c +++ b/overlay_mdp_services.c @@ -1,5 +1,6 @@ /* -Copyright (C) 2010-2012 Paul Gardner-Stephen, Serval Project. +Copyright (C) 2010-2012 Paul Gardner-Stephen +Copyright (C) 2010-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/overlay_olsr.c b/overlay_olsr.c index 01bb48a7..8a2b1421 100644 --- a/overlay_olsr.c +++ b/overlay_olsr.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Serval Project. + Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/overlay_packet.h b/overlay_packet.h index aa105b25..3c70a724 100644 --- a/overlay_packet.h +++ b/overlay_packet.h @@ -1,5 +1,5 @@ /* - Serval Daemon + Serval DNA MDP overlay frame Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef _SERVALD_OVERLAY_PACKET_H -#define _SERVALD_OVERLAY_PACKET_H +#ifndef __SERVAL_DNA__OVERLAY_PACKET_H +#define __SERVAL_DNA__OVERLAY_PACKET_H #include "overlay_address.h" #include "serval.h" @@ -102,4 +102,4 @@ struct overlay_frame { int op_free(struct overlay_frame *p); struct overlay_frame *op_dup(struct overlay_frame *f); -#endif +#endif //__SERVAL_DNA__OVERLAY_PACKET_H diff --git a/overlay_packetradio.c b/overlay_packetradio.c index 587f92e6..c8a967a3 100644 --- a/overlay_packetradio.c +++ b/overlay_packetradio.c @@ -1,3 +1,23 @@ +/* +Serval DNA packet radio interface +Copyright (C) 2013 Serval Project Inc. +Copyright (C) 2013 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "serval.h" #include "conf.h" #include diff --git a/overlay_queue.c b/overlay_queue.c index b239b79a..d05e52b9 100644 --- a/overlay_queue.c +++ b/overlay_queue.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Serval Project Inc + Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/pa_phone.c b/pa_phone.c index 30b58c30..6aae93c8 100644 --- a/pa_phone.c +++ b/pa_phone.c @@ -1,3 +1,22 @@ +/* +Serval DNA Portaudio phone interface +Copyright (C) 2012 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include #include "fifo.h" diff --git a/performance_timing.c b/performance_timing.c index f7d60796..a54f1e9b 100644 --- a/performance_timing.c +++ b/performance_timing.c @@ -1,6 +1,6 @@ /* Serval Distributed Numbering Architecture (DNA) - Copyright (C) 2012 Serval Project, Inc. + Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/radio_link.h b/radio_link.h index 1dd92ccf..f1da9bf9 100644 --- a/radio_link.h +++ b/radio_link.h @@ -1,5 +1,23 @@ -#ifndef __SERVALD_RADIO_LINK_H -#define __SERVALD_RADIO_LINK_H +/* +Copyright (C) 2013 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __SERVAL_DNA___RADIO_LINK_H +#define __SERVAL_DNA___RADIO_LINK_H #define HEARTBEAT_SIZE (8+9) #define LINK_MTU 255 @@ -12,4 +30,4 @@ void radio_link_state_html(struct strbuf *b, struct overlay_interface *interface int radio_link_is_busy(struct overlay_interface *interface); int radio_link_queue_packet(struct overlay_interface *interface, struct overlay_buffer *buffer); -#endif \ No newline at end of file +#endif //__SERVAL_DNA___RADIO_LINK_H diff --git a/rhizome.c b/rhizome.c index 69f9fb1b..ce7da9cd 100644 --- a/rhizome.c +++ b/rhizome.c @@ -1,6 +1,7 @@ /* -Serval Distributed Numbering Architecture (DNA) -Copyright (C) 2010 Paul Gardner-Stephen +Serval DNA Rhizome file distribution +Copyright (C) 2012-2013 Serval Project Inc. +Copyright (C) 2011-2012 Paul Gardner-Stephen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/rhizome.h b/rhizome.h index 5bfac3d7..9726b20d 100644 --- a/rhizome.h +++ b/rhizome.h @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA__RHIZOME_H -#define __SERVALDNA__RHIZOME_H +#ifndef __SERVAL_DNA__RHIZOME_H +#define __SERVAL_DNA__RHIZOME_H #include #include @@ -37,17 +37,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # endif #endif -// TODO Rename MANIFEST_ID to BUNDLE_ID -#define RHIZOME_MANIFEST_ID_BYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES -#define RHIZOME_MANIFEST_ID_STRLEN (RHIZOME_MANIFEST_ID_BYTES * 2) -#define RHIZOME_BUNDLE_KEY_BYTES (crypto_sign_edwards25519sha512batch_SECRETKEYBYTES-crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES) -#define RHIZOME_BUNDLE_KEY_STRLEN (RHIZOME_BUNDLE_KEY_BYTES * 2) +#define RHIZOME_BUNDLE_ID_BYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES +#define RHIZOME_BUNDLE_ID_STRLEN (RHIZOME_BUNDLE_ID_BYTES * 2) +#define RHIZOME_BUNDLE_KEY_BYTES (crypto_sign_edwards25519sha512batch_SECRETKEYBYTES - crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES) +#define RHIZOME_BUNDLE_KEY_STRLEN (RHIZOME_BUNDLE_KEY_BYTES * 2) #define RHIZOME_FILEHASH_BYTES SHA512_DIGEST_LENGTH #define RHIZOME_FILEHASH_STRLEN (RHIZOME_FILEHASH_BYTES * 2) #define RHIZOME_CRYPT_KEY_BYTES crypto_stream_xsalsa20_ref_KEYBYTES #define RHIZOME_CRYPT_KEY_STRLEN (RHIZOME_CRYPT_KEY_BYTES * 2) +// TODO Rename MANIFEST_ID to BUNDLE_ID +// The following constants are deprecated, use the BUNDLE_ID forms instead +#define RHIZOME_MANIFEST_ID_BYTES RHIZOME_BUNDLE_ID_BYTES +#define RHIZOME_MANIFEST_ID_STRLEN RHIZOME_BUNDLE_ID_STRLEN + // assumed to always be 2^n #define RHIZOME_CRYPT_PAGE_SIZE 4096 @@ -950,4 +954,4 @@ int overlay_mdp_service_rhizome_sync(struct overlay_frame *frame, overlay_mdp_fr int rhizome_sync_announce(); int rhizome_sync_bundle_inserted(const unsigned char *bar); -#endif //__SERVALDNA__RHIZOME_H +#endif //__SERVAL_DNA__RHIZOME_H diff --git a/rhizome_bundle.c b/rhizome_bundle.c index 77754411..64341e0c 100644 --- a/rhizome_bundle.c +++ b/rhizome_bundle.c @@ -204,6 +204,7 @@ void _rhizome_manifest_del_bundle_key(struct __sourceloc __whence, rhizome_manif void _rhizome_manifest_set_service(struct __sourceloc __whence, rhizome_manifest *m, const char *service) { if (service) { + assert(rhizome_str_is_manifest_service(service)); const char *v = rhizome_manifest_set(m, "service", service); assert(v); // TODO: remove known manifest fields from vars[] m->service = v; @@ -223,6 +224,7 @@ void _rhizome_manifest_del_service(struct __sourceloc __whence, rhizome_manifest void _rhizome_manifest_set_name(struct __sourceloc __whence, rhizome_manifest *m, const char *name) { if (name) { + assert(rhizome_str_is_manifest_name(name)); const char *v = rhizome_manifest_set(m, "name", name); assert(v); // TODO: remove known manifest fields from vars[] m->name = v; @@ -1021,7 +1023,7 @@ int rhizome_manifest_selfsign(rhizome_manifest *m) int rhizome_write_manifest_file(rhizome_manifest *m, const char *path, char append) { if (config.debug.rhizome) - DEBUGF("write manifest (%d bytes) to %s", m->manifest_all_bytes, path); + DEBUGF("write manifest (%zd bytes) to %s", m->manifest_all_bytes, path); if (!m) return WHY("Manifest is null."); if (!m->finalised) diff --git a/rhizome_crypto.c b/rhizome_crypto.c index db3c990e..e219bda4 100644 --- a/rhizome_crypto.c +++ b/rhizome_crypto.c @@ -542,7 +542,7 @@ int rhizome_manifest_extract_signature(rhizome_manifest *m, unsigned *ofs) RETURN(0); } } - WARNF("Unsupported signature at ofs=%u: type=%#02x", sig - m->manifestdata, sigType); + WARNF("Unsupported signature at ofs=%u: type=%#02x", (unsigned)(sig - m->manifestdata), sigType); RETURN(3); } diff --git a/rhizome_database.c b/rhizome_database.c index d7a269e1..a012d88c 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -1,6 +1,6 @@ /* Serval Rhizome file sharing -Copyright (C) 2012 The Serval Project, Inc. +Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/rhizome_direct_http.c b/rhizome_direct_http.c index b84a5430..431adc17 100644 --- a/rhizome_direct_http.c +++ b/rhizome_direct_http.c @@ -658,7 +658,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r) "\r\n"; /* Work out what the content length should be */ if (config.debug.rhizome_tx) - DEBUGF("manifest_all_bytes=%u, manifest_body_bytes=%u", m->manifest_all_bytes, m->manifest_body_bytes); + DEBUGF("manifest_all_bytes=%zu, manifest_body_bytes=%zu", m->manifest_all_bytes, m->manifest_body_bytes); assert(m->filesize != RHIZOME_SIZE_UNSET); size_t content_length = strlen(template2) - 2 /* minus 2 for the "%s" that gets replaced */ diff --git a/rhizome_fetch.c b/rhizome_fetch.c index efd0b51f..b69e6b2f 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -1,6 +1,6 @@ /* Serval Distributed Numbering Architecture (DNA) -Copyright (C) 2012 Serval Project, Inc. +Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -476,7 +476,7 @@ static int rhizome_import_received_bundle(struct rhizome_manifest *m) { m->finalised = 1; if (config.debug.rhizome_rx) { - DEBUGF("manifest len=%u has %u signatories. Associated filesize=%"PRIu64" bytes", + DEBUGF("manifest len=%zu has %u signatories. Associated filesize=%"PRIu64" bytes", m->manifest_all_bytes, m->sig_count, m->filesize); dump("manifest", m->manifestdata, m->manifest_all_bytes); } diff --git a/rhizome_http.c b/rhizome_http.c index 4b5f201f..468c1917 100644 --- a/rhizome_http.c +++ b/rhizome_http.c @@ -1,6 +1,6 @@ /* Serval DNA Rhizome HTTP external interface -Copyright (C) 2013 Serval Project, Inc. +Copyright (C) 2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/rhizome_store.c b/rhizome_store.c index 336c5943..78e0c0f6 100644 --- a/rhizome_store.c +++ b/rhizome_store.c @@ -1,3 +1,22 @@ +/* +Serval DNA Rhizome storage +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include "serval.h" #include "rhizome.h" diff --git a/rhizome_sync.c b/rhizome_sync.c index be5c7fcb..412294f8 100644 --- a/rhizome_sync.c +++ b/rhizome_sync.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2010-2012 Serval Project. +Copyright (C) 2010-2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/route_link.c b/route_link.c index c836c7c3..51102f3d 100644 --- a/route_link.c +++ b/route_link.c @@ -1,3 +1,22 @@ +/* +Serval DNA link state routing +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "serval.h" #include "overlay_address.h" #include "overlay_buffer.h" diff --git a/serval.h b/serval.h index 035df66e..c4d71087 100644 --- a/serval.h +++ b/serval.h @@ -1,7 +1,7 @@ /* Serval DNA header file Copyright (C) 2010-2012 Paul Gardner-Stephen -Copyright (C) 2012-2013 Serval Project, Inc. +Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,8 +18,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_SERVALD_H -#define __SERVALD_SERVALD_H +#ifndef __SERVAL_DNA__SERVAL_H +#define __SERVAL_DNA__SERVAL_H #include #include @@ -139,6 +139,7 @@ struct in_addr { extern const char version_servald[]; +extern const char copyright_servald[]; /* Fundamental types. */ @@ -213,6 +214,7 @@ extern char *batman_peerfile; struct subscriber; struct decode_context; +struct socket_address; /* Make sure we have space to put bytes of the packet as we go along */ #define CHECK_PACKET_LEN(B) {if (((*packet_len)+(B))>=packet_maxlen) { return WHY("Packet composition ran out of space."); } } @@ -522,7 +524,6 @@ typedef struct overlay_mdp_frame { /* Server-side MDP functions */ int overlay_mdp_swap_src_dst(overlay_mdp_frame *mdp); -struct socket_address; int overlay_mdp_dispatch(overlay_mdp_frame *mdp, struct socket_address *client); void overlay_mdp_encode_ports(struct overlay_buffer *plaintext, mdp_port_t dst_port, mdp_port_t src_port); int overlay_mdp_dnalookup_reply(const sockaddr_mdp *dstaddr, const sid_t *resolved_sidp, const char *uri, const char *did, const char *name); @@ -700,4 +701,4 @@ int link_stop_routing(struct subscriber *subscriber); int generate_nonce(unsigned char *nonce,int bytes); -#endif // __SERVALD_SERVALD_H +#endif // __SERVAL_DNA__SERVAL_H diff --git a/socket.h b/socket.h index 5a167f43..ce8743be 100644 --- a/socket.h +++ b/socket.h @@ -1,10 +1,39 @@ -#ifndef __SERVALD_SOCKET_H -#define __SERVALD_SOCKET_H +/* +Serval DNA header file for socket operations +Copyright (C) 2012-2013 Serval Project Inc. -#ifndef WIN32 -#include +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef __SERVAL_DNA___SOCKET_H +#define __SERVAL_DNA___SOCKET_H + +#ifdef WIN32 +# include "win32/win32.h" +#else +# include +# ifdef HAVE_SYS_SOCKET_H +# include +# endif +# ifdef HAVE_NETINET_IN_H +# include +# endif #endif +#include "log.h" + struct socket_address{ socklen_t addrlen; union{ @@ -54,4 +83,6 @@ ssize_t _recv_message(struct __sourceloc, int fd, struct socket_address *address #define send_message(fd, address, data) _send_message(__WHENCE__, (fd), (address), (data)) #define recv_message(fd, address, data) _recv_message(__WHENCE__, (fd), (address), (data)) -#endif +ssize_t recvwithttl(int sock, unsigned char *buffer, size_t bufferlen, int *ttl, struct socket_address *recvaddr); + +#endif // __SERVAL_DNA___SOCKET_H diff --git a/sourcefiles.mk b/sourcefiles.mk index 86dc3dcd..4894d7cc 100644 --- a/sourcefiles.mk +++ b/sourcefiles.mk @@ -17,11 +17,13 @@ SERVAL_SOURCES = \ $(SERVAL_BASE)http_server.c \ $(SERVAL_BASE)keyring.c \ $(SERVAL_BASE)log.c \ + $(SERVAL_BASE)log_util.c \ $(SERVAL_BASE)lsif.c \ $(SERVAL_BASE)main.c \ $(SERVAL_BASE)radio_link.c \ $(SERVAL_BASE)meshms.c \ $(SERVAL_BASE)mdp_client.c \ + $(SERVAL_BASE)mdp_net.c \ $(SERVAL_BASE)os.c \ $(SERVAL_BASE)mem.c \ $(SERVAL_BASE)instance.c \ diff --git a/str.c b/str.c index 4849f8a0..b1ac6a79 100644 --- a/str.c +++ b/str.c @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define __SERVAL_DNA_STR_INLINE +#define __SERVAL_DNA__STR_INLINE #include "str.h" #include "strbuf_helpers.h" #include "constants.h" diff --git a/str.h b/str.h index 86f81644..5b6fb2d2 100644 --- a/str.h +++ b/str.h @@ -17,8 +17,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVAL_DNA_STR_H__ -#define __SERVAL_DNA_STR_H__ +#ifndef __SERVAL_DNA__STR_H__ +#define __SERVAL_DNA__STR_H__ #include #include @@ -26,11 +26,11 @@ #include #include -#ifndef __SERVAL_DNA_STR_INLINE +#ifndef __SERVAL_DNA__STR_INLINE # if __GNUC__ && !__GNUC_STDC_INLINE__ -# define __SERVAL_DNA_STR_INLINE extern inline +# define __SERVAL_DNA__STR_INLINE extern inline # else -# define __SERVAL_DNA_STR_INLINE inline +# define __SERVAL_DNA__STR_INLINE inline # endif #endif @@ -53,7 +53,7 @@ extern const char hexdigit_lower[16]; * * @author Andrew Bettison */ -__SERVAL_DNA_STR_INLINE int is_xsubstring(const char *text, int len) +__SERVAL_DNA__STR_INLINE int is_xsubstring(const char *text, int len) { while (len--) if (!isxdigit(*text++)) @@ -66,7 +66,7 @@ __SERVAL_DNA_STR_INLINE int is_xsubstring(const char *text, int len) * * @author Andrew Bettison */ -__SERVAL_DNA_STR_INLINE int is_xstring(const char *text, int len) +__SERVAL_DNA__STR_INLINE int is_xstring(const char *text, int len) { while (len--) if (!isxdigit(*text++)) @@ -209,43 +209,43 @@ extern uint8_t _serval_ctype_0[UINT8_MAX]; extern uint8_t _serval_ctype_1[UINT8_MAX]; extern uint8_t _serval_ctype_2[UINT8_MAX]; -__SERVAL_DNA_STR_INLINE int is_http_char(char c) { +__SERVAL_DNA__STR_INLINE int is_http_char(char c) { return isascii(c); } -__SERVAL_DNA_STR_INLINE int is_http_ctl(char c) { +__SERVAL_DNA__STR_INLINE int is_http_ctl(char c) { return iscntrl(c); } -__SERVAL_DNA_STR_INLINE int is_base64_digit(char c) { +__SERVAL_DNA__STR_INLINE int is_base64_digit(char c) { return (_serval_ctype_0[(unsigned char) c] & _SERVAL_CTYPE_0_BASE64) != 0; } -__SERVAL_DNA_STR_INLINE int is_base64url_digit(char c) { +__SERVAL_DNA__STR_INLINE int is_base64url_digit(char c) { return (_serval_ctype_0[(unsigned char) c] & _SERVAL_CTYPE_0_BASE64URL) != 0; } -__SERVAL_DNA_STR_INLINE int is_base64_pad(char c) { +__SERVAL_DNA__STR_INLINE int is_base64_pad(char c) { return c == '='; } -__SERVAL_DNA_STR_INLINE int is_base64url_pad(char c) { +__SERVAL_DNA__STR_INLINE int is_base64url_pad(char c) { return c == '='; } -__SERVAL_DNA_STR_INLINE uint8_t base64_digit(char c) { +__SERVAL_DNA__STR_INLINE uint8_t base64_digit(char c) { return _serval_ctype_0[(unsigned char) c] & _SERVAL_CTYPE_0_BASE64_MASK; } -__SERVAL_DNA_STR_INLINE uint8_t base64url_digit(char c) { +__SERVAL_DNA__STR_INLINE uint8_t base64url_digit(char c) { return _serval_ctype_0[(unsigned char) c] & _SERVAL_CTYPE_0_BASE64_MASK; } -__SERVAL_DNA_STR_INLINE int is_multipart_boundary(char c) { +__SERVAL_DNA__STR_INLINE int is_multipart_boundary(char c) { return (_serval_ctype_2[(unsigned char) c] & _SERVAL_CTYPE_2_MULTIPART_BOUNDARY) != 0; } -__SERVAL_DNA_STR_INLINE int is_valid_multipart_boundary_string(const char *s) +__SERVAL_DNA__STR_INLINE int is_valid_multipart_boundary_string(const char *s) { if (s[0] == '\0') return 0; @@ -255,11 +255,11 @@ __SERVAL_DNA_STR_INLINE int is_valid_multipart_boundary_string(const char *s) return s[-1] != ' '; } -__SERVAL_DNA_STR_INLINE int is_http_separator(char c) { +__SERVAL_DNA__STR_INLINE int is_http_separator(char c) { return (_serval_ctype_1[(unsigned char) c] & _SERVAL_CTYPE_1_HTTP_SEPARATOR) != 0; } -__SERVAL_DNA_STR_INLINE int is_http_token(char c) { +__SERVAL_DNA__STR_INLINE int is_http_token(char c) { return is_http_char(c) && !is_http_ctl(c) && !is_http_separator(c); } @@ -268,7 +268,7 @@ __SERVAL_DNA_STR_INLINE int is_http_token(char c) { * * @author Andrew Bettison */ -__SERVAL_DNA_STR_INLINE int hexvalue(char c) { +__SERVAL_DNA__STR_INLINE int hexvalue(char c) { return isxdigit(c) ? _serval_ctype_1[(unsigned char) c] & _SERVAL_CTYPE_1_HEX_MASK : -1; } @@ -302,24 +302,24 @@ const char *strnchr(const char *s, size_t n, char c); * @author Andrew Bettison */ -__SERVAL_DNA_STR_INLINE ssize_t str_index_dfl(const char *s, char c, ssize_t dfl) +__SERVAL_DNA__STR_INLINE ssize_t str_index_dfl(const char *s, char c, ssize_t dfl) { const char *r = strchr(s, c); return r ? r - s : dfl; } -__SERVAL_DNA_STR_INLINE ssize_t str_rindex_dfl(const char *s, char c, ssize_t dfl) +__SERVAL_DNA__STR_INLINE ssize_t str_rindex_dfl(const char *s, char c, ssize_t dfl) { const char *r = strrchr(s, c); return r ? r - s : dfl; } -__SERVAL_DNA_STR_INLINE ssize_t str_index(const char *s, char c) +__SERVAL_DNA__STR_INLINE ssize_t str_index(const char *s, char c) { return str_index_dfl(s, c, -1); } -__SERVAL_DNA_STR_INLINE ssize_t str_rindex(const char *s, char c) +__SERVAL_DNA__STR_INLINE ssize_t str_rindex(const char *s, char c) { return str_rindex_dfl(s, c, -1); } @@ -447,15 +447,15 @@ int str_to_uint64_interval_ms(const char *str, int64_t *result, const char **aft */ int str_is_uri(const char *uri); -__SERVAL_DNA_STR_INLINE int is_uri_char_scheme(char c) { +__SERVAL_DNA__STR_INLINE int is_uri_char_scheme(char c) { return (_serval_ctype_1[(unsigned char) c] & _SERVAL_CTYPE_1_URI_SCHEME) != 0; } -__SERVAL_DNA_STR_INLINE int is_uri_char_unreserved(char c) { +__SERVAL_DNA__STR_INLINE int is_uri_char_unreserved(char c) { return (_serval_ctype_1[(unsigned char) c] & _SERVAL_CTYPE_1_URI_UNRESERVED) != 0; } -__SERVAL_DNA_STR_INLINE int is_uri_char_reserved(char c) { +__SERVAL_DNA__STR_INLINE int is_uri_char_reserved(char c) { return (_serval_ctype_1[(unsigned char) c] & _SERVAL_CTYPE_1_URI_RESERVED) != 0; } @@ -464,7 +464,7 @@ __SERVAL_DNA_STR_INLINE int is_uri_char_reserved(char c) { * * @author Andrew Bettison */ -__SERVAL_DNA_STR_INLINE int str_is_uri_scheme(const char *scheme) +__SERVAL_DNA__STR_INLINE int str_is_uri_scheme(const char *scheme) { if (!isalpha(*scheme++)) return 0; @@ -530,4 +530,4 @@ int str_uri_authority_port(const char *auth, uint16_t *portp); int parse_argv(char *cmdline, char delim, char **argv, int max_argv); -#endif // __SERVAL_DNA_STR_H__ +#endif // __SERVAL_DNA__STR_H__ diff --git a/testframework.sh b/testframework.sh index 903a7cc1..7a26bbf5 100644 --- a/testframework.sh +++ b/testframework.sh @@ -127,6 +127,7 @@ declare -a _tfw_test_names=() declare -a _tfw_test_sourcefiles=() declare -a _tfw_job_pgids=() declare -a _tfw_forked_pids=() +declare -a _tfw_forked_labels=() # The rest of this file is parsed for extended glob patterns. _tfw_shopt _tfw_orig_shopt -s extglob @@ -1648,13 +1649,15 @@ fork() { shift [ -n "$_tfw_forkid" ] && error "fork label '%$_tfw_forklabel' already in use" fi + local desc="fork[$forkid]${_tfw_forklabel:+ %$_tfw_forklabel}" local _tfw_process_tmp="$_tfw_tmp/fork-$forkid" mkdir "$_tfw_process_tmp" || _tfw_fatalexit - $_tfw_assert_noise && tfw_log "# fork[$forkid] START" $(shellarg "$@") - ( "$@" ) 6>"$_tfw_process_tmp/log.stdout" 1>&6 2>"$_tfw_process_tmp/log.stderr" 7>"$_tfw_process_tmp/log.xtrace" & + $_tfw_assert_noise && tfw_log "# $desc START" $(shellarg "$@") + "$@" 6>"$_tfw_process_tmp/log.stdout" 1>&6 2>"$_tfw_process_tmp/log.stderr" 7>"$_tfw_process_tmp/log.xtrace" & _tfw_forked_pids[$forkid]=$! + _tfw_forked_labels[$forkid]="$_tfw_forklabel" [ -n "$_tfw_forklabel" ] && eval _tfw_fork_label_$_tfw_forklabel=$forkid - $_tfw_assert_noise && tfw_log "# fork[$forkid] ${_tfw_forklabel:+%$_tfw_forklabel }pid=$! STARTED" + $_tfw_assert_noise && tfw_log "# $desc pid=$! STARTED" } fork_terminate() { @@ -1664,7 +1667,7 @@ fork_terminate() { for arg; do _tfw_set_forklabel "$arg" || error "not a fork label '$arg'" [ -n "$_tfw_forkid" ] || error "no such fork: %$_tfw_forklabel" - _tfw_terminate $_tfw_forkid + _tfw_forkterminate $_tfw_forkid done } @@ -1692,7 +1695,7 @@ fork_terminate_all() { $_tfw_assert_noise && tfw_log "# fork_terminate_all" local forkid for ((forkid=0; forkid < ${#_tfw_forked_pids[*]}; ++forkid)); do - _tfw_terminate $forkid + _tfw_forkterminate $forkid done } @@ -1728,12 +1731,14 @@ _tfw_set_forklabel() { return 1 } -_tfw_terminate() { +_tfw_forkterminate() { local forkid="$1" [ -z "$forkid" ] && return 1 local pid=${_tfw_forked_pids[$forkid]} + local label=${_tfw_forked_labels[$forkid]} + local desc="fork[$forkid]${label:+ %$label}" [ -z "$pid" ] && return 1 - $_tfw_assert_noise && tfw_log "# fork[$forkid] kill -TERM $pid" + $_tfw_assert_noise && tfw_log "# $desc kill -TERM $pid" kill -TERM $pid 2>/dev/null } @@ -1741,30 +1746,32 @@ _tfw_forkwait() { local forkid="$1" [ -z "$forkid" ] && return 0 local pid=${_tfw_forked_pids[$forkid]} + local label=${_tfw_forked_labels[$forkid]} [ -z "$pid" ] && return 0 kill -0 $pid 2>/dev/null && return 1 # still running _tfw_forked_pids[$forkid]= wait $pid # should not block because process has exited local status=$? - $_tfw_assert_noise && tfw_log "# fork[$forkid] pid=$pid EXIT status=$status" - echo "++++++++++ fork[$forkid] log.stdout ++++++++++" + local desc="fork[$forkid]${label:+ %$label}" + $_tfw_assert_noise && tfw_log "# $desc pid=$pid EXIT status=$status" + echo "++++++++++ $desc log.stdout ++++++++++" cat $_tfw_tmp/fork-$forkid/log.stdout echo "++++++++++" - echo "++++++++++ fork[$forkid] log.stderr ++++++++++" + echo "++++++++++ $desc log.stderr ++++++++++" cat $_tfw_tmp/fork-$forkid/log.stderr echo "++++++++++" if $_tfw_trace; then - echo "++++++++++ fork[$forkid] log.xtrace ++++++++++" + echo "++++++++++ $desc log.xtrace ++++++++++" cat $_tfw_tmp/fork-$forkid/log.xtrace echo "++++++++++" fi case $status in 0) ;; 143) ;; # terminated with SIGTERM (probably from fork_terminate) - 1) _tfw_fail "fork[$forkid] process exited with FAIL status";; - 254) _tfw_error "fork[$forkid] process exited with ERROR status";; - 255) _tfw_fatal "fork[$forkid] process exited with FATAL status";; - *) _tfw_error "fork[$forkid] process exited with status=$status";; + 1) _tfw_fail "$desc process exited with FAIL status";; + 254) _tfw_error "$desc process exited with ERROR status";; + 255) _tfw_fatal "$desc process exited with FATAL status";; + *) _tfw_error "$desc process exited with status=$status";; esac return 0 } diff --git a/testnacl.c b/testnacl.c index 8bd74edf..3e51c7b3 100644 --- a/testnacl.c +++ b/testnacl.c @@ -1,3 +1,22 @@ +/* +Serval DNA crypto NaCl test utility +Copyright (C) 2011 Paul Gardner-Stephen + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include #include #include diff --git a/tfw_createfile.c b/tfw_createfile.c index fad4ec8f..863704d7 100644 --- a/tfw_createfile.c +++ b/tfw_createfile.c @@ -1,6 +1,6 @@ /* Serval Project testing framework utility - create fixture file -Copyright (C) 2012 Serval Project, Inc. +Copyright (C) 2012 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/uuid.c b/uuid.c index d77f369b..a0209a7e 100644 --- a/uuid.c +++ b/uuid.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define __SERVALDNA_UUID_H_INLINE +#define __SERVAL_DNA__UUID_H_INLINE #include "uuid.h" #include "os.h" #include "str.h" diff --git a/uuid.h b/uuid.h index fea11631..1675b663 100644 --- a/uuid.h +++ b/uuid.h @@ -17,19 +17,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALDNA_UUID_H -#define __SERVALDNA_UUID_H +#ifndef __SERVAL_DNA__UUID_H +#define __SERVAL_DNA__UUID_H #include #include #include #include "strbuf.h" -#ifndef __SERVALDNA_UUID_H_INLINE +#ifndef __SERVAL_DNA__UUID_H_INLINE # if __GNUC__ && !__GNUC_STDC_INLINE__ -# define __SERVALDNA_UUID_H_INLINE extern inline +# define __SERVAL_DNA__UUID_H_INLINE extern inline # else -# define __SERVALDNA_UUID_H_INLINE inline +# define __SERVAL_DNA__UUID_H_INLINE inline # endif #endif @@ -74,11 +74,11 @@ enum uuid_version { UUID_VERSION_NAME_SHA1 = 5 }; -__SERVALDNA_UUID_H_INLINE int cmp_uuid_t(const uuid_t *a, const uuid_t *b) { +__SERVAL_DNA__UUID_H_INLINE int cmp_uuid_t(const uuid_t *a, const uuid_t *b) { return memcmp(a->u.binary, b->u.binary, sizeof a->u.binary); } -__SERVALDNA_UUID_H_INLINE int uuid_is_valid(const uuid_t *any_uuid) { +__SERVAL_DNA__UUID_H_INLINE int uuid_is_valid(const uuid_t *any_uuid) { return (any_uuid->u.record.clock_seq_hi_and_reserved & 0xc0) == 0x80; } @@ -125,4 +125,4 @@ strbuf strbuf_uuid(strbuf, const uuid_t *valid_uuid); */ int str_to_uuid(const char *str, uuid_t *result, const char **afterp); -#endif //__SERVALDNA_OS_H +#endif //__SERVAL_DNA__OS_H diff --git a/version_servald.c b/version_servald.c index 32028fd5..1bf11a42 100644 --- a/version_servald.c +++ b/version_servald.c @@ -1,5 +1,29 @@ +/* +Serval DNA version and copyright strings +Copyright (C) 2013 Serval Project Inc. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef SERVALD_VERSION #error "SERVALD_VERSION is not defined" #endif +#ifndef SERVALD_COPYRIGHT +#error "SERVALD_COPYRIGHT is not defined" +#endif + const char version_servald[] = SERVALD_VERSION; +const char copyright_servald[] = SERVALD_COPYRIGHT; diff --git a/vomp_console.c b/vomp_console.c index 8af9d70e..3f57c4ea 100644 --- a/vomp_console.c +++ b/vomp_console.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Serval Project + Copyright (C) 2012-2013 Serval Project Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/xprintf.h b/xprintf.h index 91d81b9a..25757ceb 100644 --- a/xprintf.h +++ b/xprintf.h @@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __SERVALD_XPRINTF_H -#define __SERVALD_XPRINTF_H +#ifndef __SERVAL_DNA__XPRINTF_H +#define __SERVAL_DNA__XPRINTF_H /* Generalised (extensible) printf framework. * @@ -107,4 +107,4 @@ CONTEXT_VPRINTF _cx_vprintf_mallocbuf; #define XPRINTF_STRBUF(SB) _XPRINTF(_cx_vprintf_strbuf,(SB)) CONTEXT_VPRINTF _cx_vprintf_strbuf; -#endif // __SERVALD_XPRINTF_H +#endif // __SERVAL_DNA__XPRINTF_H