5
5
/** @todo r=bird: Cut&Past rules... Please fix DHCP refs! */
8
* Copyright (C) 2009 Oracle Corporation
8
* Copyright (C) 2009-2011 Oracle Corporation
10
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
11
* available from http://www.virtualbox.org. This file is free software;
16
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
/** @page pg_net_dhcp VBoxNetDHCP
21
* Write a few words...
25
19
/*******************************************************************************
27
21
*******************************************************************************/
63
56
/*******************************************************************************
64
57
* Structures and Typedefs *
65
58
*******************************************************************************/
59
static RTGETOPTDEF g_aGetOptDef[] =
61
{ "--name", 'N', RTGETOPT_REQ_STRING },
62
{ "--network", 'n', RTGETOPT_REQ_STRING },
63
{ "--trunk-name", 't', RTGETOPT_REQ_STRING },
64
{ "--trunk-type", 'T', RTGETOPT_REQ_STRING },
65
{ "--mac-address", 'a', RTGETOPT_REQ_MACADDR },
66
{ "--ip-address", 'i', RTGETOPT_REQ_IPV4ADDR },
67
{ "--verbose", 'v', RTGETOPT_REQ_NOTHING },
66
69
VBoxNetBaseService::VBoxNetBaseService()
68
/* numbers from DrvIntNet */
69
m_cbSendBuf = 36 * _1K;
70
m_cbRecvBuf = 218 * _1K;
71
m_hIf = INTNET_HANDLE_INVALID;
75
m_Name = "VBoxNetNAT";
78
72
VBoxNetBaseService::~VBoxNetBaseService()
98
92
m_pSession = NIL_RTR0PTR;
96
int VBoxNetBaseService::init()
98
/* numbers from DrvIntNet */
99
m_cbSendBuf = 36 * _1K;
100
m_cbRecvBuf = 218 * _1K;
101
m_hIf = INTNET_HANDLE_INVALID;
105
m_Name = "VBoxNetNAT";
106
m_Network = "intnet";
107
for(unsigned int i = 0; i < RT_ELEMENTS(g_aGetOptDef); ++i)
108
m_vecOptionDefs.push_back(&g_aGetOptDef[i]);
102
112
* Parse the arguments.
109
119
int VBoxNetBaseService::parseArgs(int argc, char **argv)
111
static const RTGETOPTDEF s_aOptionDefs[] =
113
{ "--name", 'N', RTGETOPT_REQ_STRING },
114
{ "--network", 'n', RTGETOPT_REQ_STRING },
115
{ "--trunk-name", 't', RTGETOPT_REQ_STRING },
116
{ "--trunk-type", 'T', RTGETOPT_REQ_STRING },
117
{ "--mac-address", 'a', RTGETOPT_REQ_MACADDR },
118
{ "--ip-address", 'i', RTGETOPT_REQ_IPV4ADDR },
119
{ "--verbose", 'v', RTGETOPT_REQ_NOTHING },
122
122
RTGETOPTSTATE State;
123
int rc = RTGetOptInit(&State, argc, argv, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0 /*fFlags*/);
123
PRTGETOPTDEF paOptionArray = getOptionsPtr();
124
int rc = RTGetOptInit(&State, argc, argv, paOptionArray, m_vecOptionDefs.size(), 0, 0 /*fFlags*/);
124
125
AssertRCReturn(rc, 49);
125
126
Log2(("BaseService: parseArgs enter\n"));
184
185
RTBldCfgVersion());
185
for (size_t i = 0; i < RT_ELEMENTS(s_aOptionDefs); i++)
186
RTPrintf(" -%c, %s\n", s_aOptionDefs[i].iShort, s_aOptionDefs[i].pszLong);
186
for (unsigned int i = 0; i < m_vecOptionDefs.size(); i++)
187
RTPrintf(" -%c, %s\n", m_vecOptionDefs[i]->iShort, m_vecOptionDefs[i]->pszLong);
187
188
usage(); /* to print Service Specific usage */
191
rc = RTGetOptPrintError(rc, &Val);
192
RTPrintf("Use --help for more information.\n");
192
int rc1 = parseOpt(rc, Val);
195
rc = RTGetOptPrintError(rc, &Val);
196
RTPrintf("Use --help for more information.\n");
202
RTMemFree(paOptionArray);
351
PRTGETOPTDEF VBoxNetBaseService::getOptionsPtr()
353
PRTGETOPTDEF pOptArray = NULL;
354
pOptArray = (PRTGETOPTDEF)RTMemAlloc(sizeof(RTGETOPTDEF) * m_vecOptionDefs.size());
357
for (unsigned int i = 0; i < m_vecOptionDefs.size(); ++i)
359
PRTGETOPTDEF pOpt = m_vecOptionDefs[i];
360
memcpy(&pOptArray[i], m_vecOptionDefs[i], sizeof(RTGETOPTDEF));