source: mainline/uspace/lib/c/generic/dhcp.c@ a35b458

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a35b458 was b7fd2a0, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * Copyright (c) 2013 Jiri Svoboda
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 libc
30 * @{
31 */
32/** @file
33 */
34
35#include <async.h>
36#include <assert.h>
37#include <errno.h>
38#include <inet/dhcp.h>
39#include <ipc/dhcp.h>
40#include <ipc/services.h>
41#include <loc.h>
42#include <stdlib.h>
43
44static async_sess_t *dhcp_sess = NULL;
45
46errno_t dhcp_init(void)
47{
48 service_id_t dhcp_svc;
49 errno_t rc;
50
51 assert(dhcp_sess == NULL);
52
53 rc = loc_service_get_id(SERVICE_NAME_DHCP, &dhcp_svc,
54 IPC_FLAG_BLOCKING);
55 if (rc != EOK)
56 return ENOENT;
57
58 dhcp_sess = loc_service_connect(dhcp_svc, INTERFACE_DHCP,
59 IPC_FLAG_BLOCKING);
60 if (dhcp_sess == NULL)
61 return ENOENT;
62
63 return EOK;
64}
65
66errno_t dhcp_link_add(sysarg_t link_id)
67{
68 async_exch_t *exch = async_exchange_begin(dhcp_sess);
69
70 errno_t rc = async_req_1_0(exch, DHCP_LINK_ADD, link_id);
71 async_exchange_end(exch);
72
73 return rc;
74}
75
76errno_t dhcp_link_remove(sysarg_t link_id)
77{
78 async_exch_t *exch = async_exchange_begin(dhcp_sess);
79
80 errno_t rc = async_req_1_0(exch, DHCP_LINK_REMOVE, link_id);
81 async_exchange_end(exch);
82
83 return rc;
84}
85
86errno_t dhcp_discover(sysarg_t link_id)
87{
88 async_exch_t *exch = async_exchange_begin(dhcp_sess);
89
90 errno_t rc = async_req_1_0(exch, DHCP_DISCOVER, link_id);
91 async_exchange_end(exch);
92
93 return rc;
94}
95
96/** @}
97 */
Note: See TracBrowser for help on using the repository browser.