#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "libgdbr.h"
#include <stdio.h>
Go to the source code of this file.
◆ pack()
Definition at line 206 of file packet.c.
214 msg_len = strlen(
msg);
215 if (msg_len >
g->send_max + 5) {
216 eprintf(
"%s: message too long: %s", __func__,
msg);
222 g->send_buff[0] =
'$';
226 if (*
src ==
'#' || *
src ==
'$' || *
src ==
'}') {
228 if (msg_len >
g->send_max + 5) {
229 eprintf(
"%s: message too long: %s", __func__,
msg);
232 g->send_buff[
g->send_len++] =
'}';
233 g->send_buff[
g->send_len++] = *
src++ ^ 0x20;
236 g->send_buff[
g->send_len++] = *
src++;
242 while (
src[run_len] == prev) {
247 g->send_buff[
g->send_len++] = *
src++;
252 if (run_len == 35 || run_len == 36) {
254 }
else if (run_len > 126) {
257 g->send_buff[
g->send_len++] =
'*';
258 g->send_buff[
g->send_len++] = run_len;
259 msg_len -= run_len - 27;
262 g->send_buff[
g->send_len] =
'\0';
static struct sockaddr static addrlen static backlog const void msg
uint8_t cmd_checksum(const char *command)
References cmd_checksum(), eprintf, g, msg, snprintf, and src.
Referenced by send_msg(), xprint::to_x(), and xprint::to_x_32().
◆ read_packet()
Function reads data from the established connection.
- Parameters
-
g | the "instance" of the current libgdbr session |
vcont | whether it's called to receive reply to a vcont packet |
- Returns
- a failure code (currently -1) or 0 if call successfully
Definition at line 143 of file packet.c.
147 eprintf(
"Initialize libgdbr_t first\n");
151 if (
g->read_len > 0) {
154 g->data[
g->data_len] =
'\0';
155 if (
g->server_debug) {
156 eprintf(
"getpkt (\"%s\"); %s\n",
g->data,
157 g->no_ack ?
"[no ack sent]" :
"[sending ack]");
163 for (
i = 0;
i <
g->num_retries && !
g->isbreaked; vcont ? 0 :
i++) {
165 if (ret == 0 && !vcont) {
173 eprintf(
"%s: read failed\n", __func__);
178 eprintf(
"%s: unpack failed\n", __func__);
182 g->data[
g->data_len] =
'\0';
183 if (
g->server_debug) {
184 eprintf(
"getpkt (\"%s\"); %s\n",
g->data,
185 g->no_ack ?
"[no ack sent]" :
"[sending ack]");
RZ_API int rz_socket_ready(RzSocket *s, int secs, int usecs)
RZ_API void RZ_API int rz_socket_read(RzSocket *s, ut8 *read, int len)
static int unpack(libgdbr_t *g, struct parse_ctx *ctx, int len)
◆ send_packet()
sends a packet sends a packet to the established connection
- Parameters
-
g | the "instance" of the current libgdbr session |
- Returns
- a failure code (currently -1) or 0 if call successfully
Definition at line 193 of file packet.c.
195 eprintf(
"Initialize libgdbr_t first\n");
198 if (
g->server_debug) {
199 g->send_buff[
g->send_len] =
'\0';
200 eprintf(
"putpkt (\"%s\"); %s\n",
g->send_buff,
201 g->no_ack ?
"[noack mode]" :
"[looking for ack]");
RZ_API int rz_socket_write(RzSocket *s, void *buf, int len)
References eprintf, g, and rz_socket_write().
Referenced by send_msg().