source: mainline/uspace/lib/net/include/adt/module_map.h@ 849ed54

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 849ed54 was 849ed54, checked in by Martin Decky <martin@…>, 15 years ago

Networking work:
Split the networking stack into end-user library (libsocket) and two helper libraries (libnet and libnetif).
Don't use over-the-hand compiling and linking, but rather separation of conserns.
There might be still some issues and the non-modular networking architecture is currently broken, but this will be fixed soon.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[21580dd]1/*
2 * Copyright (c) 2009 Lukas Mejdrech
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup net
30 * @{
31 */
32
33/** @file
34 * Character string to module map.
35 */
36
37#ifndef __NET_MODULES_MAP_H__
38#define __NET_MODULES_MAP_H__
39
40#include <task.h>
41
42#include <ipc/services.h>
43
[849ed54]44#include <net_modules.h>
[21580dd]45
[849ed54]46#include <adt/generic_char_map.h>
[21580dd]47
48/** Type definition of the module structure.
49 * @see module_struct
50 */
51typedef struct module_struct module_t;
52
53/** Type definition of the module structure pointer.
54 * @see module_struct
55 */
56typedef module_t * module_ref;
57
58/** Module map.
59 * Sorted by module names.
60 * @see generic_char_map.h
61 */
[aadf01e]62GENERIC_CHAR_MAP_DECLARE(modules, module_t)
[21580dd]63
64/** Module structure.
65 */
66struct module_struct{
67 /** Module task identifier if running.
68 */
[aadf01e]69 task_id_t task_id;
[21580dd]70 /** Module service identifier.
71 */
[aadf01e]72 services_t service;
[21580dd]73 /** Module phone if running and connected.
74 */
[aadf01e]75 int phone;
[21580dd]76 /** Usage counter.
77 */
[aadf01e]78 int usage;
[21580dd]79 /** Module name.
80 */
[aadf01e]81 const char * name;
[21580dd]82 /** Module full path filename.
83 */
[aadf01e]84 const char * filename;
[21580dd]85 /** Connecting function.
86 */
[aadf01e]87 connect_module_t * connect_module;
[21580dd]88};
89
90/** Adds module to the module map.
91 * @param[out] module The module structure added.
92 * @param[in] modules The module map.
93 * @param[in] name The module name.
94 * @param[in] filename The full path filename.
95 * @param[in] service The module service.
96 * @param[in] task_id The module current task identifier. Zero (0) means not running.
97 * @param[in] connect_module The module connecting function.
98 * @returns EOK on success.
99 * @returns ENOMEM if there is not enough memory left.
100 */
[aadf01e]101int add_module(module_ref * module, modules_ref modules, const char * name, const char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module);
[21580dd]102
103/** Searches and returns the specified module.
104 * If the module is not running, the module filaname is spawned.
105 * If the module is not connected, the connect_function is called.
106 * @param[in] modules The module map.
107 * @param[in] name The module name.
108 * @returns The running module found. It does not have to be connected.
109 * @returns NULL if there is no such module.
110 */
[aadf01e]111module_ref get_running_module(modules_ref modules, char * name);
[21580dd]112
113/** Starts the given module.
114 * @param[in] fname The module full or relative path filename.
115 * @returns The new module task identifier on success.
116 * @returns 0 if there is no such module.
117 */
[aadf01e]118task_id_t spawn(const char * fname);
[21580dd]119
120#endif
121
122/** @}
123 */
Note: See TracBrowser for help on using the repository browser.