43 #include <minwinbase.h>
46 #define OUTSTANDING_MESSAGES 10
48 #define PIPE_PREFIX "\\\\.\\pipe\\"
49 #define P802_1AS_PIPENAME "gptp-ctrl"
58 uint32_t pdelay_count;
73 typedef enum { BASE_MSG = 0, CTRL_MSG, QUERY_MSG, OFFSET_MSG }
NPIPE_MSG_TYPE;
100 DWORD last_error = ERROR_SUCCESS;
101 if(
sz == 0 )
return false;
102 if( WriteFile( pipe,
this,
sz, &bytes_written, NULL ) == 0 ) {
103 last_error = GetLastError();
105 if( last_error == ERROR_SUCCESS || last_error == ERROR_PIPE_LISTENING ) {
108 XPTPD_ERROR(
"Failed to write to named pipe: %u", last_error );
118 long read_ol( HANDLE pipe,
long offs, HANDLE event ) {
120 long sz_l = (long)
sz;
122 if( sz_l - offs < 0 || sz_l == 0 )
return -1;
123 if( sz_l - offs == 0 )
return offs;
125 if( event != NULL ) {
132 if( ReadFile( pipe, ((
char *)
this)+offs,
ol_read_req, &bytes_read, lol ) == 0 ) {
133 int err = GetLastError();
134 if( err != ERROR_IO_PENDING ) {
137 return err == ERROR_IO_PENDING ? 0 : -1;
139 return (bytes_read == sz_l-offs) ? offs+bytes_read : -1;
149 if( GetOverlappedResult( pipe, &
ol_read, &bytes_read,
false ) == 0 ) {
160 long read( HANDLE pipe,
long offs ) {
161 return read_ol( pipe, offs, NULL );
203 memset( &this->offset, 0,
sizeof( this->offset ));
229 this->offset = *offset;
270 typedef enum { MAC_ADDR, IP_ADDR, INVALID_ADDR }
AddrWhich;
303 return (result == 0) ?
true :
false;
323 return (result < 0) ?
true :
false;
418 #define NPIPE_MAX_CLIENT_MSG_SZ (sizeof( WindowsNPipeMsgClient ))
419 #define NPIPE_MAX_SERVER_MSG_SZ (sizeof( WindowsNPipeMsgServer ))
420 #define NPIPE_MAX_MSG_SZ (NPIPE_MAX_CLIENT_MSG_SZ > NPIPE_MAX_SERVER_MSG_SZ ? NPIPE_MAX_CLIENT_MSG_SZ : NPIPE_MAX_SERVER_MSG_SZ)
NPIPE_MSG_TYPE
Definition: windows/daemon_cl/ipcdef.hpp:73
CtrlWhich getCtrlWhich()
Gets control type.
Definition: windows/daemon_cl/ipcdef.hpp:372
CtrlWhich
Definition: windows/daemon_cl/ipcdef.hpp:263
Definition: windows/daemon_cl/ipcdef.hpp:275
DWORD ol_read_req
Definition: windows/daemon_cl/ipcdef.hpp:84
DWORD sz
Definition: windows/daemon_cl/ipcdef.hpp:80
long read_ol(HANDLE pipe, long offs, HANDLE event)
Reads from the pipe.
Definition: windows/daemon_cl/ipcdef.hpp:118
WinNPipeQueryMessage b
Definition: windows/daemon_cl/ipcdef.hpp:407
PeerAddr getPeerAddr()
Gets peer addresses.
Definition: windows/daemon_cl/ipcdef.hpp:361
Definition: windows/daemon_cl/ipcdef.hpp:330
void init()
Initializes interface and clears the Offset message.
Definition: windows/daemon_cl/ipcdef.hpp:201
FrequencyRatio getLocalSystemFreqOffset()
Gets Local to system frequency offset.
Definition: windows/daemon_cl/ipcdef.hpp:250
#define ETHER_ADDR_OCTETS
Definition: ptptypes.hpp:41
FrequencyRatio ls_freqoffset
Definition: windows/daemon_cl/ipcdef.hpp:178
Definition: windows/daemon_cl/ipcdef.hpp:414
void init()
Initializes the interface.
Definition: windows/daemon_cl/ipcdef.hpp:398
Definition: windows/daemon_cl/ipcdef.hpp:78
void init(int64_t ml_phoffset, FrequencyRatio ml_freqoffset, int64_t ls_phoffset, FrequencyRatio ls_freqoffset, uint64_t local_time)
Initializes the interface with specific values.
Definition: windows/daemon_cl/ipcdef.hpp:214
NPIPE_MSG_TYPE type
Definition: windows/daemon_cl/ipcdef.hpp:81
Definition: linux/src/ipcdef.hpp:45
AddrWhich which
Definition: windows/daemon_cl/ipcdef.hpp:277
int64_t ml_phoffset
Definition: windows/daemon_cl/ipcdef.hpp:175
NPIPE_MSG_TYPE getType()
Gets pipe message type.
Definition: windows/daemon_cl/ipcdef.hpp:167
Definition: windows/daemon_cl/ipcdef.hpp:392
PortState
Definition: ptptypes.hpp:48
bool write(HANDLE pipe)
Writes to the named pipe.
Definition: windows/daemon_cl/ipcdef.hpp:98
bool operator<(const PeerAddr &other) const
Implements the operator '<' overloading method.
Definition: windows/daemon_cl/ipcdef.hpp:310
Definition: windows/daemon_cl/ipcdef.hpp:405
#define XPTPD_ERROR(fmt,...)
Definition: debugout.hpp:41
void _init()
Initializes interface.
Definition: windows/daemon_cl/ipcdef.hpp:193
void setPeerAddr(PeerAddr addr)
Sets peer address.
Definition: windows/daemon_cl/ipcdef.hpp:367
FrequencyRatio getMasterLocalFreqOffset()
Gets Master to local frequency offset.
Definition: windows/daemon_cl/ipcdef.hpp:240
void init()
Initializes interace's internal variables.
Definition: windows/daemon_cl/ipcdef.hpp:340
FrequencyRatio ml_freqoffset
Definition: windows/daemon_cl/ipcdef.hpp:176
int64_t getLocalSystemOffset()
Gets local to system phase offset.
Definition: windows/daemon_cl/ipcdef.hpp:245
WinNPipeOffsetUpdateMessage a
Definition: windows/daemon_cl/ipcdef.hpp:415
uint8_t mac[ETHER_ADDR_OCTETS]
Definition: windows/daemon_cl/ipcdef.hpp:282
long read_ol_complete(HANDLE pipe)
Reads completely the overlapped result.
Definition: windows/daemon_cl/ipcdef.hpp:147
uint64_t local_time
Definition: windows/daemon_cl/ipcdef.hpp:179
bool operator==(const PeerAddr &other) const
Implements the operator '==' overloading method.
Definition: windows/daemon_cl/ipcdef.hpp:290
AddrWhich
Definition: windows/daemon_cl/ipcdef.hpp:270
int64_t getMasterLocalOffset()
Gets master to local phase offset.
Definition: windows/daemon_cl/ipcdef.hpp:235
void setCtrlWhich(CtrlWhich which)
Sets control message type.
Definition: windows/daemon_cl/ipcdef.hpp:378
#define IP_ADDR_OCTETS
Definition: ptptypes.hpp:42
void init()
Initializes the interface.
Definition: windows/daemon_cl/ipcdef.hpp:90
void init(CtrlWhich which, PeerAddr addr)
Initializes Interface's internal variables and sets control and addresses values. ...
Definition: windows/daemon_cl/ipcdef.hpp:351
uint16_t getFlags()
Gets internal flags.
Definition: windows/daemon_cl/ipcdef.hpp:384
WinNPipeCtrlMessage a
Definition: windows/daemon_cl/ipcdef.hpp:406
long double FrequencyRatio
Definition: ptptypes.hpp:39
int64_t ls_phoffset
Definition: windows/daemon_cl/ipcdef.hpp:177
void init(Offset *offset)
Initializes the interface based on the Offset structure.
Definition: windows/daemon_cl/ipcdef.hpp:227
OVERLAPPED ol_read
Definition: windows/daemon_cl/ipcdef.hpp:83
uint64_t getLocalTime()
Gets local time.
Definition: windows/daemon_cl/ipcdef.hpp:255
uint8_t ip[IP_ADDR_OCTETS]
Definition: windows/daemon_cl/ipcdef.hpp:283
long read(HANDLE pipe, long offs)
Reads from the pipe.
Definition: windows/daemon_cl/ipcdef.hpp:160
Definition: windows/daemon_cl/ipcdef.hpp:185
Definition: windows/daemon_cl/ipcdef.hpp:173