mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging
slirp updates # gpg: Signature made Sat 29 Apr 2017 05:45:24 PM BST # gpg: using RSA key 0xB0A51BF58C9179C5 # gpg: Good signature from "Samuel Thibault <samuel.thibault@aquilenet.fr>" # gpg: aka "Samuel Thibault <sthibault@debian.org>" # gpg: aka "Samuel Thibault <samuel.thibault@gnu.org>" # gpg: aka "Samuel Thibault <samuel.thibault@inria.fr>" # gpg: aka "Samuel Thibault <samuel.thibault@labri.fr>" # gpg: aka "Samuel Thibault <samuel.thibault@ens-lyon.org>" # gpg: aka "Samuel Thibault <samuel.thibault@u-bordeaux.fr>" # Primary key fingerprint: 900C B024 B679 31D4 0F82 304B D017 8C76 7D06 9EE6 # Subkey fingerprint: AEBF 7448 FAB9 453A 4552 390E B0A5 1BF5 8C91 79C5 * sthibault/tags/samuel-thibault: slirp: VMStatify remaining except for loop slirp: VMStatify socket level slirp: Common lhost/fhost union slirp: VMStatify sbuf slirp: VMState conversion; tcpcb slirp: fix pinging the virtual ipv4 DNS server slirp: tftp, copy sockaddr_size slirp/smb: Replace constant strings by glib string slirp: allow host port 0 for hostfwd Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
+18
-14
@@ -80,7 +80,7 @@ typedef struct SlirpState {
|
||||
Slirp *slirp;
|
||||
Notifier exit_notifier;
|
||||
#ifndef _WIN32
|
||||
char smb_dir[128];
|
||||
gchar *smb_dir;
|
||||
#endif
|
||||
} SlirpState;
|
||||
|
||||
@@ -487,7 +487,7 @@ static int slirp_hostfwd(SlirpState *s, const char *redir_str,
|
||||
goto fail_syntax;
|
||||
}
|
||||
host_port = strtol(buf, &end, 0);
|
||||
if (*end != '\0' || host_port < 1 || host_port > 65535) {
|
||||
if (*end != '\0' || host_port < 0 || host_port > 65535) {
|
||||
goto fail_syntax;
|
||||
}
|
||||
|
||||
@@ -558,11 +558,10 @@ int net_slirp_redir(const char *redir_str)
|
||||
/* automatic user mode samba server configuration */
|
||||
static void slirp_smb_cleanup(SlirpState *s)
|
||||
{
|
||||
char cmd[128];
|
||||
int ret;
|
||||
|
||||
if (s->smb_dir[0] != '\0') {
|
||||
snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
|
||||
if (s->smb_dir) {
|
||||
gchar *cmd = g_strdup_printf("rm -rf %s", s->smb_dir);
|
||||
ret = system(cmd);
|
||||
if (ret == -1 || !WIFEXITED(ret)) {
|
||||
error_report("'%s' failed.", cmd);
|
||||
@@ -570,15 +569,17 @@ static void slirp_smb_cleanup(SlirpState *s)
|
||||
error_report("'%s' failed. Error code: %d",
|
||||
cmd, WEXITSTATUS(ret));
|
||||
}
|
||||
s->smb_dir[0] = '\0';
|
||||
g_free(cmd);
|
||||
g_free(s->smb_dir);
|
||||
s->smb_dir = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int slirp_smb(SlirpState* s, const char *exported_dir,
|
||||
struct in_addr vserver_addr)
|
||||
{
|
||||
char smb_conf[128];
|
||||
char smb_cmdline[128];
|
||||
char *smb_conf;
|
||||
char *smb_cmdline;
|
||||
struct passwd *passwd;
|
||||
FILE *f;
|
||||
|
||||
@@ -600,19 +601,19 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.XXXXXX");
|
||||
if (!mkdtemp(s->smb_dir)) {
|
||||
error_report("could not create samba server dir '%s'", s->smb_dir);
|
||||
s->smb_dir[0] = 0;
|
||||
s->smb_dir = g_dir_make_tmp("qemu-smb.XXXXXX", NULL);
|
||||
if (!s->smb_dir) {
|
||||
error_report("could not create samba server dir");
|
||||
return -1;
|
||||
}
|
||||
snprintf(smb_conf, sizeof(smb_conf), "%s/%s", s->smb_dir, "smb.conf");
|
||||
smb_conf = g_strdup_printf("%s/%s", s->smb_dir, "smb.conf");
|
||||
|
||||
f = fopen(smb_conf, "w");
|
||||
if (!f) {
|
||||
slirp_smb_cleanup(s);
|
||||
error_report("could not create samba server configuration file '%s'",
|
||||
smb_conf);
|
||||
g_free(smb_conf);
|
||||
return -1;
|
||||
}
|
||||
fprintf(f,
|
||||
@@ -651,15 +652,18 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
|
||||
);
|
||||
fclose(f);
|
||||
|
||||
snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -l %s -s %s",
|
||||
smb_cmdline = g_strdup_printf("%s -l %s -s %s",
|
||||
CONFIG_SMBD_COMMAND, s->smb_dir, smb_conf);
|
||||
g_free(smb_conf);
|
||||
|
||||
if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0 ||
|
||||
slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) {
|
||||
slirp_smb_cleanup(s);
|
||||
g_free(smb_cmdline);
|
||||
error_report("conflicting/invalid smbserver address");
|
||||
return -1;
|
||||
}
|
||||
g_free(smb_cmdline);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -152,8 +152,9 @@ icmp_input(struct mbuf *m, int hlen)
|
||||
switch (icp->icmp_type) {
|
||||
case ICMP_ECHO:
|
||||
ip->ip_len += hlen; /* since ip_input subtracts this */
|
||||
if (ip->ip_dst.s_addr == slirp->vhost_addr.s_addr) {
|
||||
icmp_reflect(m);
|
||||
if (ip->ip_dst.s_addr == slirp->vhost_addr.s_addr ||
|
||||
ip->ip_dst.s_addr == slirp->vnameserver_addr.s_addr) {
|
||||
icmp_reflect(m);
|
||||
} else if (slirp->restricted) {
|
||||
goto freeit;
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@
|
||||
#define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc)
|
||||
|
||||
struct sbuf {
|
||||
u_int sb_cc; /* actual chars in buffer */
|
||||
u_int sb_datalen; /* Length of data */
|
||||
uint32_t sb_cc; /* actual chars in buffer */
|
||||
uint32_t sb_datalen; /* Length of data */
|
||||
char *sb_wptr; /* write pointer. points to where the next
|
||||
* bytes should be written in the sbuf */
|
||||
char *sb_rptr; /* read pointer. points to where the next
|
||||
|
||||
+278
-228
File diff suppressed because it is too large
Load Diff
+11
-13
@@ -15,6 +15,12 @@
|
||||
* Our socket structure
|
||||
*/
|
||||
|
||||
union slirp_sockaddr {
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
};
|
||||
|
||||
struct socket {
|
||||
struct socket *so_next,*so_prev; /* For a linked list of sockets */
|
||||
|
||||
@@ -30,23 +36,15 @@ struct socket {
|
||||
* PING reply's */
|
||||
struct tcpiphdr *so_ti; /* Pointer to the original ti within
|
||||
* so_mconn, for non-blocking connections */
|
||||
int so_urgc;
|
||||
union { /* foreign host */
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
} fhost;
|
||||
uint32_t so_urgc;
|
||||
union slirp_sockaddr fhost; /* Foreign host */
|
||||
#define so_faddr fhost.sin.sin_addr
|
||||
#define so_fport fhost.sin.sin_port
|
||||
#define so_faddr6 fhost.sin6.sin6_addr
|
||||
#define so_fport6 fhost.sin6.sin6_port
|
||||
#define so_ffamily fhost.ss.ss_family
|
||||
|
||||
union { /* local host */
|
||||
struct sockaddr_storage ss;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in6 sin6;
|
||||
} lhost;
|
||||
union slirp_sockaddr lhost; /* Local host */
|
||||
#define so_laddr lhost.sin.sin_addr
|
||||
#define so_lport lhost.sin.sin_port
|
||||
#define so_laddr6 lhost.sin6.sin6_addr
|
||||
@@ -56,8 +54,8 @@ struct socket {
|
||||
uint8_t so_iptos; /* Type of service */
|
||||
uint8_t so_emu; /* Is the socket emulated? */
|
||||
|
||||
u_char so_type; /* Type of socket, UDP or TCP */
|
||||
int so_state; /* internal state flags SS_*, below */
|
||||
uint8_t so_type; /* Type of socket, UDP or TCP */
|
||||
int32_t so_state; /* internal state flags SS_*, below */
|
||||
|
||||
struct tcpcb *so_tcpcb; /* pointer to TCP protocol control block */
|
||||
u_int so_expire; /* When the socket will expire */
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ struct tcpcb {
|
||||
short t_rxtcur; /* current retransmit value */
|
||||
short t_dupacks; /* consecutive dup acks recd */
|
||||
u_short t_maxseg; /* maximum segment size */
|
||||
char t_force; /* 1 if forcing out a byte */
|
||||
uint8_t t_force; /* 1 if forcing out a byte */
|
||||
u_short t_flags;
|
||||
#define TF_ACKNOW 0x0001 /* ack peer immediately */
|
||||
#define TF_DELACK 0x0002 /* ack, but try to delay it */
|
||||
@@ -109,8 +109,8 @@ struct tcpcb {
|
||||
uint32_t max_sndwnd; /* largest window peer has offered */
|
||||
|
||||
/* out-of-band data */
|
||||
char t_oobflags; /* have some */
|
||||
char t_iobc; /* input character */
|
||||
uint8_t t_oobflags; /* have some */
|
||||
uint8_t t_iobc; /* input character */
|
||||
#define TCPOOB_HAVEDATA 0x01
|
||||
#define TCPOOB_HADDATA 0x02
|
||||
short t_softerror; /* possible error not yet reported */
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ static int tftp_session_allocate(Slirp *slirp, struct sockaddr_storage *srcsas,
|
||||
|
||||
found:
|
||||
memset(spt, 0, sizeof(*spt));
|
||||
spt->client_addr = *srcsas;
|
||||
memcpy(&spt->client_addr, srcsas, sockaddr_size(srcsas));
|
||||
spt->fd = -1;
|
||||
spt->block_size = 512;
|
||||
spt->client_port = tp->udp.uh_sport;
|
||||
|
||||
Reference in New Issue
Block a user