OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
networkhandler.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, Rockwell Automation, Inc.
3  * All rights reserved.
4  *
5  ******************************************************************************/
6 #include <string.h>
7 #include <stdlib.h>
8 #include <winsock2.h>
9 #include <windows.h>
10 #include <Ws2tcpip.h>
11 
12 #include "networkhandler.h"
13 
14 #include "generic_networkhandler.h"
15 
17  LARGE_INTEGER performance_counter;
18  LARGE_INTEGER performance_frequency;
19 
20  QueryPerformanceCounter(&performance_counter);
21  QueryPerformanceFrequency(&performance_frequency);
22 
23  return (MicroSeconds) (performance_counter.QuadPart * 1000000LL
24  / performance_frequency.QuadPart);
25 }
26 
28  return (MilliSeconds) (getMicroSeconds() / 1000ULL);
29 }
30 
32  WSADATA wsaData;
33  const WORD wVersionRequested = MAKEWORD(2, 2);
34  WSAStartup(wVersionRequested, &wsaData);
35 
36  return kEipStatusOk;
37 }
38 
39 void CloseSocketPlatform(int socket_handle) {
40  closesocket(socket_handle);
41 }
42 
43 int SetSocketToNonBlocking(int socket_handle) {
44  u_long iMode = 1;
45  return ioctlsocket(socket_handle, FIONBIO, &iMode);
46 }
47 
48 int SetQosOnSocket(const int socket,
49  CipUsint qos_value) {
50  return 0; // Dummy implementation, until a working one is viable
51 }
MilliSeconds GetMilliSeconds(void)
This function shall return the current time in milliseconds relative to epoch, and shall be implement...
void CloseSocketPlatform(int socket_handle)
Platform dependent code to close a socket.
unsigned long long MicroSeconds
Definition: typedefs.h:69
int SetSocketToNonBlocking(int socket_handle)
EipStatus
EIP stack status enum.
Definition: typedefs.h:93
uint8_t CipUsint
Definition: typedefs.h:46
int SetQosOnSocket(int socket, CipUsint qos_value)
EipStatus NetworkHandlerInitializePlatform(void)
Executes platform dependent network handler initialization code.
unsigned long MilliSeconds
Definition: typedefs.h:68
MicroSeconds getMicroSeconds()