<!--
{
  "documentType" : "article",
  "framework" : "GSS",
  "identifier" : "/documentation/GSS/function-status",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Function Status"
}
-->

# Function Status

Evaluate return values that most GSS-API functions use to indicate the outcome of an operation.

## Discussion

The functions of the GSS-API return two status codes. The major status code, delivered as the function’s return value, provides a mechanism-independent status output. A value of [`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE) typically indicates success, but the code is actually composed of several fields that enable communicating a more nuanced result.  Always check the major status code to determine if an operation succeeds.

The minor status code provides additional information, often mechanism-specific, when an operation fails. This result returns using the [`OM_uint32`](/documentation/GSS/OM_uint32) pointer given as the function’s first argument. Examine this value to further debug a problem. For example, many functions allocate memory as a side effect of their main task. If memory allocation fails, the entire operation fails. But while the major status indicates a generic problem, a minor status of `ENOMEM` indicates that failed memory allocation is the exact culprit.

Three bitfields bundled together make up major status codes in a single [`OM_uint32`](/documentation/GSS/OM_uint32) value. These fields are:

- The calling error: A generic GSS-API error in the most significant 8 bits.
- The routine error: An error specific to the routine in the next 8 bits.
- Supplementary Information: Additional information about the error in the lower 16 bits.

When a function successfully runs to completion, it returns zero for all of these fields. As a convenience, you can compare the result directly with the status code [`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE) to test for this condition.

![Diagram of the three bitfields that make up the status codes in a value: the 8 bit calling error, the 8 bit routine error, and the 16 bit supplementary information.](images/com.apple.gss/media-3402053@2x.png)

For any other result, use one of the available extraction macros (such as [`GSS_CALLING_ERROR`](/documentation/GSS/GSS_CALLING_ERROR)) to obtain a value that you compare against one of the known error codes. For example, you can test for a failure to read one of the function inputs as follows:

```objc
OM_uint32 major = <# Some GSS call #>
if (GSS_CALLING_ERROR(major) == GSS_S_CALL_INACCESSIBLE_READ) {
    // Handle the error
}
```

Use the [`gss_display_status(_:_:_:_:_:_:)`](/documentation/GSS/gss_display_status(_:_:_:_:_:_:)) function to retrieve a human readable string corresponding to a given status result.

## Topics

### Status and Error Creation

[`OM_uint32`](/documentation/GSS/OM_uint32)

A 32-bit unsigned integer.

[`OM_uint64`](/documentation/GSS/OM_uint64)

A 64-bit unsigned integer.

[`gss_uint32`](/documentation/GSS/gss_uint32)

A 32-bit unsigned integer.

[`gss_status_id_t`](/documentation/GSS/gss_status_id_t)

A pointer to a status result.

[`GSS_C_MECH_CODE`](/documentation/GSS/GSS_C_MECH_CODE)

A flag that indicates the status code comes from a call to an underlying mechanism, such as Kerberos.

[`GSS_C_GSS_CODE`](/documentation/GSS/GSS_C_GSS_CODE)

A flag that indicates the named status code comes from a GSS-API call.

