Commit 74da3f32 authored by Aurelio Colosimo's avatar Aurelio Colosimo

integration of msg.c src file, containing function for message handling

parent 86c25f77
......@@ -27,6 +27,11 @@ int pp_memcmp(void *s1, const void *s2, int count)
return memcmp(s1, s2, count);
}
void *pp_memset(void *s, int c, int count)
{
return memset(s, c, count);
}
void pp_get_stamp(uint32_t *sptr)
{
*sptr = htonl(time(NULL));
......
......@@ -31,6 +31,7 @@ int main(int argc, char **argv)
if (!ppi)
exit(__LINE__);
ppi->sent_seq_id = calloc(16, sizeof(*ppi->sent_seq_id));
ppi->defaultDS = calloc(1, sizeof(*ppi->defaultDS));
ppi->currentDS = calloc(1, sizeof(*ppi->currentDS));
ppi->parentDS = calloc(1, sizeof(*ppi->parentDS));
......@@ -38,7 +39,8 @@ int main(int argc, char **argv)
ppi->timePropertiesDS = calloc(1, sizeof(*ppi->timePropertiesDS));
if ((!ppi->defaultDS) || (!ppi->currentDS) || (!ppi->parentDS)
|| (!ppi->portDS) || (!ppi->timePropertiesDS))
|| (!ppi->portDS) || (!ppi->timePropertiesDS) || (!ppi->sent_seq_id)
)
exit(__LINE__);
if (posix_open_ch(ppi, ifname)) {
......
......@@ -15,5 +15,6 @@ extern void pp_puts(const char *s);
extern int pp_strnlen(const char *s, int maxlen);
extern void *pp_memcpy(void *d, const void *s, int count);
extern int pp_memcmp(void *s1, const void *s2, int count);
extern void *pp_memset(void *s, int c, int count);
#endif /* __PTP_DEP_H__ */
......@@ -42,4 +42,15 @@
#define PP_TWO_STEP_FLAG 2
#define PP_VERSION_PTP 2
#define PP_HEADER_LENGTH 34
#define PP_ANNOUNCE_LENGTH 64
#define PP_SYNC_LENGTH 44
#define PP_FOLLOW_UP_LENGTH 44
#define PP_PDELAY_REQ_LENGTH 54
#define PP_DELAY_REQ_LENGTH 44
#define PP_DELAY_RESP_LENGTH 54
#define PP_PDELAY_RESP_LENGTH 54
#define PP_PDELAY_RESP_FOLLOW_UP_LENGTH 54
#define PP_MANAGEMENT_LENGTH 48
#endif /* __PTP_CONSTANTS_H__ */
......@@ -108,13 +108,13 @@ struct pp_instance {
DSTimeProperties *timePropertiesDS;
struct pp_timer *timers[PP_TIMER_ARRAY_SIZE];
/* FIXME: check the variables below. Now inherited from ptpd src*/
/* FIXME: check the variables from now on. Now inherited from ptpd src*/
UInteger16 number_foreign_records;
Integer16 max_foreign_records;
Integer16 foreign_record_i;
Integer16 foreign_record_best;
Boolean record_update;
MsgHeader msg_tmp_header;
union {
MsgSync sync;
MsgFollowUp follow;
......@@ -127,6 +127,11 @@ struct pp_instance {
MsgAnnounce announce;
MsgSignaling signaling;
} msg_tmp;
UInteger16 *sent_seq_id; /* sequence id of the last message sent of the
* same type
*/
MsgHeader msg_tmp_header;
MsgHeader pdelay_req_hdr;
};
......@@ -150,8 +155,11 @@ 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_send_packet(struct pp_instance *ppi, void *pkt, int len);
extern UInteger32 pp_htonl(UInteger32 hostlong);
extern UInteger16 pp_htons(UInteger16 hostlong);
/* Timers */
extern int pp_timer_init(struct pp_instance *ppi); /* initializes timer common
structure */
extern int pp_timer_start(struct pp_timer *tm);
......
......@@ -18,6 +18,7 @@ OBJ-libstd := $D/state-table-default.o \
$D/state-uncalibrated.o \
$D/state-slave.o \
$D/bmc.o \
$D/msg.o \
$D/open-close.o
$(TARGET).o: $(LIBSTD)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment