-
Notifications
You must be signed in to change notification settings - Fork 0
Signaling Protocol
The RedPhone signaling protocol is very similar to a RESTful HTTP API, where every request yields a corresponding response, and authentication is done through an Authorization header.
Like SIP, however, both endpoints are simultaneously server and client, issuing requests and responses to each-other. You can browse the code for the available RedPhone signals.
RedPhone's basic signal format resembles a HTTP REST API:
<verb> <resource> HTTP/1.0\r\n
Authorization: [Basic|OTP] <authorization_string>\r\n
Content-Length: <length>\r\n
\r\n
<content>
Responses also resemble HTTP:
HTTP/1.0 <response_code> <response_string>\r\n
Content-Length: <length>\r\n
\r\n
<content>
The RedPhone signaling protocol differs from HTTP in the following ways:
- The addition of new HTTP verbs, beyond GET, PUT, and DELETE.
- The addition of a new Authorization type,
OTP. - That both ends of a signaling connection act as both client and server, each receiving requests and issuing responses.
The OTP Authorization type is a mechanism for transmitting HOTP-formatted credentials. The basic format is:
Authorization: OTP Base64Encoded(<phone_number>:<HOTP_credential>:<counter>)
- <phone_number> is the identifying number the device registered with.
- <HOTP_credential> is Hmac-SHA1(authentication_key, counter)
- <authentication_key> is an 144bit random key created by the client at registration time.
- <counter> is a monotonically incrementing counter. The server will not accept a counter value <= a value it has already seen.
-
Description: Sent by an
initiatorclient who wishes to establish a call with aresponder - Verb: GET
- Resource: /session/<responder_number>
Response Codes:
- 404: No such user, the specified responder number isn't registered with RedPhone.
- 401: Authentication failed.
- 200: Initiate successful.
Response body (application/json encoded):
{
"relayPort" : <port> // The UDP port for this session allocated on the relay server.
"sessionId" : <sessionId> // The session ID allocated for this session.
"serverName" : <name> // The name of the relay server.
}
-
Description: Sent by a
responderto indicate that it received an initiate signal, and that it is currently ringing. - Verb: RING
- Resource: /session/<session_id>
Response Codes:
- 404: No such session, or stale session.
- 401: Authentication failed.
- 200: Relayed.
-
Description: Sent by a
responderto indicate that it received an initiate signal, but that it is not able to ring (typically another call is in progress). - Verb: BUSY
- Resource: /session/<session_id>
Response Codes:
- 404: No such session, or stale session.
- 401: Authentication failed.
- 200: Relayed.
-
Description: Sent by an
initiatororresponderto indicate that they are terminating the call. - Verb: DELETE
- Resource: /session/<session_id>
Response Codes:
- 404: No such session, or stale session.
- 401: Authentication failed.
- 200: Relayed.
The initiate signal is transmitted to a responder via SMS, C2DM, or GCM. These are compact transports with limited space, and require special formatting to account for these size restrictions.
When transmitted over such transports, the initiate signal is encoded using protobuf. You can view the source for the protobuf IDL here.
This signal is also encrypted, of course, which is documented separately.