[`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE)

The operation completed without error.

[`gss_display_status`](/documentation/GSS/gss_display_status(_:_:_:_:_:_:))

Returns a human readable string for a status code.

[`GSSCreateError`](/documentation/GSS/GSSCreateError(_:_:_:))

Returns an error object based on GSS-API major and minor status codes.

### Calling Errors

[`GSS_S_CALL_BAD_STRUCTURE`](/documentation/GSS/GSS_S_CALL_BAD_STRUCTURE)

Improperly formatted parameter.

[`GSS_S_CALL_INACCESSIBLE_READ`](/documentation/GSS/GSS_S_CALL_INACCESSIBLE_READ)

A required input parameter could not be read.

[`GSS_S_CALL_INACCESSIBLE_WRITE`](/documentation/GSS/GSS_S_CALL_INACCESSIBLE_WRITE)

A required output parameter failed to write.

### Routine Errors

[`GSS_S_BAD_MECH`](/documentation/GSS/GSS_S_BAD_MECH)

Unsupported mechanism.

[`GSS_S_BAD_NAME`](/documentation/GSS/GSS_S_BAD_NAME)

Invalid name.

[`GSS_S_BAD_NAMETYPE`](/documentation/GSS/GSS_S_BAD_NAMETYPE)

Unsupported name type.

[`GSS_S_BAD_MIC`](/documentation/GSS/GSS_S_BAD_MIC)

Failed token integrity check.

[`GSS_S_BAD_SIG`](/documentation/GSS/GSS_S_BAD_SIG)

Failed token integrity check.

[`GSS_S_BAD_STATUS`](/documentation/GSS/GSS_S_BAD_STATUS)

Invalid status selector.

[`GSS_S_BAD_BINDINGS`](/documentation/GSS/GSS_S_BAD_BINDINGS)

Channel bindings mismatch.

[`GSS_S_NO_CRED`](/documentation/GSS/GSS_S_NO_CRED)

No valid credentials.

[`GSS_S_NO_CONTEXT`](/documentation/GSS/GSS_S_NO_CONTEXT)

No valid security context.

[`GSS_S_DEFECTIVE_TOKEN`](/documentation/GSS/GSS_S_DEFECTIVE_TOKEN)

Defective token.

[`GSS_S_DEFECTIVE_CREDENTIAL`](/documentation/GSS/GSS_S_DEFECTIVE_CREDENTIAL)

Defective credential.

[`GSS_S_CREDENTIALS_EXPIRED`](/documentation/GSS/GSS_S_CREDENTIALS_EXPIRED)

Expired credential.

[`GSS_S_CONTEXT_EXPIRED`](/documentation/GSS/GSS_S_CONTEXT_EXPIRED)

Expired context.

[`GSS_S_FAILURE`](/documentation/GSS/GSS_S_FAILURE)

An unspecified error.

[`GSS_S_BAD_QOP`](/documentation/GSS/GSS_S_BAD_QOP)

Unsupported QOP value.

[`GSS_S_UNAUTHORIZED`](/documentation/GSS/GSS_S_UNAUTHORIZED)

Unauthorized operation.

[`GSS_S_UNAVAILABLE`](/documentation/GSS/GSS_S_UNAVAILABLE)

Unavailable operation.

[`GSS_S_DUPLICATE_ELEMENT`](/documentation/GSS/GSS_S_DUPLICATE_ELEMENT)

A duplicate credential element requested.

[`GSS_S_NAME_NOT_MN`](/documentation/GSS/GSS_S_NAME_NOT_MN)

The name contains multimechanism elements.

[`GSS_S_BAD_MECH_ATTR`](/documentation/GSS/GSS_S_BAD_MECH_ATTR)

Unknown mechanism attribute.

[`GSS_S_CRED_UNAVAIL`](/documentation/GSS/GSS_S_CRED_UNAVAIL)

Unavailable credential.

### Token Macros

[`GSS_S_CONTINUE_NEEDED`](/documentation/GSS/GSS_S_CONTINUE_NEEDED)

A request for continuation during context establishment.

[`GSS_S_DUPLICATE_TOKEN`](/documentation/GSS/GSS_S_DUPLICATE_TOKEN)

The detection of a duplicate per-message token.

[`GSS_S_OLD_TOKEN`](/documentation/GSS/GSS_S_OLD_TOKEN)

The detection of a timed-out per-message token.

[`GSS_S_UNSEQ_TOKEN`](/documentation/GSS/GSS_S_UNSEQ_TOKEN)

The detection of a reordered (early) per-message token.

[`GSS_S_GAP_TOKEN`](/documentation/GSS/GSS_S_GAP_TOKEN)

The detection of a skipped predecessor token.

### Extraction Macros

[`GSS_ERROR`](/documentation/GSS/GSS_ERROR)

A macro that masks the supplementary info out of a major status code, leaving both calling and routine error fields.

[`GSS_CALLING_ERROR`](/documentation/GSS/GSS_CALLING_ERROR)

A macro that masks out all but the calling error field from a major status code.

[`GSS_ROUTINE_ERROR`](/documentation/GSS/GSS_ROUTINE_ERROR)

A macro that masks out all but the routine error field from a major status code.

[`GSS_SUPPLEMENTARY_INFO`](/documentation/GSS/GSS_SUPPLEMENTARY_INFO)

A macro that masks out all but the supplementary information field from a major status code.

### Masks and Offsets

[`GSS_C_CALLING_ERROR_MASK`](/documentation/GSS/GSS_C_CALLING_ERROR_MASK)

A mask with a width that matches the calling error field.

[`GSS_C_CALLING_ERROR_OFFSET`](/documentation/GSS/GSS_C_CALLING_ERROR_OFFSET)

The offset of the calling error field within the major status code.

[`GSS_C_ROUTINE_ERROR_MASK`](/documentation/GSS/GSS_C_ROUTINE_ERROR_MASK)

A mask with a width that matches the routine error field.

[`GSS_C_ROUTINE_ERROR_OFFSET`](/documentation/GSS/GSS_C_ROUTINE_ERROR_OFFSET)

The offset of the routine error field within the major status code.

[`GSS_C_SUPPLEMENTARY_MASK`](/documentation/GSS/GSS_C_SUPPLEMENTARY_MASK)

A mask with a width that matches the supplementary information field.

[`GSS_C_SUPPLEMENTARY_OFFSET`](/documentation/GSS/GSS_C_SUPPLEMENTARY_OFFSET)

The offset of the supplementary information field within the major status code.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)