VirtualBox

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

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

Hopefully working solaris 10 detection.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1/** $Id: vbox-libdlpi.cpp 9112 2008-05-26 10:11:34Z 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/* Solaris 10 and below has no dlpi. */
23#ifndef __SunOS_5.10
24
25#include "vbox-libdlpi.h"
26
27#include <iprt/err.h>
28#include <iprt/ldr.h>
29
30/**
31 * Global pointer to the libdlpi module. This should only be set once all needed libraries
32 * and symbols have been successfully loaded.
33 */
34static RTLDRMOD g_hLibDlpi = NULL;
35
36/**
37 * Whether we have tried to load libdlpi yet. This flag should only be set
38 * to "true" after we have either loaded both libraries and all symbols which we need,
39 * or failed to load something and unloaded.
40 */
41static bool g_fCheckedForLibDlpi = false;
42
43/** All the symbols we need from libdlpi.
44 * @{
45 */
46int (*g_pfnLibDlpiOpen)(const char *, dlpi_handle_t *, uint_t);
47void (*g_pfnLibDlpiClose)(dlpi_handle_t);
48int (*g_pfnLibDlpiInfo)(dlpi_handle_t, dlpi_info_t *, uint_t);
49int (*g_pfnLibDlpiBind)(dlpi_handle_t, uint_t, uint_t *);
50int (*g_pfnLibDlpiSetPhysAddr)(dlpi_handle_t, uint_t, const void *, size_t);
51int (*g_pfnLibDlpiPromiscon)(dlpi_handle_t, uint_t);
52int (*g_pfnLibDlpiRecv)(dlpi_handle_t, void *, size_t *, void *, size_t *, int, dlpi_recvinfo_t *);
53int (*g_pfnLibDlpiFd)(dlpi_handle_t);
54/** @} */
55
56bool VBoxLibDlpiFound(void)
57{
58 RTLDRMOD hLibDlpi;
59
60 if (g_hLibDlpi && g_fCheckedForLibDlpi)
61 return true;
62 if (g_fCheckedForLibDlpi)
63 return false;
64 if (!RT_SUCCESS(RTLdrLoad(LIB_DLPI, &hLibDlpi)))
65 return false;
66 if ( RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_open", (void **)&g_pfnLibDlpiOpen))
67 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_close", (void **)&g_pfnLibDlpiClose))
68 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_info", (void **)&g_pfnLibDlpiInfo))
69 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_bind", (void **)&g_pfnLibDlpiBind))
70 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_promiscon", (void **)&g_pfnLibDlpiPromiscon))
71 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_set_physaddr", (void **)&g_pfnLibDlpiSetPhysAddr))
72 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_recv", (void **)&g_pfnLibDlpiRecv))
73 && RT_SUCCESS(RTLdrGetSymbol(hLibDlpi, "dlpi_fd", (void **)&g_pfnLibDlpiFd))
74 )
75 {
76 g_hLibDlpi = hLibDlpi;
77 g_fCheckedForLibDlpi = true;
78 return true;
79 }
80 else
81 {
82 RTLdrClose(hLibDlpi);
83 g_fCheckedForLibDlpi = true;
84 return false;
85 }
86}
87
88#endif /* __SunOS_5.10 */
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