3 docCopyright("Rich Collins", 2007)
4 docLicense("BSD revised")
5 docCategory("Networking")
6 docDescription("Interface to network adapter functionality")
9 #include "IoNetworkAdapter.h"
12 #include "OSXMacAddress.h"
13 #include "WindowsMacAddress.h"
15 IoTag
*IoNetworkAdapter_newTag(void *state
)
17 IoTag
*tag
= IoTag_newWithName_("NetworkAdapter");
18 IoTag_state_(tag
, state
);
19 IoTag_cloneFunc_(tag
, (IoTagCloneFunc
*)IoNetworkAdapter_rawClone
);
23 IoNetworkAdapter
*IoNetworkAdapter_proto(void *state
)
25 IoNetworkAdapter
*self
= IoObject_new(state
);
26 IoObject_tag_(self
, IoNetworkAdapter_newTag(state
));
28 IoState_registerProtoWithFunc_(state
, self
, IoNetworkAdapter_proto
);
31 IoMethodTable methodTable
[] = {
32 {"macAddress", IoNetworkAdapter_macAddress
},
35 IoObject_addMethodTable_(self
, methodTable
);
40 IoNetworkAdapter
*IoNetworkAdapter_rawClone(IoNetworkAdapter
*proto
)
42 IoNetworkAdapter
*self
= IoObject_rawClonePrimitive(proto
);
46 IoNetworkAdapter
*IoNetworkAdapter_new(void *state
)
48 IoNetworkAdapter
*proto
= IoState_protoWithInitFunction_(state
, IoNetworkAdapter_proto
);
49 return IOCLONE(proto
);
52 /* ----------------------------------------------------------- */
54 IoSeq
*IoNetworkAdapter_macAddress(IoNetworkAdapter
*self
, IoObject
*locals
, IoMessage
*m
)
57 docSlot("macAddress", "Returns the MAC address for the primary network adapter in a Hex string.")
60 #if defined(WIN32) || defined(__APPLE__) || defined(MACOSX)
61 char * mac
= macAddress();
62 return mac
? IOSYMBOL(mac
) : IONIL(self
);