dwrite: Implement CreateFontFaceFromHdc().
[wine.git] / dlls / wpcap / wpcap.c
blobda545a81f253c9af0f08350fd97e56775bedb9f2
1 /*
2 * WPcap.dll Proxy.
4 * Copyright 2011, 2014 André Hentschel
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 #include <pcap/pcap.h>
22 #include "winsock2.h"
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(wpcap);
28 WINE_DECLARE_DEBUG_CHANNEL(winediag);
30 void CDECL wine_pcap_breakloop(pcap_t *p)
32 TRACE("(%p)\n", p);
33 return pcap_breakloop(p);
36 void CDECL wine_pcap_close(pcap_t *p)
38 TRACE("(%p)\n", p);
39 pcap_close(p);
42 int CDECL wine_pcap_compile(pcap_t *p, struct bpf_program *program, const char *buf, int optimize,
43 unsigned int mask)
45 TRACE("(%p %p %s %i %u)\n", p, program, debugstr_a(buf), optimize, mask);
46 return pcap_compile(p, program, buf, optimize, mask);
49 int CDECL wine_pcap_datalink(pcap_t *p)
51 TRACE("(%p)\n", p);
52 return pcap_datalink(p);
55 int CDECL wine_pcap_datalink_name_to_val(const char *name)
57 TRACE("(%s)\n", debugstr_a(name));
58 return pcap_datalink_name_to_val(name);
61 const char* CDECL wine_pcap_datalink_val_to_description(int dlt)
63 TRACE("(%i)\n", dlt);
64 return pcap_datalink_val_to_description(dlt);
67 const char* CDECL wine_pcap_datalink_val_to_name(int dlt)
69 TRACE("(%i)\n", dlt);
70 return pcap_datalink_val_to_name(dlt);
73 typedef struct
75 void (CALLBACK *pfn_cb)(u_char *, const struct pcap_pkthdr *, const u_char *);
76 void *user_data;
77 } PCAP_HANDLER_CALLBACK;
79 static void pcap_handler_callback(u_char *user_data, const struct pcap_pkthdr *h, const u_char *p)
81 PCAP_HANDLER_CALLBACK *pcb;
82 TRACE("(%p %p %p)\n", user_data, h, p);
83 pcb = (PCAP_HANDLER_CALLBACK *)user_data;
84 pcb->pfn_cb(pcb->user_data, h, p);
85 HeapFree(GetProcessHeap(), 0, pcb);
86 TRACE("Callback COMPLETED\n");
89 int CDECL wine_pcap_dispatch(pcap_t *p, int cnt,
90 void (CALLBACK *callback)(u_char *, const struct pcap_pkthdr *, const u_char *),
91 unsigned char *user)
93 TRACE("(%p %i %p %p)\n", p, cnt, callback, user);
95 if (callback)
97 PCAP_HANDLER_CALLBACK *pcb;
98 pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
99 pcb->pfn_cb = callback;
100 pcb->user_data = user;
101 return pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
104 return pcap_dispatch(p, cnt, NULL, user);
107 int CDECL wine_pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
109 int ret;
111 TRACE("(%p %p)\n", alldevsp, errbuf);
112 ret = pcap_findalldevs(alldevsp, errbuf);
113 if(alldevsp && !*alldevsp)
114 ERR_(winediag)("Failed to access raw network (pcap), this requires special permissions.\n");
116 return ret;
119 int CDECL wine_pcap_findalldevs_ex(char *source, void *auth, pcap_if_t **alldevs, char *errbuf)
121 FIXME("(%s %p %p %p): partial stub\n", debugstr_a(source), auth, alldevs, errbuf);
122 return wine_pcap_findalldevs(alldevs, errbuf);
125 void CDECL wine_pcap_freealldevs(pcap_if_t *alldevs)
127 TRACE("(%p)\n", alldevs);
128 pcap_freealldevs(alldevs);
131 void CDECL wine_pcap_freecode(struct bpf_program *fp)
133 TRACE("(%p)\n", fp);
134 return pcap_freecode(fp);
137 typedef struct _AirpcapHandle *PAirpcapHandle;
138 PAirpcapHandle CDECL wine_pcap_get_airpcap_handle(pcap_t *p)
140 TRACE("(%p)\n", p);
141 return NULL;
144 char* CDECL wine_pcap_geterr(pcap_t *p)
146 TRACE("(%p)\n", p);
147 return pcap_geterr(p);
150 int CDECL wine_pcap_getnonblock(pcap_t *p, char *errbuf)
152 TRACE("(%p %p)\n", p, errbuf);
153 return pcap_getnonblock(p, errbuf);
156 const char* CDECL wine_pcap_lib_version(void)
158 const char* ret = pcap_lib_version();
159 TRACE("%s\n", debugstr_a(ret));
160 return ret;
163 int CDECL wine_pcap_list_datalinks(pcap_t *p, int **dlt_buffer)
165 TRACE("(%p %p)\n", p, dlt_buffer);
166 return pcap_list_datalinks(p, dlt_buffer);
169 char* CDECL wine_pcap_lookupdev(char *errbuf)
171 TRACE("(%p)\n", errbuf);
172 return pcap_lookupdev(errbuf);
175 int CDECL wine_pcap_lookupnet(const char *device, unsigned int *netp, unsigned int *maskp,
176 char *errbuf)
178 TRACE("(%s %p %p %p)\n", debugstr_a(device), netp, maskp, errbuf);
179 return pcap_lookupnet(device, netp, maskp, errbuf);
182 int CDECL wine_pcap_loop(pcap_t *p, int cnt,
183 void (CALLBACK *callback)(u_char *, const struct pcap_pkthdr *, const u_char *),
184 unsigned char *user)
186 TRACE("(%p %i %p %p)\n", p, cnt, callback, user);
188 if (callback)
190 PCAP_HANDLER_CALLBACK *pcb;
191 pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
192 pcb->pfn_cb = callback;
193 pcb->user_data = user;
194 return pcap_loop(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
197 return pcap_loop(p, cnt, NULL, user);
200 int CDECL wine_pcap_major_version(pcap_t *p)
202 TRACE("(%p)\n", p);
203 return pcap_major_version(p);
206 int CDECL wine_pcap_minor_version(pcap_t *p)
208 TRACE("(%p)\n", p);
209 return pcap_minor_version(p);
212 const unsigned char* CDECL wine_pcap_next(pcap_t *p, struct pcap_pkthdr *h)
214 TRACE("(%p %p)\n", p, h);
215 return pcap_next(p, h);
218 int CDECL wine_pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header, const unsigned char **pkt_data)
220 TRACE("(%p %p %p)\n", p, pkt_header, pkt_data);
221 return pcap_next_ex(p, pkt_header, pkt_data);
224 #define PCAP_OPENFLAG_PROMISCUOUS 1
226 pcap_t* CDECL wine_pcap_open(const char *source, int snaplen, int flags, int read_timeout,
227 void *auth, char *errbuf)
229 int promisc = flags & PCAP_OPENFLAG_PROMISCUOUS;
230 FIXME("(%s %i %i %i %p %p): partial stub\n", debugstr_a(source), snaplen, flags, read_timeout,
231 auth, errbuf);
232 return pcap_open_live(source, snaplen, promisc, read_timeout, errbuf);
235 pcap_t* CDECL wine_pcap_open_live(const char *source, int snaplen, int promisc, int to_ms,
236 char *errbuf)
238 TRACE("(%s %i %i %i %p)\n", debugstr_a(source), snaplen, promisc, to_ms, errbuf);
239 return pcap_open_live(source, snaplen, promisc, to_ms, errbuf);
242 int CDECL wine_pcap_sendpacket(pcap_t *p, const unsigned char *buf, int size)
244 TRACE("(%p %p %i)\n", p, buf, size);
245 return pcap_sendpacket(p, buf, size);
248 int CDECL wine_pcap_set_datalink(pcap_t *p, int dlt)
250 TRACE("(%p %i)\n", p, dlt);
251 return pcap_set_datalink(p, dlt);
254 int CDECL wine_pcap_setbuff(pcap_t * p, int dim)
256 FIXME("(%p %i) stub\n", p, dim);
257 return 0;
260 int CDECL wine_pcap_setfilter(pcap_t *p, struct bpf_program *fp)
262 TRACE("(%p %p)\n", p, fp);
263 return pcap_setfilter(p, fp);
266 int CDECL wine_pcap_setnonblock(pcap_t *p, int nonblock, char *errbuf)
268 TRACE("(%p %i %p)\n", p, nonblock, errbuf);
269 return pcap_setnonblock(p, nonblock, errbuf);
272 int CDECL wine_pcap_snapshot(pcap_t *p)
274 TRACE("(%p)\n", p);
275 return pcap_snapshot(p);
278 int CDECL wine_pcap_stats(pcap_t *p, struct pcap_stat *ps)
280 TRACE("(%p %p)\n", p, ps);
281 return pcap_stats(p, ps);
284 int CDECL wine_wsockinit(void)
286 WSADATA wsadata;
287 TRACE("()\n");
288 if (WSAStartup(MAKEWORD(1,1), &wsadata)) return -1;
289 return 0;