port: Hook into the unicast service logic.
Now that all the pieces are in place, hook the port logic into the unicast service code. Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
63598688b7
commit
b9b18268cd
1
config.c
1
config.c
|
@ -265,6 +265,7 @@ struct config_item config_tab[] = {
|
|||
PORT_ITEM_INT("udp_ttl", 1, 1, 255),
|
||||
PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
|
||||
GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
|
||||
PORT_ITEM_INT("unicast_listen", 0, 0, 1),
|
||||
PORT_ITEM_INT("unicast_master_table", 0, 0, INT_MAX),
|
||||
PORT_ITEM_INT("unicast_req_duration", 3600, 10, INT_MAX),
|
||||
GLOB_ITEM_INT("use_syslog", 1, 0, 1),
|
||||
|
|
|
@ -42,6 +42,7 @@ hybrid_e2e 0
|
|||
net_sync_monitor 0
|
||||
tc_spanning_tree 0
|
||||
tx_timestamp_timeout 1
|
||||
unicast_listen 0
|
||||
unicast_master_table 0
|
||||
unicast_req_duration 3600
|
||||
use_syslog 1
|
||||
|
|
7
port.c
7
port.c
|
@ -41,6 +41,7 @@
|
|||
#include "tmv.h"
|
||||
#include "tsproc.h"
|
||||
#include "unicast_client.h"
|
||||
#include "unicast_service.h"
|
||||
#include "util.h"
|
||||
|
||||
#define ALLOWED_LOST_RESPONSES 3
|
||||
|
@ -2212,6 +2213,7 @@ void port_close(struct port *p)
|
|||
rtnl_close(p->fda.fd[FD_RTNL]);
|
||||
}
|
||||
|
||||
unicast_service_cleanup(p);
|
||||
transport_destroy(p->trp);
|
||||
tsproc_destroy(p->tsproc);
|
||||
if (p->fault_fd >= 0) {
|
||||
|
@ -2476,7 +2478,7 @@ static enum fsm_event bc_event(struct port *p, int fd_index)
|
|||
|
||||
case FD_UNICAST_SRV_TIMER:
|
||||
pr_debug("port %hu: unicast service timeout", portnum(p));
|
||||
return EV_NONE;
|
||||
return unicast_service_timer(p) ? EV_FAULT_DETECTED : EV_NONE;
|
||||
|
||||
case FD_UNICAST_REQ_TIMER:
|
||||
pr_debug("port %hu: unicast request timeout", portnum(p));
|
||||
|
@ -2892,6 +2894,9 @@ struct port *port_open(int phc_index,
|
|||
config_set_section_int(cfg, p->name, "hybrid_e2e", 1)) {
|
||||
goto err_port;
|
||||
}
|
||||
if (number && unicast_service_initialize(p)) {
|
||||
goto err_port;
|
||||
}
|
||||
p->hybrid_e2e = config_get_int(cfg, p->name, "hybrid_e2e");
|
||||
|
||||
if (number && type == CLOCK_TYPE_P2P && p->delayMechanism != DM_P2P) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
#include "port_private.h"
|
||||
#include "unicast_client.h"
|
||||
#include "unicast_service.h"
|
||||
|
||||
struct ptp_message *port_signaling_construct(struct port *p,
|
||||
struct address *address,
|
||||
|
@ -49,7 +50,7 @@ struct ptp_message *port_signaling_construct(struct port *p,
|
|||
int process_signaling(struct port *p, struct ptp_message *m)
|
||||
{
|
||||
struct tlv_extra *extra;
|
||||
int err = 0;
|
||||
int err = 0, result;
|
||||
|
||||
switch (p->state) {
|
||||
case PS_INITIALIZING:
|
||||
|
@ -69,13 +70,29 @@ int process_signaling(struct port *p, struct ptp_message *m)
|
|||
TAILQ_FOREACH(extra, &m->tlv_list, list) {
|
||||
switch (extra->tlv->type) {
|
||||
case TLV_REQUEST_UNICAST_TRANSMISSION:
|
||||
result = unicast_service_add(p, m, extra);
|
||||
switch (result) {
|
||||
case SERVICE_GRANTED:
|
||||
err = unicast_service_grant(p, m, extra);
|
||||
break;
|
||||
case SERVICE_DENIED:
|
||||
err = unicast_service_deny(p, m, extra);
|
||||
break;
|
||||
case SERVICE_DISABLED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case TLV_GRANT_UNICAST_TRANSMISSION:
|
||||
unicast_client_grant(p, m, extra);
|
||||
break;
|
||||
|
||||
case TLV_CANCEL_UNICAST_TRANSMISSION:
|
||||
err = unicast_client_cancel(p, m, extra);
|
||||
unicast_service_remove(p, m, extra);
|
||||
break;
|
||||
|
||||
case TLV_ACKNOWLEDGE_CANCEL_UNICAST_TRANSMISSION:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -403,7 +403,9 @@ int unicast_service_initialize(struct port *p)
|
|||
if (!config_get_int(cfg, p->name, "unicast_listen")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (config_set_section_int(cfg, p->name, "hybrid_e2e", 1)) {
|
||||
return -1;
|
||||
}
|
||||
p->unicast_service = calloc(1, sizeof(*p->unicast_service));
|
||||
if (!p->unicast_service) {
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue