Philippe Reynes | 6ec70bc | 2020-09-18 14:13:00 +0200 | [diff] [blame] | 1 | Udp framework |
| 2 | |
| 3 | The udp framework is build on top of network framework and is designed |
| 4 | to define new protocol or new command based on udp without modifying |
| 5 | the network framework. |
| 6 | |
| 7 | The udp framework define a function udp_loop that take as argument |
| 8 | a structure udp_ops (defined in include/net/udp.h) : |
| 9 | |
| 10 | struct udp_ops { |
| 11 | int (*prereq)(void *data); |
| 12 | int (*start)(void *data); |
| 13 | void *data; |
| 14 | }; |
| 15 | |
| 16 | The callback prereq define if all the requirements are |
| 17 | valid before running the network/udp loop. |
| 18 | |
| 19 | The callback start define the first step in the network/udp loop, |
| 20 | and it may also be used to configure a timemout and udp handler. |
| 21 | |
| 22 | The pointer data is used to store private data that |
| 23 | could be used by both callback. |
| 24 | |
| 25 | A simple example to use this framework: |
| 26 | |
| 27 | static struct udp_ops udp_ops = { |
| 28 | .prereq = wmp_prereq, |
| 29 | .start = wmp_start, |
| 30 | .data = NULL, |
| 31 | }; |
| 32 | |
| 33 | ... |
| 34 | |
| 35 | err = udp_loop(&udp_ops); |