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 #ifdef WORDS_BIGENDIAN
22 #define IPV4_ADDR(b1, b2, b3, b4) (((unsigned int)b1 << 24) | (b2 << 16) | (b3 << 8) | b4)
24 #define IPV4_ADDR(b1, b2, b3, b4) (((unsigned int)b4 << 24) | (b3 << 16) | (b2 << 8) | b1)
27 NTSTATUS
nsi_enumerate_all_ex( struct nsi_enumerate_all_ex
*params
);
28 NTSTATUS
nsi_get_all_parameters_ex( struct nsi_get_all_parameters_ex
*params
);
29 NTSTATUS
nsi_get_parameter_ex( struct nsi_get_parameter_ex
*params
);
31 static inline NTSTATUS
nsi_enumerate_all( UINT unk
, UINT unk2
, const NPI_MODULEID
*module
, UINT table
,
32 void *key_data
, UINT key_size
, void *rw_data
, UINT rw_size
,
33 void *dynamic_data
, UINT dynamic_size
, void *static_data
, UINT static_size
,
36 struct nsi_enumerate_all_ex params
;
39 params
.unknown
[0] = 0;
40 params
.unknown
[1] = 0;
41 params
.module
= module
;
43 params
.first_arg
= unk
;
44 params
.second_arg
= unk2
;
45 params
.key_data
= key_data
;
46 params
.key_size
= key_size
;
47 params
.rw_data
= rw_data
;
48 params
.rw_size
= rw_size
;
49 params
.dynamic_data
= dynamic_data
;
50 params
.dynamic_size
= dynamic_size
;
51 params
.static_data
= static_data
;
52 params
.static_size
= static_size
;
53 params
.count
= *count
;
55 status
= nsi_enumerate_all_ex( ¶ms
);
56 *count
= params
.count
;
60 BOOL
convert_luid_to_unix_name( const NET_LUID
*luid
, const char **unix_name
);
61 BOOL
convert_unix_name_to_luid( const char *unix_name
, NET_LUID
*luid
);
63 static inline BOOL
convert_luid_to_index( const NET_LUID
*luid
, UINT
*index
)
65 struct nsi_get_parameter_ex params
;
66 params
.unknown
[0] = 0;
67 params
.unknown
[1] = 0;
70 params
.module
= &NPI_MS_NDIS_MODULEID
;
71 params
.table
= NSI_NDIS_IFINFO_TABLE
;
73 params
.key_size
= sizeof(*luid
);
74 params
.param_type
= NSI_PARAM_TYPE_STATIC
;
76 params
.data_size
= sizeof(*index
);
77 params
.data_offset
= FIELD_OFFSET(struct nsi_ndis_ifinfo_static
, if_index
);
79 return !nsi_get_parameter_ex( ¶ms
);
82 static inline BOOL
convert_index_to_luid( UINT index
, NET_LUID
*luid
)
84 struct nsi_get_parameter_ex params
;
85 params
.unknown
[0] = 0;
86 params
.unknown
[1] = 0;
89 params
.module
= &NPI_MS_NDIS_MODULEID
;
90 params
.table
= NSI_NDIS_INDEX_LUID_TABLE
;
92 params
.key_size
= sizeof(index
);
93 params
.param_type
= NSI_PARAM_TYPE_STATIC
;
95 params
.data_size
= sizeof(*luid
);
96 params
.data_offset
= 0;
98 return !nsi_get_parameter_ex( ¶ms
);
101 struct ipv6_addr_scope
107 struct ipv6_addr_scope
*get_ipv6_addr_scope_table( unsigned int *size
);
108 UINT
find_ipv6_addr_scope( const IN6_ADDR
*addr
, const struct ipv6_addr_scope
*table
, unsigned int size
);
113 unsigned int unix_pid
;
116 struct pid_map
*get_pid_map( unsigned int *num_entries
);
117 unsigned int find_owning_pid( struct pid_map
*map
, unsigned int num_entries
, UINT_PTR inode
);
123 NTSTATUS (*enumerate_all
)( void *key_data
, UINT key_size
, void *rw_data
, UINT rw_size
,
124 void *dynamic_data
, UINT dynamic_size
,
125 void *static_data
, UINT static_size
, UINT_PTR
*count
);
126 NTSTATUS (*get_all_parameters
)( const void *key
, UINT key_size
, void *rw_data
, UINT rw_size
,
127 void *dynamic_data
, UINT dynamic_size
,
128 void *static_data
, UINT static_size
);
129 NTSTATUS (*get_parameter
)( const void *key
, UINT key_size
, UINT param_type
,
130 void *data
, UINT data_size
, UINT data_offset
);
135 const NPI_MODULEID
*module
;
136 const struct module_table
*tables
;
139 extern const struct module ndis_module
;
140 extern const struct module ipv4_module
;
141 extern const struct module ipv6_module
;
142 extern const struct module tcp_module
;
143 extern const struct module udp_module
;
145 static inline int ascii_strncasecmp( const char *s1
, const char *s2
, size_t n
)
151 l1
= (unsigned char)((*s1
>= 'A' && *s1
<= 'Z') ? *s1
+ ('a' - 'A') : *s1
);
152 l2
= (unsigned char)((*s2
>= 'A' && *s2
<= 'Z') ? *s2
+ ('a' - 'A') : *s2
);
153 if (l1
!= l2
) return l1
- l2
;
161 static inline int ascii_strcasecmp( const char *s1
, const char *s2
)
163 return ascii_strncasecmp( s1
, s2
, -1 );
166 NTSTATUS
icmp_cancel_listen( void *args
);
167 NTSTATUS
icmp_close( void *args
);
168 NTSTATUS
icmp_listen( void *args
);
169 NTSTATUS
icmp_send_echo( void *args
);