syntax = "proto2";

package KismetExternalHttp;

option optimize_for = LITE_RUNTIME;

// Request an auth token be sent in a HttpAuthToken frame
message HttpAuthTokenRequest {

}

// Send a HTTP session auth token to the helper (Kismet->Helper)
// This lets the helper access administrative functions on the server
// without having to pass an actual login password
message HttpAuthToken {
    required string token = 1;
}

// Define an endpoint (Helper->Kismet)
// Registers a HTTP endpoint; requests to this endpoint will be sent to the
// helper via the HttpRequest message, which will, in turn, expect replies
// via the HttpResponse message.
message HttpRegisterUri {
    // Full URI, including file type; Helpers cannot take advantage of the Kismet
    // multi-serialization types so they must define a URI for each type
    required string uri = 1;
    // Method; ie GET or POST; a URI can only implement a single method and
    // must register multiple URIs for multiple methods.
    required string method = 2;
    // Authentication - does the URI require authentication?  The proxy can 
    // handle this automatically.
    optional bool obsolete_auth_required = 3;
}

// Sub-block of HTTP data, per-field
message SubHttpVariableData {
    // GET or POST field sent to Kismet
    required string field = 1;
    // Content of GET or POST data, as parsed by microhttpd
    required string content = 2;
}

// Handle an incoming HTTP request (Kismet->Helper)
message HttpRequest {
    // Unique ID of request, must be returned in the HttpResponse
    required uint32 req_id = 1;
    // Full URI of request
    required string uri = 2;
    // Method
    required string method = 3;
    // If post, a map of post variables
    repeated SubHttpVariableData variable_data = 4;
}

// Cancel an existing request (remote end went away)
message HttpRequestCancel {
    // Unique ID of request
    required uint32 req_id = 1;
}

// Sub-block of headers to send with the first response
message SubHttpHeader {
    // Header type to send
    required string header = 1;
    // Content of header
    required string content = 2;
}

// Respond to HTTP data (Helper->Kismet)
message HttpResponse {
    // Unique ID of request we're responding to
    required uint32 req_id = 1;
    // Headers being sent, if any
    repeated SubHttpHeader header_content = 2;
    // Content being sent, if any
    optional bytes content = 3;
    // Result code, if we're concluding this connection
    optional uint32 resultcode = 4;
    // Is this the end of this connection?
    optional bool close_response = 5;
}

