aboutsummaryrefslogtreecommitdiff
path: root/slirp
diff options
context:
space:
mode:
Diffstat (limited to 'slirp')
-rw-r--r--slirp/libslirp.h7
-rw-r--r--slirp/slirp.c15
-rw-r--r--slirp/tftp.c2
-rw-r--r--slirp/tftp.h2
4 files changed, 23 insertions, 3 deletions
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 47824b2413..772427d110 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -3,8 +3,10 @@
#ifdef _WIN32
#include <winsock2.h>
+int inet_aton(const char *cp, struct in_addr *ia);
#else
#include <sys/select.h>
+#include <arpa/inet.h>
#endif
void slirp_init(void);
@@ -20,4 +22,9 @@ void slirp_input(const uint8_t *pkt, int pkt_len);
int slirp_can_output(void);
void slirp_output(const uint8_t *pkt, int pkt_len);
+int slirp_redir(int is_udp, int host_port,
+ struct in_addr guest_addr, int guest_port);
+
+extern const char *tftp_prefix;
+
#endif
diff --git a/slirp/slirp.c b/slirp/slirp.c
index 405647b48c..bc2b15509a 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -617,3 +617,18 @@ void if_encap(const uint8_t *ip_data, int ip_data_len)
memcpy(buf + sizeof(struct ethhdr), ip_data, ip_data_len);
slirp_output(buf, ip_data_len + ETH_HLEN);
}
+
+int slirp_redir(int is_udp, int host_port,
+ struct in_addr guest_addr, int guest_port)
+{
+ if (is_udp) {
+ if (!udp_listen(htons(host_port), guest_addr.s_addr,
+ htons(guest_port), 0))
+ return -1;
+ } else {
+ if (!solisten(htons(host_port), guest_addr.s_addr,
+ htons(guest_port), 0))
+ return -1;
+ }
+ return 0;
+}
diff --git a/slirp/tftp.c b/slirp/tftp.c
index e50d255393..90526625c0 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -36,7 +36,7 @@ struct tftp_session {
struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
-char *tftp_prefix;
+const char *tftp_prefix;
static void tftp_session_update(struct tftp_session *spt)
{
diff --git a/slirp/tftp.h b/slirp/tftp.h
index 3ee666a153..f0560b6ab0 100644
--- a/slirp/tftp.h
+++ b/slirp/tftp.h
@@ -29,6 +29,4 @@ struct tftp_t {
} x;
};
-extern char *tftp_prefix;
-
void tftp_input(struct mbuf *m);