1 // Licensed under the Apache License, Version 2.0
2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4 // All files in the project carrying such notice may not be copied, modified, or distributed
5 // except according to those terms.
6 //! Contains the public definitions and structures for the UDP-specific parts of MIB-II
7 // #include <winapifamily.h>
8 use shared::basetsd::DWORD64;
9 use shared::in6addr::IN6_ADDR;
10 use shared::minwindef::DWORD;
11 use shared::ntdef::{INT, LARGE_INTEGER, UCHAR, ULONGLONG};
12 const ANY_SIZE: usize = 1;
13 pub const TCPIP_OWNING_MODULE_SIZE: usize = 16;
14 STRUCT!{struct MIB_UDPROW {
15     dwLocalAddr: DWORD,
16     dwLocalPort: DWORD,
17 }}
18 pub type PMIB_UDPROW = *mut MIB_UDPROW;
19 STRUCT!{struct MIB_UDPTABLE {
20     dwNumEntries: DWORD,
21     table: [MIB_UDPROW; ANY_SIZE],
22 }}
23 pub type PMIB_UDPTABLE = *mut MIB_UDPTABLE;
24 // FIXME: SIZEOF_UDPTABLE(x)
25 STRUCT!{struct MIB_UDPROW_OWNER_PID {
26     dwLocalAddr: DWORD,
27     dwLocalPort: DWORD,
28     dwOwningPid: DWORD,
29 }}
30 pub type PMIB_UDPROW_OWNER_PID = *mut MIB_UDPROW_OWNER_PID;
31 STRUCT!{struct MIB_UDPTABLE_OWNER_PID {
32     dwNumEntries: DWORD,
33     table: [MIB_UDPROW_OWNER_PID; ANY_SIZE],
34 }}
35 pub type PMIB_UDPTABLE_OWNER_PID = *mut MIB_UDPTABLE_OWNER_PID;
36 // FIXME: SIZEOF_UDPTABLE_OWNER_PID(x)
37 STRUCT!{struct MIB_UDPROW_OWNER_MODULE_u_s {
38     bitfield: INT,
39 }}
40 BITFIELD!{MIB_UDPROW_OWNER_MODULE_u_s bitfield: INT [
41     SpecificPortBind set_SpecificPortBind[0..1],
42 ]}
43 UNION!{union MIB_UDPROW_OWNER_MODULE_u {
44     [i32; 1],
45     s s_mut: MIB_UDPROW_OWNER_MODULE_u_s,
46     dwFlags dwFlags_mut: INT,
47 }}
48 STRUCT!{struct MIB_UDPROW_OWNER_MODULE {
49     dwLocalAddr: DWORD,
50     dwLocalPort: DWORD,
51     dwOwningPid: DWORD,
52     liCreateTimestamp: LARGE_INTEGER,
53     u: MIB_UDPROW_OWNER_MODULE_u,
54     OwningModuleInfo: [ULONGLONG; TCPIP_OWNING_MODULE_SIZE],
55 }}
56 pub type PMIB_UDPROW_OWNER_MODULE = *mut MIB_UDPROW_OWNER_MODULE;
57 STRUCT!{struct MIB_UDPTABLE_OWNER_MODULE {
58     dwNumEntries: DWORD,
59     table: [MIB_UDPROW_OWNER_MODULE; ANY_SIZE],
60 }}
61 pub type PMIB_UDPTABLE_OWNER_MODULE = *mut MIB_UDPTABLE_OWNER_MODULE;
62 // FIXME: SIZEOF_UDPTABLE_OWNER_MODULE(x)
63 STRUCT!{struct MIB_UDP6ROW {
64     dwLocalAddr: IN6_ADDR,
65     dwLocalScopeId: DWORD,
66     dwLocalPort: DWORD,
67 }}
68 pub type PMIB_UDP6ROW = *mut MIB_UDP6ROW;
69 STRUCT!{struct MIB_UDP6TABLE {
70     dwNumEntries: DWORD,
71     table: [MIB_UDP6ROW; ANY_SIZE],
72 }}
73 pub type PMIB_UDP6TABLE = *mut MIB_UDP6TABLE;
74 // FIXME: SIZEOF_UDP6TABLE(x)
75 STRUCT!{struct MIB_UDP6ROW_OWNER_PID {
76     ucLocalAddr: [UCHAR; 16],
77     dwLocalScopeId: DWORD,
78     dwLocalPort: DWORD,
79     dwOwningPid: DWORD,
80 }}
81 pub type PMIB_UDP6ROW_OWNER_PID = *mut MIB_UDP6ROW_OWNER_PID;
82 STRUCT!{struct MIB_UDP6TABLE_OWNER_PID {
83     dwNumEntries: DWORD,
84     table: [MIB_UDP6ROW_OWNER_PID; ANY_SIZE],
85 }}
86 pub type PMIB_UDP6TABLE_OWNER_PID = *mut MIB_UDP6TABLE_OWNER_PID;
87 // FIXME: SIZEOF_UDP6TABLE_OWNER_PID(x)
88 STRUCT!{struct MIB_UDP6ROW_OWNER_MODULE_u_s {
89     bitfield: INT,
90 }}
91 BITFIELD!{MIB_UDP6ROW_OWNER_MODULE_u_s bitfield: INT [
92     SpecificPortBind set_SpecificPortBind[0..1],
93 ]}
94 UNION!{union MIB_UDP6ROW_OWNER_MODULE_u {
95     [i32; 1],
96     s s_mut: INT,
97     dwFlags dwFlags_mut: INT,
98 }}
99 STRUCT!{struct MIB_UDP6ROW_OWNER_MODULE {
100     ucLocalAddr: [UCHAR; 16],
101     dwLocalScopeId: DWORD,
102     dwLocalPort: DWORD,
103     dwOwningPid: DWORD,
104     liCreateTimestamp: LARGE_INTEGER,
105     u: MIB_UDP6ROW_OWNER_MODULE_u,
106     OwningModuleInfo: [ULONGLONG; TCPIP_OWNING_MODULE_SIZE],
107 }}
108 pub type PMIB_UDP6ROW_OWNER_MODULE = *mut MIB_UDP6ROW_OWNER_MODULE;
109 STRUCT!{struct MIB_UDP6TABLE_OWNER_MODULE {
110     dwNumEntries: DWORD,
111     table: [MIB_UDP6ROW_OWNER_MODULE; ANY_SIZE],
112 }}
113 pub type PMIB_UDP6TABLE_OWNER_MODULE = *mut MIB_UDP6TABLE_OWNER_MODULE;
114 // FIXME: SIZEOF_UDP6TABLE_OWNER_MODULE(x)
115 STRUCT!{struct MIB_UDPSTATS {
116     dwInDatagrams: DWORD,
117     dwNoPorts: DWORD,
118     dwInErrors: DWORD,
119     dwOutDatagrams: DWORD,
120     dwNumAddrs: DWORD,
121 }}
122 pub type PMIB_UDPSTATS = *mut MIB_UDPSTATS;
123 STRUCT!{struct MIB_UDPSTATS2 {
124     dw64InDatagrams: DWORD64,
125     dwNoPorts: DWORD,
126     dwInErrors: DWORD,
127     dw64OutDatagrams: DWORD64,
128     dwNumAddrs: DWORD,
129 }}
130 pub type PMIB_UDPSTATS2 = *mut MIB_UDPSTATS2;
131