~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 Twisted Matrix Laboratories.
 
2
 * See LICENSE for details.
 
3
 */
 
4
 
 
5
 
 
6
#include<winsock2.h>
 
7
#include<assert.h>
 
8
#include<stdio.h>
 
9
#include<stdlib.h>
 
10
 
 
11
#ifndef WSAID_CONNECTEX
 
12
#define WSAID_CONNECTEX {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
 
13
#endif
 
14
#ifndef WSAID_GETACCEPTEXSOCKADDRS
 
15
#define WSAID_GETACCEPTEXSOCKADDRS {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
 
16
#endif
 
17
#ifndef WSAID_ACCEPTEX
 
18
#define WSAID_ACCEPTEX {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
 
19
#endif
 
20
/*#ifndef WSAID_TRANSMITFILE
 
21
#define WSAID_TRANSMITFILE {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
 
22
#endif*/
 
23
 
 
24
 
 
25
void *lpAcceptEx, *lpGetAcceptExSockaddrs, *lpConnectEx, *lpTransmitFile;
 
26
 
 
27
int initPointer(SOCKET s, void **fun, GUID guid) {
 
28
    int res;
 
29
    DWORD bytes;
 
30
 
 
31
    *fun = NULL;
 
32
    res = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER,
 
33
                   &guid, sizeof(guid),
 
34
                   fun, sizeof(fun),
 
35
                   &bytes, NULL, NULL);
 
36
    return !res;
 
37
}
 
38
 
 
39
int initWinsockPointers() {
 
40
    SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
 
41
    /* I hate C */
 
42
    GUID guid1 = WSAID_ACCEPTEX;
 
43
    GUID guid2 = WSAID_GETACCEPTEXSOCKADDRS;
 
44
    GUID guid3 = WSAID_CONNECTEX;
 
45
    /*GUID guid4 = WSAID_TRANSMITFILE;*/
 
46
    if (!s) {
 
47
        return 0;
 
48
    }
 
49
    if (!initPointer(s, &lpAcceptEx, guid1))
 
50
    {
 
51
        return 0;
 
52
    }
 
53
    if (!initPointer(s, &lpGetAcceptExSockaddrs, guid2)) {
 
54
        return 0;
 
55
    }
 
56
    if (!initPointer(s, &lpConnectEx, guid3)) {
 
57
        return 0;
 
58
    };
 
59
    /*initPointer(s, &lpTransmitFile, guid4);*/
 
60
    return 1;
 
61
}
 
62