Data Structures | |
struct | rfbVNCRec |
vncrec More... | |
struct | rfbClientData |
client data More... | |
struct | AppData |
app data (belongs into rfbClient?) More... | |
union | rfbCredential |
For GetCredentialProc callback function to return. More... | |
struct | rfbClient |
struct | rfbClientProtocolExtension |
Files | |
file | rfbclient.h |
Defines | |
#define | rfbClientSwap16IfLE(s) (*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
#define | rfbClientSwap32IfLE(l) |
#define | rfbClientSwap64IfLE(l) |
#define | FLASH_PORT_OFFSET 5400 |
#define | LISTEN_PORT_OFFSET 5500 |
#define | TUNNEL_PORT_OFFSET 5500 |
#define | SERVER_PORT_OFFSET 5900 |
#define | DEFAULT_SSH_CMD "/usr/bin/ssh" |
#define | DEFAULT_TUNNEL_CMD (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20") |
#define | DEFAULT_VIA_CMD (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20") |
#define | rfbCredentialTypeX509 1 |
#define | rfbCredentialTypeUser 2 |
Typedefs | |
typedef void(* | HandleTextChatProc )(struct _rfbClient *client, int value, char *text) |
Handles a text chat message. | |
typedef void(* | HandleXvpMsgProc )(struct _rfbClient *client, uint8_t version, uint8_t opcode) |
Handles XVP server messages. | |
typedef void(* | HandleKeyboardLedStateProc )(struct _rfbClient *client, int value, int pad) |
typedef rfbBool(* | HandleCursorPosProc )(struct _rfbClient *client, int x, int y) |
typedef void(* | SoftCursorLockAreaProc )(struct _rfbClient *client, int x, int y, int w, int h) |
typedef void(* | SoftCursorUnlockScreenProc )(struct _rfbClient *client) |
typedef void(* | GotFrameBufferUpdateProc )(struct _rfbClient *client, int x, int y, int w, int h) |
typedef void(* | FinishedFrameBufferUpdateProc )(struct _rfbClient *client) |
typedef char *(* | GetPasswordProc )(struct _rfbClient *client) |
typedef rfbCredential *(* | GetCredentialProc )(struct _rfbClient *client, int credentialType) |
typedef rfbBool(* | MallocFrameBufferProc )(struct _rfbClient *client) |
typedef void(* | GotXCutTextProc )(struct _rfbClient *client, const char *text, int textlen) |
typedef void(* | BellProc )(struct _rfbClient *client) |
typedef void(* | GotCursorShapeProc )(struct _rfbClient *client, int xhot, int yhot, int width, int height, int bytesPerPixel) |
typedef void(* | GotCopyRectProc )(struct _rfbClient *client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) |
typedef void(* | rfbClientLogProc )(const char *format,...) |
Functions | |
rfbBool | HandleCursorShape (rfbClient *client, int xhot, int yhot, int width, int height, uint32_t enc) |
void | listenForIncomingConnections (rfbClient *viewer) |
int | listenForIncomingConnectionsNoFork (rfbClient *viewer, int usec_timeout) |
rfbBool | ConnectToRFBServer (rfbClient *client, const char *hostname, int port) |
rfbBool | ConnectToRFBRepeater (rfbClient *client, const char *repeaterHost, int repeaterPort, const char *destHost, int destPort) |
void | SetClientAuthSchemes (rfbClient *client, const uint32_t *authSchemes, int size) |
rfbBool | InitialiseRFBConnection (rfbClient *client) |
rfbBool | SetFormatAndEncodings (rfbClient *client) |
Sends format and encoding parameters to the server. | |
rfbBool | SendIncrementalFramebufferUpdateRequest (rfbClient *client) |
rfbBool | SendFramebufferUpdateRequest (rfbClient *client, int x, int y, int w, int h, rfbBool incremental) |
Sends a framebuffer update request to the server. | |
rfbBool | SendScaleSetting (rfbClient *client, int scaleSetting) |
rfbBool | SendPointerEvent (rfbClient *client, int x, int y, int buttonMask) |
Sends a pointer event to the server. | |
rfbBool | SendKeyEvent (rfbClient *client, uint32_t key, rfbBool down) |
Sends a key event to the server. | |
rfbBool | SendClientCutText (rfbClient *client, char *str, int len) |
Places a string on the server's clipboard. | |
rfbBool | HandleRFBServerMessage (rfbClient *client) |
Handles messages from the RFB server. | |
rfbBool | TextChatSend (rfbClient *client, char *text) |
Sends a text chat message to the server. | |
rfbBool | TextChatOpen (rfbClient *client) |
Opens a text chat window on the server. | |
rfbBool | TextChatClose (rfbClient *client) |
Closes the text chat window on the server. | |
rfbBool | TextChatFinish (rfbClient *client) |
rfbBool | PermitServerInput (rfbClient *client, int enabled) |
rfbBool | SendXvpMsg (rfbClient *client, uint8_t version, uint8_t code) |
void | PrintPixelFormat (rfbPixelFormat *format) |
rfbBool | SupportsClient2Server (rfbClient *client, int messageType) |
rfbBool | SupportsServer2Client (rfbClient *client, int messageType) |
void | rfbClientSetClientData (rfbClient *client, void *tag, void *data) |
Associates a client data tag with the given pointer. | |
void * | rfbClientGetClientData (rfbClient *client, void *tag) |
Returns a pointer to the client data associated with the given tag. | |
void | rfbClientRegisterExtension (rfbClientProtocolExtension *e) |
rfbBool | ReadFromRFBServer (rfbClient *client, char *out, unsigned int n) |
rfbBool | WriteToRFBServer (rfbClient *client, char *buf, int n) |
int | FindFreeTcpPort (void) |
int | ListenAtTcpPort (int port) |
int | ListenAtTcpPortAndAddress (int port, const char *address) |
int | ConnectClientToTcpAddr (unsigned int host, int port) |
int | ConnectClientToTcpAddr6 (const char *hostname, int port) |
int | ConnectClientToUnixSock (const char *sockFile) |
int | AcceptTcpConnection (int listenSock) |
rfbBool | SetNonBlocking (int sock) |
rfbBool | SetDSCP (int sock, int dscp) |
rfbBool | StringToIPAddr (const char *str, unsigned int *addr) |
rfbBool | SameMachine (int sock) |
int | WaitForMessage (rfbClient *client, unsigned int usecs) |
Waits for an RFB message to arrive from the server. | |
rfbClient * | rfbGetClient (int bitsPerSample, int samplesPerPixel, int bytesPerPixel) |
Allocates and returns a pointer to an rfbClient structure. | |
rfbBool | rfbInitClient (rfbClient *client, int *argc, char **argv) |
Initializes the client. | |
void | rfbClientCleanup (rfbClient *client) |
Cleans up the client structure and releases the memory allocated for it. | |
Variables | |
rfbBool | rfbEnableClientLogging |
rfbClientLogProc | rfbClientLog |
rfbClientLogProc | rfbClientErr |
rfbBool | errorMessageOnReadFailure |
#define DEFAULT_SSH_CMD "/usr/bin/ssh" |
Definition at line 66 of file rfbclient.h.
#define DEFAULT_TUNNEL_CMD (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20") |
Definition at line 67 of file rfbclient.h.
#define DEFAULT_VIA_CMD (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20") |
Definition at line 69 of file rfbclient.h.
#define FLASH_PORT_OFFSET 5400 |
Definition at line 61 of file rfbclient.h.
#define LISTEN_PORT_OFFSET 5500 |
Definition at line 62 of file rfbclient.h.
#define rfbClientSwap16IfLE | ( | s | ) | (*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s)) |
Definition at line 42 of file rfbclient.h.
#define rfbClientSwap32IfLE | ( | l | ) |
(*(char *)&client->endianTest ? ((((l) & 0xff000000) >> 24) | \
(((l) & 0x00ff0000) >> 8) | \
(((l) & 0x0000ff00) << 8) | \
(((l) & 0x000000ff) << 24)) : (l))
Definition at line 45 of file rfbclient.h.
#define rfbClientSwap64IfLE | ( | l | ) |
(*(char *)&client->endianTest ? ((((l) & 0xff00000000000000ULL) >> 56) | \
(((l) & 0x00ff000000000000ULL) >> 40) | \
(((l) & 0x0000ff0000000000ULL) >> 24) | \
(((l) & 0x000000ff00000000ULL) >> 8) | \
(((l) & 0x00000000ff000000ULL) << 8) | \
(((l) & 0x0000000000ff0000ULL) << 24) | \
(((l) & 0x000000000000ff00ULL) << 40) | \
(((l) & 0x00000000000000ffULL) << 56)) : (l))
Definition at line 51 of file rfbclient.h.
#define rfbCredentialTypeUser 2 |
Definition at line 136 of file rfbclient.h.
#define rfbCredentialTypeX509 1 |
Definition at line 135 of file rfbclient.h.
#define SERVER_PORT_OFFSET 5900 |
Definition at line 64 of file rfbclient.h.
#define TUNNEL_PORT_OFFSET 5500 |
Definition at line 63 of file rfbclient.h.
typedef void(* BellProc)(struct _rfbClient *client) |
Definition at line 171 of file rfbclient.h.
typedef void(* FinishedFrameBufferUpdateProc)(struct _rfbClient *client) |
Definition at line 166 of file rfbclient.h.
typedef rfbCredential*(* GetCredentialProc)(struct _rfbClient *client, int credentialType) |
Definition at line 168 of file rfbclient.h.
typedef char*(* GetPasswordProc)(struct _rfbClient *client) |
Definition at line 167 of file rfbclient.h.
typedef void(* GotCopyRectProc)(struct _rfbClient *client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) |
Definition at line 174 of file rfbclient.h.
typedef void(* GotCursorShapeProc)(struct _rfbClient *client, int xhot, int yhot, int width, int height, int bytesPerPixel) |
Definition at line 173 of file rfbclient.h.
typedef void(* GotFrameBufferUpdateProc)(struct _rfbClient *client, int x, int y, int w, int h) |
Definition at line 165 of file rfbclient.h.
typedef void(* GotXCutTextProc)(struct _rfbClient *client, const char *text, int textlen) |
Definition at line 170 of file rfbclient.h.
typedef rfbBool(* HandleCursorPosProc)(struct _rfbClient *client, int x, int y) |
Definition at line 162 of file rfbclient.h.
typedef void(* HandleKeyboardLedStateProc)(struct _rfbClient *client, int value, int pad) |
Definition at line 161 of file rfbclient.h.
typedef void(* HandleTextChatProc)(struct _rfbClient *client, int value, char *text) |
Handles a text chat message.
If your application should accept text messages from the server, define a function with this prototype and set client->HandleTextChat to a pointer to that function subsequent to your rfbGetClient() call.
client | The client which called the text chat handler | |
value | text length if text != NULL, or one of rfbTextChatOpen, rfbTextChatClose, rfbTextChatFinished if text == NULL | |
text | The text message from the server |
Definition at line 150 of file rfbclient.h.
typedef void(* HandleXvpMsgProc)(struct _rfbClient *client, uint8_t version, uint8_t opcode) |
Handles XVP server messages.
If your application sends XVP messages to the server, you'll want to handle the server's XVP_FAIL and XVP_INIT responses. Define a function with this prototype and set client->HandleXvpMsg to a pointer to that function subsequent to your rfbGetClient() call.
client | The client which called the XVP message handler | |
version | The highest XVP extension version that the server supports | |
opcode | The opcode. 0 is XVP_FAIL, 1 is XVP_INIT |
Definition at line 160 of file rfbclient.h.
typedef rfbBool(* MallocFrameBufferProc)(struct _rfbClient *client) |
Definition at line 169 of file rfbclient.h.
typedef void(* rfbClientLogProc)(const char *format,...) |
Definition at line 363 of file rfbclient.h.
typedef void(* SoftCursorLockAreaProc)(struct _rfbClient *client, int x, int y, int w, int h) |
Definition at line 163 of file rfbclient.h.
typedef void(* SoftCursorUnlockScreenProc)(struct _rfbClient *client) |
Definition at line 164 of file rfbclient.h.
int AcceptTcpConnection | ( | int | listenSock | ) |
int ConnectClientToTcpAddr | ( | unsigned int | host, | |
int | port | |||
) |
int ConnectClientToTcpAddr6 | ( | const char * | hostname, | |
int | port | |||
) |
int ConnectClientToUnixSock | ( | const char * | sockFile | ) |
Handles messages from the RFB server.
You must call this function intermittently so LibVNCClient can parse messages from the server. For example, if your app has a draw loop, you could place a call to this function within that draw loop.
client | The client which will handle the RFB server messages |
Definition at line 1709 of file rfbproto.c.
int ListenAtTcpPort | ( | int | port | ) |
int ListenAtTcpPortAndAddress | ( | int | port, | |
const char * | address | |||
) |
void listenForIncomingConnections | ( | rfbClient * | viewer | ) |
int listenForIncomingConnectionsNoFork | ( | rfbClient * | viewer, | |
int | usec_timeout | |||
) |
static void PrintPixelFormat | ( | rfbPixelFormat * | format | ) |
void rfbClientCleanup | ( | rfbClient * | client | ) |
Cleans up the client structure and releases the memory allocated for it.
You should call this when you're done with the rfbClient structure that you allocated with rfbGetClient().
client | The client to clean up |
Definition at line 342 of file vncviewer.c.
void* rfbClientGetClientData | ( | rfbClient * | client, | |
void * | tag | |||
) |
Returns a pointer to the client data associated with the given tag.
See the the documentation for rfbClientSetClientData() for a discussion of how you can use client data.
client | The client from which to get the client data | |
tag | The tag which identifies the client data |
Definition at line 124 of file rfbproto.c.
void rfbClientRegisterExtension | ( | rfbClientProtocolExtension * | e | ) |
Definition at line 100 of file rfbproto.c.
void rfbClientSetClientData | ( | rfbClient * | client, | |
void * | tag, | |||
void * | data | |||
) |
Associates a client data tag with the given pointer.
LibVNCClient has several events to which you can associate your own handlers. These handlers have the client structure as one of their parameters. Sometimes, you may want to make data from elsewhere in your application available to these handlers without using a global variable. To do this, you call rfbClientSetClientData() and associate the data with a tag. Then, your handler can call rfbClientGetClientData() and get the a pointer to the data associated with that tag.
client | The client in which to set the client data | |
tag | A unique tag which identifies the data | |
data | A pointer to the data to associate with the tag |
Definition at line 108 of file rfbproto.c.
rfbClient* rfbGetClient | ( | int | bitsPerSample, | |
int | samplesPerPixel, | |||
int | bytesPerPixel | |||
) |
Allocates and returns a pointer to an rfbClient structure.
This will probably be the first LibVNCClient function your client code calls. Most libVNCClient functions operate on an rfbClient structure, and this function allocates memory for that structure. When you're done with the rfbClient structure pointer this function returns, you should free the memory rfbGetClient() allocated by calling rfbClientCleanup().
A pixel is one dot on the screen. The number of bytes in a pixel will depend on the number of samples in that pixel and the number of bits in each sample. A sample represents one of the primary colors in a color model. The RGB color model uses red, green, and blue samples respectively. Suppose you wanted to use 16-bit RGB color: You would have three samples per pixel (one for each primary color), five bits per sample (the quotient of 16 RGB bits divided by three samples), and two bytes per pixel (the smallest multiple of eight bits in which the 16-bit pixel will fit). If you wanted 32-bit RGB color, you would have three samples per pixel again, eight bits per sample (since that's how 32-bit color is defined), and four bytes per pixel (the smallest multiple of eight bits in which the 32-bit pixel will fit.
bitsPerSample | The number of bits in a sample | |
samplesPerPixel | The number of samples in a pixel | |
bytesPerPixel | The number of bytes in a pixel |
Definition at line 110 of file vncviewer.c.
Initializes the client.
The format is {PROGRAM_NAME, [OPTIONS]..., HOST}. This function does not initialize the program name if the rfbClient's program name is set already. The options are as follows:
Option | Description |
---|---|
-listen | Listen for incoming connections. |
-listennofork | Listen for incoming connections without forking. |
-play | Set this client to replay a previously recorded session. |
-encodings | Set the encodings to use. The next item in the argv array is the encodings string, consisting of comma separated encodings like 'tight,ultra,raw'. |
-compress | Set the compression level. The next item in the argv array is the compression level as an integer. Ranges from 0 (lowest) to 9 (highest). |
-scale | Set the scaling level. The next item in the argv array is the scaling level as an integer. The screen will be scaled down by this factor. |
-qosdscp | Set the Quality of Service Differentiated Services Code Point (QoS DSCP). The next item in the argv array is the code point as an integer. |
-repeaterdest | Set a VNC repeater address. The next item in the argv array is the repeater's address as a string. |
The host may include a port number (delimited by a ':').
client | The client to initialize | |
argc | The number of arguments to the initializer | |
argv | The arguments to the initializer as an array of NULL terminated strings |
Definition at line 263 of file vncviewer.c.
rfbBool SameMachine | ( | int | sock | ) |
Places a string on the server's clipboard.
Use this function if you want to be able to copy and paste between the server and your application. For instance, when your application is notified that the user copied some text onto the clipboard, you would call this function to synchronize the server's clipboard with your local clipboard.
client | The client structure through which to send the client cut text message | |
str | The string to send (doesn't need to be NULL terminated) | |
len | The length of the string |
Definition at line 1690 of file rfbproto.c.
rfbBool SendFramebufferUpdateRequest | ( | rfbClient * | client, | |
int | x, | |||
int | y, | |||
int | w, | |||
int | h, | |||
rfbBool | incremental | |||
) |
Sends a framebuffer update request to the server.
A VNC client may request an update from the server at any time. You can also specify which portions of the screen you want updated. This can be handy if a pointer is at certain location and the user pressed a mouse button, for instance. Then you can immediately request an update of the region around the pointer from the server.
client | The client through which to send the request | |
x | The horizontal position of the update request rectangle | |
y | The vertical position of the update request rectangle | |
w | The width of the update request rectangle | |
h | The height of the update request rectangle | |
incremental | false: server sends rectangle even if nothing changed. true: server only sends changed parts of rectangle. |
Definition at line 1487 of file rfbproto.c.
Definition at line 1474 of file rfbproto.c.
Sends a key event to the server.
If your application is not merely a VNC viewer (i.e. it controls the server), you'll want to send the keys that the user presses to the server. Use this function to do that.
client | The client through which to send the key event | |
key | An rfbKeySym defined in rfb/keysym.h | |
down | true if this was a key down event, false otherwise |
Definition at line 1672 of file rfbproto.c.
Sends a pointer event to the server.
A pointer event includes a cursor location and a button mask. The button mask indicates which buttons on the pointing device are pressed. Each button is represented by a bit in the button mask. A 1 indicates the button is pressed while a 0 indicates that it is not pressed. You may use these pre-defined button masks by ORing them together: rfbButton1Mask, rfbButton2Mask, rfbButton3Mask, rfbButton4Mask rfbButton5Mask
client | The client through which to send the pointer event | |
x | the horizontal location of the cursor | |
y | the vertical location of the cursor | |
buttonMask | the button mask indicating which buttons are pressed |
Definition at line 1650 of file rfbproto.c.
void SetClientAuthSchemes | ( | rfbClient * | client, | |
const uint32_t * | authSchemes, | |||
int | size | |||
) |
Definition at line 1009 of file rfbproto.c.
rfbBool SetDSCP | ( | int | sock, | |
int | dscp | |||
) |
Sends format and encoding parameters to the server.
Your application can modify the 'client' data structure directly. However some changes to this structure must be communicated back to the server. For instance, if you change the encoding to hextile, the server needs to know that it should send framebuffer updates in hextile format. Likewise if you change the pixel format of the framebuffer, the server must be notified about this as well. Call this function to propagate your changes of the local 'client' structure over to the server.
client | The client in which the format or encodings have been changed |
Definition at line 1263 of file rfbproto.c.
rfbBool SetNonBlocking | ( | int | sock | ) |
rfbBool StringToIPAddr | ( | const char * | str, | |
unsigned int * | addr | |||
) |
Definition at line 272 of file rfbproto.c.
Closes the text chat window on the server.
client | The client through which to send the message |
Definition at line 1574 of file rfbproto.c.
Opens a text chat window on the server.
client | The client through which to send the message |
Definition at line 1562 of file rfbproto.c.
Sends a text chat message to the server.
client | The client through which to send the message | |
text | The text to send |
Definition at line 1540 of file rfbproto.c.
int WaitForMessage | ( | rfbClient * | client, | |
unsigned int | usecs | |||
) |
Waits for an RFB message to arrive from the server.
Before handling a message with HandleRFBServerMessage(), you must wait for your client to receive one. This function blocks until a message is received. You may specify a timeout in microseconds. Once this number of microseconds have elapsed, the function will return.
client | The client to cause to wait until a message is received | |
usecs | The timeout in microseconds |
Definition at line 786 of file sockets.c.
Definition at line 94 of file rfbproto.c.
Definition at line 93 of file rfbproto.c.
Definition at line 69 of file rfbproto.c.