Provide a method to send a management error status message.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2012-08-02 06:36:07 +02:00
parent f233528ea4
commit 21c2fe30c7
3 changed files with 45 additions and 0 deletions

32
port.c
View File

@ -1390,6 +1390,38 @@ int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg)
return 0; return 0;
} }
int port_managment_error(struct PortIdentity pid, struct port *ingress,
struct ptp_message *req, Enumeration16 error_id)
{
struct ptp_message *msg;
struct management_tlv *mgt;
struct management_error_status *mes;
int err = 0, pdulen;
msg = port_management_reply(pid, ingress, req);
if (!msg) {
return -1;
}
mgt = (struct management_tlv *) req->management.suffix;
mes = (struct management_error_status *) msg->management.suffix;
mes->type = TLV_MANAGEMENT_ERROR_STATUS;
mes->length = 8;
mes->error = error_id;
mes->id = mgt->id;
pdulen = msg->header.messageLength + sizeof(*mes);
msg->header.messageLength = pdulen;
msg->tlv_count = 1;
err = msg_pre_send(msg);
if (err) {
goto out;
}
err = port_forward(ingress, msg, pdulen);
out:
msg_put(msg);
return err;
}
struct ptp_message *port_management_reply(struct PortIdentity pid, struct ptp_message *port_management_reply(struct PortIdentity pid,
struct port *ingress, struct port *ingress,
struct ptp_message *req) struct ptp_message *req)

11
port.h
View File

@ -97,6 +97,17 @@ int port_forward(struct port *p, struct ptp_message *msg, int msglen);
*/ */
int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg); int port_manage(struct port *p, struct port *ingress, struct ptp_message *msg);
/**
* Send a management error status message.
* @param pid The id of the responding port.
* @param ingress Port on which the 'req' was received.
* @param req The management message which triggered the error.
* @param error_id One of the management error ID values.
* @return Zero on success, non-zero otherwise.
*/
int port_managment_error(struct PortIdentity pid, struct port *ingress,
struct ptp_message *req, Enumeration16 error_id);
/** /**
* Allocate a reply to a management message. * Allocate a reply to a management message.
* *

2
tlv.h
View File

@ -21,6 +21,8 @@
#define HAVE_TLV_H #define HAVE_TLV_H
#include "ddt.h" #include "ddt.h"
#include "msg.h"
#include "port.h"
/* TLV types */ /* TLV types */
#define TLV_MANAGEMENT 0x0001 #define TLV_MANAGEMENT 0x0001