Add mosquitto_property_command_check()

pull/1022/head
Roger A. Light 7 years ago
parent 636e813d1c
commit 63a479564b

@ -96,4 +96,5 @@ MOSQ_1.6 {
global:
mosquitto_subscribe_multiple;
mosquitto_property_free_all;
mosquitto_property_command_check;
} MOSQ_1.5;

@ -1897,6 +1897,20 @@ libmosq_EXPORT int mosquitto_validate_utf8(const char *str, int len);
*/
libmosq_EXPORT void mosquitto_property_free_all(mosquitto_property **properties);
/*
* Function: mosquitto_property_command_check
*
* Check whether a property identifier is valid for the given command.
*
* Parameters:
* command - MQTT command (e.g. CMD_CONNECT)
* identifier - MQTT property (e.g. MQTT_PROP_USER_PROPERTY)
*
* Returns:
* MOSQ_ERR_SUCCESS - if the identifier is valid for command
* MOSQ_ERR_PROTOCOL - if the identifier is not valid for use with command.
*/
int mosquitto_property_command_check(int command, int identifier);
#ifdef __cplusplus
}

@ -451,13 +451,9 @@ int property__write_all(struct mosquitto__packet *packet, struct mqtt5__property
}
static int property__command_check(int command, struct mqtt5__property *properties)
int mosquitto_property_command_check(int command, int identifier)
{
struct mqtt5__property *p;
p = properties;
while(p){
switch(p->identifier){
switch(identifier){
case MQTT_PROP_PAYLOAD_FORMAT_INDICATOR:
case MQTT_PROP_MESSAGE_EXPIRY_INTERVAL:
case MQTT_PROP_CONTENT_TYPE:
@ -545,6 +541,18 @@ static int property__command_check(int command, struct mqtt5__property *properti
default:
return MOSQ_ERR_PROTOCOL;
}
return MOSQ_ERR_SUCCESS;
}
static int property__command_check(int command, struct mqtt5__property *properties)
{
struct mqtt5__property *p;
int rc;
p = properties;
while(p){
rc = mosquitto_property_command_check(command, p->identifier);
if(rc) return rc;
p = p->next;
}

Loading…
Cancel
Save