Add conn conn_pop_packet.
This commit is contained in:
parent
b9bef6a9af
commit
9ac39e6a12
|
@ -5,29 +5,54 @@
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "(gdb) Launch",
|
"name": "mini-gdbstub",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/mini-gdbstub/build/emu",
|
"program": "${workspaceFolder}/mini-gdbstub/build/emu",
|
||||||
"args": ["./mini-gdbstub/build/emu_test.bin"],
|
"args": [
|
||||||
|
"./mini-gdbstub/build/emu_test.bin"
|
||||||
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}/mini-gdbstub",
|
"cwd": "${workspaceFolder}/mini-gdbstub",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
{
|
{
|
||||||
"description": "Enable pretty-printing for gdb",
|
"description": "Enable pretty-printing for gdb",
|
||||||
"text": "-enable-pretty-printing",
|
"text": "-enable-pretty-printing",
|
||||||
"ignoreFailures": true
|
"ignoreFailures": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Set Disassembly Flavor to Intel",
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
"text": "-gdb-set disassembly-flavor intel",
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
"ignoreFailures": true
|
"ignoreFailures": true
|
||||||
}
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gdbstub",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/gdbstub/build/stub",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"cwd": "${workspaceFolder}/gdbstub",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Set Disassembly Flavor to Intel",
|
||||||
|
"text": "-gdb-set disassembly-flavor intel",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -8,5 +8,11 @@ int main(int argc, char *argv[]) {
|
||||||
conn_t conn;
|
conn_t conn;
|
||||||
if (!conn_init(&conn, "127.0.0.1", 1234)) std::cout << "conn_init error" << std::endl;
|
if (!conn_init(&conn, "127.0.0.1", 1234)) std::cout << "conn_init error" << std::endl;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
conn_recv_packet(&conn);
|
||||||
|
packet_t *pkt = conn_pop_packet(&conn);
|
||||||
|
printf("packet = %s\n", pkt->data);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
|
||||||
#define MAX_SEND_PACKET_SIZE (0x1000)
|
#define MAX_SEND_PACKET_SIZE (0x1000)
|
||||||
#define MAX_DATA_PAYLOAD (MAX_SEND_PACKET_SIZE - (2 + CSUM_SIZE + 2))
|
#define MAX_DATA_PAYLOAD (MAX_SEND_PACKET_SIZE - (2 + CSUM_SIZE + 2))
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int listen_fd;
|
int listen_fd;
|
||||||
int socket_fd;
|
int socket_fd;
|
||||||
|
|
||||||
pktbuf_t pktbuf;
|
pktbuf_t pktbuf;
|
||||||
} conn_t;
|
} conn_t;
|
||||||
|
|
||||||
bool conn_init(conn_t *conn, char *addr_str, int port);
|
bool conn_init(conn_t *conn, char *addr_str, int port);
|
||||||
|
|
Loading…
Reference in New Issue