Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
PPSi
Commits
39ed260c
Commit
39ed260c
authored
Dec 06, 2011
by
Aurelio Colosimo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime opts and initializing state mostly implemented
parent
8f51b53c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
212 additions
and
20 deletions
+212
-20
Makefile
arch-gnu-linux/Makefile
+2
-1
posix-socket.c
arch-gnu-linux/posix-socket.c
+13
-0
posix-startup.c
arch-gnu-linux/posix-startup.c
+10
-0
posix-timer.c
arch-gnu-linux/posix-timer.c
+59
-0
constants.h
include/pproto/constants.h
+3
-0
ieee1588_types.h
include/pproto/ieee1588_types.h
+5
-1
pproto.h
include/pproto/pproto.h
+48
-4
open-close.c
proto-standard/open-close.c
+25
-1
state-initializing.c
proto-standard/state-initializing.c
+47
-13
No files found.
arch-gnu-linux/Makefile
View file @
39ed260c
...
@@ -8,7 +8,8 @@ LIBARCH := $A/libarch.a
...
@@ -8,7 +8,8 @@ LIBARCH := $A/libarch.a
OBJ-libarch
:=
$A
/posix-startup.o
\
OBJ-libarch
:=
$A
/posix-startup.o
\
$A
/main-loop.o
\
$A
/main-loop.o
\
$A
/posix-socket.o
\
$A
/posix-socket.o
\
$A
/posix-io.o
$A
/posix-io.o
\
$A
/posix-timer.o
\
$(LIBARCH)
:
$(OBJ-libarch)
$(LIBARCH)
:
$(OBJ-libarch)
$(AR)
r
$@
$^
$(AR)
r
$@
$^
...
...
arch-gnu-linux/posix-socket.c
View file @
39ed260c
...
@@ -91,3 +91,16 @@ int posix_net_init(struct pp_instance *ppi)
...
@@ -91,3 +91,16 @@ int posix_net_init(struct pp_instance *ppi)
int
pp_net_init
(
struct
pp_instance
*
ppi
)
int
pp_net_init
(
struct
pp_instance
*
ppi
)
__attribute__
((
alias
(
"posix_net_init"
)));
__attribute__
((
alias
(
"posix_net_init"
)));
/*
* Shutdown all the network stuff
* TODO
*/
int
posix_net_shutdown
(
struct
pp_instance
*
ppi
)
{
return
0
;
}
int
pp_net_shutdown
(
struct
pp_instance
*
ppi
)
__attribute__
((
alias
(
"posix_net_shutdown"
)));
arch-gnu-linux/posix-startup.c
View file @
39ed260c
...
@@ -31,6 +31,16 @@ int main(int argc, char **argv)
...
@@ -31,6 +31,16 @@ int main(int argc, char **argv)
if
(
!
ppi
)
if
(
!
ppi
)
exit
(
__LINE__
);
exit
(
__LINE__
);
ppi
->
defaultDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
defaultDS
));
ppi
->
currentDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
currentDS
));
ppi
->
parentDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
parentDS
));
ppi
->
portDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
portDS
));
ppi
->
timePropertiesDS
=
calloc
(
1
,
sizeof
(
*
ppi
->
timePropertiesDS
));
if
((
!
ppi
->
defaultDS
)
||
(
!
ppi
->
currentDS
)
||
(
!
ppi
->
parentDS
)
||
(
!
ppi
->
portDS
)
||
(
!
ppi
->
timePropertiesDS
))
exit
(
__LINE__
);
if
(
posix_open_ch
(
ppi
,
ifname
))
{
if
(
posix_open_ch
(
ppi
,
ifname
))
{
pp_diag_fatal
(
ppi
,
"open_ch"
,
strerror
(
errno
));
pp_diag_fatal
(
ppi
,
"open_ch"
,
strerror
(
errno
));
}
}
...
...
arch-gnu-linux/posix-timer.c
0 → 100644
View file @
39ed260c
/*
* FIXME header
*/
/* Timer interface for GNU/Linux (and most likely other posix systems */
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <pproto/pproto.h>
#include <pproto/diag.h>
#include "posix.h"
extern
int
posix_timer_init
(
struct
pp_timer
*
tm
)
{
/* TODO */
return
0
;
}
extern
int
posix_timer_start
(
struct
pp_timer
*
tm
)
{
/* TODO */
return
0
;
}
extern
int
posix_timer_stop
(
struct
pp_timer
*
tm
)
{
/* TODO */
return
0
;
}
extern
int
posix_timer_update
(
struct
pp_timer
*
tm
)
{
/* TODO */
return
0
;
}
extern
int
posix_timer_expired
(
struct
pp_timer
*
tm
)
{
/* TODO */
return
0
;
}
int
pp_timer_init
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_init"
)));
int
pp_timer_start
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_start"
)));
int
pp_timer_stop
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_stop"
)));
int
pp_timer_update
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_update"
)));
int
pp_timer_expired
(
struct
pp_timer
*
tm
)
__attribute__
((
alias
(
"posix_timer_expired"
)));
include/pproto/constants.h
View file @
39ed260c
...
@@ -39,4 +39,7 @@
...
@@ -39,4 +39,7 @@
#define PP_TIMER_ANNOUNCE_RECEIPT 3
#define PP_TIMER_ANNOUNCE_RECEIPT 3
#define PP_TIMER_ANNOUNCE_INTERVAL 4
#define PP_TIMER_ANNOUNCE_INTERVAL 4
#define PP_TWO_STEP_FLAG 2
#define PP_VERSION_PTP 2
#endif
/* __PTP_CONSTANTS_H__ */
#endif
/* __PTP_CONSTANTS_H__ */
include/pproto/ieee1588_types.h
View file @
39ed260c
...
@@ -24,6 +24,10 @@ typedef uint8_t Enumeration4;
...
@@ -24,6 +24,10 @@ typedef uint8_t Enumeration4;
typedef
uint8_t
UInteger4
;
typedef
uint8_t
UInteger4
;
typedef
uint8_t
Nibble
;
typedef
uint8_t
Nibble
;
#define PP_CLOCK_IDENTITY_LENGTH 8
/* FIXME: each struct must be aligned for lower memory usage */
typedef
struct
{
typedef
struct
{
uint32_t
lsb
;
uint32_t
lsb
;
uint16_t
msb
;
uint16_t
msb
;
...
@@ -48,7 +52,7 @@ typedef struct {
...
@@ -48,7 +52,7 @@ typedef struct {
Integer32
nanoseconds
;
Integer32
nanoseconds
;
}
TimeInternal
;
}
TimeInternal
;
typedef
Octet
*
ClockIdentity
;
/*FIXME: allocate CLOCK_IDENTITY_LENGTH = 8 */
typedef
Octet
ClockIdentity
[
PP_CLOCK_IDENTITY_LENGTH
];
typedef
struct
{
typedef
struct
{
ClockIdentity
clockIdentity
;
ClockIdentity
clockIdentity
;
...
...
include/pproto/pproto.h
View file @
39ed260c
/*
/*
*
Alessandro Rubini for CERN, 2011 -- public domain
*
FIXME: header
*/
*/
#ifndef __PTP_PROTO_H__
#ifndef __PTP_PROTO_H__
#define __PTP_PROTO_H__
#define __PTP_PROTO_H__
...
@@ -8,15 +8,47 @@
...
@@ -8,15 +8,47 @@
#include <stdarg.h>
#include <stdarg.h>
#include <arch/arch.h>
/* ntohs and so on */
#include <arch/arch.h>
/* ntohs and so on */
#include <pproto/ieee1588_types.h>
#include <pproto/ieee1588_types.h>
#include <pproto/constants.h>
/*
/*
* Runtime options. Default values can be overridden by command line.
* Runtime options. Default values can be overridden by command line.
*/
*/
struct
pp_runtime_opts
{
struct
pp_runtime_opts
{
/* TODO */
ClockQuality
clock_quality
;
TimeInternal
inboundLatency
,
outboundLatency
;
Integer32
max_rst
;
/* Maximum number of nanoseconds to reset */
Integer32
max_dly
;
/* Maximum number of nanoseconds of delay */
Integer32
ttl
;
char
*
unicast_addr
;
UInteger32
slave_only
:
1
,
no_adjust
:
1
,
display_stats
:
1
,
csv_stats
:
1
,
ethernet_mode
:
1
,
e2e_mode
:
1
,
ofst_first_updated
:
1
,
no_rst_clk
:
1
,
use_syslog
:
1
;
Integer16
ap
,
ai
;
Integer16
s
;
Integer16
max_foreign_records
;
Integer16
cur_utc_ofst
;
Integer8
announce_intvl
;
Integer8
sync_intvl
;
UInteger8
prio1
;
UInteger8
prio2
;
UInteger8
domain_number
;
char
*
iface_name
;
void
*
arch_opts
;
/*TODO ARCH: arch_opts, for arch-gnu-linux, might include the following:
* int log_fd;
* char *record_file; [PP_PATH_MAX]
* FILE *record_fp;
* char *file; [PP_PATH_MAX]
*/
};
};
extern
struct
pp_runtime_opts
default_rt_opts
;
/* preinitialized
extern
struct
pp_runtime_opts
default_rt_opts
;
/* preinitialized
* with default values */
* with default values */
...
@@ -64,14 +96,26 @@ extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv);
...
@@ -64,14 +96,26 @@ extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv);
/* Network stuff */
/* Network stuff */
extern
int
pp_net_init
(
struct
pp_instance
*
ppi
);
extern
int
pp_net_init
(
struct
pp_instance
*
ppi
);
extern
int
pp_net_shutdown
(
struct
pp_instance
*
ppi
);
extern
int
pp_recv_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
int
pp_recv_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
int
pp_send_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
extern
int
pp_send_packet
(
struct
pp_instance
*
ppi
,
void
*
pkt
,
int
len
);
/* Timer stuff */
struct
pp_timer
{
int
dummy
;
/* FIXME */
};
extern
int
pp_timer_init
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_start
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_stop
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_update
(
struct
pp_timer
*
tm
);
extern
int
pp_timer_expired
(
struct
pp_timer
*
tm
);
/* Get a timestamp */
/* Get a timestamp */
extern
void
pp_get_stamp
(
uint32_t
*
sptr
);
extern
void
pp_get_stamp
(
uint32_t
*
sptr
);
/*
/*
* The state machine itself is an array of these structures.
* The state machine itself is an array of these structures.
*/
*/
...
...
proto-standard/open-close.c
View file @
39ed260c
...
@@ -12,7 +12,31 @@
...
@@ -12,7 +12,31 @@
*/
*/
struct
pp_runtime_opts
default_rt_opts
=
{
struct
pp_runtime_opts
default_rt_opts
=
{
/* TODO */
.
max_rst
=
FALSE
,
.
max_dly
=
FALSE
,
.
slave_only
=
FALSE
,
.
no_adjust
=
TRUE
,
.
display_stats
=
FALSE
,
.
csv_stats
=
FALSE
,
.
ethernet_mode
=
FALSE
,
.
e2e_mode
=
FALSE
,
.
ofst_first_updated
=
FALSE
,
.
no_rst_clk
=
PP_DEFAULT_NO_RESET_CLOCK
,
.
use_syslog
=
FALSE
,
.
ap
=
PP_DEFAULT_AP
,
.
ai
=
PP_DEFAULT_AI
,
.
s
=
PP_DEFAULT_DELAY_S
,
.
max_foreign_records
=
PP_DEFAULT_MAX_FOREIGN_RECORDS
,
.
cur_utc_ofst
=
PP_DEFAULT_UTC_OFFSET
,
.
announce_intvl
=
PP_DEFAULT_ANNOUNCE_INTERVAL
,
.
sync_intvl
=
PP_DEFAULT_SYNC_INTERVAL
,
.
prio1
=
PP_DEFAULT_PRIORITY1
,
.
prio2
=
PP_DEFAULT_PRIORITY2
,
.
domain_number
=
PP_DEFAULT_DOMAIN_NUMBER
,
.
unicast_addr
=
0
,
.
iface_name
=
0
,
.
ttl
=
1
,
.
arch_opts
=
0
,
};
};
...
...
proto-standard/state-initializing.c
View file @
39ed260c
...
@@ -10,24 +10,58 @@
...
@@ -10,24 +10,58 @@
int
pp_initializing
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
int
pp_initializing
(
struct
pp_instance
*
ppi
,
unsigned
char
*
pkt
,
int
plen
)
{
{
struct
pp_runtime_opts
*
rt_opts
=
ppi
->
rt_opts
;
pp_net_shutdown
(
ppi
);
/* FIXME
if
(
pp_net_init
(
ppi
)
<
0
)
if
(
pp_net_init
(
ppi
)
<
0
)
goto
failure
;
goto
failure
;
*/
/* TODO initialize other stuff */
/* Initialize default data set */
/* TODO copy &ppi->rt_opts to &ppi->ppc. Do it here, no real need for a
ppi
->
defaultDS
->
twoStepFlag
=
PP_TWO_STEP_FLAG
;
initData function */
/* TODO initialize clockIdentity with MAC address */
/* TODO ARCH initTimer(); define a "timer" abstract object, define it for
ppi
->
defaultDS
->
clockIdentity
[
3
]
=
0xff
;
all the archs and initialize it here */
ppi
->
defaultDS
->
clockIdentity
[
4
]
=
0xfe
;
/* TODO CHECK initClock(rtOpts, ptpClock); check what is it for */
ppi
->
defaultDS
->
numberPorts
=
1
;
/* TODO CHECK m1(ptpClock);*/
pp_memcpy
(
&
ppi
->
defaultDS
->
clockQuality
,
&
rt_opts
->
clock_quality
,
/* TODO initializes header of a packet msgPackHeader(ptpClock->msgObuf,
sizeof
(
ClockQuality
));
ptpClock); */
ppi
->
defaultDS
->
priority1
=
rt_opts
->
prio1
;
ppi
->
defaultDS
->
priority2
=
rt_opts
->
prio2
;
if
(
1
)
/* FIXME: implement above */
ppi
->
defaultDS
->
domainNumber
=
rt_opts
->
domain_number
;
ppi
->
defaultDS
->
slaveOnly
=
rt_opts
->
slave_only
;
if
(
rt_opts
->
slave_only
)
ppi
->
defaultDS
->
clockQuality
.
clockClass
=
255
;
/* Initialize port data set */
pp_memcpy
(
ppi
->
portDS
->
portIdentity
.
clockIdentity
,
ppi
->
defaultDS
->
clockIdentity
,
PP_CLOCK_IDENTITY_LENGTH
);
ppi
->
portDS
->
portIdentity
.
portNumber
=
1
;
ppi
->
portDS
->
logMinDelayReqInterval
=
PP_DEFAULT_DELAYREQ_INTERVAL
;
ppi
->
portDS
->
peerMeanPathDelay
.
seconds
=
0
;
ppi
->
portDS
->
peerMeanPathDelay
.
nanoseconds
=
0
;
ppi
->
portDS
->
logAnnounceInterval
=
rt_opts
->
announce_intvl
;
ppi
->
portDS
->
announceReceiptTimeout
=
PP_DEFAULT_ANNOUNCE_RECEIPT_TIMEOUT
;
ppi
->
portDS
->
logSyncInterval
=
rt_opts
->
sync_intvl
;
ppi
->
portDS
->
delayMechanism
=
PP_DEFAULT_DELAY_MECHANISM
;
ppi
->
portDS
->
logMinPdelayReqInterval
=
PP_DEFAULT_PDELAYREQ_INTERVAL
;
ppi
->
portDS
->
versionNumber
=
PP_VERSION_PTP
;
if
(
pp_timer_init
(
0
))
/* FIXME */
goto
failure
;
goto
failure
;
/* TODO Check the following code coming from ptpd.
*
* Init all remaining stuff:
* initClock(rtOpts, ptpClock);
*
* Set myself as master (in case will not receive any announce):
* m1(ptpClock);
*
* Prepare a message:
* msgPackHeader(ptpClock->msgObuf,ptpClock);
*/
ppi
->
next_state
=
PPS_LISTENING
;
ppi
->
next_state
=
PPS_LISTENING
;
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment