gPTP Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
windows_hal.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 
3  Copyright (c) 2009-2012, Intel Corporation
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8 
9  1. Redistributions of source code must retain the above copyright notice,
10  this list of conditions and the following disclaimer.
11 
12  2. Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  3. Neither the name of the Intel Corporation nor the names of its
17  contributors may be used to endorse or promote products derived from
18  this software without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  POSSIBILITY OF SUCH DAMAGE.
31 
32 ******************************************************************************/
33 
34 #ifndef WINDOWS_HAL_HPP
35 #define WINDOWS_HAL_HPP
36 
39 #include <minwindef.h>
40 #include <IPCListener.hpp>
41 #include "avbts_osnet.hpp"
42 #include "avbts_oslock.hpp"
43 #include "avbts_oscondition.hpp"
44 #include "avbts_ostimerq.hpp"
45 #include "avbts_ostimer.hpp"
46 #include "avbts_osthread.hpp"
47 #include "packet.hpp"
48 #include "ieee1588.hpp"
49 #include "iphlpapi.h"
50 #include "ipcdef.hpp"
51 #include "tsc.hpp"
52 
53 #include "avbts_osipc.hpp"
54 
55 #include <ntddndis.h>
56 
57 #include <map>
58 #include <list>
59 
66 private:
67  pfhandle_t handle;
68  LinkLayerAddress local_addr;
69 public:
78  virtual net_result send( LinkLayerAddress *addr, uint8_t *payload, size_t length, bool timestamp ) {
79  packet_addr_t dest;
80  addr->toOctetArray( dest.addr );
81  if( sendFrame( handle, &dest, PTP_ETHERTYPE, payload, length ) != PACKET_NO_ERROR ) return net_fatal;
82  return net_succeed;
83  }
91  virtual net_result nrecv( LinkLayerAddress *addr, uint8_t *payload, size_t &length ) {
92  packet_addr_t dest;
93  packet_error_t pferror = recvFrame( handle, &dest, payload, length );
94  if( pferror != PACKET_NO_ERROR && pferror != PACKET_RECVTIMEOUT_ERROR ) return net_fatal;
95  if( pferror == PACKET_RECVTIMEOUT_ERROR ) return net_trfail;
96  *addr = LinkLayerAddress( dest.addr );
97  return net_succeed;
98  }
104  virtual void getLinkLayerAddress( LinkLayerAddress *addr ) {
105  *addr = local_addr;
106  }
111  virtual unsigned getPayloadOffset() {
112  return PACKET_HDR_LENGTH;
113  }
118  closeInterface( handle );
119  if( handle != NULL ) freePacketHandle( handle );
120  }
121 protected:
125  WindowsPCAPNetworkInterface() { handle = NULL; };
126 };
127 
133 public:
141  virtual bool createInterface( OSNetworkInterface **net_iface, InterfaceLabel *label, HWTimestamper *timestamper ) {
143  LinkLayerAddress *addr = dynamic_cast<LinkLayerAddress *>(label);
144  if( addr == NULL ) goto error_nofree;
145  net_iface_l->local_addr = *addr;
146  packet_addr_t pfaddr;
147  addr->toOctetArray( pfaddr.addr );
148  if( mallocPacketHandle( &net_iface_l->handle ) != PACKET_NO_ERROR ) goto error_nofree;
149  if( openInterfaceByAddr( net_iface_l->handle, &pfaddr, 1 ) != PACKET_NO_ERROR ) goto error_free_handle;
150  if( packetBind( net_iface_l->handle, PTP_ETHERTYPE ) != PACKET_NO_ERROR ) goto error_free_handle;
151  *net_iface = net_iface_l;
152 
153  return true;
154 
155 error_free_handle:
156 error_nofree:
157  delete net_iface_l;
158 
159  return false;
160  }
161 };
162 
166 class WindowsLock : public OSLock {
167  friend class WindowsLockFactory;
168 private:
169  OSLockType type;
170  DWORD thread_id;
171  HANDLE lock_c;
172  OSLockResult lock_l( DWORD timeout ) {
173  DWORD wait_result = WaitForSingleObject( lock_c, timeout );
174  if( wait_result == WAIT_TIMEOUT ) return oslock_held;
175  else if( wait_result == WAIT_OBJECT_0 ) return oslock_ok;
176  else return oslock_fail;
177 
178  }
179  OSLockResult nonreentrant_lock_l( DWORD timeout ) {
180  OSLockResult result;
181  DWORD wait_result;
182  wait_result = WaitForSingleObject( lock_c, timeout );
183  if( wait_result == WAIT_OBJECT_0 ) {
184  if( thread_id == GetCurrentThreadId() ) {
185  result = oslock_self;
186  ReleaseMutex( lock_c );
187  } else {
188  result = oslock_ok;
189  thread_id = GetCurrentThreadId();
190  }
191  } else if( wait_result == WAIT_TIMEOUT ) result = oslock_held;
192  else result = oslock_fail;
193 
194  return result;
195  }
196 protected:
201  lock_c = NULL;
202  }
207  bool initialize( OSLockType type ) {
208  lock_c = CreateMutex( NULL, false, NULL );
209  if( lock_c == NULL ) return false;
210  this->type = type;
211  return true;
212  }
218  if( type == oslock_recursive ) {
219  return lock_l( INFINITE );
220  }
221  return nonreentrant_lock_l( INFINITE );
222  }
228  if( type == oslock_recursive ) {
229  return lock_l( 0 );
230  }
231  return nonreentrant_lock_l( 0 );
232  }
238  ReleaseMutex( lock_c );
239  return oslock_ok;
240  }
241 };
242 
247 public:
254  WindowsLock *lock = new WindowsLock();
255  if( !lock->initialize( type )) {
256  delete lock;
257  lock = NULL;
258  }
259  return lock;
260  }
261 };
262 
267  friend class WindowsConditionFactory;
268 private:
269  SRWLOCK lock;
270  CONDITION_VARIABLE condition;
271 protected:
275  bool initialize() {
276  InitializeSRWLock( &lock );
277  InitializeConditionVariable( &condition );
278  return true;
279  }
280 public:
285  bool wait_prelock() {
286  AcquireSRWLockExclusive( &lock );
287  up();
288  return true;
289  }
295  bool wait() {
296  BOOL result = SleepConditionVariableSRW( &condition, &lock, INFINITE, 0 );
297  bool ret = false;
298  if( result == TRUE ) {
299  down();
300  ReleaseSRWLockExclusive( &lock );
301  ret = true;
302  }
303  return ret;
304  }
309  bool signal() {
310  AcquireSRWLockExclusive( &lock );
311  if( waiting() ) WakeAllConditionVariable( &condition );
312  ReleaseSRWLockExclusive( &lock );
313  return true;
314  }
315 };
316 
321 public:
323  WindowsCondition *result = new WindowsCondition();
324  return result->initialize() ? result : NULL;
325  }
326 };
327 
328 class WindowsTimerQueue;
329 
330 struct TimerQueue_t;
331 
337  HANDLE timer_handle;
338  HANDLE queue_handle;
341  int type;
342  bool rm;
345 };
346 
350 typedef std::list<WindowsTimerQueueHandlerArg *> TimerArgList_t;
354 struct TimerQueue_t {
356  HANDLE queue_handle;
357  SRWLOCK lock;
358 };
359 
363 VOID CALLBACK WindowsTimerQueueHandler( PVOID arg_in, BOOLEAN ignore );
364 
368 typedef std::map<int,TimerQueue_t> TimerQueueMap_t;
369 
374  friend class WindowsTimerQueueFactory;
375  friend VOID CALLBACK WindowsTimerQueueHandler( PVOID arg_in, BOOLEAN ignore );
376 private:
377  TimerQueueMap_t timerQueueMap;
378  TimerArgList_t retiredTimers;
379  SRWLOCK retiredTimersLock;
380  void cleanupRetiredTimers() {
381  AcquireSRWLockExclusive( &retiredTimersLock );
382  while( !retiredTimers.empty() ) {
383  WindowsTimerQueueHandlerArg *retired_arg = retiredTimers.front();
384  retiredTimers.pop_front();
385  ReleaseSRWLockExclusive( &retiredTimersLock );
386  DeleteTimerQueueTimer( retired_arg->queue_handle, retired_arg->timer_handle, INVALID_HANDLE_VALUE );
387  if( retired_arg->rm ) delete retired_arg->inner_arg;
388  delete retired_arg;
389  AcquireSRWLockExclusive( &retiredTimersLock );
390  }
391  ReleaseSRWLockExclusive( &retiredTimersLock );
392 
393  }
394 protected:
399  InitializeSRWLock( &retiredTimersLock );
400  };
401 public:
412  bool addEvent( unsigned long micros, int type, ostimerq_handler func, event_descriptor_t *arg, bool rm, unsigned *event ) {
414  cleanupRetiredTimers();
415  if( timerQueueMap.find(type) == timerQueueMap.end() ) {
416  timerQueueMap[type].queue_handle = CreateTimerQueue();
417  InitializeSRWLock( &timerQueueMap[type].lock );
418  }
419  outer_arg->queue_handle = timerQueueMap[type].queue_handle;
420  outer_arg->inner_arg = arg;
421  outer_arg->func = func;
422  outer_arg->queue = this;
423  outer_arg->type = type;
424  outer_arg->rm = rm;
425  outer_arg->timer_queue = &timerQueueMap[type];
426  AcquireSRWLockExclusive( &timerQueueMap[type].lock );
427  CreateTimerQueueTimer( &outer_arg->timer_handle, timerQueueMap[type].queue_handle, WindowsTimerQueueHandler, (void *) outer_arg, micros/1000, 0, 0 );
428  timerQueueMap[type].arg_list.push_front(outer_arg);
429  ReleaseSRWLockExclusive( &timerQueueMap[type].lock );
430  return true;
431  }
438  bool cancelEvent( int type, unsigned *event ) {
439  TimerQueueMap_t::iterator iter = timerQueueMap.find( type );
440  if( iter == timerQueueMap.end() ) return false;
441  AcquireSRWLockExclusive( &timerQueueMap[type].lock );
442  while( ! timerQueueMap[type].arg_list.empty() ) {
443  WindowsTimerQueueHandlerArg *del_arg = timerQueueMap[type].arg_list.front();
444  timerQueueMap[type].arg_list.pop_front();
445  ReleaseSRWLockExclusive( &timerQueueMap[type].lock );
446  DeleteTimerQueueTimer( del_arg->queue_handle, del_arg->timer_handle, INVALID_HANDLE_VALUE );
447  if( del_arg->rm ) delete del_arg->inner_arg;
448  delete del_arg;
449  AcquireSRWLockExclusive( &timerQueueMap[type].lock );
450  }
451  ReleaseSRWLockExclusive( &timerQueueMap[type].lock );
452 
453  return true;
454  }
455 };
456 
460 VOID CALLBACK WindowsTimerQueueHandler( PVOID arg_in, BOOLEAN ignore );
461 
466 public:
473  WindowsTimerQueue *timerq = new WindowsTimerQueue();
474  return timerq;
475  };
476 };
477 
481 class WindowsTimer : public OSTimer {
482  friend class WindowsTimerFactory;
483 public:
489  virtual unsigned long sleep( unsigned long micros ) {
490  Sleep( micros/1000 );
491  return micros;
492  }
493 protected:
498 };
499 
504 public:
509  virtual OSTimer *createTimer() {
510  return new WindowsTimer();
511  }
512 };
513 
517 struct OSThreadArg {
519  void *arg;
521 };
522 
526 DWORD WINAPI OSThreadCallback( LPVOID input );
527 
531 class WindowsThread : public OSThread {
532  friend class WindowsThreadFactory;
533 private:
534  HANDLE thread_id;
535  OSThreadArg *arg_inner;
536 public:
543  virtual bool start( OSThreadFunction function, void *arg ) {
544  arg_inner = new OSThreadArg();
545  arg_inner->func = function;
546  arg_inner->arg = arg;
547  thread_id = CreateThread( NULL, 0, OSThreadCallback, arg_inner, 0, NULL );
548  if( thread_id == NULL ) return false;
549  else return true;
550  }
556  virtual bool join( OSThreadExitCode &exit_code ) {
557  if( WaitForSingleObject( thread_id, INFINITE ) != WAIT_OBJECT_0 ) return false;
558  exit_code = arg_inner->ret;
559  delete arg_inner;
560  return true;
561  }
562 protected:
567 };
568 
573 public:
579  return new WindowsThread();
580  }
581 };
582 
583 #define NETCLOCK_HZ_OTHER 1056000000
584 #define NETCLOCK_HZ_NANO 1000000000
585 #define ONE_WAY_PHY_DELAY 8000
586 #define NANOSECOND_CLOCK_PART_DESCRIPTION "I217-LM"
587 #define NETWORK_CARD_ID_PREFIX "\\\\.\\"
588 #define OID_INTEL_GET_RXSTAMP 0xFF020264
589 #define OID_INTEL_GET_TXSTAMP 0xFF020263
590 #define OID_INTEL_GET_SYSTIM 0xFF020262
591 #define OID_INTEL_SET_SYSTIM 0xFF020261
596 class WindowsTimestamper : public HWTimestamper {
597 private:
598  // No idea whether the underlying implementation is thread safe
599  HANDLE miniport;
600  LARGE_INTEGER tsc_hz;
601  LARGE_INTEGER netclock_hz;
602  DWORD readOID( NDIS_OID oid, void *output_buffer, DWORD size, DWORD *size_returned ) {
603  NDIS_OID oid_l = oid;
604  DWORD rc = DeviceIoControl(
605  miniport,
606  IOCTL_NDIS_QUERY_GLOBAL_STATS,
607  &oid_l,
608  sizeof(oid_l),
609  output_buffer,
610  size,
611  size_returned,
612  NULL );
613  if( rc == 0 ) return GetLastError();
614  return ERROR_SUCCESS;
615  }
616  Timestamp nanoseconds64ToTimestamp( uint64_t time ) {
617  Timestamp timestamp;
618  timestamp.nanoseconds = time % 1000000000;
619  timestamp.seconds_ls = (time / 1000000000) & 0xFFFFFFFF;
620  timestamp.seconds_ms = (uint16_t)((time / 1000000000) >> 32);
621  return timestamp;
622  }
623  uint64_t scaleNativeClockToNanoseconds( uint64_t time ) {
624  long double scaled_output = ((long double)netclock_hz.QuadPart)/1000000000;
625  scaled_output = ((long double) time)/scaled_output;
626  return (uint64_t) scaled_output;
627  }
628  uint64_t scaleTSCClockToNanoseconds( uint64_t time ) {
629  long double scaled_output = ((long double)tsc_hz.QuadPart)/1000000000;
630  scaled_output = ((long double) time)/scaled_output;
631  return (uint64_t) scaled_output;
632  }
633 public:
640  virtual bool HWTimestamper_init( InterfaceLabel *iface_label, OSNetworkInterface *net_iface );
654  virtual bool HWTimestamper_gettime( Timestamp *system_time, Timestamp *device_time, uint32_t *local_clock, uint32_t *nominal_clock_rate )
655  {
656  DWORD buf[6];
657  DWORD returned;
658  uint64_t now_net, now_tsc;
659  DWORD result;
660 
661  memset( buf, 0xFF, sizeof( buf ));
662  if(( result = readOID( OID_INTEL_GET_SYSTIM, buf, sizeof(buf), &returned )) != ERROR_SUCCESS ) return false;
663 
664  now_net = (((uint64_t)buf[1]) << 32) | buf[0];
665  now_net = scaleNativeClockToNanoseconds( now_net );
666  *device_time = nanoseconds64ToTimestamp( now_net );
667  device_time->_version = version;
668 
669  now_tsc = (((uint64_t)buf[3]) << 32) | buf[2];
670  now_tsc = scaleTSCClockToNanoseconds( now_tsc );
671  *system_time = nanoseconds64ToTimestamp( now_tsc );
672  system_time->_version = version;
673 
674  return true;
675  }
676 
686  virtual int HWTimestamper_txtimestamp( PortIdentity *identity, uint16_t sequenceId, Timestamp &timestamp, unsigned &clock_value, bool last )
687  {
688  DWORD buf[4], buf_tmp[4];
689  DWORD returned = 0;
690  uint64_t tx_r,tx_s;
691  DWORD result;
692  while(( result = readOID( OID_INTEL_GET_TXSTAMP, buf_tmp, sizeof(buf_tmp), &returned )) == ERROR_SUCCESS ) {
693  memcpy( buf, buf_tmp, sizeof( buf ));
694  }
695  if( result != ERROR_GEN_FAILURE ) {
696  fprintf( stderr, "Error is: %d\n", result );
697  return -1;
698  }
699  if( returned != sizeof(buf_tmp) ) return -72;
700  tx_r = (((uint64_t)buf[1]) << 32) | buf[0];
701  tx_s = scaleNativeClockToNanoseconds( tx_r );
702  tx_s += ONE_WAY_PHY_DELAY;
703  timestamp = nanoseconds64ToTimestamp( tx_s );
704  timestamp._version = version;
705 
706  return 0;
707  }
708 
718  virtual int HWTimestamper_rxtimestamp( PortIdentity *identity, uint16_t sequenceId, Timestamp &timestamp, unsigned &clock_value, bool last )
719  {
720  DWORD buf[4], buf_tmp[4];
721  DWORD returned;
722  uint64_t rx_r,rx_s;
723  DWORD result;
724  uint16_t packet_sequence_id;
725  while(( result = readOID( OID_INTEL_GET_RXSTAMP, buf_tmp, sizeof(buf_tmp), &returned )) == ERROR_SUCCESS ) {
726  memcpy( buf, buf_tmp, sizeof( buf ));
727  }
728  if( result != ERROR_GEN_FAILURE ) return -1;
729  if( returned != sizeof(buf_tmp) ) return -72;
730  packet_sequence_id = *((uint32_t *) buf+3) >> 16;
731  if( PLAT_ntohs( packet_sequence_id ) != sequenceId ) return -72;
732  rx_r = (((uint64_t)buf[1]) << 32) | buf[0];
733  rx_s = scaleNativeClockToNanoseconds( rx_r );
734  rx_s -= ONE_WAY_PHY_DELAY;
735  timestamp = nanoseconds64ToTimestamp( rx_s );
736  timestamp._version = version;
737 
738  return 0;
739  }
740 };
741 
742 
746 class WindowsNamedPipeIPC : public OS_IPC {
747 private:
748  HANDLE pipe_;
749  LockableOffset lOffset_;
750  PeerList peerList_;
751 public:
755  WindowsNamedPipeIPC() : pipe_(INVALID_HANDLE_VALUE) { };
760  if (pipe_ != 0 && pipe_ != INVALID_HANDLE_VALUE)
761  ::CloseHandle(pipe_);
762  }
768  virtual bool init(OS_IPC_ARG *arg = NULL);
781  virtual bool update(int64_t ml_phoffset, int64_t ls_phoffset, FrequencyRatio ml_freqoffset, FrequencyRatio ls_freq_offset, uint64_t local_time,
782  uint32_t sync_count, uint32_t pdelay_count, PortState port_state);
783 };
784 
785 #endif
virtual net_result send(LinkLayerAddress *addr, uint8_t *payload, size_t length, bool timestamp)
Sends a packet to a remote address.
Definition: windows_hal.hpp:78
Definition: avbts_osnet.hpp:330
int type
Definition: windows_hal.hpp:341
Definition: ieee1588.hpp:101
Definition: ieee1588.hpp:445
virtual ~WindowsPCAPNetworkInterface()
Definition: windows_hal.hpp:117
packet_error_t
Definition: packet.hpp:60
virtual bool join(OSThreadExitCode &exit_code)
Joins a terminated thread.
Definition: windows_hal.hpp:556
WindowsPCAPNetworkInterface()
Definition: windows_hal.hpp:125
struct packet_handle * pfhandle_t
Definition: packet.hpp:75
virtual unsigned getPayloadOffset()
Gets the offset to the start of data in the Layer 2 Frame.
Definition: windows_hal.hpp:111
Definition: windows_hal.hpp:166
virtual int HWTimestamper_rxtimestamp(PortIdentity *identity, uint16_t sequenceId, Timestamp &timestamp, unsigned &clock_value, bool last)
Gets the RX timestamp.
Definition: windows_hal.hpp:718
Definition: avbts_ostimer.hpp:62
friend VOID CALLBACK WindowsTimerQueueHandler(PVOID arg_in, BOOLEAN ignore)
Definition: windows_hal.hpp:481
Definition: windows_hal.hpp:465
HANDLE queue_handle
Definition: windows_hal.hpp:356
virtual OSTimer * createTimer()
Creates a new timer.
Definition: windows_hal.hpp:509
std::list< WindowsTimerQueueHandlerArg * > TimerArgList_t
Definition: windows_hal.hpp:350
uint8_t addr[ETHER_ADDR_OCTETS]
Definition: packet.hpp:70
Definition: avbts_ostimerq.hpp:49
OSCondition * createCondition()
Creates OSCondition class.
Definition: windows_hal.hpp:322
virtual bool start(OSThreadFunction function, void *arg)
Starts a new thread.
Definition: windows_hal.hpp:543
#define OID_INTEL_GET_TXSTAMP
Definition: windows_hal.hpp:589
WindowsTimer()
Definition: windows_hal.hpp:497
uint16_t PLAT_ntohs(uint16_t s)
Converts the unsigned short integer netshort from network byte order to host byte order...
void toOctetArray(uint8_t *address_octet_array)
Gets first 6 bytes from ethernet address of object LinkLayerAddress.
Definition: avbts_osnet.hpp:137
packet_error_t openInterfaceByAddr(pfhandle_t pfhandle, packet_addr_t *addr, int timeout)
Opens the interface by link layer address. Uses libpcap.
Definition: avbts_port.hpp:76
void freePacketHandle(pfhandle_t pfhandle)
Close the packet handle.
bool wait_prelock()
Acquire a new lock and increment the condition counter.
Definition: windows_hal.hpp:285
void * arg
Definition: linux_hal_common.hpp:494
Definition: avbts_clock.hpp:77
Definition: avbts_oscondition.hpp:106
Definition: ieee1588.hpp:93
#define OID_INTEL_GET_SYSTIM
Definition: windows_hal.hpp:590
Definition: linux_hal_common.hpp:492
OSLock * createLock(OSLockType type)
Creates a new lock mechanism.
Definition: windows_hal.hpp:253
bool initialize(OSLockType type)
Initializes lock interface.
Definition: windows_hal.hpp:207
uint8_t _version
8 bit version value
Definition: ieee1588.hpp:251
bool initialize()
Definition: windows_hal.hpp:275
packet_error_t recvFrame(pfhandle_t pfhandle, packet_addr_t *addr, uint8_t *payload, size_t &length)
Receives a frame.
bool waiting()
Checks if OS is waiting.
Definition: avbts_oscondition.hpp:96
bool cancelEvent(int type, unsigned *event)
Cancels an event from the queue.
Definition: windows_hal.hpp:438
packet_error_t packetBind(struct packet_handle *handle, uint16_t ethertype)
Set filters for packet handler.
Definition: windows_hal.hpp:503
void(* ostimerq_handler)(void *)
Definition: avbts_ostimerq.hpp:42
virtual bool createInterface(OSNetworkInterface **net_iface, InterfaceLabel *label, HWTimestamper *timestamper)
Create a network interface.
Definition: windows_hal.hpp:141
Definition: windows_hal.hpp:336
OSLockType
Definition: avbts_oslock.hpp:44
Definition: windows_hal.hpp:746
PortState
Definition: ptptypes.hpp:48
packet_error_t sendFrame(pfhandle_t pfhandle, packet_addr_t *addr, uint16_t ethertype, uint8_t *payload, size_t length)
Sends a frame through an interface using libpcap.
OSLockResult trylock()
Tries to acquire lock.
Definition: windows_hal.hpp:227
WindowsLock()
Definition: windows_hal.hpp:200
void closeInterface(pfhandle_t pfhandle)
Close the interface.
WindowsThread()
Definition: windows_hal.hpp:566
OSThreadFunction func
Definition: linux_hal_common.hpp:493
Definition: avbts_ostimerq.hpp:91
virtual OSTimerQueue * createOSTimerQueue(IEEE1588Clock *clock)
Creates a new timer queue.
Definition: windows_hal.hpp:472
Definition: avbts_osnet.hpp:52
bool wait()
Waits for a condition and decrements the condition counter when the condition is met.
Definition: windows_hal.hpp:295
#define PTP_ETHERTYPE
Definition: ptptypes.hpp:43
std::map< int, TimerQueue_t > TimerQueueMap_t
Definition: windows_hal.hpp:368
TimerArgList_t arg_list
Definition: windows_hal.hpp:355
Definition: avbts_oscondition.hpp:42
OSLockResult
Definition: avbts_oslock.hpp:52
void up()
Counts up waiting condition.
Definition: avbts_oscondition.hpp:80
#define OID_INTEL_GET_RXSTAMP
Definition: windows_hal.hpp:588
~WindowsNamedPipeIPC()
Definition: windows_hal.hpp:759
ostimerq_handler func
Definition: windows_hal.hpp:340
uint16_t seconds_ms
32 bit seconds MSB value
Definition: ieee1588.hpp:250
packet_error_t mallocPacketHandle(pfhandle_t *pfhandle_r)
Allocate memory for the packet handle.
Definition: avbts_osnet.hpp:277
bool addEvent(unsigned long micros, int type, ostimerq_handler func, event_descriptor_t *arg, bool rm, unsigned *event)
Create a new event and add it to the timer queue.
Definition: windows_hal.hpp:412
virtual int HWTimestamper_txtimestamp(PortIdentity *identity, uint16_t sequenceId, Timestamp &timestamp, unsigned &clock_value, bool last)
Gets the TX timestamp.
Definition: windows_hal.hpp:686
Definition: windows_hal.hpp:531
OSLockResult unlock()
Releases lock.
Definition: windows_hal.hpp:237
#define PACKET_HDR_LENGTH
Definition: packet.hpp:43
virtual bool HWTimestamper_gettime(Timestamp *system_time, Timestamp *device_time, uint32_t *local_clock, uint32_t *nominal_clock_rate)
Get the cross timestamping information. The gPTP subsystem uses these samples to calculate ratios whi...
Definition: windows_hal.hpp:654
WindowsNamedPipeIPC()
Definition: windows_hal.hpp:755
HANDLE queue_handle
Definition: windows_hal.hpp:338
Definition: windows_hal.hpp:246
VOID CALLBACK WindowsTimerQueueHandler(PVOID arg_in, BOOLEAN ignore)
Definition: windows_hal.hpp:132
Definition: PeerList.hpp:68
void down()
Conds down waiting condition.
Definition: avbts_oscondition.hpp:88
WindowsTimerQueue()
Definition: windows_hal.hpp:398
Definition: avbts_ostimer.hpp:42
DWORD WINAPI OSThreadCallback(LPVOID input)
virtual void getLinkLayerAddress(LinkLayerAddress *addr)
Gets the link layer address (MAC) of the network adapter.
Definition: windows_hal.hpp:104
bool signal()
Sends a signal to unblock other threads.
Definition: windows_hal.hpp:309
OSThreadExitCode
Definition: avbts_osthread.hpp:44
Definition: windows_hal.hpp:572
Definition: avbts_oslock.hpp:98
Definition: IPCListener.hpp:47
Definition: avbts_osthread.hpp:54
virtual bool init(OS_IPC_ARG *arg=NULL)
Initializes the IPC arguments.
net_result
Definition: avbts_osnet.hpp:272
#define ONE_WAY_PHY_DELAY
Definition: windows_hal.hpp:585
Definition: packet.hpp:69
Definition: windows_hal.hpp:354
Definition: avbts_oslock.hpp:57
OSThreadExitCode ret
Definition: linux_hal_common.hpp:495
Definition: avbts_osipc.hpp:56
Definition: avbts_osipc.hpp:46
long double FrequencyRatio
Definition: ptptypes.hpp:39
Definition: windows_hal.hpp:373
Definition: windows_hal.hpp:320
virtual unsigned long sleep(unsigned long micros)
Sleep for an amount of time.
Definition: windows_hal.hpp:489
OSLockResult lock()
Acquires lock.
Definition: windows_hal.hpp:217
Definition: windows_hal.hpp:266
bool rm
Definition: windows_hal.hpp:342
uint32_t seconds_ls
32 bit seconds LSB value
Definition: ieee1588.hpp:249
SRWLOCK lock
Definition: windows_hal.hpp:357
event_descriptor_t * inner_arg
Definition: windows_hal.hpp:339
virtual bool update(int64_t ml_phoffset, int64_t ls_phoffset, FrequencyRatio ml_freqoffset, FrequencyRatio ls_freq_offset, uint64_t local_time, uint32_t sync_count, uint32_t pdelay_count, PortState port_state)
Updates IPC interface values.
Definition: avbts_osthread.hpp:78
WindowsTimerQueue * queue
Definition: windows_hal.hpp:343
Definition: ieee1588.hpp:222
OSThreadExitCode(* OSThreadFunction)(void *)
Definition: avbts_osthread.hpp:49
OSThread * createThread()
Creates a new windows thread.
Definition: windows_hal.hpp:578
HANDLE timer_handle
Definition: windows_hal.hpp:337
virtual net_result nrecv(LinkLayerAddress *addr, uint8_t *payload, size_t &length)
Receives a packet from a remote address.
Definition: windows_hal.hpp:91
TimerQueue_t * timer_queue
Definition: windows_hal.hpp:344
Definition: windows_hal.hpp:64
uint32_t nanoseconds
32 bit nanoseconds value
Definition: ieee1588.hpp:248