diff options
author | ng0 <ng0@infotropique.org> | 2017-09-03 15:59:10 +0000 |
---|---|---|
committer | ng0 <ng0@infotropique.org> | 2017-09-03 15:59:10 +0000 |
commit | e611bc0456f78032d43c775afb35bfb31461483a (patch) | |
tree | 1e037f924756f6b81e56f690512625ee0aeea4d7 /doc | |
parent | 20c4a27a2ac99e9fb900722fe28242b06393cf8a (diff) | |
download | gnunet-e611bc0456f78032d43c775afb35bfb31461483a.tar.gz gnunet-e611bc0456f78032d43c775afb35bfb31461483a.zip |
gnunet-c-tutorial: Some @file{} changes.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/gnunet-c-tutorial.texi | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/doc/gnunet-c-tutorial.texi b/doc/gnunet-c-tutorial.texi index a6d46da31..e157eeceb 100644 --- a/doc/gnunet-c-tutorial.texi +++ b/doc/gnunet-c-tutorial.texi | |||
@@ -264,9 +264,9 @@ network since this could lead to confusing output. This modifications | |||
264 | will replace the default settings: | 264 | will replace the default settings: |
265 | @example | 265 | @example |
266 | [PATHS] | 266 | [PATHS] |
267 | GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data | 267 | GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data |
268 | [hostlist] | 268 | [hostlist] |
269 | SERVERS = # prevent bootstrapping | 269 | SERVERS = # prevent bootstrapping |
270 | @end example | 270 | @end example |
271 | 271 | ||
272 | @subsection Start a peer | 272 | @subsection Start a peer |
@@ -279,8 +279,8 @@ ARM starts, stops and even restarts services automatically or on demand when a c | |||
279 | You interact with the ARM service using the gnunet-arm tool. | 279 | You interact with the ARM service using the gnunet-arm tool. |
280 | GNUnet can then be started with gnunet-arm -s and stopped with | 280 | GNUnet can then be started with gnunet-arm -s and stopped with |
281 | gnunet-arm -e. An additional service not automatically started | 281 | gnunet-arm -e. An additional service not automatically started |
282 | can be started using gnunet-arm -i <service name> and stopped | 282 | can be started using @command{gnunet-arm -i <service name>} and stopped |
283 | using gnunet-arm -k <servicename>. | 283 | using @command{gnunet-arm -k <servicename>}. |
284 | 284 | ||
285 | Once you have started your peer, you can use many other GNUnet commands | 285 | Once you have started your peer, you can use many other GNUnet commands |
286 | to interact with it. For example, you can run: | 286 | to interact with it. For example, you can run: |
@@ -329,13 +329,13 @@ Section sec:testbed. | |||
329 | We will now start a second peer on your machine. | 329 | We will now start a second peer on your machine. |
330 | For the second peer, you will need to manually create a modified | 330 | For the second peer, you will need to manually create a modified |
331 | configuration file to avoid conflicts with ports and directories. | 331 | configuration file to avoid conflicts with ports and directories. |
332 | A peers configuration file is by default located in ~/.gnunet/gnunet.conf. | 332 | A peers configuration file is by default located in @file{~/.gnunet/gnunet.conf}. |
333 | This file is typically very short or even empty as only the differences to the | 333 | This file is typically very short or even empty as only the differences to the |
334 | defaults need to be specified. The defaults are located in | 334 | defaults need to be specified. The defaults are located in |
335 | many files in the $PREFIX/share/gnunet/config.d directory. | 335 | many files in the @file{$PREFIX/share/gnunet/config.d} directory. |
336 | 336 | ||
337 | To configure the second peer, use the files | 337 | To configure the second peer, use the files |
338 | $PREFIX/share/gnunet/config.d as a template for your main | 338 | @file{$PREFIX/share/gnunet/config.d} as a template for your main |
339 | configuration file: | 339 | configuration file: |
340 | @example | 340 | @example |
341 | $ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf | 341 | $ cat $PREFIX/share/gnunet/config.d/*.conf > peer2.conf |
@@ -352,7 +352,7 @@ Now you have to edit peer2.conf and change: | |||
352 | \end{itemize} | 352 | \end{itemize} |
353 | to a fresh, unique value. Make sure that the PORT numbers stay | 353 | to a fresh, unique value. Make sure that the PORT numbers stay |
354 | below 65536. From now on, whenever you interact with the second | 354 | below 65536. From now on, whenever you interact with the second |
355 | peer, you need to specify -c peer2.conf as an additional | 355 | peer, you need to specify @command{-c peer2.conf} as an additional |
356 | command line argument. | 356 | command line argument. |
357 | 357 | ||
358 | Now, generate the 2nd peer's private key: | 358 | Now, generate the 2nd peer's private key: |
@@ -416,8 +416,8 @@ If you want to use the \texttt{peerinfo} tool to connect your peers, you should: | |||
416 | \item{Give the output to the second peer by running {\tt gnunet-peerinfo -c peer2.conf -p '<output>'}} | 416 | \item{Give the output to the second peer by running {\tt gnunet-peerinfo -c peer2.conf -p '<output>'}} |
417 | \end{itemize} | 417 | \end{itemize} |
418 | 418 | ||
419 | Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's | 419 | Check that they are connected using @command{gnunet-core -c peer1.conf}, |
420 | peer identity: | 420 | which should give you the other peer's peer identity: |
421 | @example | 421 | @example |
422 | $ gnunet-core -c peer1.conf | 422 | $ gnunet-core -c peer1.conf |
423 | Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' | 423 | Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' |
@@ -433,7 +433,7 @@ possible to run around tens of peers without drastically increasing the load on | |||
433 | system. | 433 | system. |
434 | 434 | ||
435 | The testbed service can be access through its API | 435 | The testbed service can be access through its API |
436 | \texttt{include/gnunet\_testbed\_service.h}. The API provides many routines for | 436 | @file{include/gnunet\_testbed\_service.h}. The API provides many routines for |
437 | managing a group of peers. It also provides a helper function | 437 | managing a group of peers. It also provides a helper function |
438 | \texttt{GNUNET\_TESTBED\_test\_run()} to quickly setup a minimalistic testing | 438 | \texttt{GNUNET\_TESTBED\_test\_run()} to quickly setup a minimalistic testing |
439 | environment on a single host. | 439 | environment on a single host. |
@@ -446,7 +446,7 @@ and assigns the ports in configurations only if they are free. | |||
446 | 446 | ||
447 | Additionally, the testbed service also reads its options from the same | 447 | Additionally, the testbed service also reads its options from the same |
448 | configuration file. Various available options and details about them can be | 448 | configuration file. Various available options and details about them can be |
449 | found in the testbed default configuration file \texttt{src/testbed/testbed.conf}. | 449 | found in the testbed default configuration file @file{src/testbed/testbed.conf}. |
450 | 450 | ||
451 | With the testbed API, a sample test case can be structured as follows: | 451 | With the testbed API, a sample test case can be structured as follows: |
452 | % <lynX> Is there a way to pick a more readable font for this include? | 452 | % <lynX> Is there a way to pick a more readable font for this include? |
@@ -454,7 +454,7 @@ With the testbed API, a sample test case can be structured as follows: | |||
454 | \lstinputlisting{testbed_test.c} | 454 | \lstinputlisting{testbed_test.c} |
455 | The source code for the above listing can be found at | 455 | The source code for the above listing can be found at |
456 | @uref{https://gnunet.org/git/gnunet.git/tree/doc/testbed_test.c} | 456 | @uref{https://gnunet.org/git/gnunet.git/tree/doc/testbed_test.c} |
457 | or in the {\tt doc/} folder of your repository check-out. | 457 | or in the @file{doc/} folder of your repository check-out. |
458 | After installing GNUnet, the above source code can be compiled as: | 458 | After installing GNUnet, the above source code can be compiled as: |
459 | @example | 459 | @example |
460 | $ export CPPFLAGS="-I/path/to/gnunet/headers" | 460 | $ export CPPFLAGS="-I/path/to/gnunet/headers" |
@@ -464,7 +464,7 @@ $ touch template.conf # Generate (empty) configuration | |||
464 | $ ./testbed-test # run it (press CTRL-C to stop) | 464 | $ ./testbed-test # run it (press CTRL-C to stop) |
465 | @end example | 465 | @end example |
466 | The \texttt{CPPFLAGS} and \texttt{LDFLAGS} are necessary if GNUnet is installed | 466 | The \texttt{CPPFLAGS} and \texttt{LDFLAGS} are necessary if GNUnet is installed |
467 | into a different directory other than \texttt{/usr/local}. | 467 | into a different directory other than @file{/usr/local}. |
468 | 468 | ||
469 | All of testbed API's peer management functions treat management actions as | 469 | All of testbed API's peer management functions treat management actions as |
470 | operations and return operation handles. It is expected that the operations | 470 | operations and return operation handles. It is expected that the operations |
@@ -507,14 +507,14 @@ disconnect from the service with the provided service handle (\texttt{op\_result | |||
507 | Exercise: Find out how many peers you can run on your system. | 507 | Exercise: Find out how many peers you can run on your system. |
508 | 508 | ||
509 | Exercise: Find out how to create a 2D torus topology by changing the | 509 | Exercise: Find out how to create a 2D torus topology by changing the |
510 | options in the configuration file. See @uref{https://gnunet.org/supported-topologies} | 510 | options in the configuration file. See @uref{https://gnunet.org/supported-topologies} |
511 | Then use the DHT API to store and retrieve values in the | 511 | Then use the DHT API to store and retrieve values in the |
512 | network. | 512 | network. |
513 | 513 | ||
514 | 514 | ||
515 | @section Developing Applications | 515 | @section Developing Applications |
516 | 516 | ||
517 | @subsection gnunet-ext} | 517 | @subsection gnunet-ext |
518 | To develop a new peer-to-peer application or to extend GNUnet we provide | 518 | To develop a new peer-to-peer application or to extend GNUnet we provide |
519 | a template build system for writing GNUnet extensions in C. It can be | 519 | a template build system for writing GNUnet extensions in C. It can be |
520 | obtained as follows: | 520 | obtained as follows: |
@@ -556,13 +556,13 @@ In addition the ext systems provides: | |||
556 | @subsection Adapting the Template | 556 | @subsection Adapting the Template |
557 | 557 | ||
558 | The first step for writing any extension with a new service is to | 558 | The first step for writing any extension with a new service is to |
559 | ensure that the {\tt ext.conf.in} file contains entries for the | 559 | ensure that the @file{ext.conf.in} file contains entries for the |
560 | \texttt{UNIXPATH}, \texttt{PORT} and \texttt{BINARY} for the service in a section named after | 560 | \texttt{UNIXPATH}, \texttt{PORT} and \texttt{BINARY} for the service in a section named after |
561 | the service. | 561 | the service. |
562 | 562 | ||
563 | If you want to adapt the template rename the {\tt ext.conf.in} to match your | 563 | If you want to adapt the template rename the @file{ext.conf.in} to match your |
564 | services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac} | 564 | services name, you have to modify the \texttt{AC\_OUTPUT} section in @file{configure.ac} |
565 | in the \texttt{gnunet-ext} root. | 565 | in the @file{gnunet-ext} root. |
566 | 566 | ||
567 | @section Writing a Client Application | 567 | @section Writing a Client Application |
568 | 568 | ||
@@ -658,7 +658,7 @@ The first and most important step in writing a client library is to | |||
658 | decide on an API for the library. Typical API calls include | 658 | decide on an API for the library. Typical API calls include |
659 | connecting to the service, performing application-specific requests | 659 | connecting to the service, performing application-specific requests |
660 | and cleaning up. Many examples for such service APIs can be found | 660 | and cleaning up. Many examples for such service APIs can be found |
661 | in the {\tt gnunet/src/include/gnunet\_*\_service.h} files. | 661 | in the @file{gnunet/src/include/gnunet\_*\_service.h} files. |
662 | 662 | ||
663 | Then, a client-service protocol needs to be designed. This typically | 663 | Then, a client-service protocol needs to be designed. This typically |
664 | involves defining various message formats in a header that will be | 664 | involves defining various message formats in a header that will be |
@@ -670,7 +670,7 @@ convention, all fields in IPC (and P2P) messages must be in big-endian | |||
670 | format (and thus should be read using {\tt ntohl} and similar | 670 | format (and thus should be read using {\tt ntohl} and similar |
671 | functions and written using {\tt htonl} and similar functions). | 671 | functions and written using {\tt htonl} and similar functions). |
672 | Unique message types must be defined for each message struct in the | 672 | Unique message types must be defined for each message struct in the |
673 | {\tt gnunet\_protocols.h} header (or an extension-specific include | 673 | @file{gnunet\_protocols.h} header (or an extension-specific include |
674 | file). | 674 | file). |
675 | 675 | ||
676 | @subsubsection Connecting to the Service} | 676 | @subsubsection Connecting to the Service} |
@@ -714,7 +714,7 @@ struct GNUNET_MessageHeader | |||
714 | }; | 714 | }; |
715 | @end example | 715 | @end example |
716 | 716 | ||
717 | Existing message types are defined in {\tt gnunet\_protocols.h}\\ | 717 | Existing message types are defined in @file{gnunet\_protocols.h}\\ |
718 | A common way to create a message is with an envelope: | 718 | A common way to create a message is with an envelope: |
719 | 719 | ||
720 | \lstset{language=C} | 720 | \lstset{language=C} |
@@ -731,7 +731,7 @@ GNUNET_mq_send (mq, env); | |||
731 | Exercise: Define a message struct that includes a 32-bit | 731 | Exercise: Define a message struct that includes a 32-bit |
732 | unsigned integer in addition to the standard GNUnet MessageHeader. | 732 | unsigned integer in addition to the standard GNUnet MessageHeader. |
733 | Add a C struct and define a fresh protocol number for your message. | 733 | Add a C struct and define a fresh protocol number for your message. |
734 | (Protocol numbers in gnunet-ext are defined in \lstinline|gnunet-ext/src/include/gnunet_protocols_ext.h|)} | 734 | Protocol numbers in gnunet-ext are defined in @file{gnunet-ext/src/include/gnunet_protocols_ext.h} |
735 | 735 | ||
736 | Exercise: Find out how you can determine the number of messages in a message queue.} | 736 | Exercise: Find out how you can determine the number of messages in a message queue.} |
737 | 737 | ||
@@ -819,11 +819,11 @@ implement the corresponding service. | |||
819 | 819 | ||
820 | @subsection Code Placement} | 820 | @subsection Code Placement} |
821 | 821 | ||
822 | New services are placed in their own subdirectory under {\tt gnunet/src}. | 822 | New services are placed in their own subdirectory under @file{gnunet/src}. |
823 | This subdirectory should contain the API implementation file {\tt SERVICE\_api.c}, | 823 | This subdirectory should contain the API implementation file @file{SERVICE\_api.c}, |
824 | the description of the client-service protocol {\tt SERVICE.h} and P2P protocol | 824 | the description of the client-service protocol @file{SERVICE.h} and P2P protocol |
825 | {\tt SERVICE\_protocol.h}, the implementation of the service itself | 825 | @file{SERVICE\_protocol.h}, the implementation of the service itself |
826 | {\tt gnunet-service-SERVICE.h} and several files for tests, including test code | 826 | @file{gnunet-service-SERVICE.h} and several files for tests, including test code |
827 | and configuration files. | 827 | and configuration files. |
828 | 828 | ||
829 | @subsection Starting a Service} | 829 | @subsection Starting a Service} |
@@ -1229,8 +1229,8 @@ In order to store data in the DHT, it is necessary to provide a block | |||
1229 | plugin. The DHT uses the block plugin to ensure that only well-formed | 1229 | plugin. The DHT uses the block plugin to ensure that only well-formed |
1230 | requests and replies are transmitted over the network. | 1230 | requests and replies are transmitted over the network. |
1231 | 1231 | ||
1232 | The block plugin should be put in a file {\tt | 1232 | The block plugin should be put in a file @file{plugin\_block\_SERVICE.c} |
1233 | plugin\_block\_SERVICE.c} in the service's respective directory. The | 1233 | in the service's respective directory. The |
1234 | mandatory functions that need to be implemented for a block plugin are | 1234 | mandatory functions that need to be implemented for a block plugin are |
1235 | described in the following sections. | 1235 | described in the following sections. |
1236 | 1236 | ||
@@ -1238,7 +1238,7 @@ described in the following sections. | |||
1238 | 1238 | ||
1239 | The evaluate function should validate a reply or a request. It returns | 1239 | The evaluate function should validate a reply or a request. It returns |
1240 | a {\tt GNUNET\_BLOCK\_EvaluationResult}, which is an enumeration. All | 1240 | a {\tt GNUNET\_BLOCK\_EvaluationResult}, which is an enumeration. All |
1241 | possible answers are in {\tt gnunet\_block\_lib.h}. The function will | 1241 | possible answers are in @file{gnunet\_block\_lib.h}. The function will |
1242 | be called with a {\tt reply\_block} argument of {\tt NULL} for | 1242 | be called with a {\tt reply\_block} argument of {\tt NULL} for |
1243 | requests. Note that depending on how {\tt evaluate} is called, only | 1243 | requests. Note that depending on how {\tt evaluate} is called, only |
1244 | some of the possible return values are valid. The specific meaning of | 1244 | some of the possible return values are valid. The specific meaning of |
@@ -1265,8 +1265,8 @@ block_plugin_SERVICE_evaluate (void *cls, | |||
1265 | 1265 | ||
1266 | Note that it is mandatory to detect duplicate replies in this function | 1266 | Note that it is mandatory to detect duplicate replies in this function |
1267 | and return the respective status code. Duplicate detection is | 1267 | and return the respective status code. Duplicate detection is |
1268 | typically done using the Bloom filter block group provided by {\tt | 1268 | typically done using the Bloom filter block group provided by |
1269 | libgnunetblockgroup.so}. Failure to do so may cause replies to | 1269 | @file{libgnunetblockgroup.so}. Failure to do so may cause replies to |
1270 | circle in the network. | 1270 | circle in the network. |
1271 | 1271 | ||
1272 | @subsubsection Deriving a key from a reply | 1272 | @subsubsection Deriving a key from a reply |
@@ -1428,10 +1428,10 @@ monitor_handle = GNUNET_DHT_monitor_start (dht_handle, | |||
1428 | 1428 | ||
1429 | @section Debugging with gnunet-arm | 1429 | @section Debugging with gnunet-arm |
1430 | 1430 | ||
1431 | Even if services are managed by {\tt gnunet-arm}, you can start them with | 1431 | Even if services are managed by @command{gnunet-arm}, you can start them with |
1432 | {\tt gdb} or {\tt valgrind}. For example, you could add the following lines | 1432 | @command{gdb} or @command{valgrind}. For example, you could add the following lines |
1433 | to your configuration file to start the DHT service in a {\tt gdb} session in a | 1433 | to your configuration file to start the DHT service in a @command{gdb} session in a |
1434 | fresh {\tt xterm}: | 1434 | fresh @command{xterm}: |
1435 | 1435 | ||
1436 | @example | 1436 | @example |
1437 | [dht] | 1437 | [dht] |
@@ -1457,12 +1457,12 @@ running \texttt{configure}. More details about logging can be found under | |||
1457 | @uref{https://gnunet.org/logging}. | 1457 | @uref{https://gnunet.org/logging}. |
1458 | 1458 | ||
1459 | You should also probably enable the creation of core files, by setting | 1459 | You should also probably enable the creation of core files, by setting |
1460 | {\tt ulimit}, and echo'ing 1 into {\tt /proc/sys/kernel/core\_uses\_pid}. | 1460 | {\tt ulimit}, and echo'ing 1 into @file{/proc/sys/kernel/core\_uses\_pid}. |
1461 | Then you can investigate the core dumps with {\tt gdb}, which is often | 1461 | Then you can investigate the core dumps with @command{gdb}, which is often |
1462 | the fastest method to find simple errors. | 1462 | the fastest method to find simple errors. |
1463 | 1463 | ||
1464 | Exercise: Add a memory leak to your service and obtain a trace | 1464 | Exercise: Add a memory leak to your service and obtain a trace |
1465 | pointing to the leak using {\tt valgrind} while running the service | 1465 | pointing to the leak using @command{valgrind} while running the service |
1466 | from {\tt gnunet-service-arm}.} | 1466 | from @command{gnunet-service-arm}. |
1467 | 1467 | ||
1468 | @bye | 1468 | @bye |