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

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

unify interface API

  • introduce new interfaces
  • unify location service clients to always expect service ID as the second argument
  • remove obsolete methods that take explicit exchange management arguments (first phase)
  • use interfaces in device drivers, devman, location service, logger, inet
  • 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
46int dhcp_init(void)
47{
48 service_id_t dhcp_svc;
49 int 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
66int dhcp_link_add(sysarg_t link_id)
67{
68 async_exch_t *exch = async_exchange_begin(dhcp_sess);
69
70 int rc = async_req_1_0(exch, DHCP_LINK_ADD, link_id);
71 async_exchange_end(exch);
72
73 return rc;
74}
75
76int dhcp_link_remove(sysarg_t link_id)
77{
78 async_exch_t *exch = async_exchange_begin(dhcp_sess);
79
80 int rc = async_req_1_0(exch, DHCP_LINK_REMOVE, link_id);
81 async_exchange_end(exch);
82
83 return rc;
84}
85
86int dhcp_discover(sysarg_t link_id)
87{
88 async_exch_t *exch = async_exchange_begin(dhcp_sess);
89
90 int 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.