/* In addition, there are reserved session identifiers that can be defined for vehicle manufacturers and vehicle suppliers specific use. */
static int handle_diagnostic_session_control(struct upgrade_uds_t *self_p, int length)
/* In addition, there are reserved session identifiers that can be defined for vehicle manufacturers and vehicle suppliers specific use. */
static int handle_diagnostic_session_control(struct upgrade_uds_t *self_p, int length)
{
    uint8_t session;
    int res;
    if (length < 1) {
        ignore_and_write_negative_response(self_p,
                                           0,
                                           DIAGNOSTIC_SESSION_CONTROL,
                                           INCORRECT_MESSAGE_LENGTH_OR_INVALID_FORMAT);
        return (-1);
    }
    chan_read(self_p->chin_p, &session, sizeof(session));
    length -= 1;
    switch (session) {
    case DIAGNOSTIC_SESSION_CONTROL_DEFAULT:
        res = handle_diagnostic_session_control_default(self_p, length);
        break;
    default:
        ignore_and_write_negative_response(self_p,
                                           0,
                                           DIAGNOSTIC_SESSION_CONTROL,
                                           REQUEST_OUT_OF_RANGE);
        res = -1;
        break;
    }
    return (res);
}