mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
trezor.msg: udp supports only one interface
This commit is contained in:
parent
a2a4b285d4
commit
d77373eef7
@ -15,6 +15,7 @@
|
|||||||
#include "../../trezorhal/usb.h"
|
#include "../../trezorhal/usb.h"
|
||||||
#include "../../trezorhal/touch.h"
|
#include "../../trezorhal/touch.h"
|
||||||
|
|
||||||
|
#define TREZOR_UDP_IFACE 0
|
||||||
#define TREZOR_UDP_PORT 21324
|
#define TREZOR_UDP_PORT 21324
|
||||||
|
|
||||||
static int sock;
|
static int sock;
|
||||||
@ -74,6 +75,9 @@ int usb_vcp_add(const usb_vcp_info_t *info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int usb_hid_can_read(uint8_t iface_num) {
|
int usb_hid_can_read(uint8_t iface_num) {
|
||||||
|
if (iface_num != TREZOR_UDP_IFACE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
struct pollfd fds[] = {
|
struct pollfd fds[] = {
|
||||||
{ sock, POLLIN, 0 },
|
{ sock, POLLIN, 0 },
|
||||||
};
|
};
|
||||||
@ -86,6 +90,9 @@ int usb_hid_can_read(uint8_t iface_num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int usb_hid_can_write(uint8_t iface_num) {
|
int usb_hid_can_write(uint8_t iface_num) {
|
||||||
|
if (iface_num != TREZOR_UDP_IFACE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
struct pollfd fds[] = {
|
struct pollfd fds[] = {
|
||||||
{ sock, POLLOUT, 0 },
|
{ sock, POLLOUT, 0 },
|
||||||
};
|
};
|
||||||
@ -98,6 +105,9 @@ int usb_hid_can_write(uint8_t iface_num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
|
int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
|
||||||
|
if (iface_num != TREZOR_UDP_IFACE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
struct sockaddr_in si;
|
struct sockaddr_in si;
|
||||||
socklen_t sl = sizeof(si);
|
socklen_t sl = sizeof(si);
|
||||||
ssize_t r = recvfrom(sock, buf, len, MSG_DONTWAIT, (struct sockaddr *)&si, &sl);
|
ssize_t r = recvfrom(sock, buf, len, MSG_DONTWAIT, (struct sockaddr *)&si, &sl);
|
||||||
@ -116,6 +126,9 @@ int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
|
||||||
|
if (iface_num != TREZOR_UDP_IFACE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ssize_t r = len;
|
ssize_t r = len;
|
||||||
if (slen > 0) {
|
if (slen > 0) {
|
||||||
r = sendto(sock, buf, len, MSG_DONTWAIT, (const struct sockaddr *)&si_other, slen);
|
r = sendto(sock, buf, len, MSG_DONTWAIT, (const struct sockaddr *)&si_other, slen);
|
||||||
|
Loading…
Reference in New Issue
Block a user