| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /*******************************************************************************
- * Copyright (c) 2009, Rockwell Automation, Inc.
- * All rights reserved.
- *
- ******************************************************************************/
- #include "networkhandler.h"
- #include <fcntl.h>
- #include "opener_error.h"
- #include "trace.h"
- #include "encap.h"
- #include "opener_user_conf.h"
- MilliSeconds GetMilliSeconds(void) {
- return rt_tick_get_millisecond();
- }
- EipStatus NetworkHandlerInitializePlatform(void) {
- /* Add platform dependent code here if necessary */
- return kEipStatusOk;
- }
- void ShutdownSocketPlatform(int socket_handle) {
- if (0 != shutdown(socket_handle, SHUT_RDWR)) {
- int error_code = GetSocketErrorNumber();
- char *error_message = GetErrorMessage(error_code);
- OPENER_TRACE_ERR("Failed shutdown() socket %d - Error Code: %d - %s\n",
- socket_handle,
- error_code,
- error_message);
- FreeErrorMessage(error_message);
- }
- }
- void CloseSocketPlatform(int socket_handle) {
- closesocket(socket_handle);
- }
- int SetSocketToNonBlocking(int socket_handle) {
- return fcntl(socket_handle, F_SETFL, fcntl(socket_handle,
- F_GETFL,
- 0) | O_NONBLOCK);
- }
- int SetQosOnSocket(const int socket,
- CipUsint qos_value) {
- /* Quote from Vol. 2, Section 5-7.4.2 DSCP Value Attributes:
- * Note that the DSCP value, if placed directly in the ToS field
- * in the IP header, must be shifted left 2 bits. */
- int set_tos = qos_value << 2;
- return setsockopt(socket, IPPROTO_IP, IP_TOS, &set_tos, sizeof(set_tos));
- }
|