NetworkAdapterImpl.cpp revision dc347997cbc5a4093aef762f4f37c9adf21fe1e5
//////////////////////////////////////////////////////////////////////////////// * Initializes the network adapter object. * @param aParent Handle of the parent object. /* Enclose the state transition NotReady->InInit->Ready */ /* default to Am79C973 */ /* generate the MAC address early to guarantee it is the same both after * changing some other property (i.e. after mData.backup()) and after the * subsequent mData.rollback(). */ /* Confirm a successful initialization */ * Initializes the network adapter object given another network adapter object * (a kind of copy constructor). This object shares data with * the object passed as an argument. * @note This object must be destroyed before the original object * it shares data with is destroyed. * @note Locks @a aThat object for reading. /* Enclose the state transition NotReady->InInit->Ready */ /* Confirm a successful initialization */ * Initializes the guest object given another guest object * (a kind of copy constructor). This object makes a private copy of data * of the original object passed as an argument. * @note Locks @a aThat object for reading. /* Enclose the state transition NotReady->InInit->Ready */ /* Confirm a successful initialization */ * Uninitializes the instance and sets the ready flag to FALSE. * Called either from FinalRelease() or by the parent when it gets destroyed. /* Enclose the state transition Ready->InUninit->NotReady */ // INetworkAdapter properties //////////////////////////////////////////////////////////////////////////////// /* the machine needs to be mutable */ /* make sure the value is allowed */ #
endif /* VBOX_WITH_VIRTIO */ tr(
"Invalid network adapter type '%d'"),
// leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ * Are we supposed to generate a MAC? // leave the lock before informing callbacks * Verify given MAC address /* canonicalize hex digits to capital letters */ if (c >=
'a' && c <=
'f')
/** @todo the runtime lacks an ascii lower/upper conv */ /* we only accept capital letters */ if (((c <
'0') || (c >
'9')) &&
((c <
'A') || (c >
'F')))
/* the second digit must have even value for unicast addresses */ if ((i ==
1) && (!!(c &
1) == (c >=
'0' && c <=
'9')))
/* we must have parsed exactly 12 characters */ // leave the lock before informing callbacks // we have left the lock in any case at this point /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ /* if an empty/null string is to be set, internal networking must be tr(
"Empty or null internal network name is not valid"));
// leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks /* the machine needs to be mutable */ // leave the lock before informing callbacks // INetworkAdapter methods //////////////////////////////////////////////////////////////////////////////// /* the machine needs to be mutable */ // Commented this for now as it resets the parameter mData->mNATNetwork // which is essential while changing the Attachment dynamically. // leave the lock before informing callbacks /* If changing the attachment failed then we can't assume * that the previous attachment will attach correctly * and thus return error along with dettaching all /* the machine needs to be mutable */ /* don't do anything if we're already host interface attached */ /* first detach the current attachment */ // Commented this for now as it reset the parameter mData->mHostInterface // which is essential while changing the Attachment dynamically. // leave the lock before informing callbacks /* If changing the attachment failed then we can't assume * that the previous attachment will attach correctly * and thus return error along with dettaching all /* the machine needs to be mutable */ /* don't do anything if we're already internal network attached */ /* first detach the current attachment */ // Commented this for now as it reset the parameter mData->mInternalNetwork // which is essential while changing the Attachment dynamically. /* there must an internal network name */ LogRel ((
"Internal network name not defined, " "setting to default \"intnet\"\n"));
// leave the lock before informing callbacks /* If changing the attachment failed then we can't assume * that the previous attachment will attach correctly * and thus return error along with dettaching all /* the machine needs to be mutable */ /* don't do anything if we're already host interface attached */ /* first detach the current attachment */ // Commented this for now as it reset the parameter mData->mHostInterface // which is essential while changing the Attachment dynamically. // leave the lock before informing callbacks /* If changing the attachment failed then we can't assume * that the previous attachment will attach correctly * and thus return error along with dettaching all /* the machine needs to be mutable */ // leave the lock before informing callbacks // public methods only for internal purposes //////////////////////////////////////////////////////////////////////////////// * Loads settings from the given adapter node. * May be called once right after this object creation. * @param aAdapterNode <Adapter> node. * @note Locks this object for writing. /* Note: we assume that the default values for attributes of optional * nodes are assigned in the Data::Data() constructor and don't do it * here. It implies that this method may only be called after constructing * a new BIOSSettings object while all its data fields are in the default * values. Exceptions are fields whose creation time defaults don't match * values that should be applied when these fields are not explicitly set * in the settings file (for backwards compatibility reasons). This takes * place when a setting of a newly created object must default to A while * the same setting of an object loaded from the old settings file must /* MAC address (can be null) */ /* line speed (defaults to 100 Mbps) */ /* tracing (defaults to false) */ // after loading settings, we are no longer different from the XML on disk * Saves settings to the given adapter node. * Note that the given Adapter node is comletely empty on input. * @param aAdapterNode <Adapter> node. * @note Locks this object for reading. // after saving settings, we are no longer different from the XML on disk * Returns true if any setter method has modified settings of this instance. * @note Locks this object for writing. * @note Locks this object for writing, together with the peer object (also * for writing) if there is one. /* lock both for writing since we modify both (mPeer is "master" so locked /* attach new data to the peer and reshare it */ * @note Locks this object for writing, together with the peer object * represented by @a aThat (locked for reading). /* peer is not modified, lock it for reading (aThat is "master" so locked /* this will back up current data */ #
endif // VBOX_WITH_E1000 /* Set default network adapter for this OS type */ /* Enable and connect the first one adapter to the NAT */ //////////////////////////////////////////////////////////////////////////////// * Worker routine for detach handling. No locking, no notifications. * @note Must be called from under the object's write lock. /* reset handle and device name */ /* reset handle and device name */ * Generates a new unique MAC address based on our vendor ID and * @note Must be called from under the object's write lock or within the init * Our strategy is as follows: the first three bytes are our fixed * vendor ID (080027). The remaining 3 bytes will be taken from the * start of a GUID. This is a fairly safe algorithm. /* vi: set tabstop=4 shiftwidth=4 expandtab: */