VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/solaris/vbox-libdlpi.cpp@ 13949

Last change on this file since 13949 was 9124, checked in by vboxsync, 17 years ago

Cleanup of the Solaris 10 detection, reducing ifdef clutter in the C files and avoid using the system namespace.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1/** $Id: vbox-libdlpi.cpp 9124 2008-05-26 13:48:23Z vboxsync $ */
2/** @file
3 * Dynamically load libdpli & symbols on Solaris hosts, Internal header.
4 */
5
6/*
7 * Copyright (C) 2008 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include "vbox-libdlpi.h"
23
24#include <iprt/err.h>
25#include <iprt/ldr.h>
26
27/**
28 * Global pointer to the libdlpi module. This should only be set once all needed libraries
29 * and symbols have been successfully loaded.
30 */
31static RTLDRMOD g_hLibDlpi = NULL;
32
33/**
34 * Whether we have tried to load libdlpi yet. This flag should only be set
35 * to "true" after we have either loaded both libraries and all symbols which we need,
36 * or failed to load something and unloaded.
37 */
38static bool g_fCheckedForLibDlpi = false;
39
40/** All the symbols we need from libdlpi.
41 * @{
42 */
43int (*g_pfnLibDlpiOpen)(const char *, dlpi_handle_t *, uint_t);
44void (*g_pfnLibDlpiClose)(dlpi_handle_t);
45int (*g_pfnLibDlpiInfo)(dlpi_handle_t, dlpi_info_t *, uint_t);
46int (*g_pfnLibDlpiBind)(dlpi_handle_t, uint_t, uint_t *);
47int (*g_pfnLibDlpiSetPhysAddr)(dlpi_handle_t, uint_t, const void *, size_t);
48int (*g_pfnLibDlpiPromiscon)(dlpi_handle_t, uint_t);
49int (*g_pfnLibDlpiRecv)(dlpi_handle_t, void *, size_t *, void *, size_t *, int, dlpi_recvinfo_t *);
50int (*g_pfnLibDlpiFd)(dlpi_handle_t);
51/** @} */
52
53bool VBoxLibDlpiFound(void)
54{
55 RTLDRMOD hLibDlpi;
56
57 if (g_hLibDlpi && g_fCheckedForLibDlpi)
58 return true;
59 if (g_fCheckedForLibDlpi)
60 return false;
61 if (!RT_SUCCESS(RTLdrLoad(LIB_DLPI, &hLibDlpi)))
62 return false;
63 if ( RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_open", (void **)&g_pfnLibDlpiOpen))
64 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_close", (void **)&g_pfnLibDlpiClose))
65 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_info", (void **)&g_pfnLibDlpiInfo))
66 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_bind", (void **)&g_pfnLibDlpiBind))
67 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_promiscon", (void **)&g_pfnLibDlpiPromiscon))
68 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_set_physaddr", (void **)&g_pfnLibDlpiSetPhysAddr))
69 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_recv", (void **)&g_pfnLibDlpiRecv))
70 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_fd", (void **)&g_pfnLibDlpiFd))
71 )
72 {
73 g_hLibDlpi = hLibDlpi;
74 g_fCheckedForLibDlpi = true;
75 return true;
76 }
77 else
78 {
79 RTLdrClose(hLibDlpi);
80 g_fCheckedForLibDlpi = true;
81 return false;
82 }
83}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette