2 * nsiproxy.sys unixlib private header
4 * Copyright 2021 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 NTSTATUS
nsi_enumerate_all_ex( struct nsi_enumerate_all_ex
*params
) DECLSPEC_HIDDEN
;
22 NTSTATUS
nsi_get_all_parameters_ex( struct nsi_get_all_parameters_ex
*params
) DECLSPEC_HIDDEN
;
23 NTSTATUS
nsi_get_parameter_ex( struct nsi_get_parameter_ex
*params
) DECLSPEC_HIDDEN
;
25 static inline NTSTATUS
nsi_enumerate_all( DWORD unk
, DWORD unk2
, const NPI_MODULEID
*module
, DWORD table
,
26 void *key_data
, DWORD key_size
, void *rw_data
, DWORD rw_size
,
27 void *dynamic_data
, DWORD dynamic_size
, void *static_data
, DWORD static_size
,
30 struct nsi_enumerate_all_ex params
;
33 params
.unknown
[0] = 0;
34 params
.unknown
[1] = 0;
35 params
.module
= module
;
37 params
.first_arg
= unk
;
38 params
.second_arg
= unk2
;
39 params
.key_data
= key_data
;
40 params
.key_size
= key_size
;
41 params
.rw_data
= rw_data
;
42 params
.rw_size
= rw_size
;
43 params
.dynamic_data
= dynamic_data
;
44 params
.dynamic_size
= dynamic_size
;
45 params
.static_data
= static_data
;
46 params
.static_size
= static_size
;
47 params
.count
= *count
;
49 status
= nsi_enumerate_all_ex( ¶ms
);
50 *count
= params
.count
;
54 BOOL
convert_luid_to_unix_name( const NET_LUID
*luid
, const char **unix_name
) DECLSPEC_HIDDEN
;
55 BOOL
convert_unix_name_to_luid( const char *unix_name
, NET_LUID
*luid
) DECLSPEC_HIDDEN
;
57 static inline BOOL
convert_luid_to_index( const NET_LUID
*luid
, DWORD
*index
)
59 struct nsi_get_parameter_ex params
;
60 params
.unknown
[0] = 0;
61 params
.unknown
[1] = 0;
64 params
.module
= &NPI_MS_NDIS_MODULEID
;
65 params
.table
= NSI_NDIS_IFINFO_TABLE
;
67 params
.key_size
= sizeof(*luid
);
68 params
.param_type
= NSI_PARAM_TYPE_STATIC
;
70 params
.data_size
= sizeof(*index
);
71 params
.data_offset
= FIELD_OFFSET(struct nsi_ndis_ifinfo_static
, if_index
);
73 return !nsi_get_parameter_ex( ¶ms
);
76 static inline BOOL
convert_index_to_luid( DWORD index
, NET_LUID
*luid
)
78 struct nsi_get_parameter_ex params
;
79 params
.unknown
[0] = 0;
80 params
.unknown
[1] = 0;
83 params
.module
= &NPI_MS_NDIS_MODULEID
;
84 params
.table
= NSI_NDIS_INDEX_LUID_TABLE
;
86 params
.key_size
= sizeof(index
);
87 params
.param_type
= NSI_PARAM_TYPE_STATIC
;
89 params
.data_size
= sizeof(*luid
);
90 params
.data_offset
= 0;
92 return !nsi_get_parameter_ex( ¶ms
);
95 struct ipv6_addr_scope
101 struct ipv6_addr_scope
*get_ipv6_addr_scope_table( unsigned int *size
) DECLSPEC_HIDDEN
;
102 DWORD
find_ipv6_addr_scope( const IN6_ADDR
*addr
, const struct ipv6_addr_scope
*table
, unsigned int size
) DECLSPEC_HIDDEN
;
107 unsigned int unix_pid
;
110 struct pid_map
*get_pid_map( unsigned int *num_entries
) DECLSPEC_HIDDEN
;
111 unsigned int find_owning_pid( struct pid_map
*map
, unsigned int num_entries
, UINT_PTR inode
) DECLSPEC_HIDDEN
;
117 NTSTATUS (*enumerate_all
)( void *key_data
, DWORD key_size
, void *rw_data
, DWORD rw_size
,
118 void *dynamic_data
, DWORD dynamic_size
,
119 void *static_data
, DWORD static_size
, DWORD_PTR
*count
);
120 NTSTATUS (*get_all_parameters
)( const void *key
, DWORD key_size
, void *rw_data
, DWORD rw_size
,
121 void *dynamic_data
, DWORD dynamic_size
,
122 void *static_data
, DWORD static_size
);
123 NTSTATUS (*get_parameter
)( const void *key
, DWORD key_size
, DWORD param_type
,
124 void *data
, DWORD data_size
, DWORD data_offset
);
129 const NPI_MODULEID
*module
;
130 const struct module_table
*tables
;
133 extern const struct module ndis_module DECLSPEC_HIDDEN
;
134 extern const struct module ipv4_module DECLSPEC_HIDDEN
;
135 extern const struct module ipv6_module DECLSPEC_HIDDEN
;
136 extern const struct module tcp_module DECLSPEC_HIDDEN
;
137 extern const struct module udp_module DECLSPEC_HIDDEN
;
139 static inline int ascii_strncasecmp( const char *s1
, const char *s2
, size_t n
)
145 l1
= (unsigned char)((*s1
>= 'A' && *s1
<= 'Z') ? *s1
+ ('a' - 'A') : *s1
);
146 l2
= (unsigned char)((*s2
>= 'A' && *s2
<= 'Z') ? *s2
+ ('a' - 'A') : *s2
);
147 if (l1
!= l2
) return l1
- l2
;
155 static inline int ascii_strcasecmp( const char *s1
, const char *s2
)
157 return ascii_strncasecmp( s1
, s2
, -1 );
160 NTSTATUS
icmp_cancel_listen( void *args
) DECLSPEC_HIDDEN
;
161 NTSTATUS
icmp_close( void *args
) DECLSPEC_HIDDEN
;
162 NTSTATUS
icmp_listen( void *args
) DECLSPEC_HIDDEN
;
163 NTSTATUS
icmp_send_echo( void *args
) DECLSPEC_HIDDEN
;