1 using System;
2 using System.Runtime.InteropServices;
3 
4 namespace System.Net.NetworkInformation {
5 	namespace MacOsStructs {
6 		internal struct ifaddrs
7 		{
8 			public IntPtr  ifa_next;
9 			public string  ifa_name;
10 			public uint    ifa_flags;
11 			public IntPtr  ifa_addr;
12 			public IntPtr  ifa_netmask;
13 			public IntPtr  ifa_dstaddr;
14 			public IntPtr  ifa_data;
15 		}
16 
17 		internal struct sockaddr
18 		{
19 			public byte  sa_len;
20 			public byte  sa_family;
21 		}
22 
23 		internal struct sockaddr_in
24 		{
25 			public byte   sin_len;
26 			public byte   sin_family;
27 			public ushort sin_port;
28 			public uint   sin_addr;
29 		}
30 
31 		internal struct in6_addr
32 		{
33 			[MarshalAs (UnmanagedType.ByValArray, SizeConst=16)]
34 			public byte[] u6_addr8;
35 		}
36 
37 		internal struct sockaddr_in6
38 		{
39 			public byte     sin6_len;
40 			public byte     sin6_family;
41 			public ushort   sin6_port;
42 			public uint     sin6_flowinfo;
43 			public in6_addr sin6_addr;
44 			public uint     sin6_scope_id;
45 		}
46 
47 		internal struct sockaddr_dl
48 		{
49 			public byte   sdl_len;
50 			public byte   sdl_family;
51 			public ushort sdl_index;
52 			public byte   sdl_type;
53 			public byte   sdl_nlen;
54 			public byte   sdl_alen;
55 			public byte   sdl_slen;
56 			public byte[] sdl_data;
57 
ReadSystem.Net.NetworkInformation.MacOsStructs.sockaddr_dl58 			internal void Read (IntPtr ptr)
59 			{
60 				sdl_len = Marshal.ReadByte (ptr, 0);
61 				sdl_family = Marshal.ReadByte (ptr, 1);
62 				sdl_index = (ushort) Marshal.ReadInt16 (ptr, 2);
63 				sdl_type = Marshal.ReadByte (ptr, 4);
64 				sdl_nlen = Marshal.ReadByte (ptr, 5);
65 				sdl_alen = Marshal.ReadByte (ptr, 6);
66 				sdl_slen = Marshal.ReadByte (ptr, 7);
67 				sdl_data = new byte [Math.Max (12, sdl_len - 8)];
68 				Marshal.Copy (new IntPtr (ptr.ToInt64 () + 8), sdl_data, 0, sdl_data.Length);
69 			}
70 		}
71 
72 	}
73 
74 	internal enum MacOsArpHardware {
75 		ETHER = 0x6,
76 		ATM = 0x25,
77 		SLIP = 0x1c,
78 		PPP = 0x17,
79 		LOOPBACK = 0x18,
80 		FDDI = 0xf
81 	}
82 
83 	internal enum MacOsInterfaceFlags {
84 		IFF_UP = 0x1,				/* interface is up */
85 		IFF_BROADCAST = 0x2,		/* broadcast address valid */
86 		IFF_DEBUG = 0x4,			/* turn on debugging */
87 		IFF_LOOPBACK = 0x8,			/* is a loopback net */
88 		IFF_POINTOPOINT = 0x10,		/* interface is point-to-point link */
89 		IFF_NOTRAILERS = 0x20,		/* avoid use of trailers */
90 		IFF_RUNNING = 0x40,			/* resources allocated */
91 		IFF_NOARP = 0x80,			/* no address resolution protocol */
92 		IFF_PROMISC = 0x100,		/* receive all packets */
93 		IFF_ALLMULTI = 0x200,		/* receive all multicast packets */
94 		IFF_OACTIVE = 0x400,		/* transmission in progress */
95 		IFF_SIMPLEX = 0x800,		/* can't hear own transmissions */
96 		IFF_LINK0 = 0x1000,			/* per link layer defined bit */
97 		IFF_LINK1 = 0x2000,			/* per link layer defined bit */
98 		IFF_LINK2 = 0x4000,			/* per link layer defined bit */
99 		IFF_MULTICAST = 0x8000		/* supports multicast */
100 	}
101 }
102