VirtualBox

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

Last change on this file since 28800 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1/** $Id: vbox-libdlpi.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * Dynamically load libdpli & symbols on Solaris hosts, Internal header.
4 */
5
6/*
7 * Copyright (C) 2008 Oracle Corporation
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
18#include "vbox-libdlpi.h"
19
20#include <iprt/err.h>
21#include <iprt/ldr.h>
22
23/**
24 * Global pointer to the libdlpi module. This should only be set once all needed libraries
25 * and symbols have been successfully loaded.
26 */
27static RTLDRMOD g_hLibDlpi = NULL;
28
29/**
30 * Whether we have tried to load libdlpi yet. This flag should only be set
31 * to "true" after we have either loaded both libraries and all symbols which we need,
32 * or failed to load something and unloaded.
33 */
34static bool g_fCheckedForLibDlpi = false;
35
36/** All the symbols we need from libdlpi.
37 * @{
38 */
39int (*g_pfnLibDlpiOpen)(const char *, dlpi_handle_t *, uint_t);
40void (*g_pfnLibDlpiClose)(dlpi_handle_t);
41int (*g_pfnLibDlpiInfo)(dlpi_handle_t, dlpi_info_t *, uint_t);
42int (*g_pfnLibDlpiBind)(dlpi_handle_t, uint_t, uint_t *);
43int (*g_pfnLibDlpiSetPhysAddr)(dlpi_handle_t, uint_t, const void *, size_t);
44int (*g_pfnLibDlpiPromiscon)(dlpi_handle_t, uint_t);
45int (*g_pfnLibDlpiRecv)(dlpi_handle_t, void *, size_t *, void *, size_t *, int, dlpi_recvinfo_t *);
46int (*g_pfnLibDlpiFd)(dlpi_handle_t);
47/** @} */
48
49bool VBoxLibDlpiFound(void)
50{
51 RTLDRMOD hLibDlpi;
52
53 if (g_hLibDlpi && g_fCheckedForLibDlpi)
54 return true;
55 if (g_fCheckedForLibDlpi)
56 return false;
57 if (!RT_SUCCESS(RTLdrLoad(LIB_DLPI, &hLibDlpi)))
58 return false;
59 if ( RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_open", (void **)&g_pfnLibDlpiOpen))
60 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_close", (void **)&g_pfnLibDlpiClose))
61 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_info", (void **)&g_pfnLibDlpiInfo))
62 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_bind", (void **)&g_pfnLibDlpiBind))
63 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_promiscon", (void **)&g_pfnLibDlpiPromiscon))
64 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_set_physaddr", (void **)&g_pfnLibDlpiSetPhysAddr))
65 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_recv", (void **)&g_pfnLibDlpiRecv))
66 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_fd", (void **)&g_pfnLibDlpiFd))
67 )
68 {
69 g_hLibDlpi = hLibDlpi;
70 g_fCheckedForLibDlpi = true;
71 return true;
72 }
73 else
74 {
75 RTLdrClose(hLibDlpi);
76 g_fCheckedForLibDlpi = true;
77 return false;
78 }
79}
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