393 changed files with 0 additions and 150665 deletions
@ -1,24 +0,0 @@
|
||||
*.d |
||||
*.o |
||||
*.a |
||||
*.out |
||||
*.swp |
||||
tags |
||||
build |
||||
UNIT_* |
||||
core |
||||
core.* |
||||
.DS_Store |
||||
cscope.files |
||||
cscope.out |
||||
*.so |
||||
*.aux |
||||
*.pdf |
||||
*.toc |
||||
*.gz |
||||
*.log |
||||
*.pyc |
||||
*.elf |
||||
*.gcov |
||||
*.gcda |
||||
*.gcno |
||||
@ -1,13 +0,0 @@
|
||||
before_install: |
||||
- sudo apt-get update -qq |
||||
- sudo apt-get install -y vde2 check libvdeplug2-dev libpcap-dev psmisc |
||||
- sudo pip install cpp-coveralls |
||||
- make clean |
||||
- rm -f *.gc* |
||||
|
||||
install: make GCOV=1 && make units ARCH=faulty GCOV=1 && make test GCOV=1 |
||||
language: c |
||||
script: |
||||
- ./test/coverage.sh |
||||
after_success: |
||||
- coveralls --exclude test/ --exclude modules/ptsocket --exclude build --exclude modules/pico_dev_mock.c --exclude modules/pico_dev_null.c --exclude modules/pico_dev_pcap.c --exclude modules/pico_dev_tap_windows.c --exclude modules/pico_dev_tun.c --gcov-options='\-lp' |
||||
@ -1,8 +0,0 @@
|
||||
|
||||
External contributions to picoTCP are very welcome. We do, however, ask that you sign the Contributor License Agreement. |
||||
We don't ask you to sign away your copyright. The CLA simply grants us an additional license on the code you wrote. This allows us to also use picoTCP in commercial projects, which enables us to keep investing time and money in creating a better TCP/IP stack. |
||||
|
||||
Please read the [Agreement](https://docs.google.com/forms/d/1-z6lsT75l6ZIrgHGEWrWdHylJ6xxpjc7FwGfL2ilDFU/viewform), and if you agree with it, fill in your information. |
||||
You will receive a mail with a timestamp. Please modify our [CLA confirmation page](https://github.com/tass-belgium/picotcp/wiki/picoTCP-CLA-Confirmation-Page), adding the timestamp and your github username. This way we can be sure that nobody else filled in your info in the form. |
||||
|
||||
Pull requests by people who haven't signed the CLA will, unfortunately, have to be rejected. |
||||
@ -1,8 +0,0 @@
|
||||
PicoTCP. Copyright (c) 2012-2017 Altran Intelligent Systems. |
||||
|
||||
Released under the GNU General Public License, version 2, or (at your option) |
||||
version 3. |
||||
See LICENSE.GPLv2 and LICENSE.GPLv3 for details. |
||||
|
||||
Different licensing models may exist, at the sole discretion of |
||||
the Copyright holders. |
||||
@ -1,339 +0,0 @@
|
||||
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. |
||||
|
||||
<one line to give the program's name and a brief idea of what it does.> |
||||
Copyright (C) <year> <name of author> |
||||
|
||||
This program is free software; you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation; either version 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. |
||||
|
||||
<signature of Ty Coon>, 1 April 1989 |
||||
Ty Coon, President of Vice |
||||
|
||||
This General Public License does not permit incorporating your program into |
||||
proprietary programs. If your program is a subroutine library, you may |
||||
consider it more useful to permit linking proprietary applications with the |
||||
library. If this is what you want to do, use the GNU Lesser General |
||||
Public License instead of this License. |
||||
@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE |
||||
Version 3, 29 June 2007 |
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> |
||||
Everyone is permitted to copy and distribute verbatim copies |
||||
of this license document, but changing it is not allowed. |
||||
|
||||
Preamble |
||||
|
||||
The GNU General Public License is a free, copyleft license for |
||||
software and other kinds of works. |
||||
|
||||
The licenses for most software and other practical works are designed |
||||
to take away your freedom to share and change the works. By contrast, |
||||
the GNU General Public License is intended to guarantee your freedom to |
||||
share and change all versions of a program--to make sure it remains free |
||||
software for all its users. We, the Free Software Foundation, use the |
||||
GNU General Public License for most of our software; it applies also to |
||||
any other work released this way by its authors. You can apply it to |
||||
your programs, too. |
||||
|
||||
When we speak of free software, we are referring to freedom, not |
||||
price. Our General Public Licenses are designed to make sure that you |
||||
have the freedom to distribute copies of free software (and charge for |
||||
them if you wish), that you receive source code or can get it if you |
||||
want it, that you can change the software or use pieces of it in new |
||||
free programs, and that you know you can do these things. |
||||
|
||||
To protect your rights, we need to prevent others from denying you |
||||
these rights or asking you to surrender the rights. Therefore, you have |
||||
certain responsibilities if you distribute copies of the software, or if |
||||
you modify it: responsibilities to respect the freedom of others. |
||||
|
||||
For example, if you distribute copies of such a program, whether |
||||
gratis or for a fee, you must pass on to the recipients the same |
||||
freedoms that you received. You must make sure that they, too, receive |
||||
or can get the source code. And you must show them these terms so they |
||||
know their rights. |
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps: |
||||
(1) assert copyright on the software, and (2) offer you this License |
||||
giving you legal permission to copy, distribute and/or modify it. |
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains |
||||
that there is no warranty for this free software. For both users' and |
||||
authors' sake, the GPL requires that modified versions be marked as |
||||
changed, so that their problems will not be attributed erroneously to |
||||
authors of previous versions. |
||||
|
||||
Some devices are designed to deny users access to install or run |
||||
modified versions of the software inside them, although the manufacturer |
||||
can do so. This is fundamentally incompatible with the aim of |
||||
protecting users' freedom to change the software. The systematic |
||||
pattern of such abuse occurs in the area of products for individuals to |
||||
use, which is precisely where it is most unacceptable. Therefore, we |
||||
have designed this version of the GPL to prohibit the practice for those |
||||
products. If such problems arise substantially in other domains, we |
||||
stand ready to extend this provision to those domains in future versions |
||||
of the GPL, as needed to protect the freedom of users. |
||||
|
||||
Finally, every program is threatened constantly by software patents. |
||||
States should not allow patents to restrict development and use of |
||||
software on general-purpose computers, but in those that do, we wish to |
||||
avoid the special danger that patents applied to a free program could |
||||
make it effectively proprietary. To prevent this, the GPL assures that |
||||
patents cannot be used to render the program non-free. |
||||
|
||||
The precise terms and conditions for copying, distribution and |
||||
modification follow. |
||||
|
||||
TERMS AND CONDITIONS |
||||
|
||||
0. Definitions. |
||||
|
||||
"This License" refers to version 3 of the GNU General Public License. |
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of |
||||
works, such as semiconductor masks. |
||||
|
||||
"The Program" refers to any copyrightable work licensed under this |
||||
License. Each licensee is addressed as "you". "Licensees" and |
||||
"recipients" may be individuals or organizations. |
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work |
||||
in a fashion requiring copyright permission, other than the making of an |
||||
exact copy. The resulting work is called a "modified version" of the |
||||
earlier work or a work "based on" the earlier work. |
||||
|
||||
A "covered work" means either the unmodified Program or a work based |
||||
on the Program. |
||||
|
||||
To "propagate" a work means to do anything with it that, without |
||||
permission, would make you directly or secondarily liable for |
||||
infringement under applicable copyright law, except executing it on a |
||||
computer or modifying a private copy. Propagation includes copying, |
||||
distribution (with or without modification), making available to the |
||||
public, and in some countries other activities as well. |
||||
|
||||
To "convey" a work means any kind of propagation that enables other |
||||
parties to make or receive copies. Mere interaction with a user through |
||||
a computer network, with no transfer of a copy, is not conveying. |
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" |
||||
to the extent that it includes a convenient and prominently visible |
||||
feature that (1) displays an appropriate copyright notice, and (2) |
||||
tells the user that there is no warranty for the work (except to the |
||||
extent that warranties are provided), that licensees may convey the |
||||
work under this License, and how to view a copy of this License. If |
||||
the interface presents a list of user commands or options, such as a |
||||
menu, a prominent item in the list meets this criterion. |
||||
|
||||
1. Source Code. |
||||
|
||||
The "source code" for a work means the preferred form of the work |
||||
for making modifications to it. "Object code" means any non-source |
||||
form of a work. |
||||
|
||||
A "Standard Interface" means an interface that either is an official |
||||
standard defined by a recognized standards body, or, in the case of |
||||
interfaces specified for a particular programming language, one that |
||||
is widely used among developers working in that language. |
||||
|
||||
The "System Libraries" of an executable work include anything, other |
||||
than the work as a whole, that (a) is included in the normal form of |
||||
packaging a Major Component, but which is not part of that Major |
||||
Component, and (b) serves only to enable use of the work with that |
||||
Major Component, or to implement a Standard Interface for which an |
||||
implementation is available to the public in source code form. A |
||||
"Major Component", in this context, means a major essential component |
||||
(kernel, window system, and so on) of the specific operating system |
||||
(if any) on which the executable work runs, or a compiler used to |
||||
produce the work, or an object code interpreter used to run it. |
||||
|
||||
The "Corresponding Source" for a work in object code form means all |
||||
the source code needed to generate, install, and (for an executable |
||||
work) run the object code and to modify the work, including scripts to |
||||
control those activities. However, it does not include the work's |
||||
System Libraries, or general-purpose tools or generally available free |
||||
programs which are used unmodified in performing those activities but |
||||
which are not part of the work. For example, Corresponding Source |
||||
includes interface definition files associated with source files for |
||||
the work, and the source code for shared libraries and dynamically |
||||
linked subprograms that the work is specifically designed to require, |
||||
such as by intimate data communication or control flow between those |
||||
subprograms and other parts of the work. |
||||
|
||||
The Corresponding Source need not include anything that users |
||||
can regenerate automatically from other parts of the Corresponding |
||||
Source. |
||||
|
||||
The Corresponding Source for a work in source code form is that |
||||
same work. |
||||
|
||||
2. Basic Permissions. |
||||
|
||||
All rights granted under this License are granted for the term of |
||||
copyright on the Program, and are irrevocable provided the stated |
||||
conditions are met. This License explicitly affirms your unlimited |
||||
permission to run the unmodified Program. The output from running a |
||||
covered work is covered by this License only if the output, given its |
||||
content, constitutes a covered work. This License acknowledges your |
||||
rights of fair use or other equivalent, as provided by copyright law. |
||||
|
||||
You may make, run and propagate covered works that you do not |
||||
convey, without conditions so long as your license otherwise remains |
||||
in force. You may convey covered works to others for the sole purpose |
||||
of having them make modifications exclusively for you, or provide you |
||||
with facilities for running those works, provided that you comply with |
||||
the terms of this License in conveying all material for which you do |
||||
not control copyright. Those thus making or running the covered works |
||||
for you must do so exclusively on your behalf, under your direction |
||||
and control, on terms that prohibit them from making any copies of |
||||
your copyrighted material outside their relationship with you. |
||||
|
||||
Conveying under any other circumstances is permitted solely under |
||||
the conditions stated below. Sublicensing is not allowed; section 10 |
||||
makes it unnecessary. |
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law. |
||||
|
||||
No covered work shall be deemed part of an effective technological |
||||
measure under any applicable law fulfilling obligations under article |
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or |
||||
similar laws prohibiting or restricting circumvention of such |
||||
measures. |
||||
|
||||
When you convey a covered work, you waive any legal power to forbid |
||||
circumvention of technological measures to the extent such circumvention |
||||
is effected by exercising rights under this License with respect to |
||||
the covered work, and you disclaim any intention to limit operation or |
||||
modification of the work as a means of enforcing, against the work's |
||||
users, your or third parties' legal rights to forbid circumvention of |
||||
technological measures. |
||||
|
||||
4. Conveying Verbatim Copies. |
||||
|
||||
You may convey verbatim copies of the Program's source code as you |
||||
receive it, in any medium, provided that you conspicuously and |
||||
appropriately publish on each copy an appropriate copyright notice; |
||||
keep intact all notices stating that this License and any |
||||
non-permissive terms added in accord with section 7 apply to the code; |
||||
keep intact all notices of the absence of any warranty; and give all |
||||
recipients a copy of this License along with the Program. |
||||
|
||||
You may charge any price or no price for each copy that you convey, |
||||
and you may offer support or warranty protection for a fee. |
||||
|
||||
5. Conveying Modified Source Versions. |
||||
|
||||
You may convey a work based on the Program, or the modifications to |
||||
produce it from the Program, in the form of source code under the |
||||
terms of section 4, provided that you also meet all of these conditions: |
||||
|
||||
a) The work must carry prominent notices stating that you modified |
||||
it, and giving a relevant date. |
||||
|
||||
b) The work must carry prominent notices stating that it is |
||||
released under this License and any conditions added under section |
||||
7. This requirement modifies the requirement in section 4 to |
||||
"keep intact all notices". |
||||
|
||||
c) You must license the entire work, as a whole, under this |
||||
License to anyone who comes into possession of a copy. This |
||||
License will therefore apply, along with any applicable section 7 |
||||
additional terms, to the whole of the work, and all its parts, |
||||
regardless of how they are packaged. This License gives no |
||||
permission to license the work in any other way, but it does not |
||||
invalidate such permission if you have separately received it. |
||||
|
||||
d) If the work has interactive user interfaces, each must display |
||||
Appropriate Legal Notices; however, if the Program has interactive |
||||
interfaces that do not display Appropriate Legal Notices, your |
||||
work need not make them do so. |
||||
|
||||
A compilation of a covered work with other separate and independent |
||||
works, which are not by their nature extensions of the covered work, |
||||
and which are not combined with it such as to form a larger program, |
||||
in or on a volume of a storage or distribution medium, is called an |
||||
"aggregate" if the compilation and its resulting copyright are not |
||||
used to limit the access or legal rights of the compilation's users |
||||
beyond what the individual works permit. Inclusion of a covered work |
||||
in an aggregate does not cause this License to apply to the other |
||||
parts of the aggregate. |
||||
|
||||
6. Conveying Non-Source Forms. |
||||
|
||||
You may convey a covered work in object code form under the terms |
||||
of sections 4 and 5, provided that you also convey the |
||||
machine-readable Corresponding Source under the terms of this License, |
||||
in one of these ways: |
||||
|
||||
a) Convey the object code in, or embodied in, a physical product |
||||
(including a physical distribution medium), accompanied by the |
||||
Corresponding Source fixed on a durable physical medium |
||||
customarily used for software interchange. |
||||
|
||||
b) Convey the object code in, or embodied in, a physical product |
||||
(including a physical distribution medium), accompanied by a |
||||
written offer, valid for at least three years and valid for as |
||||
long as you offer spare parts or customer support for that product |
||||
model, to give anyone who possesses the object code either (1) a |
||||
copy of the Corresponding Source for all the software in the |
||||
product that is covered by this License, on a durable physical |
||||
medium customarily used for software interchange, for a price no |
||||
more than your reasonable cost of physically performing this |
||||
conveying of source, or (2) access to copy the |
||||
Corresponding Source from a network server at no charge. |
||||
|
||||
c) Convey individual copies of the object code with a copy of the |
||||
written offer to provide the Corresponding Source. This |
||||
alternative is allowed only occasionally and noncommercially, and |
||||
only if you received the object code with such an offer, in accord |
||||
with subsection 6b. |
||||
|
||||
d) Convey the object code by offering access from a designated |
||||
place (gratis or for a charge), and offer equivalent access to the |
||||
Corresponding Source in the same way through the same place at no |
||||
further charge. You need not require recipients to copy the |
||||
Corresponding Source along with the object code. If the place to |
||||
copy the object code is a network server, the Corresponding Source |
||||
may be on a different server (operated by you or a third party) |
||||
that supports equivalent copying facilities, provided you maintain |
||||
clear directions next to the object code saying where to find the |
||||
Corresponding Source. Regardless of what server hosts the |
||||
Corresponding Source, you remain obligated to ensure that it is |
||||
available for as long as needed to satisfy these requirements. |
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided |
||||
you inform other peers where the object code and Corresponding |
||||
Source of the work are being offered to the general public at no |
||||
charge under subsection 6d. |
||||
|
||||
A separable portion of the object code, whose source code is excluded |
||||
from the Corresponding Source as a System Library, need not be |
||||
included in conveying the object code work. |
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any |
||||
tangible personal property which is normally used for personal, family, |
||||
or household purposes, or (2) anything designed or sold for incorporation |
||||
into a dwelling. In determining whether a product is a consumer product, |
||||
doubtful cases shall be resolved in favor of coverage. For a particular |
||||
product received by a particular user, "normally used" refers to a |
||||
typical or common use of that class of product, regardless of the status |
||||
of the particular user or of the way in which the particular user |
||||
actually uses, or expects or is expected to use, the product. A product |
||||
is a consumer product regardless of whether the product has substantial |
||||
commercial, industrial or non-consumer uses, unless such uses represent |
||||
the only significant mode of use of the product. |
||||
|
||||
"Installation Information" for a User Product means any methods, |
||||
procedures, authorization keys, or other information required to install |
||||
and execute modified versions of a covered work in that User Product from |
||||
a modified version of its Corresponding Source. The information must |
||||
suffice to ensure that the continued functioning of the modified object |
||||
code is in no case prevented or interfered with solely because |
||||
modification has been made. |
||||
|
||||
If you convey an object code work under this section in, or with, or |
||||
specifically for use in, a User Product, and the conveying occurs as |
||||
part of a transaction in which the right of possession and use of the |
||||
User Product is transferred to the recipient in perpetuity or for a |
||||
fixed term (regardless of how the transaction is characterized), the |
||||
Corresponding Source conveyed under this section must be accompanied |
||||
by the Installation Information. But this requirement does not apply |
||||
if neither you nor any third party retains the ability to install |
||||
modified object code on the User Product (for example, the work has |
||||
been installed in ROM). |
||||
|
||||
The requirement to provide Installation Information does not include a |
||||
requirement to continue to provide support service, warranty, or updates |
||||
for a work that has been modified or installed by the recipient, or for |
||||
the User Product in which it has been modified or installed. Access to a |
||||
network may be denied when the modification itself materially and |
||||
adversely affects the operation of the network or violates the rules and |
||||
protocols for communication across the network. |
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, |
||||
in accord with this section must be in a format that is publicly |
||||
documented (and with an implementation available to the public in |
||||
source code form), and must require no special password or key for |
||||
unpacking, reading or copying. |
||||
|
||||
7. Additional Terms. |
||||
|
||||
"Additional permissions" are terms that supplement the terms of this |
||||
License by making exceptions from one or more of its conditions. |
||||
Additional permissions that are applicable to the entire Program shall |
||||
be treated as though they were included in this License, to the extent |
||||
that they are valid under applicable law. If additional permissions |
||||
apply only to part of the Program, that part may be used separately |
||||
under those permissions, but the entire Program remains governed by |
||||
this License without regard to the additional permissions. |
||||
|
||||
When you convey a copy of a covered work, you may at your option |
||||
remove any additional permissions from that copy, or from any part of |
||||
it. (Additional permissions may be written to require their own |
||||
removal in certain cases when you modify the work.) You may place |
||||
additional permissions on material, added by you to a covered work, |
||||
for which you have or can give appropriate copyright permission. |
||||
|
||||
Notwithstanding any other provision of this License, for material you |
||||
add to a covered work, you may (if authorized by the copyright holders of |
||||
that material) supplement the terms of this License with terms: |
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the |
||||
terms of sections 15 and 16 of this License; or |
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or |
||||
author attributions in that material or in the Appropriate Legal |
||||
Notices displayed by works containing it; or |
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or |
||||
requiring that modified versions of such material be marked in |
||||
reasonable ways as different from the original version; or |
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or |
||||
authors of the material; or |
||||
|
||||
e) Declining to grant rights under trademark law for use of some |
||||
trade names, trademarks, or service marks; or |
||||
|
||||
f) Requiring indemnification of licensors and authors of that |
||||
material by anyone who conveys the material (or modified versions of |
||||
it) with contractual assumptions of liability to the recipient, for |
||||
any liability that these contractual assumptions directly impose on |
||||
those licensors and authors. |
||||
|
||||
All other non-permissive additional terms are considered "further |
||||
restrictions" within the meaning of section 10. If the Program as you |
||||
received it, or any part of it, contains a notice stating that it is |
||||
governed by this License along with a term that is a further |
||||
restriction, you may remove that term. If a license document contains |
||||
a further restriction but permits relicensing or conveying under this |
||||
License, you may add to a covered work material governed by the terms |
||||
of that license document, provided that the further restriction does |
||||
not survive such relicensing or conveying. |
||||
|
||||
If you add terms to a covered work in accord with this section, you |
||||
must place, in the relevant source files, a statement of the |
||||
additional terms that apply to those files, or a notice indicating |
||||
where to find the applicable terms. |
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the |
||||
form of a separately written license, or stated as exceptions; |
||||
the above requirements apply either way. |
||||
|
||||
8. Termination. |
||||
|
||||
You may not propagate or modify a covered work except as expressly |
||||
provided under this License. Any attempt otherwise to propagate or |
||||
modify it is void, and will automatically terminate your rights under |
||||
this License (including any patent licenses granted under the third |
||||
paragraph of section 11). |
||||
|
||||
However, if you cease all violation of this License, then your |
||||
license from a particular copyright holder is reinstated (a) |
||||
provisionally, unless and until the copyright holder explicitly and |
||||
finally terminates your license, and (b) permanently, if the copyright |
||||
holder fails to notify you of the violation by some reasonable means |
||||
prior to 60 days after the cessation. |
||||
|
||||
Moreover, your license from a particular copyright holder is |
||||
reinstated permanently if the copyright holder notifies you of the |
||||
violation by some reasonable means, this is the first time you have |
||||
received notice of violation of this License (for any work) from that |
||||
copyright holder, and you cure the violation prior to 30 days after |
||||
your receipt of the notice. |
||||
|
||||
Termination of your rights under this section does not terminate the |
||||
licenses of parties who have received copies or rights from you under |
||||
this License. If your rights have been terminated and not permanently |
||||
reinstated, you do not qualify to receive new licenses for the same |
||||
material under section 10. |
||||
|
||||
9. Acceptance Not Required for Having Copies. |
||||
|
||||
You are not required to accept this License in order to receive or |
||||
run a copy of the Program. Ancillary propagation of a covered work |
||||
occurring solely as a consequence of using peer-to-peer transmission |
||||
to receive a copy likewise does not require acceptance. However, |
||||
nothing other than this License grants you permission to propagate or |
||||
modify any covered work. These actions infringe copyright if you do |
||||
not accept this License. Therefore, by modifying or propagating a |
||||
covered work, you indicate your acceptance of this License to do so. |
||||
|
||||
10. Automatic Licensing of Downstream Recipients. |
||||
|
||||
Each time you convey a covered work, the recipient automatically |
||||
receives a license from the original licensors, to run, modify and |
||||
propagate that work, subject to this License. You are not responsible |
||||
for enforcing compliance by third parties with this License. |
||||
|
||||
An "entity transaction" is a transaction transferring control of an |
||||
organization, or substantially all assets of one, or subdividing an |
||||
organization, or merging organizations. If propagation of a covered |
||||
work results from an entity transaction, each party to that |
||||
transaction who receives a copy of the work also receives whatever |
||||
licenses to the work the party's predecessor in interest had or could |
||||
give under the previous paragraph, plus a right to possession of the |
||||
Corresponding Source of the work from the predecessor in interest, if |
||||
the predecessor has it or can get it with reasonable efforts. |
||||
|
||||
You may not impose any further restrictions on the exercise of the |
||||
rights granted or affirmed under this License. For example, you may |
||||
not impose a license fee, royalty, or other charge for exercise of |
||||
rights granted under this License, and you may not initiate litigation |
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that |
||||
any patent claim is infringed by making, using, selling, offering for |
||||
sale, or importing the Program or any portion of it. |
||||
|
||||
11. Patents. |
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this |
||||
License of the Program or a work on which the Program is based. The |
||||
work thus licensed is called the contributor's "contributor version". |
||||
|
||||
A contributor's "essential patent claims" are all patent claims |
||||
owned or controlled by the contributor, whether already acquired or |
||||
hereafter acquired, that would be infringed by some manner, permitted |
||||
by this License, of making, using, or selling its contributor version, |
||||
but do not include claims that would be infringed only as a |
||||
consequence of further modification of the contributor version. For |
||||
purposes of this definition, "control" includes the right to grant |
||||
patent sublicenses in a manner consistent with the requirements of |
||||
this License. |
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free |
||||
patent license under the contributor's essential patent claims, to |
||||
make, use, sell, offer for sale, import and otherwise run, modify and |
||||
propagate the contents of its contributor version. |
||||
|
||||
In the following three paragraphs, a "patent license" is any express |
||||
agreement or commitment, however denominated, not to enforce a patent |
||||
(such as an express permission to practice a patent or covenant not to |
||||
sue for patent infringement). To "grant" such a patent license to a |
||||
party means to make such an agreement or commitment not to enforce a |
||||
patent against the party. |
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, |
||||
and the Corresponding Source of the work is not available for anyone |
||||
to copy, free of charge and under the terms of this License, through a |
||||
publicly available network server or other readily accessible means, |
||||
then you must either (1) cause the Corresponding Source to be so |
||||
available, or (2) arrange to deprive yourself of the benefit of the |
||||
patent license for this particular work, or (3) arrange, in a manner |
||||
consistent with the requirements of this License, to extend the patent |
||||
license to downstream recipients. "Knowingly relying" means you have |
||||
actual knowledge that, but for the patent license, your conveying the |
||||
covered work in a country, or your recipient's use of the covered work |
||||
in a country, would infringe one or more identifiable patents in that |
||||
country that you have reason to believe are valid. |
||||
|
||||
If, pursuant to or in connection with a single transaction or |
||||
arrangement, you convey, or propagate by procuring conveyance of, a |
||||
covered work, and grant a patent license to some of the parties |
||||
receiving the covered work authorizing them to use, propagate, modify |
||||
or convey a specific copy of the covered work, then the patent license |
||||
you grant is automatically extended to all recipients of the covered |
||||
work and works based on it. |
||||
|
||||
A patent license is "discriminatory" if it does not include within |
||||
the scope of its coverage, prohibits the exercise of, or is |
||||
conditioned on the non-exercise of one or more of the rights that are |
||||
specifically granted under this License. You may not convey a covered |
||||
work if you are a party to an arrangement with a third party that is |
||||
in the business of distributing software, under which you make payment |
||||
to the third party based on the extent of your activity of conveying |
||||
the work, and under which the third party grants, to any of the |
||||
parties who would receive the covered work from you, a discriminatory |
||||
patent license (a) in connection with copies of the covered work |
||||
conveyed by you (or copies made from those copies), or (b) primarily |
||||
for and in connection with specific products or compilations that |
||||
contain the covered work, unless you entered into that arrangement, |
||||
or that patent license was granted, prior to 28 March 2007. |
||||
|
||||
Nothing in this License shall be construed as excluding or limiting |
||||
any implied license or other defenses to infringement that may |
||||
otherwise be available to you under applicable patent law. |
||||
|
||||
12. No Surrender of Others' Freedom. |
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or |
||||
otherwise) that contradict the conditions of this License, they do not |
||||
excuse you from the conditions of this License. If you cannot convey a |
||||
covered work so as to satisfy simultaneously your obligations under this |
||||
License and any other pertinent obligations, then as a consequence you may |
||||
not convey it at all. For example, if you agree to terms that obligate you |
||||
to collect a royalty for further conveying from those to whom you convey |
||||
the Program, the only way you could satisfy both those terms and this |
||||
License would be to refrain entirely from conveying the Program. |
||||
|
||||
13. Use with the GNU Affero General Public License. |
||||
|
||||
Notwithstanding any other provision of this License, you have |
||||
permission to link or combine any covered work with a work licensed |
||||
under version 3 of the GNU Affero General Public License into a single |
||||
combined work, and to convey the resulting work. The terms of this |
||||
License will continue to apply to the part which is the covered work, |
||||
but the special requirements of the GNU Affero General Public License, |
||||
section 13, concerning interaction through a network will apply to the |
||||
combination as such. |
||||
|
||||
14. Revised Versions of this License. |
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of |
||||
the GNU General Public License from time to time. Such new versions will |
||||
be similar in spirit to the present version, but may differ in detail to |
||||
address new problems or concerns. |
||||
|
||||
Each version is given a distinguishing version number. If the |
||||
Program specifies that a certain numbered version of the GNU General |
||||
Public License "or any later version" applies to it, you have the |
||||
option of following the terms and conditions either of that numbered |
||||
version or of any later version published by the Free Software |
||||
Foundation. If the Program does not specify a version number of the |
||||
GNU General Public License, you may choose any version ever published |
||||
by the Free Software Foundation. |
||||
|
||||
If the Program specifies that a proxy can decide which future |
||||
versions of the GNU General Public License can be used, that proxy's |
||||
public statement of acceptance of a version permanently authorizes you |
||||
to choose that version for the Program. |
||||
|
||||
Later license versions may give you additional or different |
||||
permissions. However, no additional obligations are imposed on any |
||||
author or copyright holder as a result of your choosing to follow a |
||||
later version. |
||||
|
||||
15. Disclaimer of Warranty. |
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY |
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT |
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY |
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, |
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM |
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF |
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION. |
||||
|
||||
16. Limitation of Liability. |
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS |
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY |
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE |
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF |
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD |
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), |
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
||||
SUCH DAMAGES. |
||||
|
||||
17. Interpretation of Sections 15 and 16. |
||||
|
||||
If the disclaimer of warranty and limitation of liability provided |
||||
above cannot be given local legal effect according to their terms, |
||||
reviewing courts shall apply local law that most closely approximates |
||||
an absolute waiver of all civil liability in connection with the |
||||
Program, unless a warranty or assumption of liability accompanies a |
||||
copy of the Program in return for a fee. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
How to Apply These Terms to Your New Programs |
||||
|
||||
If you develop a new program, and you want it to be of the greatest |
||||
possible use to the public, the best way to achieve this is to make it |
||||
free software which everyone can redistribute and change under these terms. |
||||
|
||||
To do so, attach the following notices to the program. It is safest |
||||
to attach them to the start of each source file to most effectively |
||||
state the exclusion of warranty; and each file should have at least |
||||
the "copyright" line and a pointer to where the full notice is found. |
||||
|
||||
<one line to give the program's name and a brief idea of what it does.> |
||||
Copyright (C) <year> <name of author> |
||||
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. |
||||
|
||||
Also add information on how to contact you by electronic and paper mail. |
||||
|
||||
If the program does terminal interaction, make it output a short |
||||
notice like this when it starts in an interactive mode: |
||||
|
||||
<program> Copyright (C) <year> <name of author> |
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
||||
This is free software, and you are welcome to redistribute it |
||||
under certain conditions; type `show c' for details. |
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate |
||||
parts of the General Public License. Of course, your program's commands |
||||
might be different; for a GUI interface, you would use an "about box". |
||||
|
||||
You should also get your employer (if you work as a programmer) or school, |
||||
if any, to sign a "copyright disclaimer" for the program, if necessary. |
||||
For more information on this, and how to apply and follow the GNU GPL, see |
||||
<http://www.gnu.org/licenses/>. |
||||
|
||||
The GNU General Public License does not permit incorporating your program |
||||
into proprietary programs. If your program is a subroutine library, you |
||||
may consider it more useful to permit linking proprietary applications with |
||||
the library. If this is what you want to do, use the GNU Lesser General |
||||
Public License instead of this License. But first, please read |
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>. |
||||
@ -1,27 +0,0 @@
|
||||
RTOS: |
||||
IPV4: ETH |
||||
IPV6: |
||||
DEVLOOP: |
||||
CRC: |
||||
ETH: |
||||
TCP: IPV4 |
||||
UDP: IPV4 |
||||
IPV4FRAG: IPV4 |
||||
NAT: IPV4 UDP |
||||
ICMP4: IPV4 |
||||
MCAST: UDP |
||||
PING: ICMP4 |
||||
DHCP_CLIENT: UDP |
||||
DHCP_SERVER: UDP |
||||
DNS_CLIENT: UDP |
||||
IPFILTER: IPV4 |
||||
OLSR: MCAST |
||||
SLAACV4: IPV4 |
||||
SNTP_CLIENT: DNS_CLIENT |
||||
TFTP: UDP |
||||
MDNS: MCAST |
||||
DNS_SD: MDNS |
||||
AODV: IPV4 UDP |
||||
PPP: IPV4 |
||||
6LOWPAN: IPV6 |
||||
IEEE802154: 6LOWPAN |
||||
@ -1,508 +0,0 @@
|
||||
-include ../../config.mk |
||||
-include ../../tools/kconfig/.config |
||||
|
||||
OS:=$(shell uname)
|
||||
CC:=$(CROSS_COMPILE)gcc
|
||||
LD:=$(CROSS_COMPILE)ld
|
||||
AR:=$(CROSS_COMPILE)ar
|
||||
RANLIB:=$(CROSS_COMPILE)ranlib
|
||||
SIZE:=$(CROSS_COMPILE)size
|
||||
STRIP_BIN:=$(CROSS_COMPILE)strip
|
||||
TEST_LDFLAGS=-pthread $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o -lvdeplug
|
||||
UNIT_LDFLAGS=-lcheck -lm -pthread -lrt -lsubunit
|
||||
UNIT_CFLAGS= $(CFLAGS) -Wno-missing-braces
|
||||
|
||||
LIBNAME:="libpicotcp.a"
|
||||
|
||||
PREFIX?=$(PWD)/build
|
||||
DEBUG?=1
|
||||
PROFILE?=0
|
||||
PERF?=0
|
||||
ENDIAN?=little
|
||||
STRIP?=0
|
||||
RTOS?=0
|
||||
GENERIC?=0
|
||||
PTHREAD?=0
|
||||
ADDRESS_SANITIZER?=1
|
||||
GCOV?=0
|
||||
|
||||
# Default compiled-in protocols
|
||||
#
|
||||
TCP?=1
|
||||
UDP?=1
|
||||
ETH?=1
|
||||
IPV4?=1
|
||||
IPV4FRAG?=1
|
||||
IPV6FRAG?=0
|
||||
NAT?=1
|
||||
ICMP4?=1
|
||||
MCAST?=1
|
||||
DEVLOOP?=1
|
||||
PING?=1
|
||||
DHCP_CLIENT?=1
|
||||
DHCP_SERVER?=1
|
||||
DNS_CLIENT?=1
|
||||
MDNS?=1
|
||||
DNS_SD?=1
|
||||
SNTP_CLIENT?=1
|
||||
IPFILTER?=1
|
||||
CRC?=1
|
||||
OLSR?=0
|
||||
SLAACV4?=1
|
||||
TFTP?=1
|
||||
AODV?=1
|
||||
MEMORY_MANAGER?=0
|
||||
MEMORY_MANAGER_PROFILING?=0
|
||||
TUN?=0
|
||||
TAP?=0
|
||||
PCAP?=0
|
||||
PPP?=1
|
||||
6LOWPAN?=0
|
||||
IEEE802154?=0
|
||||
IPC?=0
|
||||
CYASSL?=0
|
||||
WOLFSSL?=0
|
||||
POLARSSL?=0
|
||||
|
||||
#IPv6 related
|
||||
IPV6?=1
|
||||
|
||||
TEST?=0
|
||||
ifeq ($(TEST),1) |
||||
6LOWPAN=1
|
||||
IEEE802154=1
|
||||
endif |
||||
|
||||
UNITS?=0
|
||||
ifeq ($(UNITS),1) |
||||
6LOWPAN=1
|
||||
IEEE802154=1
|
||||
ARCH=faulty
|
||||
endif |
||||
|
||||
UNITS_MM?=0
|
||||
ifeq ($(UNITS_MM),1) |
||||
6LOWPAN=1
|
||||
IEEE802154=1
|
||||
MEMORY_MANAGER=1
|
||||
endif |
||||
|
||||
EXTRA_CFLAGS+=-DPICO_COMPILE_TIME=`date +%s`
|
||||
EXTRA_CFLAGS+=$(PLATFORM_CFLAGS)
|
||||
|
||||
CFLAGS=-I$(PREFIX)/include -Iinclude -Imodules $(EXTRA_CFLAGS)
|
||||
# options for adding warnings
|
||||
CFLAGS+= -Wall -W -Wextra -Wshadow -Wcast-qual -Wwrite-strings -Wundef -Wdeclaration-after-statement
|
||||
CFLAGS+= -Wconversion -Wcast-align -Wmissing-prototypes
|
||||
# options for supressing warnings
|
||||
CFLAGS+= -Wno-missing-field-initializers
|
||||
|
||||
ifeq ($(CC),clang) |
||||
CFLAGS+= -Wunreachable-code-break -Wpointer-bool-conversion -Wmissing-variable-declarations
|
||||
endif |
||||
|
||||
ifeq ($(OS),Darwin) |
||||
LIBSIZE=stat -f%z
|
||||
ifeq ($(SIZE),size)
|
||||
SUMSIZE=$(SIZE)
|
||||
else
|
||||
SUMSIZE=$(SIZE) -t
|
||||
endif
|
||||
else |
||||
LIBSIZE=du -b
|
||||
SUMSIZE=$(SIZE) -t
|
||||
endif |
||||
|
||||
ifeq ($(DEBUG),1) |
||||
CFLAGS+=-ggdb
|
||||
else |
||||
ifeq ($(PERF), 1)
|
||||
CFLAGS+=-O3
|
||||
else
|
||||
CFLAGS+=-Os
|
||||
endif
|
||||
endif |
||||
|
||||
ifeq ($(PROFILE),1) |
||||
CFLAGS+=-pg
|
||||
endif |
||||
|
||||
ifeq ($(TFTP),1) |
||||
MOD_OBJ+=$(LIBBASE)modules/pico_strings.o $(LIBBASE)modules/pico_tftp.o
|
||||
OPTIONS+=-DPICO_SUPPORT_TFTP
|
||||
endif |
||||
|
||||
ifeq ($(AODV),1) |
||||
MOD_OBJ+=$(LIBBASE)modules/pico_aodv.o
|
||||
OPTIONS+=-DPICO_SUPPORT_AODV
|
||||
endif |
||||
|
||||
ifeq ($(GENERIC),1) |
||||
CFLAGS+=-DGENERIC
|
||||
endif |
||||
|
||||
ifeq ($(PTHREAD),1) |
||||
CFLAGS+=-DPICO_SUPPORT_PTHREAD
|
||||
endif |
||||
|
||||
|
||||
ifneq ($(ENDIAN),little) |
||||
CFLAGS+=-DPICO_BIGENDIAN
|
||||
endif |
||||
|
||||
ifneq ($(RTOS),0) |
||||
OPTIONS+=-DPICO_SUPPORT_RTOS
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm4-hardfloat) |
||||
CFLAGS+=-DCORTEX_M4_HARDFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm4-softfloat) |
||||
CFLAGS+=-DCORTEX_M4_SOFTFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfloat-abi=soft -mthumb-interwork
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm3) |
||||
CFLAGS+=-DCORTEX_M3 -mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm0plus) |
||||
CFLAGS+=-DCORTEX_M0PLUS -mcpu=cortex-m0plus -mthumb -mlittle-endian -mthumb-interwork
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),arm9) |
||||
CFLAGS+=-DARM9 -mcpu=arm9e -march=armv5te -gdwarf-2 -Wall -marm -mthumb-interwork -fpack-struct
|
||||
endif |
||||
|
||||
ifeq ($(ADDRESS_SANITIZER),1) |
||||
TEST_LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
|
||||
endif |
||||
|
||||
ifeq ($(GCOV),1) |
||||
TEST_LDFLAGS+=-lgcov --coverage
|
||||
CFLAGS+=-fprofile-arcs -ftest-coverage
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),faulty) |
||||
CFLAGS+=-DFAULTY -DUNIT_TEST
|
||||
ifeq ($(ADDRESS_SANITIZER),1)
|
||||
CFLAGS+=-fsanitize=address
|
||||
endif
|
||||
CFLAGS+=-fno-omit-frame-pointer
|
||||
UNITS_OBJ+=test/pico_faulty.o
|
||||
TEST_OBJ+=test/pico_faulty.o
|
||||
DUMMY_EXTRA+=test/pico_faulty.o
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),msp430) |
||||
CFLAGS+=-DMSP430
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),esp8266) |
||||
CFLAGS+=-DESP8266 -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),mt7681) |
||||
CFLAGS+=-DMT7681 -fno-builtin -ffunction-sections -fno-strict-aliasing -m16bit -mabi=2 -mbaseline=V2 -mcpu=n9 -mno-div -mel -mmw-count=8 -mno-ext-mac -mno-dx-regs
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),pic24) |
||||
CFLAGS+=-DPIC24 -c -mcpu=24FJ256GA106 -MMD -MF -g -omf=elf \
|
||||
-mlarge-code -mlarge-data -msmart-io=1 -msfr-warn=off
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),pic32) |
||||
CFLAGS+=-DPIC32
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),atmega128) |
||||
CFLAGS+=-Wall -mmcu=atmega128 -DAVR
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),none) |
||||
CFLAGS+=-DARCHNONE
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),shared) |
||||
CFLAGS+=-fPIC
|
||||
endif |
||||
|
||||
%.o:%.c deps |
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
CORE_OBJ= stack/pico_stack.o \
|
||||
stack/pico_frame.o \
|
||||
stack/pico_device.o \
|
||||
stack/pico_protocol.o \
|
||||
stack/pico_socket.o \
|
||||
stack/pico_socket_multicast.o \
|
||||
stack/pico_tree.o \
|
||||
stack/pico_md5.o
|
||||
|
||||
POSIX_OBJ+= modules/pico_dev_vde.o \
|
||||
modules/pico_dev_tun.o \
|
||||
modules/pico_dev_ipc.o \
|
||||
modules/pico_dev_tap.o \
|
||||
modules/pico_dev_mock.o
|
||||
|
||||
include rules/debug.mk |
||||
|
||||
ifneq ($(ETH),0) |
||||
include rules/eth.mk
|
||||
endif |
||||
ifneq ($(IPV4),0) |
||||
include rules/ipv4.mk
|
||||
endif |
||||
ifneq ($(IPV4FRAG),0) |
||||
include rules/ipv4frag.mk
|
||||
endif |
||||
ifneq ($(ICMP4),0) |
||||
include rules/icmp4.mk
|
||||
endif |
||||
ifneq ($(TCP),0) |
||||
include rules/tcp.mk
|
||||
endif |
||||
ifneq ($(UDP),0) |
||||
include rules/udp.mk
|
||||
endif |
||||
ifneq ($(MCAST),0) |
||||
include rules/mcast.mk
|
||||
include rules/igmp.mk
|
||||
include rules/mld.mk
|
||||
endif |
||||
ifneq ($(NAT),0) |
||||
include rules/nat.mk
|
||||
endif |
||||
ifneq ($(DEVLOOP),0) |
||||
include rules/devloop.mk
|
||||
endif |
||||
ifneq ($(DHCP_CLIENT),0) |
||||
include rules/dhcp_client.mk
|
||||
endif |
||||
ifneq ($(DHCP_SERVER),0) |
||||
include rules/dhcp_server.mk
|
||||
endif |
||||
ifneq ($(DNS_CLIENT),0) |
||||
include rules/dns_client.mk
|
||||
endif |
||||
ifneq ($(MDNS),0) |
||||
include rules/mdns.mk
|
||||
endif |
||||
ifneq ($(DNS_SD),0) |
||||
include rules/dns_sd.mk
|
||||
endif |
||||
ifneq ($(IPFILTER),0) |
||||
include rules/ipfilter.mk
|
||||
endif |
||||
ifneq ($(CRC),0) |
||||
include rules/crc.mk
|
||||
endif |
||||
ifneq ($(OLSR),0) |
||||
include rules/olsr.mk
|
||||
endif |
||||
ifneq ($(SLAACV4),0) |
||||
include rules/slaacv4.mk
|
||||
endif |
||||
ifneq ($(IPV6),0) |
||||
include rules/ipv6.mk
|
||||
endif |
||||
ifneq ($(MEMORY_MANAGER),0) |
||||
include rules/memory_manager.mk
|
||||
endif |
||||
ifneq ($(MEMORY_MANAGER_PROFILING),0) |
||||
OPTIONS+=-DPICO_SUPPORT_MM_PROFILING
|
||||
endif |
||||
ifneq ($(SNTP_CLIENT),0) |
||||
include rules/sntp_client.mk
|
||||
endif |
||||
ifneq ($(TUN),0) |
||||
include rules/tun.mk
|
||||
endif |
||||
ifneq ($(TAP),0) |
||||
include rules/tap.mk
|
||||
endif |
||||
ifneq ($(PCAP),0) |
||||
include rules/pcap.mk
|
||||
endif |
||||
ifneq ($(PPP),0) |
||||
include rules/ppp.mk
|
||||
endif |
||||
ifneq ($(6LOWPAN), 0) |
||||
include rules/6lowpan.mk
|
||||
endif |
||||
ifneq ($(IPC),0) |
||||
include rules/ipc.mk
|
||||
endif |
||||
ifneq ($(CYASSL),0) |
||||
include rules/cyassl.mk
|
||||
endif |
||||
ifneq ($(WOLFSSL),0) |
||||
include rules/wolfssl.mk
|
||||
endif |
||||
ifneq ($(POLARSSL),0) |
||||
include rules/polarssl.mk
|
||||
endif |
||||
|
||||
all: mod core lib |
||||
|
||||
core: $(CORE_OBJ) |
||||
@mkdir -p $(PREFIX)/lib
|
||||
@mv stack/*.o $(PREFIX)/lib
|
||||
|
||||
mod: $(MOD_OBJ) |
||||
@mkdir -p $(PREFIX)/modules
|
||||
@mv modules/*.o $(PREFIX)/modules || echo
|
||||
|
||||
posix: all $(POSIX_OBJ) |
||||
@mv modules/*.o $(PREFIX)/modules || echo
|
||||
|
||||
|
||||
TEST_ELF= test/picoapp.elf
|
||||
TEST6_ELF= test/picoapp6.elf
|
||||
|
||||
|
||||
test: posix |
||||
@if [ $(TEST) -eq 0 ]; then \
|
||||
echo "\n\nsmoke tests should be compiled with TEST=1 from now on!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@mkdir -p $(PREFIX)/test/
|
||||
@make -C test/examples PREFIX=$(PREFIX)
|
||||
@echo -e "\t[CC] picoapp.o"
|
||||
@$(CC) -c -o $(PREFIX)/examples/picoapp.o test/picoapp.c $(CFLAGS) -Itest/examples
|
||||
@echo -e "\t[LD] $@"
|
||||
@$(CC) -g -o $(TEST_ELF) -I include -I modules -I $(PREFIX)/include -Wl,--start-group $(TEST_LDFLAGS) $(TEST_OBJ) $(PREFIX)/examples/*.o -Wl,--end-group
|
||||
@mv test/*.elf $(PREFIX)/test
|
||||
@install $(PREFIX)/$(TEST_ELF) $(PREFIX)/$(TEST6_ELF)
|
||||
|
||||
tst: test |
||||
|
||||
$(PREFIX)/include/pico_defines.h: |
||||
@mkdir -p $(PREFIX)/lib
|
||||
@mkdir -p $(PREFIX)/include
|
||||
@bash ./mkdeps.sh $(PREFIX) $(OPTIONS)
|
||||
|
||||
|
||||
deps: $(PREFIX)/include/pico_defines.h |
||||
|
||||
|
||||
|
||||
lib: mod core |
||||
@cp -f include/*.h $(PREFIX)/include
|
||||
@cp -fa include/arch $(PREFIX)/include
|
||||
@cp -f modules/*.h $(PREFIX)/include
|
||||
@echo -e "\t[AR] $(PREFIX)/lib/$(LIBNAME)"
|
||||
@$(AR) cru $(PREFIX)/lib/$(LIBNAME) $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o \
|
||||
|| $(AR) cru $(PREFIX)/lib/$(LIBNAME) $(PREFIX)/lib/*.o
|
||||
@echo -e "\t[RANLIB] $(PREFIX)/lib/$(LIBNAME)"
|
||||
@$(RANLIB) $(PREFIX)/lib/$(LIBNAME)
|
||||
@test $(STRIP) -eq 1 && (echo -e "\t[STRIP] $(PREFIX)/lib/$(LIBNAME)" \
|
||||
&& $(STRIP_BIN) $(PREFIX)/lib/$(LIBNAME)) \
|
||||
|| echo -e "\t[KEEP SYMBOLS] $(PREFIX)/lib/$(LIBNAME)"
|
||||
@echo -e "\t[LIBSIZE] `$(LIBSIZE) $(PREFIX)/lib/$(LIBNAME)`"
|
||||
@echo -e "`$(SUMSIZE) $(PREFIX)/lib/$(LIBNAME)`"
|
||||
|
||||
loop: mod core |
||||
mkdir -p $(PREFIX)/test
|
||||
@$(CC) -c -o $(PREFIX)/modules/pico_dev_loop.o modules/pico_dev_loop.c $(CFLAGS)
|
||||
@$(CC) -c -o $(PREFIX)/loop_ping.o test/loop_ping.c $(CFLAGS) -ggdb
|
||||
|
||||
units: mod core lib $(UNITS_OBJ) $(MOD_OBJ) |
||||
@if [ $(UNITS) -eq 0 ]; then \
|
||||
echo "\n\nunit tests should be compiled with UNITS=1 from now on!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo -e "\n\t[UNIT TESTS SUITE]"
|
||||
@mkdir -p $(PREFIX)/test
|
||||
@echo -e "\t[CC] units.o"
|
||||
@$(CC) -g -c -o $(PREFIX)/test/units.o test/units.c $(UNIT_CFLAGS) -I stack -I modules -I includes -I test/unit -DUNIT_TEST
|
||||
@echo -e "\t[LD] $(PREFIX)/test/units"
|
||||
@$(CC) -o $(PREFIX)/test/units $(UNIT_CFLAGS) $(PREFIX)/test/units.o $(UNIT_LDFLAGS) \
|
||||
$(UNITS_OBJ) $(PREFIX)/modules/pico_aodv.o \
|
||||
$(PREFIX)/modules/pico_fragments.o
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_protocol.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_protocol.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_frame.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_frame.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_seq.elf $(UNIT_CFLAGS) -I. test/unit/modunit_seq.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_tcp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_tcp.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_client.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_client.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_common.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_common.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_mdns.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_mdns.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_sd.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dns_sd.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dev_loop.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dev_loop.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_ipv6_nd.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ipv6_nd.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_ethernet.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ethernet.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_stack.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_stack.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_tftp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_tftp.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_sntp_client.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_sntp_client.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_ipfilter.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_ipfilter.c stack/pico_tree.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_aodv.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_aodv.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_fragments.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_fragments.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_queue.elf $(UNIT_CFLAGS) -I. test/unit/modunit_queue.c $(UNIT_LDFLAGS) $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dev_ppp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_dev_ppp.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_mld.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_mld.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_igmp.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_igmp.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_hotplug_detection.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_hotplug_detection.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_802154.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_802154.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_6lowpan.elf $(UNIT_CFLAGS) -I. -I test/examples test/unit/modunit_pico_6lowpan.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_strings.elf $(UNIT_CFLAGS) -I. test/unit/modunit_pico_strings.c $(UNIT_LDFLAGS) $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
|
||||
devunits: mod core lib |
||||
@echo -e "\n\t[UNIT TESTS SUITE: device drivers]"
|
||||
@mkdir -p $(PREFIX)/test/unit/device/
|
||||
@echo -e "\t[CC] picotcp_mock.o"
|
||||
@$(CC) -c -o $(PREFIX)/test/unit/device/picotcp_mock.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/picotcp_mock.c
|
||||
@$(CC) -c -o $(PREFIX)/test/unit/device/unit_dev_vde.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/unit_dev_vde.c
|
||||
@echo -e "\t[LD] $(PREFIX)/test/devunits"
|
||||
@$(CC) -o $(PREFIX)/test/devunits $(CFLAGS) -I stack $(PREFIX)/test/unit/device/*.o -lcheck -lm -pthread -lrt
|
||||
|
||||
units_mm: mod core lib |
||||
@if [ $(UNITS_MM) -eq 0 ]; then \
|
||||
echo "\n\nMM unit tests should be compiled with UNITS_MM=1 from now on!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo -e "\n\t[UNIT TESTS SUITE]"
|
||||
@mkdir -p $(PREFIX)/test
|
||||
@echo -e "\t[CC] units_mm.o"
|
||||
@$(CC) -c -o $(PREFIX)/test/units_mm.o test/unit/unit_mem_manager.c $(CFLAGS) -I stack -I modules -I includes -I test/unit
|
||||
@echo -e "\t[LD] $(PREFIX)/test/units"
|
||||
@$(CC) -o $(PREFIX)/test/units_mm $(CFLAGS) $(PREFIX)/test/units_mm.o -lcheck -lm -pthread -lrt
|
||||
|
||||
|
||||
clean: |
||||
@echo -e "\t[CLEAN] $(PREFIX)/"
|
||||
@rm -rf $(PREFIX) tags
|
||||
|
||||
mbed: |
||||
@echo -e "\t[Creating PicoTCP.zip]"
|
||||
@rm -f PicoTCP.zip
|
||||
@cp include/pico_socket.h include/socket.tmp
|
||||
@echo "#define MBED\n" > include/mbed.tmp
|
||||
@cat include/mbed.tmp include/socket.tmp > include/pico_socket.h
|
||||
@zip -0 PicoTCP.zip -r include modules stack -x include/arch/ include/arch/* include/pico_config.h include/*.tmp modules/pico_dev_*
|
||||
@rm include/pico_socket.h include/mbed.tmp
|
||||
@mv include/socket.tmp include/pico_socket.h
|
||||
|
||||
|
||||
style: |
||||
@find . -iname "*.[c|h]" | xargs uncrustify --replace -l C -c uncrustify.cfg || true
|
||||
@find . -iname "*unc-backup*" |xargs rm || true
|
||||
|
||||
dummy: mod core lib $(DUMMY_EXTRA) |
||||
@echo testing configuration...
|
||||
@$(CC) -c -o test/dummy.o test/dummy.c $(CFLAGS)
|
||||
@$(CC) -o dummy test/dummy.o $(DUMMY_EXTRA) $(PREFIX)/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
|
||||
@echo done.
|
||||
@rm -f test/dummy.o dummy
|
||||
|
||||
ppptest: test/ppp.c lib |
||||
gcc -ggdb -c -o ppp.o test/ppp.c -I $(PREFIX)/include/ -I $(PREFIX)/modules/ $(CFLAGS)
|
||||
gcc -o ppp ppp.o $(PREFIX)/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
|
||||
rm -f ppp.o
|
||||
|
||||
.PHONY: coverity |
||||
coverity: |
||||
@make clean
|
||||
@cov-build --dir $(PREFIX)/cov-int make
|
||||
@tar czvf $(PREFIX)/coverity.tgz -C $(PREFIX) cov-int
|
||||
|
||||
FORCE: |
||||
@ -1,403 +0,0 @@
|
||||
-include ../../config.mk |
||||
-include ../../tools/kconfig/.config |
||||
|
||||
WATCOM_PATH:=/opt/watcom
|
||||
CC:=$(WATCOM_PATH)/binl/$(CROSS_COMPILE)wcc386
|
||||
LD:=$(WATCOM_PATH)/binl/$(CROSS_COMPILE)wcl386
|
||||
AR:=$(WATCOM_PATH)/binl/$(CROSS_COMPILE)wlib
|
||||
RANLIB:=$(WATCOM_PATH)/binl/$(CROSS_COMPILE)ranlib
|
||||
SIZE:=$(CROSS_COMPILE)size
|
||||
STRIP_BIN:=$(CROSS_COMPILE)strip
|
||||
TEST_LDFLAGS=-pthread $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o -lvdeplug
|
||||
LIBNAME:=libpicotcp.a
|
||||
|
||||
PREFIX?=$(PWD)/build
|
||||
DEBUG?=1
|
||||
PROFILE?=0
|
||||
PERF?=0
|
||||
ENDIAN?=little
|
||||
STRIP?=0
|
||||
RTOS?=0
|
||||
GENERIC?=0
|
||||
PTHREAD?=0
|
||||
ADDRESS_SANITIZER?=1
|
||||
|
||||
# Default compiled-in protocols
|
||||
#
|
||||
TCP?=1
|
||||
UDP?=1
|
||||
ETH?=1
|
||||
IPV4?=1
|
||||
IPV4FRAG?=1
|
||||
IPV6FRAG?=0
|
||||
NAT?=1
|
||||
ICMP4?=1
|
||||
MCAST?=1
|
||||
DEVLOOP?=1
|
||||
PING?=1
|
||||
DHCP_CLIENT?=1
|
||||
DHCP_SERVER?=1
|
||||
DNS_CLIENT?=1
|
||||
MDNS?=1
|
||||
DNS_SD?=1
|
||||
SNTP_CLIENT?=1
|
||||
IPFILTER?=1
|
||||
CRC?=1
|
||||
OLSR?=0
|
||||
SLAACV4?=1
|
||||
TFTP?=1
|
||||
AODV?=1
|
||||
MEMORY_MANAGER?=0
|
||||
MEMORY_MANAGER_PROFILING?=0
|
||||
TUN?=0
|
||||
TAP?=0
|
||||
PCAP?=0
|
||||
PPP?=0
|
||||
CYASSL?=0
|
||||
WOLFSSL?=0
|
||||
POLARSSL?=0
|
||||
|
||||
#IPv6 related
|
||||
IPV6?=1
|
||||
|
||||
EXTRA_CFLAGS+=-dPICO_COMPILE_TIME=`date +%s`
|
||||
EXTRA_CFLAGS+=$(PLATFORM_CFLAGS)
|
||||
|
||||
CFLAGS=-i=$(WATCOM_PATH)/h -i=$(PREFIX)/include -i=include -i=modules $(EXTRA_CFLAGS) -q
|
||||
|
||||
|
||||
ifeq ($(DEBUG),1) |
||||
CFLAGS+=-od -of -d9
|
||||
else |
||||
ifeq ($(PERF), 1)
|
||||
CFLAGS+=
|
||||
else
|
||||
CFLAGS+=
|
||||
endif
|
||||
endif |
||||
|
||||
ifeq ($(TFTP),1) |
||||
MOD_OBJ+=$(LIBBASE)modules/pico_strings.o $(LIBBASE)modules/pico_tftp.o
|
||||
OPTIONS+=-dPICO_SUPPORT_TFTP
|
||||
endif |
||||
|
||||
ifeq ($(AODV),1) |
||||
MOD_OBJ+=$(LIBBASE)modules/pico_aodv.o
|
||||
OPTIONS+=-dPICO_SUPPORT_AODV
|
||||
endif |
||||
|
||||
ifeq ($(GENERIC),1) |
||||
CFLAGS+=-dGENERIC
|
||||
endif |
||||
|
||||
ifeq ($(PTHREAD),1) |
||||
CFLAGS+=-dPICO_SUPPORT_PTHREAD
|
||||
endif |
||||
|
||||
|
||||
ifneq ($(ENDIAN),little) |
||||
CFLAGS+=-dPICO_BIGENDIAN
|
||||
endif |
||||
|
||||
ifneq ($(RTOS),0) |
||||
OPTIONS+=-dPICO_SUPPORT_RTOS
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm4-hardfloat) |
||||
CFLAGS+=-dCORTEX_M4_HARDFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork -fsingle-precision-constant
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm4-softfloat) |
||||
CFLAGS+=-dCORTEX_M4_SOFTFLOAT -mcpu=cortex-m4 -mthumb -mlittle-endian -mfloat-abi=soft -mthumb-interwork
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),cortexm3) |
||||
CFLAGS+=-dCORTEX_M3 -mcpu=cortex-m3 -mthumb -mlittle-endian -mthumb-interwork
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),arm9) |
||||
CFLAGS+=-dARM9 -mcpu=arm9e -march=armv5te -gdwarf-2 -Wall -marm -mthumb-interwork -fpack-struct
|
||||
endif |
||||
|
||||
ifeq ($(ADDRESS_SANITIZER),1) |
||||
TEST_LDFLAGS+=-fsanitize=address -fno-omit-frame-pointer
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),faulty) |
||||
CFLAGS+=-dFAULTY -dUNIT_TEST
|
||||
CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
|
||||
UNITS_OBJ+=test/pico_faulty.o
|
||||
TEST_OBJ+=test/pico_faulty.o
|
||||
DUMMY_EXTRA+=test/pico_faulty.o
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),msp430) |
||||
CFLAGS+=-dMSP430
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),esp8266) |
||||
CFLAGS+=-dESP8266 -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),mt7681) |
||||
CFLAGS+=-dMT7681 -fno-builtin -ffunction-sections -fno-strict-aliasing -m16bit -mabi=2 -mbaseline=V2 -mcpu=n9 -mno-div -mel -mmw-count=8 -mno-ext-mac -mno-dx-regs
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),pic24) |
||||
CFLAGS+=-dPIC24 -mcpu=24FJ256GA106 -MMD -MF -g -omf=elf \
|
||||
-mlarge-code -mlarge-data -msmart-io=1 -msfr-warn=off
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),atmega128) |
||||
CFLAGS+=-Wall -mmcu=atmega128 -dAVR
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),none) |
||||
CFLAGS+=-dARCHNONE
|
||||
endif |
||||
|
||||
ifeq ($(ARCH),shared) |
||||
CFLAGS+=-fPIC
|
||||
endif |
||||
|
||||
%.o:%.c deps |
||||
$(CC) $(CFLAGS) -fo=$@ $<
|
||||
|
||||
CORE_OBJ= stack/pico_stack.o \
|
||||
stack/pico_frame.o \
|
||||
stack/pico_device.o \
|
||||
stack/pico_protocol.o \
|
||||
stack/pico_socket.o \
|
||||
stack/pico_socket_multicast.o \
|
||||
stack/pico_tree.o \
|
||||
stack/pico_md5.o
|
||||
|
||||
POSIX_OBJ+= modules/pico_dev_vde.o \
|
||||
modules/pico_dev_tun.o \
|
||||
modules/pico_dev_tap.o \
|
||||
modules/pico_dev_mock.o
|
||||
|
||||
ifneq ($(ETH),0) |
||||
include rules/eth.mk
|
||||
endif |
||||
ifneq ($(IPV4),0) |
||||
include rules/ipv4.mk
|
||||
endif |
||||
ifneq ($(IPV4FRAG),0) |
||||
include rules/ipv4frag.mk
|
||||
endif |
||||
ifneq ($(ICMP4),0) |
||||
include rules/icmp4.mk
|
||||
endif |
||||
ifneq ($(TCP),0) |
||||
include rules/tcp.mk
|
||||
endif |
||||
ifneq ($(UDP),0) |
||||
include rules/udp.mk
|
||||
endif |
||||
ifneq ($(MCAST),0) |
||||
include rules/mcast.mk
|
||||
include rules/igmp.mk
|
||||
endif |
||||
ifneq ($(NAT),0) |
||||
include rules/nat.mk
|
||||
endif |
||||
ifneq ($(DEVLOOP),0) |
||||
include rules/devloop.mk
|
||||
endif |
||||
ifneq ($(DHCP_CLIENT),0) |
||||
include rules/dhcp_client.mk
|
||||
endif |
||||
ifneq ($(DHCP_SERVER),0) |
||||
include rules/dhcp_server.mk
|
||||
endif |
||||
ifneq ($(DNS_CLIENT),0) |
||||
include rules/dns_client.mk
|
||||
endif |
||||
ifneq ($(MDNS),0) |
||||
include rules/mdns.mk
|
||||
endif |
||||
ifneq ($(DNS_SD),0) |
||||
include rules/dns_sd.mk
|
||||
endif |
||||
ifneq ($(IPFILTER),0) |
||||
include rules/ipfilter.mk
|
||||
endif |
||||
ifneq ($(CRC),0) |
||||
include rules/crc.mk
|
||||
endif |
||||
ifneq ($(OLSR),0) |
||||
include rules/olsr.mk
|
||||
endif |
||||
ifneq ($(SLAACV4),0) |
||||
include rules/slaacv4.mk
|
||||
endif |
||||
ifneq ($(IPV6),0) |
||||
include rules/ipv6.mk
|
||||
endif |
||||
ifneq ($(MEMORY_MANAGER),0) |
||||
include rules/memory_manager.mk
|
||||
endif |
||||
ifneq ($(MEMORY_MANAGER_PROFILING),0) |
||||
OPTIONS+=-dPICO_SUPPORT_MM_PROFILING
|
||||
endif |
||||
ifneq ($(SNTP_CLIENT),0) |
||||
include rules/sntp_client.mk
|
||||
endif |
||||
ifneq ($(TUN),0) |
||||
include rules/tun.mk
|
||||
endif |
||||
ifneq ($(TAP),0) |
||||
include rules/tap.mk
|
||||
endif |
||||
ifneq ($(PCAP),0) |
||||
include rules/pcap.mk
|
||||
endif |
||||
ifneq ($(PPP),0) |
||||
include rules/ppp.mk
|
||||
endif |
||||
ifneq ($(CYASSL),0) |
||||
include rules/cyassl.mk
|
||||
endif |
||||
ifneq ($(WOLFSSL),0) |
||||
include rules/wolfssl.mk
|
||||
endif |
||||
ifneq ($(POLARSSL),0) |
||||
include rules/polarssl.mk
|
||||
endif |
||||
|
||||
all: mod core lib |
||||
|
||||
core: $(CORE_OBJ) |
||||
@mkdir -p $(PREFIX)/lib
|
||||
@mv stack/*.o $(PREFIX)/lib
|
||||
|
||||
mod: $(MOD_OBJ) |
||||
@mkdir -p $(PREFIX)/modules
|
||||
@mv modules/*.o $(PREFIX)/modules || echo
|
||||
|
||||
posix: all $(POSIX_OBJ) |
||||
@mv modules/*.o $(PREFIX)/modules || echo
|
||||
|
||||
|
||||
TEST_ELF= test/picoapp.elf
|
||||
TEST6_ELF= test/picoapp6.elf
|
||||
|
||||
|
||||
test: posix |
||||
@mkdir -p $(PREFIX)/test/
|
||||
@make -C test/examples PREFIX=$(PREFIX)
|
||||
@echo -e "\t[CC] picoapp.o"
|
||||
@$(CC) -c -o $(PREFIX)/examples/picoapp.o test/picoapp.c $(CFLAGS) -Itest/examples
|
||||
@echo -e "\t[LD] $@"
|
||||
@$(CC) -g -o $(TEST_ELF) -I include -I modules -I $(PREFIX)/include -Wl,--start-group $(TEST_LDFLAGS) $(TEST_OBJ) $(PREFIX)/examples/*.o -Wl,--end-group
|
||||
@mv test/*.elf $(PREFIX)/test
|
||||
@install $(PREFIX)/$(TEST_ELF) $(PREFIX)/$(TEST6_ELF)
|
||||
|
||||
tst: test |
||||
|
||||
$(PREFIX)/include/pico_defines.h: |
||||
@mkdir -p $(PREFIX)/lib
|
||||
@mkdir -p $(PREFIX)/include
|
||||
@bash ./mkdeps.sh $(PREFIX) $(OPTIONS)
|
||||
|
||||
|
||||
deps: $(PREFIX)/include/pico_defines.h |
||||
|
||||
|
||||
|
||||
lib: mod core |
||||
@cp -f include/*.h $(PREFIX)/include
|
||||
@cp -fa include/arch $(PREFIX)/include
|
||||
@cp -f modules/*.h $(PREFIX)/include
|
||||
@echo -e "\t[AR] $(PREFIX)/lib/$(LIBNAME)"
|
||||
$(AR) -q -b -n -fag -o=$(PREFIX)/lib/$(LIBNAME) $(PREFIX)/modules/*.o $(PREFIX)/lib/*.o
|
||||
@echo || $(AR) cru $(PREFIX)/lib/$(LIBNAME) $(PREFIX)/lib/*.o
|
||||
@echo -e "\t[RANLIB] $(PREFIX)/lib/$(LIBNAME)"
|
||||
@$(RANLIB) $(PREFIX)/lib/$(LIBNAME)
|
||||
@echo -e "\t[LIBSIZE] `du -b $(PREFIX)/lib/$(LIBNAME)`"
|
||||
|
||||
loop: mod core |
||||
mkdir -p $(PREFIX)/test
|
||||
@$(CC) -c -o $(PREFIX)/modules/pico_dev_loop.o modules/pico_dev_loop.c $(CFLAGS)
|
||||
@$(CC) -c -o $(PREFIX)/loop_ping.o test/loop_ping.c $(CFLAGS) -ggdb
|
||||
|
||||
units: mod core lib $(UNITS_OBJ) $(MOD_OBJ) |
||||
@echo -e "\n\t[UNIT TESTS SUITE]"
|
||||
@mkdir -p $(PREFIX)/test
|
||||
@echo -e "\t[CC] units.o"
|
||||
@$(CC) -c -o $(PREFIX)/test/units.o test/units.c $(CFLAGS) -I stack -I modules -I includes -I test/unit -dUNIT_TEST
|
||||
@echo -e "\t[LD] $(PREFIX)/test/units"
|
||||
@$(CC) -o $(PREFIX)/test/units $(CFLAGS) $(PREFIX)/test/units.o -lcheck -lm -pthread -lrt \
|
||||
$(UNITS_OBJ) $(PREFIX)/modules/pico_aodv.o \
|
||||
$(PREFIX)/modules/pico_fragments.o
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_protocol.elf $(CFLAGS) -I. test/unit/modunit_pico_protocol.c stack/pico_tree.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_frame.elf $(CFLAGS) -I. test/unit/modunit_pico_frame.c stack/pico_tree.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_seq.elf $(CFLAGS) -I. test/unit/modunit_seq.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_tcp.elf $(CFLAGS) -I. test/unit/modunit_pico_tcp.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_client.elf $(CFLAGS) -I. test/unit/modunit_pico_dns_client.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_common.elf $(CFLAGS) -I. test/unit/modunit_pico_dns_common.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_mdns.elf $(CFLAGS) -I. test/unit/modunit_pico_mdns.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dns_sd.elf $(CFLAGS) -I. test/unit/modunit_pico_dns_sd.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dev_loop.elf $(CFLAGS) -I. test/unit/modunit_pico_dev_loop.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_ipv6_nd.elf $(CFLAGS) -I. test/unit/modunit_pico_ipv6_nd.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_pico_stack.elf $(CFLAGS) -I. test/unit/modunit_pico_stack.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_tftp.elf $(CFLAGS) -I. test/unit/modunit_pico_tftp.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_sntp_client.elf $(CFLAGS) -I. test/unit/modunit_pico_sntp_client.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_ipfilter.elf $(CFLAGS) -I. test/unit/modunit_pico_ipfilter.c stack/pico_tree.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_aodv.elf $(CFLAGS) -I. test/unit/modunit_pico_aodv.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_fragments.elf $(CFLAGS) -I. test/unit/modunit_pico_fragments.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
@$(CC) -o $(PREFIX)/test/modunit_queue.elf $(CFLAGS) -I. test/unit/modunit_queue.c -lcheck -lm -pthread -lrt $(UNITS_OBJ)
|
||||
@$(CC) -o $(PREFIX)/test/modunit_dev_ppp.elf $(CFLAGS) -I. test/unit/modunit_pico_dev_ppp.c -lcheck -lm -pthread -lrt $(UNITS_OBJ) $(PREFIX)/lib/libpicotcp.a
|
||||
|
||||
devunits: mod core lib |
||||
@echo -e "\n\t[UNIT TESTS SUITE: device drivers]"
|
||||
@mkdir -p $(PREFIX)/test/unit/device/
|
||||
@echo -e "\t[CC] picotcp_mock.o"
|
||||
@$(CC) -c -o $(PREFIX)/test/unit/device/picotcp_mock.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/picotcp_mock.c
|
||||
@$(CC) -c -o $(PREFIX)/test/unit/device/unit_dev_vde.o $(CFLAGS) -I stack -I modules -I includes -I test/unit test/unit/device/unit_dev_vde.c
|
||||
@echo -e "\t[LD] $(PREFIX)/test/devunits"
|
||||
@$(CC) -o $(PREFIX)/test/devunits $(CFLAGS) -I stack $(PREFIX)/test/unit/device/*.o -lcheck -lm -pthread -lrt
|
||||
|
||||
units_mm: mod core lib |
||||
@echo -e "\n\t[UNIT TESTS SUITE]"
|
||||
@mkdir -p $(PREFIX)/test
|
||||
@echo -e "\t[CC] units_mm.o"
|
||||
@$(CC) -c -o $(PREFIX)/test/units_mm.o test/unit/unit_mem_manager.c $(CFLAGS) -I stack -I modules -I includes -I test/unit
|
||||
@echo -e "\t[LD] $(PREFIX)/test/units"
|
||||
@$(CC) -o $(PREFIX)/test/units_mm $(CFLAGS) $(PREFIX)/test/units_mm.o -lcheck -lm -pthread -lrt
|
||||
|
||||
|
||||
clean: |
||||
@echo -e "\t[CLEAN] $(PREFIX)/"
|
||||
@rm -rf $(PREFIX) tags
|
||||
|
||||
mbed: |
||||
@echo -e "\t[Creating PicoTCP.zip]"
|
||||
@rm -f PicoTCP.zip
|
||||
@cp include/pico_socket.h include/socket.tmp
|
||||
@echo "#define MBED\n" > include/mbed.tmp
|
||||
@cat include/mbed.tmp include/socket.tmp > include/pico_socket.h
|
||||
@zip -0 PicoTCP.zip -r include modules stack -x include/arch/ include/arch/* include/pico_config.h include/*.tmp modules/pico_dev_*
|
||||
@rm include/pico_socket.h include/mbed.tmp
|
||||
@mv include/socket.tmp include/pico_socket.h
|
||||
|
||||
|
||||
style: |
||||
@find . -iname "*.[c|h]" | xargs -x uncrustify --replace -l C -c uncrustify.cfg || true
|
||||
@find . -iname "*unc-backup*" |xargs -x rm || true
|
||||
|
||||
dummy: mod core lib $(DUMMY_EXTRA) |
||||
@echo testing configuration...
|
||||
@$(CC) -c -o test/dummy.o test/dummy.c $(CFLAGS)
|
||||
@$(CC) -o dummy test/dummy.o $(DUMMY_EXTRA) $(PREFIX)/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
|
||||
@echo done.
|
||||
@rm -f test/dummy.o dummy
|
||||
|
||||
ppptest: test/ppp.c lib |
||||
gcc -ggdb -c -o ppp.o test/ppp.c -I build/include/ -I build/modules/ $(CFLAGS)
|
||||
gcc -o ppp ppp.o build/lib/libpicotcp.a $(LDFLAGS) $(CFLAGS)
|
||||
rm -f ppp.o
|
||||
|
||||
|
||||
FORCE: |
||||
@ -1,220 +0,0 @@
|
||||
# picoTCP |
||||
|
||||
--------------- |
||||
|
||||
Welcome to the one and only <font color=ff00f0>picoTCP repository</font>. |
||||
|
||||
picoTCP is a small-footprint, modular TCP/IP stack designed for embedded systems and the Internet of Things. It's actively being developed by *[Altran Intelligent Systems](http://intelligent-systems.altran.com/)*. Textual information about picoTCP, you can find on the [about page of our website](http://picotcp.com/about). |
||||
|
||||
This code is released under the terms of GNU GPL v2 and GNU GPL v3. Some rights reserved. |
||||
Other licenses may apply at the sole discretion of the copyright holders. |
||||
|
||||
Learn how to use picoTCP in your project by going through the **Getting Started guide** on our [GitHub wiki](https://github.com/tass-belgium/picotcp/wiki). |
||||
|
||||
For more information visit the [picoTCP website](http://www.picotcp.com), send us an email or contact us on [Twitter](https://twitter.com/picotcp), [Facebook](https://www.facebook.com/picoTCP) or [Reddit](http://www.reddit.com/r/picotcp/). |
||||
|
||||
Wondering about picoTCP's code quality? Check [our TiCS score](http://tics.picotcp.com:42506/tiobeweb/TICS/TqiDashboard.html#axes=Project%28%29&metric=tqi&sel=Project%28PicoTCP_rel%29) |
||||
|
||||
|
||||
--------------- |
||||
|
||||
## Continuous integration |
||||
|
||||
Functional tests: |
||||
[](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_autotest) - |
||||
Unit tests : |
||||
[](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_unit_tests) - |
||||
RFC compliance : |
||||
[](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_RF_mbed) - |
||||
TICS quality : |
||||
[](http://jenkins.picotcp.com:8080/job/picoTCP_Rel/job/PicoTCP_rel_TICS/) |
||||
Coverity Scan Build status: |
||||
[](https://scan.coverity.com/projects/7944) |
||||
|
||||
--------------- |
||||
|
||||
## Simple example |
||||
|
||||
### Preparations |
||||
This example uses Ubuntu 14.04. It works on other linux distibutions as well, though you may need to change some package names. See [setting up the environment](https://github.com/tass-belgium/picotcp/wiki/Setting-up-the-environment#prerequisite-packages) for some more info. |
||||
|
||||
```bash |
||||
sudo apt-get install git check vde2 libvdeplug2-dev libpcap0.8-dev openvpn wireshark |
||||
git clone https://github.com/tass-belgium/picotcp |
||||
cd picotcp |
||||
make TAP=1 |
||||
cd .. |
||||
``` |
||||
|
||||
### The code |
||||
|
||||
Then make a new directory, e.g. `example`, and create a file with the following content : |
||||
[//]: # (The code below is pulled through our CI - please leave the code extractor comments intact!) |
||||
[//]: # (code extractor start) |
||||
```C |
||||
#include <time.h> |
||||
#include <pico_stack.h> |
||||
#include <pico_ipv4.h> |
||||
#include <pico_icmp4.h> |
||||
#include <pico_dev_tap.h> |
||||
|
||||
#define NUM_PING 10 |
||||
|
||||
static int finished = 0; |
||||
|
||||
/* gets called when the ping receives a reply, or encounters a problem */ |
||||
void cb_ping(struct pico_icmp4_stats *s) |
||||
{ |
||||
char host[30]; |
||||
pico_ipv4_to_string(host, s->dst.addr); |
||||
if (s->err == 0) { |
||||
/* if all is well, print some pretty info */ |
||||
printf("%lu bytes from %s: icmp_req=%lu ttl=%lu time=%lu ms\n", s->size, |
||||
host, s->seq, s->ttl, (long unsigned int)s->time); |
||||
if (s->seq >= NUM_PING) |
||||
finished = 1; |
||||
} else { |
||||
/* if something went wrong, print it and signal we want to stop */ |
||||
printf("PING %lu to %s: Error %d\n", s->seq, host, s->err); |
||||
finished = 1; |
||||
} |
||||
} |
||||
|
||||
|
||||
int main(void){ |
||||
int id; |
||||
struct pico_ip4 ipaddr, netmask; |
||||
struct pico_device* dev; |
||||
|
||||
/* initialise the stack. Super important if you don't want ugly stuff like |
||||
* segfaults and such! */ |
||||
pico_stack_init(); |
||||
|
||||
/* create the tap device */ |
||||
dev = pico_tap_create("tap0"); |
||||
if (!dev) |
||||
return -1; |
||||
|
||||
/* assign the IP address to the tap interface */ |
||||
pico_string_to_ipv4("192.168.5.4", &ipaddr.addr); |
||||
pico_string_to_ipv4("255.255.255.0", &netmask.addr); |
||||
pico_ipv4_link_add(dev, ipaddr, netmask); |
||||
|
||||
printf("starting ping\n"); |
||||
id = pico_icmp4_ping("192.168.5.5", NUM_PING, 1000, 10000, 64, cb_ping); |
||||
|
||||
if (id == -1) |
||||
return -1; |
||||
|
||||
/* keep running stack ticks to have picoTCP do its network magic. Note that |
||||
* you can do other stuff here as well, or sleep a little. This will impact |
||||
* your network performance, but everything should keep working (provided |
||||
* you don't go overboard with the delays). */ |
||||
while (finished != 1) |
||||
{ |
||||
usleep(1000); |
||||
pico_stack_tick(); |
||||
} |
||||
|
||||
printf("finished !\n"); |
||||
return 0; |
||||
} |
||||
|
||||
``` |
||||
|
||||
[//]: # (code extractor stop) |
||||
|
||||
### Building and running |
||||
|
||||
Now we can compile this and link it, by running |
||||
```bash |
||||
gcc -c -o main.o -I../picotcp/build/include main.c |
||||
gcc -o main.elf main.o ../picotcp/build/lib/libpicotcp.a |
||||
``` |
||||
|
||||
Next we'll create a persistent tap device - a virtual network port. You don't need to repeat this each time, the device will exist until you reboot, or until you go `sudo tunctl -d tap0` |
||||
```bash |
||||
sudo tunctl -u <username> |
||||
sudo ifconfig tap0 192.168.5.5 |
||||
``` |
||||
|
||||
Now, you should be able to run `./main.elf`, and see output like |
||||
``` |
||||
Protocol ethernet registered (layer: 2). |
||||
Protocol ipv4 registered (layer: 3). |
||||
Protocol ipv6 registered (layer: 3). |
||||
Protocol icmp4 registered (layer: 4). |
||||
Protocol icmp6 registered (layer: 4). |
||||
Protocol igmp registered (layer: 4). |
||||
Protocol udp registered (layer: 4). |
||||
Protocol tcp registered (layer: 4). |
||||
Device tap0 created. |
||||
Assigned ipv4 192.168.5.4 to device tap0 |
||||
starting ping |
||||
64 bytes from 192.168.5.5: icmp_req=1 ttl=64 time=5 ms |
||||
64 bytes from 192.168.5.5: icmp_req=2 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=3 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=4 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=5 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=6 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=7 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=8 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=9 ttl=64 time=0 ms |
||||
64 bytes from 192.168.5.5: icmp_req=10 ttl=64 time=0 ms |
||||
finished ! |
||||
``` |
||||
|
||||
While the application is running, you can also run |
||||
``` |
||||
ping 192.168.5.4 |
||||
``` |
||||
to send pings in the other direction. |
||||
|
||||
### Investigating what happened |
||||
|
||||
Run wireshark, and sniff the tap0 interface. Then run the `./main.elf` again, and see what happens. You should see an ARP request from picoTCP to Linux, and a reply. After that you should see the ping requests and replies going back and forth. |
||||
|
||||
Note, sometimes you may see lots of other stuff, IPv6 router sollicitations, various broadcasts, mDNS, DNS-SD, etc - this is your when your Linux notices the new network interface is up, and starts all sorts of discoveries. With the persistent TAP device, this usually only happens the first time you start the application. Start a new wireshark capture, and start the application again, it should be much cleaner now. |
||||
|
||||
Now you could make some changes to the `main.c` file, and experiment a bit! Keep some statistics of your pings (max, min, avg time). Open a UDP socket, send some stuff to a netcat instance on your linux. Or build a rudimentary port scanner, see what ports are open on your machine. |
||||
|
||||
|
||||
This is just a very quick overview, more info can be found in our [wiki](https://github.com/tass-belgium/picotcp/wiki). |
||||
|
||||
--------------- |
||||
|
||||
## Contributors |
||||
|
||||
Contributors are very welcome. Report a bug, suggest a way to improve our documentation, or write some new code. |
||||
|
||||
Note however that, before accepting your code, we would ask you to sign our [Contributors License Agreement](https://docs.google.com/forms/d/1-z6lsT75l6ZIrgHGEWrWdHylJ6xxpjc7FwGfL2ilDFU/viewform). Your code remains under your copyright, and will always be available under GPLv2 and GPLv3. However, this CLA enables us to use picoTCP (including code from external contributors like you) under other licenses, including our commercial license. By doing commercial projects, we can keep investing in the quality and features of picoTCP. |
||||
|
||||
--------------- |
||||
|
||||
## PicoTCP has been used with |
||||
|
||||
**Platforms picoTCP runs on**: |
||||
ARM Cortex-M series (ST Micro STM, NXP LPC, TI Stellaris, Freescale K64F), |
||||
ARM ARM9-series (ST Micro STR9), |
||||
Texas Instruments (MSP430), |
||||
Microchip (PIC24, PIC32), |
||||
Atmel (AVR 8bit), |
||||
Linux (User space (TUN/TAP), Kernel space), |
||||
Windows (User space (TAP)) |
||||
|
||||
**Network devices picoTCP has worked with**: |
||||
BCM43362 (IEEE 802.11), MRF24WG (IEEE 802.11), LPC Ethernet ENET/EMAC (IEEE 802.3), Stellaris Ethernet (IEEE 802.3), STM32 Ethernet (IEEE 802.3), Wiznet W5100 (IEEE 802.3), USB CDC-ECM (CDC1.2), PPP, Virtual drivers ( TUN/TAP, VDE, Libpcap) |
||||
|
||||
**(RT)OSes picoTCP has been integrated into**: |
||||
No OS / Bare metal, FreeRTOS, mbed-RTOS, Frosted, linux / POSIX, MS DOS, MS Windows |
||||
|
||||
**Libraries picoTCP has been integrated with**: |
||||
wolfSSL, mbedTLS, Mongoose RESTful library, MicroPython |
||||
|
||||
**Compilers picoTCP compiles under**: |
||||
GCC, Clang, TCC, ARM-RCVT, IAR, XC-16, XC-32, MSP-GCC, AVR-GCC |
||||
|
||||
Unfortunately we can't release all the code, a.o. because some parts depend on code or binaries that aren't GPL compatible, some parts were developed under a commercial contract, and some consist of very rough proof-of-concept code. |
||||
If you want to know more about the availability under the commercial license, or the possibility of using our expert services for porting or driver development, feel free to contact us at info@picotcp.com. |
||||
|
||||
Your favorite not in the list? Check out the wiki for information and examples on how to port picoTCP to a new platform! |
||||
@ -1,15 +0,0 @@
|
||||
#!/bin/sh |
||||
|
||||
wget -O rfc4614.txt http://tools.ietf.org/rfc/rfc4614.txt |
||||
|
||||
|
||||
for RFC in `grep "\[RFC" rfc4614.txt | sed -e "s/^.*RFC/rfc/" | grep -v "rfc \|rfc$" | sed -e "s/\].*$/.txt/g" |sort |uniq`; do |
||||
wget -O ${RFC} http://tools.ietf.org/rfc/${RFC} |
||||
done |
||||
|
||||
wget -O rfc3927.txt http://tools.ietf.org/rfc/rfc3927.txt |
||||
|
||||
# Get PPP related RFC's |
||||
for RFC in $(echo 1332 1334 1661 1662 1877 1994 | sed -r "s/[^ ]+/rfc&.txt/g"); do |
||||
wget -O ${RFC} http://tools.ietf.org/rfc/${RFC} |
||||
done |
||||
@ -1,20 +0,0 @@
|
||||
Downloading the manual |
||||
---------------------- |
||||
|
||||
With every git commit, we rebuild the documentation and make the [user_doc.pdf](http://162.13.84.104/user_doc.pdf) file (click to download) publicly available. |
||||
|
||||
If for some reason, you're looking for an older version of the documentation, please check out the wanted commit in git, and compile the manual as described below. |
||||
|
||||
Compiling the manual |
||||
-------------------- |
||||
|
||||
The picoTCP user manual is written in LaTeX, which needs to be compiled to get a readable version. |
||||
First and foremost you need the compiler and some packages: |
||||
* sudo apt-get install texlive |
||||
* sudo apt-get install texlive-latex-extra |
||||
|
||||
Now, cd into docs/user_manual and do |
||||
* ./build.sh |
||||
|
||||
A user_doc.pdf should be generated in the current directory |
||||
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/bash |
||||
|
||||
pdflatex user_doc.tex && pdflatex user_doc.tex && pdflatex user_doc.tex |
||||
@ -1,42 +0,0 @@
|
||||
\section{Ad-hoc On-Demand Distance Vector Routing (AODV)} |
||||
|
||||
|
||||
AODV is a reactive routing protocol for mobile ad-hoc networks |
||||
(MANETs). Its best fit are especially ultra-low power radio networks, |
||||
or those RF topologies where sporadic traffic between a small specific set |
||||
of nodes is foreseen. |
||||
In order to create a route, one node must explicitly start the communication |
||||
towards a remote node, and the route is created ad-hoc upon the demand |
||||
for a specific network path. |
||||
AODV guarantees that the traffic generated by each node in order to create |
||||
and maintain routes is kept as low as possible. |
||||
|
||||
\subsection{pico\_aodv\_add} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will add the target device to the AODV mechanism on the machine, |
||||
meaning that it will be possible to advertise and collect routing information |
||||
using Ad-hoc On-Demand Distance Vector Routing, as described in RFC3561, through the |
||||
target device. |
||||
|
||||
In order to use multiple devices in the AODV system, this function needs to be called |
||||
multiple times, once per device. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{pico\_aodv\_add(struct pico\_device *dev);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the device is successfully added. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_aodv_add(dev); |
||||
|
||||
\end{verbatim} |
||||
|
||||
@ -1,170 +0,0 @@
|
||||
\section{DHCP client} |
||||
|
||||
% Short description/overview of module functions |
||||
A DHCP client for obtaining a dynamic IP address. DHCP is supported on multiple interfaces. |
||||
|
||||
|
||||
\subsection{pico\_dhcp\_initiate\_negotiation} |
||||
|
||||
\subsubsection*{Description} |
||||
Initiate a DHCP negotiation. The user passes a callback-function, which will be executed on DHCP success or failure. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dhcp_initiate_negotiation(struct pico_device *device, |
||||
void (*callback)(void *cli, int code), uint32_t *xid); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{device} - the device on which a negotiation should be started. |
||||
\item \texttt{callback} - the function which is executed on success or failure. This function can be called multiple times. F.e.: initially DHCP succeeded, then the DHCP server is removed long enough from the network for the lease to expire, later the server is added again to the network. The callback is called 3 times: first with code \texttt{PICO\_DHCP\_SUCCESS}, then with \texttt{PICO\_DHCP\_RESET} and finally with \texttt{PICO\_DHCP\_SUCCESS}. The callback may be called before \texttt{pico\_dhcp\_initiate\_negotiation} has returned, f.e. in case of failure to open a socket. The callback has two parameters: |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{cli} - the identifier of the negotiation |
||||
\item \texttt{code} - the id indicating success or failure, see further |
||||
\end{itemize} |
||||
\item \texttt{xid} - transaction id of the negotiation. Is set on \texttt{PICO\_DHCP\_SUCCESS}, 0 otherwise. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Possible DHCP codes} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO\_DHCP\_SUCCESS} - DHCP succeeded, the user can start using the assigned address, which can be obtained by calling \texttt{pico\_dhcp\_get\_address}. |
||||
\item \texttt{PICO\_DHCP\_ERROR} - an error occurred. DHCP is unable to recover from this error. \texttt{pico$\_$err} is set appropriately. |
||||
\item \texttt{PICO\_DHCP\_RESET} - DHCP was unable to renew its lease, and the lease expired. The user must immediately stop using the previously assigned IP, and wait for DHCP to obtain a new lease. DHCP will automatically start negotiations again. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 on success, -1 otherwise. |
||||
|
||||
\subsubsection*{Errors} % ORGANIZE |
||||
All errors are reported through the callback-function described above. |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available % pico_socket_sendto |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - protocol not supported % pico_socket_open |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument % pico_socket_bind |
||||
\item \texttt{PICO$\_$ERR$\_$ENXIO} - no such device or address |
||||
\item \texttt{PICO$\_$ERR$\_$EOPNOTSUPP} - operation not supported on socket |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
pico_dhcp_initiate_negotiation(dev, &callback_dhcpclient, &xid); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_dhcp\_client\_abort} |
||||
|
||||
\subsubsection*{Description} |
||||
Cancel the ongoing negotiation. To be used if the operation of obtaining an IP address from a remote DHCP server needs to be aborted, before the callback has been triggered. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{struct pico\_ip4 pico\_dhcp\_client\_abort(uint32\_t xid);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{xid} - the transaction id returned from the call \texttt{pico\_dhcp\_initiate\_negotiation}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 on success, -1 otherwise (i.e. the XID could not be found in the list of ongoing transactions). |
||||
|
||||
|
||||
\subsection{pico\_dhcp\_get\_identifier} |
||||
|
||||
\subsubsection*{Description} |
||||
Get the identifier needed to pass to all other \texttt{pico\_dhcp} functions. This function should only be called after a callback occurred with code \texttt{PICO\_DHCP\_SUCCESS}. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{void *pico\_dhcp\_get\_identifier(uint32\_t xid);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{xid} - transaction id of the negotiation. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
\texttt{void *} - pointer to the identifier. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
void *cli = pico_dhcp_get_identifier(xid); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico\_dhcp\_get\_address} |
||||
|
||||
\subsubsection*{Description} |
||||
Get the address that was assigned through DHCP. This function should only be called after a callback occurred with code \texttt{PICO\_DHCP\_SUCCESS}. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{struct pico\_ip4 pico\_dhcp\_get\_address(void *cli);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{cli} - the identifier that was provided by the callback on \texttt{PICO\_DHCP\_SUCCESS}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
\texttt{struct pico\_ip4} - the address that was assigned. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
struct pico_ip4 address = pico_dhcp_get_address(cli); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico\_dhcp\_get\_gateway} |
||||
|
||||
\subsubsection*{Description} |
||||
Get the address of the gateway that was assigned through DHCP. This function should |
||||
only be called after a callback occurred with code \texttt{PICO\_DHCP\_SUCCESS}. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{struct pico\_ip4 pico\_dhcp\_get\_gateway(void *cli);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{cli} - the identifier that was provided by the callback on \texttt{PICO\_DHCP\_SUCCESS}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{struct pico\_ip4} - the address of the gateway that should be used. |
||||
\end{itemize} |
||||
|
||||
\subsection{pico\_dhcp\_get\_nameserver} |
||||
|
||||
\subsubsection*{Description} |
||||
Get the address of the first or the second nameserver that was assigned through DHCP. |
||||
This function should only be called after a callback occurred with code \texttt{PICO\_DHCP\_SUCCESS}. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{struct pico\_ip4 pico\_dhcp\_get\_nameserver(void *cli, int index);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{cli} - the identifier that was provided by the callback on \texttt{PICO\_DHCP\_SUCCESS}. |
||||
\item \texttt{index} - the indes of the domain name server received. Can be either "0" or "1". |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{struct pico\_ip4} - the address of the nameserver that should be used. On failure, e.g. an invalid index was passed, it returns "255.255.255.255". If the IP address of the DNS has not been set, it may return INADDR\_ANY. |
||||
\end{itemize} |
||||
|
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
struct pico_ip4 gateway = pico_dhcp_get_gateway(cli); |
||||
\end{verbatim} |
||||
@ -1,71 +0,0 @@
|
||||
\section{DHCP server} |
||||
|
||||
% Short description/overview of module functions |
||||
|
||||
|
||||
\subsection{pico\_dhcp\_server\_initiate} |
||||
|
||||
\subsubsection*{Description} |
||||
This function starts a simple DHCP server. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_dhcp\_server\_initiate(struct pico\_dhcpd\_settings *settings);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{settings} - a pointer to a struct \texttt{pico\_dhcpd\_settings}, in which the following members matter to the user : |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{struct pico\_ip4 my\_ip} - the IP address of the device performing DHCP. Only IPs of this network will be served. |
||||
\item \texttt{uint32\_t pool\_start} - the lowest host number that may be assigned, defaults to 100 if not provided. |
||||
\item \texttt{uint32\_t pool\_end} - the highest host number that may be assigned, defaults to 254 if not provided. |
||||
\item \texttt{uint32\_t lease\_time} - the advertised lease time in seconds, defaults to 120 if not provided. |
||||
\end{itemize} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On successful startup of the dhcp server, 0 is returned. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
%everything from : |
||||
%pico_socket_open |
||||
\item PICO$\_$ERR$\_$EPROTONOSUPPORT - protocol not supported |
||||
\item PICO$\_$ERR$\_$ENETUNREACH - network unreachable |
||||
%pico_socket_bind |
||||
\item PICO$\_$ERR$\_$EINVAL - invalid argument |
||||
\item PICO$\_$ERR$\_$ENXIO - no such device or address |
||||
\end{itemize} |
||||
|
||||
\subsection{pico\_dhcp\_server\_destroy} |
||||
|
||||
\subsubsection*{Description} |
||||
This function stops a previously started DHCP server on the given device. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_dhcp\_server\_destroy(struct pico\_device *dev);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device}, to identify a previously started DHCP server that must be terminated. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, 0 is returned. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item PICO$\_$ERR$\_$ENOENT - there was no DHCP server running on the given device. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
struct pico_dhcpd_settings s = { }; |
||||
|
||||
s.my_ip.addr = long_be(0x0a280001); /* 10.40.0.1 */ |
||||
|
||||
pico_dhcp_server_initiate(&s); |
||||
\end{verbatim} |
||||
|
||||
|
||||
@ -1,115 +0,0 @@
|
||||
\section{DNS client} |
||||
|
||||
% Short description/overview of module functions |
||||
|
||||
|
||||
\subsection{pico$\_$dns$\_$client$\_$nameserver} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to add or remove nameservers. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dns_client_nameserver(struct pico_ip4 *ns, uint8_t flag); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ns} - Pointer to the address of the name server. |
||||
\item \texttt{flag} - Flag to indicate addition or removal (see further). |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Flags} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$DNS$\_$NS$\_$ADD} - to add a nameserver |
||||
\item \texttt{PICO$\_$DNS$\_$NS$\_$DEL} - to remove a nameserver |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the nameserver operation has succeeded. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_dns_client_nameserver(&addr_ns, PICO_DNS_NS_ADD); |
||||
ret = pico_dns_client_nameserver(&addr_ns, PICO_DNS_NS_DEL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$dns$\_$client$\_$getaddr} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to translate an url text string to an internet host address IP. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dns_client_getaddr(const char *url, void (*callback)(char *ip, void *arg), |
||||
void *arg); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{url} - Pointer to text string containing url text string (e.g. www.google.com). |
||||
\item \texttt{callback} - Callback function, returning the internet host address IP and the provided argument. The returned string has to be freed by the user. |
||||
\item \texttt{arg} - Pointer to an identifier for the request. The pointer is returned in the callback. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the request is sent. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_dns_client_getaddr("www.google.com", cb_getaddr, &identifier); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$dns$\_$client$\_$getname} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to translate an internet host address IP to an url text string. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dns_client_getname(const char *ip, void (*callback)(char *url, void *arg), |
||||
void *arg); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ip} - Pointer to text string containing an internet host address IP (e.g. 8.8.4.4) |
||||
\item \texttt{callback} - Callback function, receiving the url text string. Note: the returned string has to be freed by the user. |
||||
\item \texttt{arg} - Pointer to an identifier for the request. The pointer is returned in the callback. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the request is sent. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_dns_client_getname("8.8.4.4", cb_getname, &identifier); |
||||
\end{verbatim} |
||||
@ -1,85 +0,0 @@
|
||||
\section{DNS SD client} |
||||
|
||||
% Short description/overview of module functions |
||||
With this module DNS-SD services can be registered on the network to allow Zero Configuration Networking on the device. This is merely a small layer on top of Multicast DNS. |
||||
|
||||
\subsection{pico$\_$dns$\_$sd$\_$init} |
||||
|
||||
\subsubsection*{Description} |
||||
Just calls pico$\_$mdns$\_$init in its turn to initialise the mDNS-module. See 'pico$\_$mdns$\_$init' for more information. |
||||
|
||||
|
||||
\subsection{pico$\_$dns$\_$sd$\_$register$\_$service} |
||||
|
||||
\subsubsection*{Description} |
||||
Registers the service with a certain name and type on the network via Multicast DNS. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dns_sd_register_service( const char *name, |
||||
const char *type, |
||||
uint16_t port, |
||||
kv_vector *txt_data, |
||||
uint16_t ttl, |
||||
void (*callback)(pico_mdns_rtree *,char *,void *), |
||||
void *arg); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{name} - Instance-name of the service. Use a descriptive name for it but not longer than 63 characters. |
||||
\item \texttt{type} - The type of the service. For all the possible service types see: \url{http://www.dns-sd.org/servicetypes.html} |
||||
\item \texttt{port} - The portnumber on which the service runs. |
||||
\item \texttt{txt$\_$data} - Pointer to vector with key-value pairs to insert into the TXT record to give additional information about the service. Use the 'PICO$\_$DNS$\_$SD$\_$KV$\_$VECTOR$\_$DECLARE'-macro to declare a vector for key-value-pairs. This vector will be destroyed when the function returns since there's no need in keeping the contents. |
||||
\item \texttt{ttl} - TTL of the service on the network before it needs to be reconfirmed. In seconds. |
||||
\item \texttt{callback} - Callback function that gets called when the service is successfully registered on the network. |
||||
\item \texttt{arg} - Argument for callback supplied by user. This can be used if you want to pass some variable into your callback function. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the module successfully started registering the service, something else on failure. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
PICO_DNS_SD_KV_VECTOR_DECLARE(dictionary); |
||||
pico_dns_sd_register_service("Printer 2nd Floor", "_printer._sub._http._tcp", 80, \\ |
||||
&dictionary, 240, ®_cb, NULL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$dns$\_$sd$\_$kv$\_$vector$\_$add} |
||||
|
||||
\subsubsection*{Description} |
||||
Add a key-value pair the a key-value pair vector. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_dns_sd_kv_vector_add( kv_vector *vector, char *key, char *value ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{vector} - Pointer to vector to add the pair to. Declare a key-value vector with the 'PICO$\_$DNS$\_$SD$\_$KV$\_$VECTOR$\_$DECLARE'-macro. |
||||
\item \texttt{key} - Key of the pair. Cannot be NULL. |
||||
\item \texttt{value} - Value of the pair. can be NULL, empty ("") or filled ("value"). |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the pair is added successfully, something else on failure. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
PICO_DNS_SD_KV_VECTOR_DECLARE(dictionary); |
||||
pico_dns_sd_kv_vector_add(&dictionary, "pass", "1234"); |
||||
pico_dns_sd_kv_vector_add(&dictionary, "color", NULL); |
||||
\end{verbatim} |
||||
@ -1,42 +0,0 @@
|
||||
\section{IGMP} |
||||
|
||||
% Short description/overview of module functions |
||||
This module allows the user to join and leave ipv4 multicast groups. The module is based on the IGMP version 3 protocol and it's backwards compatible with version 2. Version 1 is not supported. |
||||
The IGMP module is completly driven from socket calls (\ref{socket:setoption}) and non of the IGMP application interface functions should be called by the user. If however, by any reason, it's necessary for the user to do this, the following function call is provided: |
||||
|
||||
\subsection{pico\_igmp\_state\_change} |
||||
|
||||
\subsubsection*{Description} |
||||
Change the state of the host to Non-member, Idle member or Delaying member. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_igmp_state_change(struct pico_ip4 *mcast_link, struct pico_ip4 *mcast_group, |
||||
uint8_t filter_mode, struct pico_tree *_MCASTFilter, uint8_t state) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{mcast\_link} - the link on which that multicast group should be joined. |
||||
\item \texttt{mcast\_group} - the address of the multicast group you want to join. |
||||
\item \texttt{filter\_mode} - the kind of source filtering, if applied. |
||||
\item \texttt{\_MCASTFilter} - list of multicast sources on which source filtering might be applied. |
||||
\item \texttt{state} - the prefered new state. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Errors} |
||||
In case of failure, -1 is returned, and the value of pico$\_$err |
||||
is set as follows: |
||||
|
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - Invalid argument provided |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - Not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - Invalid protocol (or protocol version) found on the link |
||||
\item \texttt{PICO$\_$ERR$\_$EFAULT} - Internal error |
||||
\end{itemize} |
||||
|
||||
%\subsubsection*{Example} |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
%\subsubsection*{Example} |
||||
@ -1,89 +0,0 @@
|
||||
\section{IP Filter} |
||||
|
||||
% Short description/overview of module functions |
||||
This module allows the user to add and remove filters. The user can filter packets based on interface, protocol, outgoing address, outgoing netmask, incomming address, incomming netmask, outgoing port, incomming port, priority and type of service. There are four types of filters: ACCEPT, PRIORITY, REJECT, DROP. When creating a PRIORITY filter, it is necessary to give a priority value in a range between '-10' and '10', '0' as default priority. |
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$filter$\_$add} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to add a filter. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_filter_add(struct pico_device *dev, uint8_t proto, |
||||
struct pico_ip4 out_addr, struct pico_ip4 out_addr_netmask, |
||||
struct pico_ip4 in_addr, struct pico_ip4 in_addr_netmask, uint16_t out_port, |
||||
uint16_t in_port, int8_t priority, uint8_t tos, enum filter_action action); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - interface to be filtered |
||||
\item \texttt{proto} - protocol to be filtered |
||||
\item \texttt{out$\_$addr} - outgoing address to be filtered |
||||
\item \texttt{out$\_$addr$\_$netmask} - outgoing address-netmask to be filtered |
||||
\item \texttt{in$\_$addr} - incomming address to be filtered |
||||
\item \texttt{in$\_$addr$\_$netmask} - incomming address-netmask to be filtered |
||||
\item \texttt{out$\_$port} - outgoing port to be filtered |
||||
\item \texttt{in$\_$port} - incomming port to be filtered |
||||
\item \texttt{priority} - priority to assign on the marked packet |
||||
\item \texttt{tos} - type of service to be filtered |
||||
\item \texttt{action} - type of action for the filter: ACCEPT, PRIORITY, REJECT and DROP. ACCEPT, filters all packets selected by the filter. PRIORITY is not yet implemented. REJECT drops all packets and send an ICMP message 'Packet Filtered' (Communication Administratively Prohibited). DROP will discard the packet silently. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the filter$\_$id from the generated filter. This id must be used when deleting the filter. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
/* block all incoming traffic on port 5555 */ |
||||
filter_id = pico_ipv4_filter_add(NULL, 6, NULL, NULL, NULL, NULL, 0, 5555, |
||||
0, 0, FILTER_REJECT); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Errors} |
||||
|
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$filter$\_$del} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to delete a filter. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_filter_del(int filter_id) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{filter$\_$id} - the id of the filter you want to delete. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
|
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EPERM} - operation not permitted |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_filter_del(filter_id); |
||||
\end{verbatim} |
||||
|
||||
|
||||
%\subsubsection*{Parameters} |
||||
%\subsubsection*{Return value} |
||||
%\subsubsection*{Errors} |
||||
%\subsubsection*{Example} |
||||
|
||||
@ -1,561 +0,0 @@
|
||||
\section{IPv4 functions} |
||||
|
||||
% Short description/overview of module functions |
||||
|
||||
\subsection{pico$\_$ipv4$\_$to$\_$string} |
||||
|
||||
\subsubsection*{Description} |
||||
Convert the internet host address IP to a string in IPv4 dotted-decimal notation. |
||||
The result is stored in the char array that ipbuf points to. The given IP address argument must be in network order (i.e. 0xC0A80101 becomes 192.168.1.1). |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_to_string(char *ipbuf, const uint32_t ip); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ipbuf} - Char array to store the result in. |
||||
\item \texttt{ip} - Internet host address in integer notation. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the conversion was successful. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_to_string(buf, ip); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$string$\_$to$\_$ipv4} |
||||
|
||||
\subsubsection*{Description} |
||||
Convert the IPv4 dotted-decimal notation into binary form. The result is stored in the |
||||
\texttt{int} that IP points to. Little endian or big endian is not taken into account. |
||||
The address supplied in \texttt{ipstr} can have one of the following |
||||
forms: a.b.c.d, a.b.c or a.b. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_string_to_ipv4(const char *ipstr, uint32_t *ip); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ipstr} - Pointer to the IP string. |
||||
\item \texttt{ip} - Int pointer to store the result in. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the conversion was successful. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_string_to_ipv4(buf, *ip); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$valid$\_$netmask} |
||||
|
||||
\subsubsection*{Description} |
||||
Check if the provided mask if valid. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_valid_netmask(uint32_t mask); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{mask} - The netmask in integer notation. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the netmask in CIDR notation is returned if the netmask is valid. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_valid_netmask(netmask); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$is$\_$unicast} |
||||
|
||||
\subsubsection*{Description} |
||||
Check if the provided address is unicast or multicast. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_is_unicast(uint32_t address); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address in integer notation. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 1 if unicast, 0 if multicast. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_is_unicast(address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$source$\_$find} |
||||
|
||||
\subsubsection*{Description} |
||||
Find the source IP for the link associated to the specified destination. |
||||
This function will use the currently configured routing table to identify the link that would be used to transmit any traffic directed to the given IP address. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip4 *pico_ipv4_source_find(struct pico_ip4 *dst); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as \texttt{struct pico$\_$ip4}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the source IP as \texttt{struct pico$\_$ip4}. |
||||
If the source can not be found, \texttt{NULL} is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
src = pico_ipv4_source_find(dst); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$link$\_$add } |
||||
|
||||
\subsubsection*{Description} |
||||
Add a new local device dev inteface, f.e. eth0, with IP address 'address' and netmask 'netmask'. A device may have more than one link configured, i.e. to access multiple networks on the same link. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_link_add(struct pico_device *dev, struct pico_ip4 address, |
||||
struct pico_ip4 netmask); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Local device. |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip4}. |
||||
\item \texttt{netmask} - Netmask of the address. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_link_add(dev, address, netmask); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$link$\_$del} |
||||
|
||||
\subsubsection*{Description} |
||||
Remove the link associated to the local device that was previously configured, corresponding to the IP address 'address'. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_link_del(struct pico_device *dev, struct pico_ip4 address); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Local device. |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip4}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_link_del(dev, address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$link$\_$find} |
||||
|
||||
\subsubsection*{Description} |
||||
Find the local device associated to the local IP address 'address'. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_device *pico_ipv4_link_find(struct pico_ip4 *address); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip4}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the local device. |
||||
On error, \texttt{NULL} is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENXIO} - no such device or address |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
dev = pico_ipv4_link_find(address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$nat$\_$enable} |
||||
|
||||
\subsubsection*{Description} |
||||
This function enables NAT functionality on the passed IPv4 link. |
||||
Forwarded packets from an internal network will have the public IP address from the passed link |
||||
and a translated port number for transmission on the external network. |
||||
Usual operation requires at least one additional link for the internal network, |
||||
which is used as a gateway for the internal hosts. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_nat_enable(struct pico_ipv4_link *link) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{link} - Pointer to a link \texttt{pico$\_$ipv4$\_$link}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_nat_enable(&external_link); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$nat$\_$disable} |
||||
|
||||
\subsubsection*{Description} |
||||
Disables the NAT functionality. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_nat_disable(void); |
||||
\end{verbatim} |
||||
|
||||
%\subsubsection*{Parameters} |
||||
|
||||
\subsubsection*{Return value} |
||||
Always returns 0. |
||||
|
||||
%\subsubsection*{Errors} |
||||
%\subsubsection*{Example} |
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$port$\_$forward} |
||||
|
||||
\subsubsection*{Description} |
||||
This function adds or deletes a rule in the IP forwarding table. Internally in the stack, |
||||
a one-direction NAT entry will be made. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_port_forward(struct pico_ip4 pub_addr, uint16_t pub_port, |
||||
struct pico_ip4 priv_addr, uint16_t priv_port, uint8_t proto, |
||||
uint8_t persistant) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{pub$\_$addr} - Public IP address, must be identical to the address of the external link. |
||||
\item \texttt{pub$\_$port} - Public port to be translated. |
||||
\item \texttt{priv$\_$addr} - Private IP address of the host on the internal network. |
||||
\item \texttt{priv$\_$port} - Private port of the host on the internal network. |
||||
\item \texttt{proto} - Protocol identifier, see supported list below. |
||||
\item \texttt{persistant} - Option for function call: create \texttt{PICO$\_$IPV4$\_$FORWARD$\_$ADD} (= 1) \\ |
||||
or delete \texttt{PICO$\_$IPV4$\_$FORWARD$\_$DEL} (= 0). |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Protocol list} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$PROTO$\_$ICMP4} |
||||
\item \texttt{PICO$\_$PROTO$\_$TCP} |
||||
\item \texttt{PICO$\_$PROTO$\_$UDP} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call 0 after a succesfull entry of the forward rule. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - not succesfull, try again |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_port_forward(ext_link_addr, ext_port, host_addr, |
||||
host_port, PICO_PROTO_UDP, 1); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$route$\_$add} |
||||
|
||||
\subsubsection*{Description} |
||||
Add a new route to the destination IP address from the local device link, f.e. eth0. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_route_add(struct pico_ip4 address, struct pico_ip4 netmask, |
||||
struct pico_ip4 gateway, int metric, struct pico_ipv4_link *link); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as \texttt{struct pico$\_$ip4}. |
||||
\item \texttt{netmask} - Netmask of the address. If zeroed, the call assumes the meaning of adding a default gateway. |
||||
\item \texttt{gateway} - Gateway of the address network. If zeroed, no gateway will be associated to this route, and the traffic towards the destination will be simply forwarded towards the given device. |
||||
\item \texttt{metric} - Metric for this route. |
||||
\item \texttt{link} - Local device interface. If a valid gateway is specified, this parameter is not mandatory, otherwise \texttt{NULL} can be used. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
%if the route already exists or no memory could be allocated. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_route_add(dst, netmask, gateway, metric, link); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$route$\_$del} |
||||
|
||||
\subsubsection*{Description} |
||||
Remove the route to the destination IP address from the local device link, f.e. etho0. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv4_route_del(struct pico_ip4 address, struct pico_ip4 netmask, |
||||
struct pico_ip4 gateway, int metric, struct pico_ipv4_link *link); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as struct \texttt{pico$\_$ip4}. |
||||
\item \texttt{netmask} - Netmask of the address. |
||||
\item \texttt{gateway} - Gateway of the address network. |
||||
\item \texttt{metric} - Metric of the route. |
||||
\item \texttt{link} - Local device interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the route is found. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv4_route_del(dst, netmask, gateway, metric, link); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv4$\_$route$\_$get$\_$gateway} |
||||
|
||||
\subsubsection*{Description} |
||||
This function gets the gateway address for the given destination IP address, if set. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip4 pico_ipv4_route_get_gateway(struct pico_ip4 *addr) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as struct \texttt{pico$\_$ip4}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success the gateway address is returned. |
||||
On error a \texttt{null} address is returned (\texttt{0.0.0.0}) and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
gateway_addr = pico_ip4 pico_ipv4_route_get_gateway(&dest_addr) |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$icmp4$\_$ping} |
||||
|
||||
\subsubsection*{Description} |
||||
This function sends out a number of ping echo requests and checks if the replies are received correctly. |
||||
The information from the replies is passed to the callback function after a succesfull reception. |
||||
If a timeout expires before a reply is received, the callback is called with the error condition. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_icmp4_ping(char *dst, int count, int interval, int timeout, int size, |
||||
void (*cb)(struct pico_icmp4_stats *)); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dst} - Pointer to the destination internet host address as text string |
||||
\item \texttt{count} - Number of pings going to be send |
||||
\item \texttt{interval} - Time between two transmissions (in ms) |
||||
\item \texttt{timeout} - Timeout period untill reply received (in ms) |
||||
\item \texttt{size} - Size of data buffer in bytes |
||||
\item \texttt{cb} - Callback for ICMP ping |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Data structure \texttt{struct pico$\_$icmp4$\_$stats}} |
||||
\begin{verbatim} |
||||
struct pico_icmp4_stats |
||||
{ |
||||
struct pico_ip4 dst; |
||||
unsigned long size; |
||||
unsigned long seq; |
||||
unsigned long time; |
||||
unsigned long ttl; |
||||
int err; |
||||
}; |
||||
\end{verbatim} |
||||
With \textbf{err} values: |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$PING$\_$ERR$\_$REPLIED} (value 0) |
||||
\item \texttt{PICO$\_$PING$\_$ERR$\_$TIMEOUT} (value 1) |
||||
\item \texttt{PICO$\_$PING$\_$ERR$\_$UNREACH} (value 2) |
||||
\item \texttt{PICO$\_$PING$\_$ERR$\_$PENDING} (value 0xFFFF) |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns a positive number, which is the ID of the ping operation just started. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
id = pico_icmp4_ping(dst_addr, 30, 10, 100, 1000, callback); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$icmp4$\_$ping$\_$abort} |
||||
|
||||
\subsubsection*{Description} |
||||
This function aborts an ongoing ping operation that has previously started using pico$\_$icmp4$\_$ping(). |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_icmp4_ping_abort(int id); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{id} - identification number for the ping operation. This has been returned by \texttt{pico$\_$icmp4$\_$ping()} and it is intended to distinguish the operation to be cancelled. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_icmp4_ping_abort(id); |
||||
\end{verbatim} |
||||
|
||||
@ -1,533 +0,0 @@
|
||||
\section{IPv6 functions} |
||||
|
||||
% Short description/overview of module functions |
||||
|
||||
\subsection{pico$\_$ipv6$\_$to$\_$string} |
||||
|
||||
\subsubsection*{Description} |
||||
Convert the internet host address IP to a string in IPv6 colon:hex notation. |
||||
The result is stored in the char array that ipbuf points to. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_to_string(char *ipbuf, const uint8_t ip[PICO_SIZE_IP6]); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ipbuf} - Char array to store the result in. |
||||
\item \texttt{ip} - Internet host address in unsigned byte array notation of lenght 16. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the conversion was successful. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_to_string(buf, ip); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$string$\_$to$\_$ipv6} |
||||
|
||||
\subsubsection*{Description} |
||||
Convert the IPv6 colon:hex notation into binary form. The result is stored in the |
||||
\texttt{int} that IP points to. |
||||
The address supplied in \texttt{ipstr} can have one of the default forms for IPv6 address |
||||
description, including at most one abbreviation skipping zeroed fields using "::" |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_string_to_ipv6(const char *ipstr, uint8_t *ip); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ipstr} - Pointer to the IP string. |
||||
\item \texttt{ip} - Int pointer to store the result in. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the conversion was successful. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_string_to_ipv6("fe80::1", *ip); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$unicast} |
||||
|
||||
\subsubsection*{Description} |
||||
Check if the provided address is unicast or multicast. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_unicast(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 1 if unicast, 0 if multicast. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_unicast(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$multicast} |
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet multicast address, i.e. it belongs to the range ff00::/8. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_multicast(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
\subsubsection*{Return value} |
||||
Returns 1 if a multicast Internet address has been provided. |
||||
%\subsubsection*{Errors} |
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_multicast(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$global} |
||||
|
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet global address, i.e. it belongs to the range 2000::/3. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_global(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 1 if a global Internet address has been provided. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_global(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$uniquelocal} |
||||
|
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet uniquelocal address, i.e. it belongs to the range fc00::/7. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_uniquelocal(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 1 if a uniquelocal Internet address has been provided. |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_uniquelocal(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$sitelocal} |
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet sitelocal address, i.e. it belongs to the range fec0::/10. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_sitelocal(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
\subsubsection*{Return value} |
||||
Returns 1 if a sitelocal Internet address has been provided. |
||||
%\subsubsection*{Errors} |
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_sitelocal(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$linklocal} |
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet linklocal address, i.e. it belongs to the range fe80::/10. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_linklocal(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
\subsubsection*{Return value} |
||||
Returns 1 if a linklocal Internet address has been provided. |
||||
%\subsubsection*{Errors} |
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_linklocal(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$localhost} |
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet localhost address, i.e. it is "::1". |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_localhost(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
\subsubsection*{Return value} |
||||
Returns 1 if a localhost Internet address has been provided. |
||||
%\subsubsection*{Errors} |
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_localhost(address); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$is$\_$undefined} |
||||
\subsubsection*{Description} |
||||
Check if the provided address is a valid Internet undefined address, i.e. it is "::0". |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_is_undefined(struct pico_ip6 *a); |
||||
\end{verbatim} |
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Internet host address. |
||||
\end{itemize} |
||||
\subsubsection*{Return value} |
||||
Returns 1 if the Internet address provided describes ANY host. |
||||
%\subsubsection*{Errors} |
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_is_undefined(address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$source$\_$find} |
||||
|
||||
\subsubsection*{Description} |
||||
Find the source IP for the link associated to the specified destination. |
||||
This function will use the currently configured routing table to identify the link that would be used to transmit any traffic directed to the given IP address. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip6 *pico_ipv6_source_find(struct pico_ip6 *dst); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as \texttt{struct pico$\_$ip6}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the source IP as \texttt{struct pico$\_$ip6}. |
||||
If the source can not be found, \texttt{NULL} is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
src = pico_ipv6_source_find(dst); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$link$\_$add } |
||||
|
||||
\subsubsection*{Description} |
||||
Add a new local device dev inteface, f.e. eth0, with IP address 'address' and netmask 'netmask'. A device may have more than one link configured, i.e. to access multiple networks on the same link. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_link_add(struct pico_device *dev, struct pico_ip6 address, |
||||
struct pico_ip6 netmask); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Local device. |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip6}. |
||||
\item \texttt{netmask} - Netmask of the address. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_link_add(dev, address, netmask); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$link$\_$del} |
||||
|
||||
\subsubsection*{Description} |
||||
Remove the link associated to the local device that was previously configured, corresponding to the IP address 'address'. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_link_del(struct pico_device *dev, struct pico_ip6 address); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Local device. |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip6}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_link_del(dev, address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$link$\_$find} |
||||
|
||||
\subsubsection*{Description} |
||||
Find the local device associated to the local IP address 'address'. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_device *pico_ipv6_link_find(struct pico_ip6 *address); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the internet host address as \texttt{struct pico$\_$ip6}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the local device. |
||||
On error, \texttt{NULL} is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENXIO} - no such device or address |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
dev = pico_ipv6_link_find(address); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$route$\_$add} |
||||
|
||||
\subsubsection*{Description} |
||||
Add a new route to the destination IP address from the local device link, f.e. eth0. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_route_add(struct pico_ip6 address, struct pico_ip6 netmask, |
||||
struct pico_ip6 gateway, int metric, struct pico_ipv6_link *link); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as \texttt{struct pico$\_$ip6}. |
||||
\item \texttt{netmask} - Netmask of the address. If zeroed, the call assumes the meaning of adding a default gateway. |
||||
\item \texttt{gateway} - Gateway of the address network. If zeroed, no gateway will be associated to this route, and the traffic towards the destination will be simply forwarded towards the given device. |
||||
\item \texttt{metric} - Metric for this route. |
||||
\item \texttt{link} - Local device interface. If a valid gateway is specified, this parameter is not mandatory, otherwise \texttt{NULL} can be used. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0. On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
%if the route already exists or no memory could be allocated. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_route_add(dst, netmask, gateway, metric, link); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$route$\_$del} |
||||
|
||||
\subsubsection*{Description} |
||||
Remove the route to the destination IP address from the local device link, f.e. etho0. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_ipv6_route_del(struct pico_ip6 address, struct pico_ip6 netmask, |
||||
struct pico_ip6 gateway, int metric, struct pico_ipv6_link *link); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as struct \texttt{pico$\_$ip6}. |
||||
\item \texttt{netmask} - Netmask of the address. |
||||
\item \texttt{gateway} - Gateway of the address network. |
||||
\item \texttt{metric} - Metric of the route. |
||||
\item \texttt{link} - Local device interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the route is found. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_ipv6_route_del(dst, netmask, gateway, metric, link); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$ipv6$\_$route$\_$get$\_$gateway} |
||||
|
||||
\subsubsection*{Description} |
||||
This function gets the gateway address for the given destination IP address, if set. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip6 pico_ipv6_route_get_gateway(struct pico_ip6 *addr) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{address} - Pointer to the destination internet host address as struct \texttt{pico$\_$ip6}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success the gateway address is returned. |
||||
On error a \texttt{null} address is returned (\texttt{0.0.0.0}) and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
gateway_addr = pico_ip6 pico_ipv6_route_get_gateway(&dest_addr) |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$dev$\_$routing$\_$enable} |
||||
|
||||
\subsubsection*{Description} |
||||
Enable IPv6 Routing messages through the specified interface. On a picoTCP IPv6 machine, |
||||
when routing is enabled, all possible routes to other links are advertised to the target interfaces. |
||||
This allows the hosts connected to the target interface to use the picoTCP IPv6 machine as a router |
||||
towards public IPv6 addresses configured on other interfaces, or reachable through known gateways. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip6 pico_ipv6_dev_routing_enable(struct pico_device *dev) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Pointer to the target device struct \texttt{pico$\_$device}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, zero is returned. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
retval = pico_ipv6_dev_routing_enable(eth1); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$ipv6$\_$dev$\_$routing$\_$disable} |
||||
|
||||
\subsubsection*{Description} |
||||
Enable IPv6 Routing messages through the specified interface. On a picoTCP IPv6 machine, |
||||
when routing is enabled, all possible routes to other links are advertised to the target interface. |
||||
This function will stop advertising reachable routes to public IPv6 addresses configured on other |
||||
interfaces, or reachable through known gateways. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_ip6 pico_ipv6_dev_routing_disable(struct pico_device *dev) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - Pointer to the target device struct \texttt{pico$\_$device}. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, zero is returned. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
retval = pico_ipv6_dev_routing_disable(eth1); |
||||
\end{verbatim} |
||||
@ -1,235 +0,0 @@
|
||||
\section{MDNS client} |
||||
|
||||
% Short description/overview of module functions |
||||
This module can register DNS resource records on the network via Multicast DNS as either \textbf{\emph{shared}} or \textbf{\emph{unique}} records. Unique records are, as the name implies, unique on the network (the record-name and -type combination is unique) and one single host has claimed the ownership of them. Shared records are records that are not unique on the network, which means multiple hosts can register records with the same record-name and -type combination. For more information on shared and unique resource record sets, see RFC6762. |
||||
|
||||
Unique records are, as it should, defended when somebody else tries to claim the same unique records. When hosts detect such a defense of another host while registering their own records, the conflict will be resolved by choosing another name for the records and another attempt is made to register those new records. |
||||
|
||||
This module only supplies the mechanisms of record registration and resolving on the network, it doesn't parses the contents of them, that's up to the application. |
||||
|
||||
\subsection{pico$\_$mdns$\_$init} |
||||
|
||||
\subsubsection*{Description} |
||||
Initialises the entire mDNS-module and sets the hostname for this machine. Sets up the global mDNS socket properly and calls callback when succeeded. Only when the module is properly initialised, records can be registered on the network. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_mdns_init( const char *hostname, |
||||
struct pico_ip4 address, |
||||
void (*callback)(pico_mdns_rtree *, char *, void *), |
||||
void *arg ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{hostname} - Hostname to register for this machine. Should end with \'.local\'. |
||||
\item \texttt{address} - IPv4-address of this machines interface to generate a hostname record from. |
||||
\item \texttt{cb$\_$initialised} - Callback-function that is called when the initialisation process is done. This will also get called when asynchronous conflicts occur for successfully registered records during run-time. The mDNS-record tree contains the registered records, the char-buffer contains the registered hostname and the void-pointer contains the passed argument. |
||||
\item \texttt{arg} - Argument for callback supplied by user. This can be used if you want to pass some variable into your callback function. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the module is properly initialised and the host started registering the hostname. Returns something else went the host failed initialising the module or registering the hostname. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
pico_mdns_init("host.local", address, &mdns_init_callback, NULL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$mdns$\_$get$\_$hostname} |
||||
|
||||
\subsubsection*{Description} |
||||
Get the current hostname for this machine. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
const char * pico_mdns_get_hostname( void ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns the current hostname for this machine when the module is initialised, returns NULL when the module is not initialised. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
char *url = pico_mdns_get_hostname(); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$mdns$\_$set$\_$hostname} |
||||
|
||||
\subsubsection*{Description} |
||||
Tries to claim a hostname for this machine. Claims automatically a unique A record with the IPv4-address of this host. The hostname won't be set directly when this functions returns, but only if the claiming of the unique record succeeded. Init-callback specified when initialising the module will be called when the hostname-record is successfully registered. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_mdns_tryclaim_hostname( const char *url, void *arg ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{url} - URL to set the hostname to. Should end with \'.local\'. |
||||
\item \texttt{arg} - Argument for init-callback supplied by user. This can be used if you want to pass some variable into your callback function. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the host started registering the hostname-record successfully, returns something else when it didn't succeed. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_mdns_tryclaim_hostname("device.local", NULL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$mdns$\_$claim} |
||||
|
||||
\subsubsection*{Description} |
||||
Claims all different mDNS records in a tree in a single API-call. All records in the mDNS record-tree are registered in a single new claim-session. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_mdns_claim( pico_mdns_rtree record_tree, |
||||
void (*callback)(pico_mdns_rtree *, char *, void *), |
||||
void *arg ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{record$\_$tree} - mDNS record-tree with records to register on the network via Multicast DNS. Can contain \textbf{\emph{unique records}} as well as \textbf{\emph{shared records}}. Declare a mDNS record-tree with the macro 'PICO$\_$MDNS$\_$RTREE$\_$DECLARE(name)', which is actually just a pico$\_$tree-struct, with a comparing-function already set. Records can be added with the preprocessor macro 'PICO$\_$MDNS$\_$RTREE$\_$ADD(pico$\_$mdns$\_$rtree *, struct pico$\_$mdns$\_$record *)'. To create mDNS records see 'pico$\_$mdns$\_$record$\_$create'. |
||||
\item \texttt{callback} - Callback function that gets called when \textbf{\emph{ALL}} records in the tree are successfully registered on the network. Records in the returned tree can differ from records originally registered due to conflict-resolution and such. |
||||
\item \texttt{arg} - Argument for callback supplied by user. This can be used if you want to pass some variable into your callback function. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the host started registering the record successfully, returns something else when it didn't succeed. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
... |
||||
PICO_MDNS_RTREE_DECLARE(rtree); |
||||
PICO_MDNS_RTREE_ADD(&rtree, &record); |
||||
int ret = pico_mdns_claim(rtree, &claimed_cb, NULL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$mdns$\_$getrecord} |
||||
|
||||
\subsubsection*{Description} |
||||
API-call to query a record with a certain URL and type. First checks the cache for this record. If no cache-entry is found, a query will be sent on the wire for this record. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_mdns_getrecord( const char *url, uint16_t type, |
||||
void (*callback)(pico_mdns_rtree *, char *, void *), |
||||
void *arg ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{url} - URL of the DNS name to query records for. |
||||
\item \texttt{type} - DNS type of the records to query for on the network. |
||||
\item \texttt{callback} - Callback to call when records are found or answers to the query are received. This functions can get called multiple times when multiple answers are possible (e.g. with shared records). It's up to the application to aggregate all these received answers, this is possible with a static variable of the type pico$\_$mdns$\_$rtree. |
||||
\item \texttt{arg} - Argument for callback supplied by user. This can be used if you want to pass some variable into your callback function. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 0 when the host started querying for these records successfully or the records are found in the cache. Returns something else when it didn't succeed. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_mdns_getrecord("_ipp._tcp.local", PICO_DNS_TYPE_PTR, &query_cb, NULL); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$mdns$\_$record$\_$create} |
||||
|
||||
\subsubsection*{Description} |
||||
Creates a single standalone mDNS resource record with given name, type and data to register on the network. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_mdns_record *pico_mdns_record_create( const char *url, |
||||
void *_rdata, |
||||
uint16_t datalen, |
||||
uint16_t rtype, |
||||
uint32_t rttl, |
||||
uint8_t flags ); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{url} - DNS resource record name in URL format. Will be converted to DNS name notation format. |
||||
\item \texttt{$\_$rdata} - Memory buffer with data to insert in the resource record. If data of record should contain a DNS name, the name in the databuffer needs to be in URL-format. |
||||
\item \texttt{datalen} - The exact length in bytes of the $\_$rdata-buffer. If data of record should contain a DNS name (f.e. with PICO$\_$DNS$\_$TYPE$\_$PTR), datalen needs to be pico$\_$dns$\_$strlen($\_$rdata). |
||||
\item \texttt{rtype} - DNS type of the resource record to be. |
||||
\item \texttt{ttl} - TTL of the resource record to be when registered on the network. In seconds. |
||||
\item \texttt{flags} - With this parameter, you can specify a record as either a shared record or a unique record with respectively PICO$\_$MDNS$\_$RECORD$\_$SHARED- or PICO$\_$MDNS$\_$RECORD$\_$UNIQUE-preprocessor defines. Records are by default registered as unique. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns a pointer to the newly created record on success, returns NULL on failure. \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
pico_ip4 ip = 0; |
||||
pico_string_to_ipv4("10.10.0.5", &(ip.addr)); |
||||
struct pico_mdns_record *record = pico_mdns_record_create("foo.local", |
||||
&(ip.addr), |
||||
PICO_SIZE_IP4, |
||||
PICO_DNS_TYPE_ANY, |
||||
120, |
||||
PICO_MDNS_RECORD_UNIQUE); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{IS$\_$HOSTNAME$\_$RECORD} |
||||
|
||||
\subsubsection*{Description} |
||||
The initialisation-callback can get called multiple times during run-time due to \emph{passive conflict detection}. A passive conflict occurs for unique records when a faulty Multicast DNS-responder doesn't apply conflict resolution after an occurred conflict. A passive conflict can also occur when a peer registers a \textbf{\emph{shared}} record with the same name and type combination as a \textbf{\emph{unique}} record that the local host already successfully registered on the network. Because of that, shared records have priority over unique records, so unfortunately the local host has to apply the conflict resolution-mechanism to it's earlier uniquely verified record. To be able to notify the application of an updated unique record, the callback gets called given in the initialisation-function. But since that callback maybe parses the returned records as the hostname-records and this isn't necessarily the case when a passive conflict occurs, a mechanism is needed to differ hostname-records from other records. This preprocessor-macro allows this. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
IS_HOSTNAME_RECORD(record) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{record} - mDNS resource record |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
Returns 1 when this record is a hostname record, returns 0 when it's not or when given pointer is a NULL pointer. |
||||
@ -1,42 +0,0 @@
|
||||
\section{MLD} |
||||
|
||||
% Short description/overview of module functions |
||||
This module allows the user to join and leave ipv6 multicast groups. The module is based on the MLD version 2 protocol and it's backwards compatible with version 1. |
||||
The MLD module is completly driven from socket calls (\ref{socket:setoption}) and non of the MLD application interface functions should be called by the user. If however, by any reason, it's necessary for the user to do this, the following function call is provided: |
||||
|
||||
\subsection{pico\_mld\_state\_change} |
||||
|
||||
\subsubsection*{Description} |
||||
Change the state of the host to Non-listener, Idle listener or Delaying listener. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_mld_state_change(struct pico_ip6 *mcast_link, struct pico_ip6 *mcast_group, |
||||
uint8_t filter_mode, struct pico_tree *_MCASTFilter, uint8_t state) |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{mcast\_link} - the link on which that multicast group should be joined. |
||||
\item \texttt{mcast\_group} - the address of the multicast group you want to join. |
||||
\item \texttt{filter\_mode} - the kind of source filtering, if applied. |
||||
\item \texttt{\_MCASTFilter} - list of multicast sources on which source filtering might be applied. |
||||
\item \texttt{state} - the prefered new state. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Errors} |
||||
In case of failure, -1 is returned, and the value of pico$\_$err |
||||
is set as follows: |
||||
|
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - Invalid argument provided |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - Not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - Invalid protocol (or protocol version) found on the link |
||||
\item \texttt{PICO$\_$ERR$\_$EFAULT} - Internal error |
||||
\end{itemize} |
||||
|
||||
%\subsubsection*{Example} |
||||
|
||||
%\subsubsection*{Errors} |
||||
|
||||
%\subsubsection*{Example} |
||||
@ -1,49 +0,0 @@
|
||||
\section{Optimized Link State Routing (OLSR) Module} |
||||
|
||||
|
||||
OLSR is a proactive routing protocol for mobile ad-hoc networks |
||||
(MANETs). It is well suited to large and dense mobile |
||||
networks, as the optimization achieved using the MPRs works well in |
||||
this context. The larger and more dense a network, the more |
||||
optimization can be achieved as compared to the classic link state |
||||
algorithm. OLSR uses hop-by-hop routing, i.e., each node uses its |
||||
local information to route packets. |
||||
|
||||
OLSR is well suited for networks, where the traffic is random and |
||||
sporadic between a larger set of nodes rather than being almost |
||||
exclusively between a small specific set of nodes. As a proactive |
||||
protocol, OLSR is also suitable for scenarios where the communicating |
||||
pairs change over time: no additional control traffic is generated in |
||||
this situation since routes are maintained for all known destinations |
||||
at all times. -- cfr. RFC3626 |
||||
|
||||
|
||||
\subsection{pico\_olsr\_add} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will add the target device to the OLSR mechanism on the machine, |
||||
meaning that it will be possible to advertise and collect routing information |
||||
using Optimized Link State Routing protocol, as described in RFC3626, through the |
||||
target device. |
||||
|
||||
In order to use multiple devices in the OLSR system, this function needs to be called |
||||
multiple times, once per device. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{pico\_olsr\_add(struct pico\_device *dev);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the device is successfully added. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_olsr_add(dev); |
||||
|
||||
\end{verbatim} |
||||
|
||||
@ -1,257 +0,0 @@
|
||||
\section{Point-to-Point Protocol (PPP)} |
||||
|
||||
PPP consists in a family of data-link protocols, providing link control, |
||||
configuration and authentication over a point-to-point link. In a connected |
||||
embedded system, it is often used to access dial-up modems over serial lines. |
||||
|
||||
This module supports GSM modem configuration by implementing part of ETSI TS 127 007. |
||||
|
||||
From the picoTCP perspective, each PPP capable device may be abstracted into its own instance |
||||
that can be created using \texttt{pico\_ppp\_create}. |
||||
|
||||
Any GSM/GPRS/3G/HSDPA module, exporting a non-blocking serial interface, such as SPI or UART, |
||||
can be connected to the ppp device abstraction, using \texttt{pico\_ppp\_set\_serial\_read}, |
||||
\texttt{pico\_ppp\_set\_serial\_write}, \texttt{pico\_ppp\_set\_serial\_set\_speed}. |
||||
|
||||
Once the physical interface is attached, the access to the remote access point gateway |
||||
can be configured using \texttt{pico\_ppp\_set\_apn}, \texttt{pico\_ppp\_set\_username} and |
||||
\texttt{pico\_ppp\_set\_password}. |
||||
|
||||
When the interface is configured, the connection may be established using |
||||
\texttt{pico\_ppp\_connect}. Even if the peer disconnects, the connection will be brought up |
||||
again automatically afterwords. |
||||
|
||||
To interrupt the connection and stop the automatic reconnection, \texttt{pico\_ppp\_disconnect} |
||||
can be called. |
||||
|
||||
\subsection{pico\_ppp\_create} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will create a new device association to be used with the ppp driver. The driver |
||||
must then afterwards be associated with lower-level serial functions in order to be used. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{struct pico\_device *pico\_ppp\_create(void);} |
||||
|
||||
\subsubsection*{Return value} |
||||
A new pico\_device is allocated and returned if the device is successfully created. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ppp = pico_ppp_create(); |
||||
|
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_ppp\_set\_serial\_read} |
||||
\subsubsection*{Description} |
||||
This function will associate the read function from an external source (e.g. a UART device API) |
||||
to the read functionality of the PPP driver. Setting up a proper read/write interface is necessary |
||||
for the PPP driver to work properly. |
||||
|
||||
The function associated with the read must be non-blocking, no matter the execution model of the system. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_serial\_read(struct pico\_device *dev, int (*sread)(struct pico\_device *, void *, int))} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{sread} - a pointer to a function of type \texttt{int fn(struct pico\_device *, void *, int)} |
||||
specifying the target serial read function. The function prototype will be called with the device pointer, |
||||
a buffer to be filled with serial data, and the maximum lenght of the usable buffer. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the serial read function is successfully associated. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
static int my_serial_read(struct pico_device *dev, void *buf, int len) |
||||
{ |
||||
return nonblock_uart_read(buf, len); |
||||
} |
||||
|
||||
pico_ppp_set_serial_read(ppp, my_serial_read); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_ppp\_set\_serial\_write} |
||||
\subsubsection*{Description} |
||||
This function will associate the write function from an external source (e.g. a UART device API) |
||||
to the write functionality of the PPP driver. Setting up a proper read/write interface is necessary |
||||
for the PPP driver to work properly. |
||||
|
||||
The function associated with the write must be non-blocking, no matter the execution model of the system. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_serial\_write(struct pico\_device *dev, int (*swrite)(struct pico\_device *, const void *, int))} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{swrite} - a pointer to a function of type \texttt{int fn(struct pico\_device *, const void *, int)} |
||||
specifying the target serial write function. The function prototype will be called with the device pointer, |
||||
a buffer to be filled with serial data, and the maximum lenght of the usable buffer. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the serial write function is successfully associated. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
static int my_serial_write(struct pico_device *dev, const void *buf, int len) |
||||
{ |
||||
return nonblock_uart_write(buf, len); |
||||
} |
||||
|
||||
pico_ppp_set_serial_write(ppp, my_serial_write); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_ppp\_set\_serial\_set\_speed} |
||||
\subsubsection*{Description} |
||||
This function will associate the set\_speed function from an external source (e.g. a UART device API) |
||||
to dynamically set the UART speed for the interface with the PPP driver. |
||||
|
||||
Calling this function is not mandatory for the PPP UART interface to work. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_serial\_set\_speed(struct pico\_device *dev, int (*sset\_speed)(struct pico\_device *, uint32\_t))} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{sset\_speed} - a pointer to a function of type \texttt{int fn(struct pico\_device *, uint32\_t speed)} |
||||
specifying the target serial set\_speed function. The function prototype will be called with the device pointer and |
||||
the speed at which the UART should be configured by PPP. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the serial set\_speed function is successfully associated. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
static int my_serial_set_speed(struct pico_device *dev, uint32_t speed) |
||||
{ |
||||
return uart_set_speed(speed); |
||||
} |
||||
|
||||
pico_ppp_set_serial_set_speed(ppp, my_serial_set_speed); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico\_ppp\_set\_apn} |
||||
\subsubsection*{Description} |
||||
This function allows the configuration of the APN name in order for PPP to correctly establish the connection |
||||
to the remote Access Point gateway. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_apn(struct pico\_device *dev, const char *apn);} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{apn} - a string containing the Access Point Name. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the APN is correctly configured. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_ppp_set_apn(dev, "internet.apn.name"); |
||||
|
||||
\end{verbatim} |
||||
\subsection{pico\_ppp\_set\_username} |
||||
\subsubsection*{Description} |
||||
This function will set an username for the PAP/CHAP authentication mechanism. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_username(struct pico\_device *dev, const char *username); } |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{username} - a string specifying the desired username. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the username is successfully configured. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_ppp_set_username(dev, "john"); |
||||
|
||||
\end{verbatim} |
||||
\subsection{pico\_ppp\_set\_password} |
||||
\subsubsection*{Description} |
||||
This function will set the password for the PAP/CHAP authentication mechanism. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_set\_password(struct pico\_device *dev, const char *password); } |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\item \texttt{username} - a string specifying the desired password. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the password is successfully configured. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_ppp_set_password(dev, "secret"); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_ppp\_connect} |
||||
\subsubsection*{Description} |
||||
This function will enable the PPP connection, by triggering the startup of the handshakes |
||||
required at all levels. If the connection is dropped, the system will try to reconnect by restarting |
||||
the handshakes, until \texttt{pico\_ppp\_disconnect} is finally called. |
||||
|
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_connect(struct pico\_device *ppp)} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the device is successfully connecting. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_ppp_connect(dev); |
||||
|
||||
\end{verbatim} |
||||
\subsection{pico\_ppp\_disconnect} |
||||
\subsubsection*{Description} |
||||
This function will disable the PPP connection, by triggering a disconnection, and by disabling the |
||||
reconnect feature, if enabled. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{int pico\_ppp\_disconnect(struct pico\_device *ppp)} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} specifying the target interface. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the device is successfully put in disconnected state. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
ret = pico_ppp_disconnect(dev); |
||||
|
||||
\end{verbatim} |
||||
@ -1,44 +0,0 @@
|
||||
\section{SLAACV4 Module} |
||||
|
||||
% Short description/overview of module functions |
||||
|
||||
|
||||
\subsection{pico\_slaacv4\_claimip} |
||||
|
||||
\subsubsection*{Description} |
||||
This function starts the ip claiming process for a device. It will generate first the local link ip using |
||||
as seed the mac address of the device. Then it will start the claim procedure described in RFC3927. |
||||
In case of success the IP is registered to the IP layer and returned using the callback function. |
||||
In case of error, code SLAACV4\_ERROR is returned. Errors occur when the maximum number of conflicts is reached. |
||||
Use the IP returned only if the return code is SLAACV4\_SUCCESS. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{pico\_slaacv4\_claimip(struct pico\_device *dev, void (*cb)(struct pico\_ip4 *ip, uint8\_t code));} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{dev} - a pointer to a struct \texttt{pico\_device} |
||||
\item \texttt{*cb} - a callback function returning the ip claimed and a return code (SLAACV4\_ERROR | SLAACV4\_SUCCESS) |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
0 returned if the claiming has started successfully |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
|
||||
dev = pico_get_device(sdev); |
||||
|
||||
ret = pico_slaacv4_claimip(dev, slaacv4_cb); |
||||
|
||||
\end{verbatim} |
||||
|
||||
\subsection{pico\_slaacv4\_unregisterip} |
||||
|
||||
\subsubsection*{Description} |
||||
This function allows to unregister the local link ip in usage. The function will remove from the route table |
||||
the local link ip and will reset the internal state of the SLAACV4 module |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\texttt{void pico\_slaacv4\_unregisterip(void);} |
||||
|
||||
@ -1,96 +0,0 @@
|
||||
\section{SNTP client} |
||||
|
||||
% Short description/overview of module functions |
||||
This module allows you to sync your device to to a specified (s)ntp server. |
||||
You can then retreive the time with the pico$\_$sntp$\_$gettimeofday function. |
||||
|
||||
|
||||
\subsection{pico$\_$sntp$\_$sync} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to sync the local time to a given sntp server in string notation. DNS resolution will be done automatically. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_sntp_sync(char *sntp_server, void (*cb_synced)(pico_err_t status)); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{sntp$\_$server} - String with the sntp server to get the time from |
||||
\item \texttt{cb$\_$synced} - Callback function that is called when the synchronisation process is done. The status variable indicates wheter the synchronisation was successful or not. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the synchronisation operation has successfully started. When both IPv4 and IPv6 are enabled, success on one is sufficient. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - compiled without DNS support |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_sntp_sync("ntp.nasa.gov", &callback); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$sntp$\_$sync$\_$ip} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to sync the local time to a given sntp server in IP address notation. |
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_sntp_sync_ip(union pico_address *sntp_addr, void (*cb_synced)(pico_err_t status)); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{sntp$\_$addr} - IP address of the sntp server to get the time from |
||||
\item \texttt{cb$\_$synced} - Callback function that is called when the synchronisation process is done. The status variable indicates wheter the synchronisation was successful or not. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the synchronisation operation has successfully started. When both IPv4 and IPv6 are enabled, success on one is sufficient. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_sntp_sync_ip(&sntp_addr, &callback); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$sntp$\_$gettimeofday} |
||||
|
||||
\subsubsection*{Description} |
||||
Function to get the current time. Be sure to call the pico$\_$sntp$\_$sync function to synchronise BEFORE calling this function. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_sntp_gettimeofday(struct pico_timeval *tv); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{tv} - Pointer to a time$\_$val struct in which the current time will be set. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 if the time is set. |
||||
On error, -1 is returned and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
int ret = pico_sntp_gettimeofday(tv); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
@ -1,800 +0,0 @@
|
||||
\section{Socket calls} |
||||
|
||||
% Short description/overview of module functions |
||||
With the socket calls, the user can open, close, bind, \ldots sockets and do read |
||||
or write operations. The provided transport protocols are UDP and TCP. |
||||
|
||||
\subsection{pico$\_$socket$\_$open} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will be called to open a socket from the application level. The created |
||||
socket will be unbound and not connected. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_socket *pico_socket_open(uint16_t net, uint16_t proto, |
||||
void (*wakeup)(uint16_t ev, struct pico_socket *s)); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{net} - Network protocol, \texttt{PICO$\_$PROTO$\_$IPV4} = 0, \texttt{PICO$\_$PROTO$\_$IPV6} = 41 |
||||
\item \texttt{proto} - Transport protocol, \texttt{PICO$\_$PROTO$\_$TCP} = 6, \texttt{PICO$\_$PROTO$\_$UDP} = 17 |
||||
\item \texttt{wakeup} - Callback function that accepts 2 parameters: |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{ev} - Events that apply to that specific socket, see further |
||||
\item \texttt{s} - Pointer to a socket of type struct \texttt{pico$\_$socket} |
||||
\end{itemize} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Possible events for sockets} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$RD} - triggered when new data arrives on the socket. A new receive action can be taken by the socket owner because this event indicates there is new data to receive. |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$WR} - triggered when ready to write to the socket. Issuing a write/send call will now succeed if the buffer has enough space to allocate new outstanding data. |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$CONN} - triggered when connection is established (TCP only). This event is received either after a successful call to \texttt{pico$\_$socket$\_$connect} to indicate that the connection has been established, or on a listening socket, indicating that a call to \texttt{pico$\_$socket$\_$accept} may now be issued in order to accept the incoming connection from a remote host. |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$CLOSE} - triggered when a FIN segment is received (TCP only). This event indicates that the other endpont has closed the connection, so the local TCP layer is only allowed to send new data until a local shutdown or close is initiated. PicoTCP is able to keep the connection half-open (only for sending) after the FIN packet has been received, allowing new data to be sent in the TCP CLOSE$\_$WAIT state. |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$FIN} - triggered when the socket is closed. No further communication is possible from this point on the socket. |
||||
\item \texttt{PICO$\_$SOCK$\_$EV$\_$ERR} - triggered when an error occurs. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns a pointer to the declared socket (\texttt{struct pico$\_$socket *}). |
||||
On error the socket is not created, \texttt{NULL} is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - protocol not supported |
||||
\item \texttt{PICO$\_$ERR$\_$ENETUNREACH} - network unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
sk_tcp = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_TCP, &wakeup); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$read} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will be called to read data from a connected socket. The function checks that the socket is bound and connected before attempting to receive data. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_read(struct pico_socket *s, void *buf, int len); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer where the received data will be stored |
||||
\item \texttt{len} - Length of the buffer (in bytes), represents the maximum amount of bytes that can be read |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes read. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EIO} - input/output error |
||||
\item \texttt{PICO$\_$ERR$\_$ESHUTDOWN} - cannot read after transport endpoint shutdown |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesRead = pico_socket_read(sk_tcp, buffer, bufferLength); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$write} |
||||
|
||||
\subsubsection*{Description} |
||||
This function will be called to write the content of a buffer to a socket that has been previously connected. |
||||
This function checks that the socket is bound, connected and that it is allowed to send data, i.e. there hasn't been a local shutdown. |
||||
This is the preferred function to use when writing data from the application to a connected stream. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_write(struct pico_socket *s, void *buf, int len); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of a (constant) buffer where the data is stored |
||||
\item \texttt{len} - Length of the data buffer \texttt{buf} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes written to the socket. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EIO} - input/output error |
||||
\item \texttt{PICO$\_$ERR$\_$ENOTCONN} - the socket is not connected |
||||
\item \texttt{PICO$\_$ERR$\_$ESHUTDOWN} - cannot send after transport endpoint shutdown |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesWritten = pico_socket_write(sk_tcp, buffer, bufLength); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$sendto} |
||||
|
||||
\subsubsection*{Description} |
||||
This function sends data from the local address to the remote address, without checking |
||||
whether the remote endpoint is connected. Specifying the destination is particularly useful while sending single datagrams |
||||
to different destinations upon consecutive calls. This is the preferred mechanism to send datagrams to a remote destination |
||||
using a UDP socket. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_sendto(struct pico_socket *s, const void *buf, int len, |
||||
void *dst, uint16_t remote_port); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Length of the buffer \texttt{buf} |
||||
\item \texttt{dst} - Pointer to the origin of the IPv4/IPv6 frame header |
||||
\item \texttt{remote$\_$port} - Portnumber of the receiving socket |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes written to the socket. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesWritten = pico_socket_sendto(sk_tcp, buf, len, &sk_tcp->remote_addr, |
||||
sk_tcp->remote_port); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$recvfrom} |
||||
|
||||
\subsubsection*{Description} |
||||
This function is called to receive data from the specified socket. |
||||
It is useful when called in the context of a non-connected socket, to receive |
||||
the information regarding the origin of the data, namely the origin address and |
||||
the remote port number. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_recvfrom(struct pico_socket *s, void *buf, int len, |
||||
void *orig, uint16_t *remote_port); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Maximum allowed length for the data to be stored in the buffer \texttt{buf} |
||||
\item \texttt{orig} - Pointer to the origin of the IPv4/IPv6 frame, (peer IP address), can be NULL |
||||
\item \texttt{remote$\_$port} - Pointer to the port number of the sender socket, can be NULL |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes read from the socket. On success, if \texttt{orig} |
||||
is not NULL, The address of the remote endpoint is stored in the memory area pointed by \texttt{orig}. |
||||
In the same way, \texttt{remote$\_$port} will contain the portnumber of the sending socket, unless a NULL is passed |
||||
from the caller. |
||||
|
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ESHUTDOWN} - cannot read after transport endpoint shutdown |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesRcvd = pico_socket_recvfrom(sk_tcp, buf, bufLen, &peer, &port); |
||||
\end{verbatim} |
||||
|
||||
\subsection{Extended Socket operations} |
||||
The interface provided by sendto/recvfrom can be extended to include more information about the network communication. |
||||
This is especially useful in UDP communication, and whenever extended information is needed about the single datagram and its encapsulation in the networking layer. |
||||
|
||||
PicoTCP offers an extra structure that can be used to set and retrieve message information while transmitting and receiving datagrams, respectively. The structure \texttt{pico$\_$msginfo} is defined as follows: |
||||
\begin{verbatim} |
||||
struct pico_msginfo { |
||||
struct pico_device *dev; |
||||
uint8_t ttl; |
||||
uint8_t tos; |
||||
}; |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$sendto$\_$extended} |
||||
|
||||
\subsubsection*{Description} |
||||
This function is an extension of the \texttt{pico$\_$socket$\_$sendto} function described above. It's exactly the same but it adds up an additional argument to set TTL and QOS information on the outgoing packet which contains the datagram. |
||||
|
||||
The usage of the extended argument makes sense in UDP context only, as the information is set at packet level, and only with UDP there is a 1:1 correspondence between datagrams and IP packets. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_sendto_extended(struct pico_socket *s, const void *buf, int len, |
||||
void *dst, uint16_t remote_port, struct pico_msginfo *info); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Length of the data that is stored in the buffer (in bytes) |
||||
\item \texttt{dst} - IPv4 or IPv6 address of the destination peer where th frame is sent |
||||
\item \texttt{remote$\_$port} - Port number of the receiving socket at the remote endpoint |
||||
\item \texttt{info} - Extended information about the packet containing this datagram. Only the fields "ttl" and "tos" are taken into consideeration, while "dev" is ignored. |
||||
|
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes written to the socket. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
struct pico_msginfo info = { }; |
||||
info.ttl = 5; |
||||
bytesWritten = pico_socket_sendto_extended(sk_tcp, buf, len, &sk_tcp->remote_addr, |
||||
sk_tcp->remote_port, &info); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$recvfrom$\_$extended} |
||||
|
||||
\subsubsection*{Description} |
||||
This function is an extension to the normal \texttt{pico$\_$socket$\_$recvfrom} function, which allows to retrieve additional information about the networking layer that has been involved in the delivery of the datagram. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_recvfrom_extended(struct pico_socket *s, void *buf, int len, |
||||
void *orig, uint16_t *remote_port, struct pico_msginfo *info); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Maximum allowed length for the data to be stored in the buffer \texttt{buf} |
||||
\item \texttt{orig} - Pointer to the origin of the IPv4/IPv6 frame header, can be NULL |
||||
\item \texttt{remote$\_$port} - Pointer to the port number of the sender socket, can be NULL |
||||
\item \texttt{info} - Extended information about the incoming packet containing this datagram. The device where the packet was received is pointed by info->dev, the maximum TTL for the packet is stored in info->ttl, and finally the field info->tos keeps track of the flags in IP header's QoS. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes read from the socket. On success, if \texttt{orig} |
||||
is not NULL, The address of the remote endpoint is stored in the memory area pointed by \texttt{orig}. |
||||
In the same way, \texttt{remote$\_$port} will contain the portnumber of the sending socket, unless a NULL is passed |
||||
from the caller. |
||||
|
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ESHUTDOWN} - cannot read after transport endpoint shutdown |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
struct pico_msginfo info; |
||||
bytesRcvd = pico_socket_recvfrom_extended(sk_tcp, buf, bufLen, &peer, &port, &info); |
||||
if (info && info->dev) { |
||||
printf("Socket received a datagram via device %s, ttl:%d, tos: %08x\n", |
||||
info->dev->name, info->ttl, info->tos); |
||||
} |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$send} |
||||
|
||||
\subsubsection*{Description} |
||||
This function is called to send data to the specified socket. |
||||
It checks if the socket is connected and then calls the |
||||
\texttt{pico$\_$socket$\_$sendto} function. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_send(struct pico_socket *s, const void *buf, int len); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Length of the buffer \texttt{buf} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes written to |
||||
the socket. On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOTCONN} - the socket is not connected |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesRcvd = pico_socket_send(sk_tcp, buf, bufLen); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$recv} |
||||
|
||||
\subsubsection*{Description} |
||||
This function directly calls the \texttt{pico$\_$socket$\_$recvfrom} function. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_recv(struct pico_socket *s, void *buf, int len); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{buf} - Void pointer to the start of the buffer |
||||
\item \texttt{len} - Maximum allowed length for the data to be stored in the buffer \texttt{buf} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns an integer representing the number of bytes read |
||||
from the socket. On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ESHUTDOWN} - cannot read after transport endpoint shutdown |
||||
\item \texttt{PICO$\_$ERR$\_$EADDRNOTAVAIL} - address not available |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
bytesRcvd = pico_socket_recv(sk_tcp, buf, bufLen); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$bind} |
||||
|
||||
\subsubsection*{Description} |
||||
This function binds a local IP-address and port to the specified socket. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_bind(struct pico_socket *s, void *local_addr, uint16_t *port); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{local$\_$addr} - Void pointer to the local IP-address |
||||
\item \texttt{port} - Local portnumber to bind with the socket |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull bind. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$ENOMEM} - not enough space |
||||
\item \texttt{PICO$\_$ERR$\_$ENXIO} - no such device or address |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_bind(sk_tcp, &sockaddr4->addr, &sockaddr4->port); |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$socket$\_$getname} |
||||
|
||||
\subsubsection*{Description} |
||||
This function returns the local IP-address and port previously bound to the specified socket. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_getname(struct pico_socket *s, void *local_addr, uint16_t *port, |
||||
uint16_t *proto); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{local$\_$addr} - Address (IPv4 or IPv6) previously associated to this socket |
||||
\item \texttt{port} - Local portnumber associated to the socket |
||||
\item \texttt{proto} - Proto of the address returned in the \texttt{local$\_$addr} field. Can be either \texttt{PICO$\_$PROTO$\_$IPV4} or \texttt{PICO$\_$PROTO$\_$IPV6} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 and populates the three fields {local$\_$addr} \texttt{port} and \texttt{proto} accordingly. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument(s) provided |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_getname(sk_tcp, address, &port, &proto); |
||||
if (errMsg == 0) { |
||||
if (proto == PICO_PROTO_IPV4) |
||||
addr4 = (struct pico_ip4 *)address; |
||||
else |
||||
addr6 = (struct pico_ip6 *)address; |
||||
} |
||||
\end{verbatim} |
||||
|
||||
\subsection{pico$\_$socket$\_$getpeername} |
||||
|
||||
\subsubsection*{Description} |
||||
This function returns the IP-address of the remote peer connected to the specified socket. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_getpeername(struct pico_socket *s, void *remote_addr, uint16_t *port, |
||||
uint16_t *proto); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{remote$\_$addr} - Address (IPv4 or IPv6) associated to the socket remote endpoint |
||||
\item \texttt{port} - Local portnumber associated to the socket |
||||
\item \texttt{proto} - Proto of the address returned in the \texttt{local$\_$addr} field. Can be either \texttt{PICO$\_$PROTO$\_$IPV4} or \texttt{PICO$\_$PROTO$\_$IPV6} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 and populates the three fields {local$\_$addr} \texttt{port} and \texttt{proto} accordingly. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument(s) provided |
||||
\item \texttt{PICO$\_$ERR$\_$ENOTCONN} - the socket is not connected to any peer |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_getpeername(sk_tcp, address, &port, &proto); |
||||
if (errMsg == 0) { |
||||
if (proto == PICO_PROTO_IPV4) |
||||
addr4 = (struct pico_ip4 *)address; |
||||
else |
||||
addr6 = (struct pico_ip6 *)address; |
||||
} |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$connect} |
||||
|
||||
\subsubsection*{Description} |
||||
This function connects a local socket to a remote socket of a server that is listening, or permanently associate a remote UDP peer as default receiver for any further outgoing traffic through this socket. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_connect(struct pico_socket *s, void *srv_addr, |
||||
uint16_t remote_port); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{srv$\_$addr} - Void pointer to the remote IP-address to connect to |
||||
\item \texttt{remote$\_$port} - Remote port number on which the socket will be connected to |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull connect. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EPROTONOSUPPORT} - protocol not supported |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EHOSTUNREACH} - host is unreachable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_connect(sk_tcp, &sockaddr4->addr, sockaddr4->port); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$listen} |
||||
|
||||
\subsubsection*{Description} |
||||
A server can use this function when a socket is opened and bound to start listening to it. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_listen(struct pico_socket *s, int backlog); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{backlog} - Maximum connection requests |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull listen start. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EISCONN} - socket is connected |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_listen(sk_tcp, 3); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$accept} |
||||
|
||||
\subsubsection*{Description} |
||||
When a server is listening on a socket and the client is trying to connect. |
||||
The server on its side will wakeup and acknowledge the connection by calling the this function. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
struct pico_socket *pico_socket_accept(struct pico_socket *s, void *orig, |
||||
uint16_t *local_port); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{orig} - Pointer to the origin of the IPv4/IPv6 frame header |
||||
\item \texttt{local$\_$port} - Portnumber of the local socket (pointer) |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns the pointer to a \texttt{struct pico$\_$socket} that |
||||
represents the client thas was just connected. Also \texttt{orig} will contain the requesting |
||||
IP-address and \texttt{remote$\_$port} will contain the portnumber of the requesting socket. |
||||
On error, \texttt{NULL} is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\item \texttt{PICO$\_$ERR$\_$EAGAIN} - resource temporarily unavailable |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
client = pico_socket_accept(sk_tcp, &peer, &port); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$shutdown} |
||||
|
||||
\subsubsection*{Description} |
||||
Used by the \texttt{pico$\_$socket$\_$close} function to shutdown read and write mode for |
||||
the specified socket. With this function one can close a socket for reading |
||||
and/or writing. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_shutdown(struct pico_socket *s, int mode); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{mode} - \texttt{PICO$\_$SHUT$\_$RDWR}, \texttt{PICO$\_$SHUT$\_$WR}, \texttt{PICO$\_$SHUT$\_$RD} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull socket shutdown. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_shutdown(s, PICO_SHUT_RDWR); |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$close} |
||||
|
||||
\subsubsection*{Description} |
||||
Function used on application level to close a socket. Always closes read and write connection. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_close(struct pico_socket *s); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull socket shutdown. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
errMsg = pico_socket_close(sk_tcp); |
||||
\end{verbatim} |
||||
|
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$setoption} |
||||
\label{socket:setoption} |
||||
\subsubsection*{Description} |
||||
Function used to set socket options. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_setoption(struct pico_socket *s, int option, void *value); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{option} - Option to be set (see further for all options) |
||||
\item \texttt{value} - Value of option (void pointer) |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Available socket options} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$TCP$\_$NODELAY} - Disables/enables the Nagle algorithm (TCP Only). |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$KEEPCNT} - Set number of probes for TCP keepalive |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$KEEPIDLE} - Set timeout value for TCP keepalive probes (in ms) |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$KEEPINTVL} - Set interval between TCP keepalive retries in case of no reply (in ms) |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$LINGER} - Set linger time for TCP TIME$\_$WAIT state (in ms) |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$RCVBUF} - Set receive buffer size for the socket |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$RCVBUF} - Set receive buffer size for the socket |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$RCVBUF} - Set receive buffer size for the socket |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$SNDBUF} - Set send buffer size for the socket |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$IF} - (Not supported) Set link multicast datagrams are sent from, default is first added link |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$TTL} - Set TTL (0-255) of multicast datagrams, default is 1 |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$LOOP} - Specifies if a copy of an outgoing multicast datagram is looped back as long as it is a member of the multicast group, default is enabled |
||||
\item \texttt{PICO$\_$IP$\_$ADD$\_$MEMBERSHIP} - Join the multicast group specified in the \textit{pico\_ip\_mreq} structure passed in the value argument |
||||
\item \texttt{PICO$\_$IP$\_$DROP$\_$MEMBERSHIP} - Leave the multicast group specified in the \textit{pico\_ip\_mreq} structure passed in the value argument |
||||
\item \texttt{PICO$\_$IP$\_$ADD$\_$SOURCE$\_$MEMBERSHIP} - Join the source-specific multicast group specified in the \textit{pico\_ip\_mreq\_source} structure passed in the value argument |
||||
\item \texttt{PICO$\_$IP$\_$DROP$\_$SOURCE$\_$MEMBERSHIP} - Leave the source-specific multicast group specified in the \textit{pico\_ip\_mreq\_source} structure passed in the value argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull setting of socket option. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_socket_setoption(sk_tcp, PICO_TCP_NODELAY, NULL); |
||||
|
||||
uint8_t ttl = 2; |
||||
ret = pico_socket_setoption(sk_udp, PICO_IP_MULTICAST_TTL, &ttl); |
||||
|
||||
uint8_t loop = 0; |
||||
ret = pico_socket_setoption(sk_udp, PICO_IP_MULTICAST_LOOP, &loop); |
||||
|
||||
struct pico_ip4 inaddr_dst, inaddr_link; |
||||
struct pico_ip_mreq mreq = {{0},{0}}; |
||||
pico_string_to_ipv4("224.7.7.7", &inaddr_dst.addr); |
||||
pico_string_to_ipv4("192.168.0.2", &inaddr_link.addr); |
||||
mreq.mcast_group_addr = inaddr_dst; |
||||
mreq.mcast_link_addr = inaddr_link; |
||||
ret = pico_socket_setoption(sk_udp, PICO_IP_ADD_MEMBERSHIP, &mreq); |
||||
ret = pico_socket_setoption(sk_udp, PICO_IP_DROP_MEMBERSHIP, &mreq) |
||||
\end{verbatim} |
||||
|
||||
|
||||
\subsection{pico$\_$socket$\_$getoption} |
||||
|
||||
\subsubsection*{Description} |
||||
Function used to get socket options. |
||||
|
||||
\subsubsection*{Function prototype} |
||||
\begin{verbatim} |
||||
int pico_socket_getoption(struct pico_socket *s, int option, void *value); |
||||
\end{verbatim} |
||||
|
||||
\subsubsection*{Parameters} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{s} - Pointer to socket of type \texttt{struct pico$\_$socket} |
||||
\item \texttt{option} - Option to be set (see further for all options) |
||||
\item \texttt{value} - Value of option (void pointer) |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Available socket options} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$TCP$\_$NODELAY} - Nagle algorithm, \texttt{value} casted to \texttt{(int *)} (0 = disabled, 1 = enabled) |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$RCVBUF} - Read current receive buffer size for the socket |
||||
\item \texttt{PICO$\_$SOCKET$\_$OPT$\_$SNDBUF} - Read current receive buffer size for the socket |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$IF} - (Not supported) Link multicast datagrams are sent from |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$TTL} - TTL (0-255) of multicast datagrams |
||||
\item \texttt{PICO$\_$IP$\_$MULTICAST$\_$LOOP} - Loop back a copy of an outgoing multicast datagram, as long as it is a member of the multicast group, or not. |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Return value} |
||||
On success, this call returns 0 after a succesfull getting of socket option. The value of |
||||
the option is written to \texttt{value}. |
||||
On error, -1 is returned, and \texttt{pico$\_$err} is set appropriately. |
||||
|
||||
\subsubsection*{Errors} |
||||
\begin{itemize}[noitemsep] |
||||
\item \texttt{PICO$\_$ERR$\_$EINVAL} - invalid argument |
||||
\end{itemize} |
||||
|
||||
\subsubsection*{Example} |
||||
\begin{verbatim} |
||||
ret = pico_socket_getoption(sk_tcp, PICO_TCP_NODELAY, &stat); |
||||
|
||||
uint8_t ttl = 0; |
||||
ret = pico_socket_getoption(sk_udp, PICO_IP_MULTICAST_TTL, &ttl); |
||||
|
||||
uint8_t loop = 0; |
||||
ret = pico_socket_getoption(sk_udp, PICO_IP_MULTICAST_LOOP, &loop); |
||||
\end{verbatim} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue