aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorng0 <ng0@infotropique.org>2017-09-03 15:59:10 +0000
committerng0 <ng0@infotropique.org>2017-09-03 15:59:10 +0000
commite611bc0456f78032d43c775afb35bfb31461483a (patch)
tree1e037f924756f6b81e56f690512625ee0aeea4d7 /doc
parent20c4a27a2ac99e9fb900722fe28242b06393cf8a (diff)
downloadgnunet-e611bc0456f78032d43c775afb35bfb31461483a.tar.gz
gnunet-e611bc0456f78032d43c775afb35bfb31461483a.zip
gnunet-c-tutorial: Some @file{} changes.
Diffstat (limited to 'doc')
-rw-r--r--doc/gnunet-c-tutorial.texi88
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
264will replace the default settings: 264will replace the default settings:
265@example 265@example
266[PATHS] 266[PATHS]
267GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data 267GNUNET_HOME = ~/gnunet1/ # Use this directory to store GNUnet data
268[hostlist] 268[hostlist]
269SERVERS = # prevent bootstrapping 269SERVERS = # 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
279You interact with the ARM service using the gnunet-arm tool. 279You interact with the ARM service using the gnunet-arm tool.
280GNUnet can then be started with gnunet-arm -s and stopped with 280GNUnet can then be started with gnunet-arm -s and stopped with
281gnunet-arm -e. An additional service not automatically started 281gnunet-arm -e. An additional service not automatically started
282can be started using gnunet-arm -i <service name> and stopped 282can be started using @command{gnunet-arm -i <service name>} and stopped
283using gnunet-arm -k <servicename>. 283using @command{gnunet-arm -k <servicename>}.
284 284
285Once you have started your peer, you can use many other GNUnet commands 285Once you have started your peer, you can use many other GNUnet commands
286to interact with it. For example, you can run: 286to interact with it. For example, you can run:
@@ -329,13 +329,13 @@ Section sec:testbed.
329We will now start a second peer on your machine. 329We will now start a second peer on your machine.
330For the second peer, you will need to manually create a modified 330For the second peer, you will need to manually create a modified
331configuration file to avoid conflicts with ports and directories. 331configuration file to avoid conflicts with ports and directories.
332A peers configuration file is by default located in ~/.gnunet/gnunet.conf. 332A peers configuration file is by default located in @file{~/.gnunet/gnunet.conf}.
333This file is typically very short or even empty as only the differences to the 333This file is typically very short or even empty as only the differences to the
334defaults need to be specified. The defaults are located in 334defaults need to be specified. The defaults are located in
335many files in the $PREFIX/share/gnunet/config.d directory. 335many files in the @file{$PREFIX/share/gnunet/config.d} directory.
336 336
337To configure the second peer, use the files 337To 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
339configuration file: 339configuration 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}
353to a fresh, unique value. Make sure that the PORT numbers stay 353to a fresh, unique value. Make sure that the PORT numbers stay
354below 65536. From now on, whenever you interact with the second 354below 65536. From now on, whenever you interact with the second
355peer, you need to specify -c peer2.conf as an additional 355peer, you need to specify @command{-c peer2.conf} as an additional
356command line argument. 356command line argument.
357 357
358Now, generate the 2nd peer's private key: 358Now, 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
419Check that they are connected using {\tt gnunet-core -c peer1.conf}, which should give you the other peer's 419Check that they are connected using @command{gnunet-core -c peer1.conf},
420peer identity: 420which 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
423Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG' 423Peer `9TVUCS8P5A7ILLBGO6 [...shortened...] 1KNBJ4NGCHP3JPVULDG'
@@ -433,7 +433,7 @@ possible to run around tens of peers without drastically increasing the load on
433system. 433system.
434 434
435The testbed service can be access through its API 435The 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
437managing a group of peers. It also provides a helper function 437managing 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
439environment on a single host. 439environment on a single host.
@@ -446,7 +446,7 @@ and assigns the ports in configurations only if they are free.
446 446
447Additionally, the testbed service also reads its options from the same 447Additionally, the testbed service also reads its options from the same
448configuration file. Various available options and details about them can be 448configuration file. Various available options and details about them can be
449found in the testbed default configuration file \texttt{src/testbed/testbed.conf}. 449found in the testbed default configuration file @file{src/testbed/testbed.conf}.
450 450
451With the testbed API, a sample test case can be structured as follows: 451With 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}
455The source code for the above listing can be found at 455The 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}
457or in the {\tt doc/} folder of your repository check-out. 457or in the @file{doc/} folder of your repository check-out.
458After installing GNUnet, the above source code can be compiled as: 458After 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
466The \texttt{CPPFLAGS} and \texttt{LDFLAGS} are necessary if GNUnet is installed 466The \texttt{CPPFLAGS} and \texttt{LDFLAGS} are necessary if GNUnet is installed
467into a different directory other than \texttt{/usr/local}. 467into a different directory other than @file{/usr/local}.
468 468
469All of testbed API's peer management functions treat management actions as 469All of testbed API's peer management functions treat management actions as
470operations and return operation handles. It is expected that the operations 470operations 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
507Exercise: Find out how many peers you can run on your system. 507Exercise: Find out how many peers you can run on your system.
508 508
509Exercise: Find out how to create a 2D torus topology by changing the 509Exercise: 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} 510options in the configuration file. See @uref{https://gnunet.org/supported-topologies}
511 Then use the DHT API to store and retrieve values in the 511Then use the DHT API to store and retrieve values in the
512 network. 512network.
513 513
514 514
515@section Developing Applications 515@section Developing Applications
516 516
517@subsection gnunet-ext} 517@subsection gnunet-ext
518To develop a new peer-to-peer application or to extend GNUnet we provide 518To develop a new peer-to-peer application or to extend GNUnet we provide
519a template build system for writing GNUnet extensions in C. It can be 519a template build system for writing GNUnet extensions in C. It can be
520obtained as follows: 520obtained as follows:
@@ -556,13 +556,13 @@ In addition the ext systems provides:
556@subsection Adapting the Template 556@subsection Adapting the Template
557 557
558The first step for writing any extension with a new service is to 558The first step for writing any extension with a new service is to
559ensure that the {\tt ext.conf.in} file contains entries for the 559ensure 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
561the service. 561the service.
562 562
563If you want to adapt the template rename the {\tt ext.conf.in} to match your 563If you want to adapt the template rename the @file{ext.conf.in} to match your
564services name, you have to modify the \texttt{AC\_OUTPUT} section in {\tt configure.ac} 564services name, you have to modify the \texttt{AC\_OUTPUT} section in @file{configure.ac}
565in the \texttt{gnunet-ext} root. 565in 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
658decide on an API for the library. Typical API calls include 658decide on an API for the library. Typical API calls include
659connecting to the service, performing application-specific requests 659connecting to the service, performing application-specific requests
660and cleaning up. Many examples for such service APIs can be found 660and cleaning up. Many examples for such service APIs can be found
661in the {\tt gnunet/src/include/gnunet\_*\_service.h} files. 661in the @file{gnunet/src/include/gnunet\_*\_service.h} files.
662 662
663Then, a client-service protocol needs to be designed. This typically 663Then, a client-service protocol needs to be designed. This typically
664involves defining various message formats in a header that will be 664involves 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
670format (and thus should be read using {\tt ntohl} and similar 670format (and thus should be read using {\tt ntohl} and similar
671functions and written using {\tt htonl} and similar functions). 671functions and written using {\tt htonl} and similar functions).
672Unique message types must be defined for each message struct in the 672Unique 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
674file). 674file).
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
717Existing message types are defined in {\tt gnunet\_protocols.h}\\ 717Existing message types are defined in @file{gnunet\_protocols.h}\\
718A common way to create a message is with an envelope: 718A 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);
731Exercise: Define a message struct that includes a 32-bit 731Exercise: Define a message struct that includes a 32-bit
732unsigned integer in addition to the standard GNUnet MessageHeader. 732unsigned integer in addition to the standard GNUnet MessageHeader.
733Add a C struct and define a fresh protocol number for your message. 733Add 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|)} 734Protocol numbers in gnunet-ext are defined in @file{gnunet-ext/src/include/gnunet_protocols_ext.h}
735 735
736Exercise: Find out how you can determine the number of messages in a message queue.} 736Exercise: 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
822New services are placed in their own subdirectory under {\tt gnunet/src}. 822New services are placed in their own subdirectory under @file{gnunet/src}.
823This subdirectory should contain the API implementation file {\tt SERVICE\_api.c}, 823This subdirectory should contain the API implementation file @file{SERVICE\_api.c},
824the description of the client-service protocol {\tt SERVICE.h} and P2P protocol 824the 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
827and configuration files. 827and 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
1229plugin. The DHT uses the block plugin to ensure that only well-formed 1229plugin. The DHT uses the block plugin to ensure that only well-formed
1230requests and replies are transmitted over the network. 1230requests and replies are transmitted over the network.
1231 1231
1232The block plugin should be put in a file {\tt 1232The 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 1233in the service's respective directory. The
1234mandatory functions that need to be implemented for a block plugin are 1234mandatory functions that need to be implemented for a block plugin are
1235described in the following sections. 1235described in the following sections.
1236 1236
@@ -1238,7 +1238,7 @@ described in the following sections.
1238 1238
1239The evaluate function should validate a reply or a request. It returns 1239The evaluate function should validate a reply or a request. It returns
1240a {\tt GNUNET\_BLOCK\_EvaluationResult}, which is an enumeration. All 1240a {\tt GNUNET\_BLOCK\_EvaluationResult}, which is an enumeration. All
1241possible answers are in {\tt gnunet\_block\_lib.h}. The function will 1241possible answers are in @file{gnunet\_block\_lib.h}. The function will
1242be called with a {\tt reply\_block} argument of {\tt NULL} for 1242be called with a {\tt reply\_block} argument of {\tt NULL} for
1243requests. Note that depending on how {\tt evaluate} is called, only 1243requests. Note that depending on how {\tt evaluate} is called, only
1244some of the possible return values are valid. The specific meaning of 1244some of the possible return values are valid. The specific meaning of
@@ -1265,8 +1265,8 @@ block_plugin_SERVICE_evaluate (void *cls,
1265 1265
1266Note that it is mandatory to detect duplicate replies in this function 1266Note that it is mandatory to detect duplicate replies in this function
1267and return the respective status code. Duplicate detection is 1267and return the respective status code. Duplicate detection is
1268typically done using the Bloom filter block group provided by {\tt 1268typically 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
1270circle in the network. 1270circle 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
1431Even if services are managed by {\tt gnunet-arm}, you can start them with 1431Even 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
1433to your configuration file to start the DHT service in a {\tt gdb} session in a 1433to your configuration file to start the DHT service in a @command{gdb} session in a
1434fresh {\tt xterm}: 1434fresh @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
1459You should also probably enable the creation of core files, by setting 1459You 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}.
1461Then you can investigate the core dumps with {\tt gdb}, which is often 1461Then you can investigate the core dumps with @command{gdb}, which is often
1462the fastest method to find simple errors. 1462the fastest method to find simple errors.
1463 1463
1464Exercise: Add a memory leak to your service and obtain a trace 1464Exercise: Add a memory leak to your service and obtain a trace
1465pointing to the leak using {\tt valgrind} while running the service 1465pointing to the leak using @command{valgrind} while running the service
1466from {\tt gnunet-service-arm}.} 1466from @command{gnunet-service-arm}.
1467 1467
1468@bye 1468@bye