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 #define WIN32_LEAN_AND_MEAN
7 #include <string.h>
8 #include <stdlib.h>
9 #include <winsock2.h>
10 #include <windows.h>
11 #include <Ws2tcpip.h>
12 
13 #include "networkhandler.h"
14 
15 #include "generic_networkhandler.h"
16 
18  LARGE_INTEGER performance_counter;
19  LARGE_INTEGER performance_frequency;
20 
21  QueryPerformanceCounter(&performance_counter);
22  QueryPerformanceFrequency(&performance_frequency);
23 
24  return (MicroSeconds) (performance_counter.QuadPart * 1000000LL
25  / performance_frequency.QuadPart);
26 }
27 
29  return (MilliSeconds) (getMicroSeconds() / 1000ULL);
30 }
31 
33  WSADATA wsaData;
34  const WORD wVersionRequested = MAKEWORD(2, 2);
35  WSAStartup(wVersionRequested, &wsaData);
36 
37  return kEipStatusOk;
38 }
39 
40 void CloseSocketPlatform(int socket_handle) {
41  closesocket(socket_handle);
42 }
43 
44 int SetSocketToNonBlocking(int socket_handle) {
45  u_long iMode = 1;
46  return ioctlsocket(socket_handle, FIONBIO, &iMode);
47 }
48 
49 int SetQosOnSocket(int socket,
50  CipUsint qos_value) {
51  CipUsint set_tos = qos_value;
52  return setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos) );
53 }
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()