Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removing rejected patching

  • Loading branch information...
commit 86928efb0d36c4b057d701dbaa7d30bd38b564fb 1 parent fdb77f3
Julien Iguchi-Cartigny kartoch authored
35 src/tools-20070815/Makefile.orig
View
@@ -1,35 +0,0 @@
-TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl)
-
-SUBDIRS = lib jail jailtest humfsify mconsole moo port-helper $(TUNCTL) \
- uml_net uml_switch watchdog umlfs
-UMLVER = $(shell date +%Y%m%d)
-TARBALL = uml_utilities_$(UMLVER).tar.bz2
-BIN_DIR = /usr/bin
-
-ifeq ($(shell uname -m),x86_64)
-LIB_DIR = /usr/lib64/uml
-else
-LIB_DIR = /usr/lib/uml
-endif
-
-CFLAGS = -g -Wall
-#CFLAGS = -g -O2 -Wall
-
-export BIN_DIR LIB_DIR CFLAGS
-
-all install:
- set -e ; for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done
-
-tarball : clean spec
- cd .. ; \
- mv tools tools-$(UMLVER); \
- tar cjf $(TARBALL) tools-$(UMLVER); \
- mv tools-$(UMLVER) tools
-
-clean:
- rm -rf *~
- rm -f uml_util.spec
- set -e ; for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@; done
-
-spec:
- sed -e 's/__UMLVER__/$(UMLVER)/' < uml_util.spec.in > uml_util.spec
11 src/tools-20070815/Makefile.rej
View
@@ -1,11 +0,0 @@
---- Makefile 2004-04-08 03:42:59.000000000 +0200
-+++ Makefile 2009-05-01 23:31:00.106571852 +0200
-@@ -1,7 +1,7 @@
- TUNCTL = $(shell [ -e /usr/include/linux/if_tun.h ] && echo tunctl)
-
- SUBDIRS = jail jailtest humfsify mconsole moo port-helper $(TUNCTL) uml_net \
-- uml_router watchdog
-+ uml_router watchdog uml_dump
- UMLVER = $(shell date +%Y%m%d)
- TARBALL = uml_utilities_$(UMLVER).tar
- BIN_DIR = /usr/bin
572 src/tools-20070815/mconsole/uml_mconsole.c.orig
View
@@ -1,572 +0,0 @@
-/* (c) Copyright 2001-2004 Jeff Dike and others
- * Licensed under the GPL, see file COPYING
- *
- * This is uml_console version 2, a tool for querying a User Mode Linux
- * instance over a local pipe connection. This tool needs to be in sync
- * with the version of the UML kernel.
- *
- * There are a very few local commands that this program knows
- * about, but by default everything gets processed by UML.
- *
- * The uml_mconsole documentation distributed with covers all mconsole
- * commands, so the docs have to be kept in sync with the kernel.
- * In future it should be possible for the docs to come from (or be
- * in common with) something over in the kernel source.
- *
- * If you are looking for the command implementation, go to the
- * files mconsole_kern.c in the Linux kernel source under arch/um.
- *
- * The program exits with error values of:
- *
- * 0 No error
- * 1 Error (need better breakdown of error type in future)
- *
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdint.h>
-#include <signal.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/uio.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-
-static char uml_name[11];
-static struct sockaddr_un sun;
-static long uml_pid;
-
-static int do_switch(char *dir, char *file, char *name)
-{
- struct stat buf;
- char pid_path[MAXPATHLEN + 1];
- FILE *fp;
- char pid[sizeof("12345\0")], *end;
- int n, x = -1;
-
- if(stat(file, &buf) == -1){
- fprintf(stderr, "Warning: couldn't stat file: %s - ", file);
- perror("");
- return 1;
- }
- sun.sun_family = AF_UNIX;
- strncpy(sun.sun_path, file, sizeof(sun.sun_path));
- strncpy(uml_name, name, sizeof(uml_name));
-
- /* Open and read PID file */
- uml_pid = -1;
-
- snprintf(pid_path, sizeof(pid_path), "%s/%s/pid", dir, name);
- fp = fopen(pid_path, "r");
- if(fp == NULL)
- return 0;
-
- while (!feof(fp) && !ferror(fp))
- fread(&pid[++x], sizeof(char), 1, fp);
-
- /* Convert read PID to number, or set PID to known error number */
- if (feof(fp) && !ferror(fp)){
- n = strtol(pid, &end, 10);
- if(end != pid)
- uml_pid = n;
- }
-
- return 0;
-}
-
-static int switch_common(char *name)
-{
- char file[MAXPATHLEN + 1], dir[MAXPATHLEN + 1], tmp[MAXPATHLEN + 1];
- char *home;
- int try_file = 1;
-
- if((home = getenv("HOME")) != NULL){
- snprintf(dir, sizeof(dir), "%s/.uml", home);
- snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name);
- if(strncmp(name, dir, strlen(dir))){
- if(!do_switch(dir, file, name)) return(0);
- try_file = 0;
- }
- }
-
- snprintf(dir, sizeof(dir), "/tmp/uml/%s", name);
- snprintf(tmp, sizeof(tmp), "/tmp/uml/%s/mconsole", name);
- if(strncmp(name, "/tmp/uml/", strlen("/tmp/uml/"))){
- if(!do_switch(dir, tmp, name))
- return 0;
- }
-
- snprintf(dir, sizeof(dir), "./");
- if(!do_switch(dir, name, name))
- return 0;
-
- if(!try_file)
- return -1;
-
- return do_switch(dir, file, name);
-}
-
-#define MCONSOLE_MAGIC (0xcafebabe)
-#define MCONSOLE_MAX_DATA (512)
-#define MCONSOLE_VERSION (2)
-
-struct mconsole_request {
- uint32_t magic;
- uint32_t version;
- uint32_t len;
- char data[MCONSOLE_MAX_DATA];
-};
-
-struct mconsole_reply {
- uint32_t err;
- uint32_t more;
- uint32_t len;
- char data[MCONSOLE_MAX_DATA];
-};
-
-static char *absolutize(char *to, size_t size, char *from)
-{
- char save_cwd[MAXPATHLEN + 1], *slash;
- size_t remaining;
-
- if(getcwd(save_cwd, sizeof(save_cwd)) == NULL) {
- perror("absolutize : unable to get cwd");
- return(NULL);
- }
- slash = strrchr(from, '/');
- if(slash != NULL){
- *slash = '\0';
- if(chdir(from)){
- fprintf(stderr, "absolutize : Can't cd to '%s', ", from);
- *slash = '/';
- perror("");
- return(NULL);
- }
- *slash = '/';
- if(getcwd(to, size) == NULL){
- fprintf(stderr, "absolutize : unable to get cwd of '%s'", from);
- perror("");
- return(NULL);
- }
- remaining = size - strlen(to);
- if(strlen(slash) + 1 > remaining){
- fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from,
- size);
- return(NULL);
- }
- strcat(to, slash);
- }
- else {
- if(strlen(save_cwd) + 1 + strlen(from) + 1 > size){
- fprintf(stderr, "absolutize : unable to fit '%s' into %zd chars\n", from,
- size);
- return(NULL);
- }
- strcpy(to, save_cwd);
- strcat(to, "/");
- strcat(to, from);
- }
- chdir(save_cwd);
- return(to);
-}
-
-static int fix_filenames(char **cmd_ptr)
-{
- char *cow_file, *backing_file, *equal, *new, *ptr = *cmd_ptr;
- char full_backing[MAXPATHLEN + 1], full_cow[MAXPATHLEN + 1];
- int len;
-
- if(strncmp(ptr, "config", strlen("config"))) return(0);
- ptr += strlen("config");
-
- while(isspace(*ptr) && (*ptr != '\0')) ptr++;
- if(*ptr == '\0') return(0);
-
- if(strncmp(ptr, "ubd", strlen("ubd"))) return(0);
-
- while((*ptr != '=') && (*ptr != '\0')) ptr++;
- if(*ptr == '\0') return(0);
-
- equal = ptr;
- cow_file = ptr + 1;
- while((*ptr != ',') && (*ptr != '\0')) ptr++;
- if(*ptr == '\0'){
- backing_file = cow_file;
- cow_file = NULL;
- }
- else {
- *ptr = '\0';
- backing_file = ptr + 1;
- }
-
- ptr = absolutize(full_backing, sizeof(full_backing), backing_file);
- backing_file = ptr ? ptr : backing_file;
-
- if(cow_file != NULL){
- ptr = absolutize(full_cow, sizeof(full_cow), cow_file);
- cow_file = ptr ? ptr : cow_file;
- }
-
- len = equal - *cmd_ptr;
- len += strlen("=") + strlen(backing_file) + 1;
- if(cow_file != NULL){
- len += strlen(",") + strlen(cow_file);
- }
-
- new = malloc(len * sizeof(char));
- if(new == NULL) return(0);
-
- strncpy(new, *cmd_ptr, equal - *cmd_ptr);
- ptr = new + (equal - *cmd_ptr);
- *ptr++ = '=';
-
- if(cow_file != NULL){
- sprintf(ptr, "%s,", cow_file);
- ptr += strlen(ptr);
- }
- strcpy(ptr, backing_file);
-
- *cmd_ptr = new;
- return(1);
-}
-
-static int rcv_output(int fd, char **output)
-{
- struct mconsole_reply reply;
- int n, err = 0, first = 1, len = 0;
-
- do {
- n = recvfrom(fd, &reply, sizeof(reply), 0, NULL, 0);
- if(n < 0){
- perror("recvmsg");
- return(1);
- }
-
- err = reply.err ? 1 : err;
-
- *output = realloc(*output, len + strlen(reply.data) + 1);
- if(*output == NULL){
- perror("realloc failed");
- return 1;
- }
-
- if(first)
- **output = '\0';
- strcat(*output, reply.data);
- len += strlen(reply.data);
- first = 0;
- } while(reply.more);
-
- return reply.err;
-}
-
-static void format_cmd(char *command, struct mconsole_request *request)
-{
- *request = ((struct mconsole_request)
- { .magic = MCONSOLE_MAGIC,
- .version = MCONSOLE_VERSION,
- .len = MIN(strlen(command),
- sizeof(request->data) - 1) });
- strncpy(request->data, command, request->len);
- request->data[request->len] = '\0';
-}
-
-static int send_cmd(int fd, char *command, char **output)
-{
- struct mconsole_request request;
-
- format_cmd(command, &request);
- if(sendto(fd, &request, sizeof(request), 0, (struct sockaddr *) &sun,
- sizeof(sun)) < 0){
- fprintf(stderr, "Sending command to '%s' : ", sun.sun_path);
- perror("");
- return 1;
- }
-
- return rcv_output(fd, output);
-}
-
-static int default_cmd(int fd, char *command)
-{
- char name[128], *output = NULL;
- int free_command, err;
-
- if((sscanf(command, "%128[^: \f\n\r\t\v]:", name) == 1) &&
- (*(name + 1) == ':')){
- if(switch_common(name))
- return(1);
- command = strchr(command, ':');
- *command++ = '\0';
- while(isspace(*command)) command++;
- }
-
- free_command = fix_filenames(&command);
-
- err = send_cmd(fd, command, &output);
- if(output != NULL){
- printf("%s %s\n", err ? "ERR" : "OK", output);
- free(output);
- }
-
- if(free_command) free(command);
-
- return err;
-}
-
-char *local_help =
-"Additional local mconsole commands:\n\
- quit - Quit mconsole\n\
- switch <socket-name> - Switch control to the given machine\n\
- log -f <filename> - use contents of <filename> as UML log messages\n\
- mconsole-version - version of this mconsole program\n\
- int - Interrupt UML session\n";
-
-static int help_cmd(int fd, char *command)
-{
- default_cmd(fd, command);
- printf("%s", local_help);
- return(0);
-}
-
-static int switch_cmd(int fd, char *command)
-{
- char *ptr;
-
- ptr = &command[strlen("switch")];
- while(isspace(*ptr)) ptr++;
- if(switch_common(ptr)) return(1);
- printf("Switched to '%s'\n", ptr);
- return(0);
-}
-
-static int log_cmd(int fd, char *command)
-{
- int len, max, chunk, input_fd, newline = 0;
- char *ptr, buf[sizeof(((struct mconsole_request *) NULL)->data)];
-
- ptr = &command[strlen("log")];
- while(isspace(*ptr)) ptr++;
-
- max = sizeof(((struct mconsole_request *) NULL)->data) - sizeof("log ") - 1;
-
- if(!strncmp(ptr, "-f", strlen("-f"))){
- ptr = &ptr[strlen("-f")];
- while(isspace(*ptr)) ptr++;
- input_fd = open(ptr, O_RDONLY);
- if(input_fd < 0){
- perror("opening file");
- exit(1);
- }
- strcpy(buf, "log ");
- ptr = buf + strlen(buf);
- while((len = read(input_fd, ptr, max)) > 0){
- ptr[len] = '\0';
- default_cmd(fd, buf);
- newline = (ptr[len - 1] == '\n');
- }
- if(len < 0){
- perror("reading file");
- exit(1);
- }
- }
- else {
- len = strlen(ptr);
- while(len > 0){
- chunk = MIN(len, max);
- sprintf(buf, "log %.*s", chunk, ptr);
- default_cmd(fd, buf);
- newline = (ptr[chunk - 1] == '\n');
-
- len -= chunk;
- ptr += chunk;
- }
- }
- if(!newline){
- sprintf(buf, "log \n");
- default_cmd(fd, buf);
- }
- return(0);
-}
-
-extern int send_fd(int fd, int target, struct sockaddr *to, int to_len,
- void *msg, int msg_len);
-
-static int umlfs_cmd(int fd, char *command)
-{
- struct mconsole_request request;
- char *end, *output, *fd_ptr;
- int fuse_fd, err;
-
- fd_ptr = command;
- fd_ptr += strlen("umlfs");
- while(isspace(*fd_ptr)) fd_ptr++;
-
- fuse_fd = strtoul(fd_ptr, &end, 0);
- if(*end != '\0'){
- output = "Failed to parse file descriptor";
- err = -EINVAL;
- goto out;
- }
-
- format_cmd(command, &request);
- err = send_fd(fuse_fd, fd, (struct sockaddr *) &sun, sizeof(sun),
- &request, sizeof(request));
- if(err){
- output = "Failed to send FUSE file descriptor";
- goto out;
- }
-
- err = rcv_output(fd, &output);
-out:
- printf("%s %s\n", err ? "ERR" : "OK", output);
- return err;
-}
-
-static int quit_cmd(int fd, char *command)
-{
- exit(0);
-}
-
-static int mversion_cmd(int fd, char *command)
-{
- printf("uml_mconsole client version %d\n", MCONSOLE_VERSION);
- return(0);
-}
-
-static int int_cmd(int fd, char *command)
-{
-
- if(uml_pid == -1){
- printf("Cannot determine the PID of your UML session, not "
- "sending signal.\n");
- return 0;
- }
-
- kill(uml_pid, SIGINT);
-
- return 0;
-}
-
-struct cmd {
- char *command;
- int (*proc)(int, char *);
-};
-
-static struct cmd cmds[] = {
- { "quit", quit_cmd },
- { "help", help_cmd },
- { "switch", switch_cmd },
- { "log", log_cmd },
- { "umlfs", umlfs_cmd },
- { "mconsole-version", mversion_cmd },
- { "int", int_cmd },
- { NULL, default_cmd }
- /* default_cmd means "send it to the UML" */
-};
-
-/* sends a command */
-int issue_command(int fd, char *command)
-{
- char *ptr;
- unsigned int i = 0;
-
- /* Trim trailing spaces left by readline's filename completion */
- ptr = &command[strlen(command) - 1];
- while(isspace(*ptr)) *ptr-- = '\0';
-
- for(i = 0; i < sizeof(cmds)/sizeof(cmds[0]); i++){
- if((cmds[i].command == NULL) ||
- !strncmp(cmds[i].command, command, strlen(cmds[i].command))){
- return((*cmds[i].proc)(fd, command));
- }
- }
-
- /* Should never get here, considering the NULL test above will match the last
- * entry of cmds */
- return(0);
-}
-
-/* sends a command in argv style array */
-int issue_commandv(int fd, char **argv)
-{
- char *command;
- int len = -1, i = 0, status;
-
- len = 1; /* space for trailing null */
- for(i = 0; argv[i] != NULL; i++)
- len += strlen(argv[i]) + 1; /* space for space */
-
- command = malloc(len);
- if(command == NULL){
- perror("issue_command");
- return(1);
- }
- command[0] = '\0';
-
- for(i = 0; argv[i] != NULL; i++) {
- strcat(command, argv[i]);
- if(argv[i+1] != NULL) strcat(command, " ");
- }
-
- status = issue_command(fd, command);
-
- free(command);
-
- return(status);
-}
-
-static void Usage(void)
-{
- fprintf(stderr, "Usage : uml_mconsole socket-name [command]\n");
- exit(1);
-}
-
-int main(int argc, char **argv)
-{
- struct sockaddr_un here;
- char *sock;
- int fd;
-
- if(argc < 2) Usage();
- strcpy(uml_name, "[None]");
- sock = argv[1];
- switch_common(sock);
-
- if((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0){
- perror("socket");
- exit(1);
- }
- here.sun_family = AF_UNIX;
- memset(here.sun_path, 0, sizeof(here.sun_path));
-
- sprintf(&here.sun_path[1], "%5d", getpid());
- if(bind(fd, (struct sockaddr *) &here, sizeof(here)) < 0){
- perror("bind");
- exit(1);
- }
-
- if(argc>2)
- exit(issue_commandv(fd, argv+2));
-
- while(1){
- char *command, prompt[1 + sizeof(uml_name) + 2 + 1];
-
- sprintf(prompt, "(%s) ", uml_name);
- command = readline(prompt);
- if(command == NULL) break;
-
- if(*command) add_history(command);
-
- issue_command(fd, command);
- free(command);
- }
- printf("\n");
- exit(0);
-}
25 src/tools-20070815/mconsole/uml_mconsole.c.rej
View
@@ -1,25 +0,0 @@
---- mconsole/uml_mconsole.c 2004-04-08 03:43:29.000000000 +0200
-+++ mconsole/uml_mconsole.c 2011-05-20 12:16:00.044639001 +0200
-@@ -62,6 +62,22 @@
- int try_file = 1;
-
- if((home = getenv("HOME")) != NULL){
-+
-+ /*****************************************/
-+ /* Changed for compatibility with Netkit */
-+ /*****************************************/
-+
-+ /* Management consoles are made available inside .netkit
-+ in the user's home directory. Look there first and
-+ everywhere else only in case of failure. */
-+
-+ snprintf(dir, sizeof(dir), "%s/.netkit/mconsole", home);
-+ snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name);
-+ if(strncmp(name, dir, strlen(dir))){
-+ if(!do_switch(dir, file, name)) return(0);
-+ try_file = 0;
-+ }
-+
- snprintf(dir, sizeof(dir), "%s/.uml", home);
- snprintf(file, sizeof(file), "%s/%s/mconsole", dir, name);
- if(strncmp(name, dir, strlen(dir))){
17 src/tools-20070815/uml_dump/Makefile
View
@@ -1,17 +0,0 @@
-OBJS = uml_dump.o
-BIN = uml_dump
-CFLAGS = -g -Wall
-
-BIN_DIR ?= /usr/bin
-
-all : $(BIN)
-
-$(BIN) : $(OBJS)
- $(CC) $(CFLAGS) -o $(BIN) $(OBJS)
-
-clean :
- rm -f $(BIN) $(OBJS) *~
-
-install : $(BIN)
- install -d $(DESTDIR)$(BIN_DIR)
- install -s $(BIN) $(DESTDIR)$(BIN_DIR)
276 src/tools-20070815/uml_dump/uml_dump.c
View
@@ -1,276 +0,0 @@
-/*
- * Copyright 2008
- * Authors:
- * - Julien Iguchi-Cartigny
- * - Jean-Baptiste Machemie
- * - Benoit Bitarelle
- * Licensed under the GPL
- *
- * TODO: receive packets from multiple uml switchs
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <signal.h>
-#include <stdio.h>
-
-#include "../uml_router/switch.h"
-#include "../uml_router/uml_switch.h"
-#include "../uml_router/port.h"
-
-/***************** PCAP Part *****************/
-
-int output_fd;
-
-unsigned char pcap_file_header[] = {
- 0xd4, 0xc3, 0xb2, 0Xa1, // magic number
- 0x02, 0x00, 0x04, 0x00, // major and minor version number: 2.4
- 0x00, 0x00, 0x00, 0x00, // thiszone: GMT
- 0x00, 0x00, 0x00, 0x00, // accuracy: 0
- 0xEA, 0x05, 0x00, 0x00, // max length of captured packet: 1514
- 0x01, 0x00, 0x00, 0x00 // data link type: ethernet
-};
-
-unsigned int pcap_packet_header[] = {
- 0, // timestamp second
- 0, // timestamp microsecond
- 0, // number of octets of packet saved in file
- 0 // actual length of packet
-};
-
-struct timeval tv;
-
-void dump_packet(struct packet *packet, int size) {
-
- int w;
-
- gettimeofday(&tv, (void*)0);
-
- pcap_packet_header[0] = tv.tv_sec;
- pcap_packet_header[1] = tv.tv_usec;
- pcap_packet_header[2] = size;
- pcap_packet_header[3] = size;
-
- w = fwrite(pcap_packet_header, sizeof(unsigned char),
- sizeof(pcap_packet_header), stdout);
-
- if(w<=0)
- perror("error when writing packet header to stdout");
-
- w = fwrite((unsigned char*)packet, sizeof(unsigned char), size, stdout);
-
- if(w<=0)
- perror("error when writing packet data to stdout");
-
- w = fflush(stdout);
-
- if(w!=0)
- perror("error flushing stdout");
-}
-
-/***************** UML Part *****************/
-
-static char *prog;
-
-static char *ctl_socket = "/tmp/uml.ctl";
-
-int connect_fd, data_out_fd, data_in_fd;
-
-void cleanup() {
- close(connect_fd);
- close(data_out_fd);
-}
-
-static void sig_handler(int sig)
-{
- fprintf(stderr,"Caught signal %d, cleaning up and exiting\n", sig);
- cleanup();
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
-}
-
-static void usage(void)
-{
- fprintf(stderr, "Usage : %s control-socket\n"
- "if no parameter %s is used as control socket\n",
- prog, ctl_socket);
- exit(1);
-}
-
-
-int main(int argc, char *argv[]) {
-
- prog = argv[0];
- argv++;
- argc--;
-
- /* parameter -help */
- if(argc == 1) {
-
- if(!strcmp(argv[0], "-help")){
- usage();
- }
-
- ctl_socket = argv[0];
- }
-
- if(argc > 1) {
- usage();
- }
-
- /* ask for the data in socket */
- if((data_in_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0){
- perror("socket");
- exit(1);
- }
-
- if(fcntl(data_in_fd, F_SETFL, O_NONBLOCK) < 0){
- perror("setting O_NONBLOCK on data in fd");
- exit(1);
- }
-
- /* prepare the data in structure */
- struct sockaddr_un data_in_sun;
-
- struct {
- char zero;
- int pid;
- int usecs;
- } name;
-
- struct timeval tv;
-
- name.zero = 0;
- name.pid = getpid();
- gettimeofday(&tv, NULL);
- name.usecs = tv.tv_usec;
-
- data_in_sun.sun_family = AF_UNIX;
- memcpy(data_in_sun.sun_path, &name, sizeof(name));
-
- /* bind data_in_socket */
- if(bind(data_in_fd, (struct sockaddr*) &data_in_sun,
- sizeof(data_in_sun)) < 0){
- perror("binding to data in socket");
- exit(1);
- }
-
- /* ask for the connect socket */
- if((connect_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0){
- perror("socket connect");
- exit(1);
- }
-
- /* start the connect socket */
- struct sockaddr_un connect_sun;
-
- connect_sun.sun_family = AF_UNIX;
- strncpy(connect_sun.sun_path, ctl_socket, sizeof(connect_sun.sun_path));
-
- if(connect(connect_fd, (struct sockaddr *)&connect_sun,
- sizeof(connect_sun)) < 0){
- perror("connect connect");
- fprintf(stderr,"check the path to control socket: %s\n", ctl_socket);
- exit(1);
- }
-
- /* prepare the request */
- struct request_v3 request;
- request.magic = 0xfeedface;
- request.version = 3;
- request.type = REQ_NEW_DUMP;
- request.sock = data_in_sun;
-
- int n;
-
- /* send the request */
- n = send(connect_fd, &request, sizeof(request), 0);
-
- if(n < sizeof(request)) {
- fprintf(stderr,"not enough byte sent or error: %d\n", n);
- exit(1);
- }
-
- /* receive the data out socket addr (we don't really care about it) */
- struct sockaddr_un data_out_sun;
-
- n = recv(connect_fd, &data_out_sun, sizeof(data_out_sun), 0);
-
- if(n < sizeof(data_out_sun)) {
- fprintf(stderr,"not enough byte received or error: %d\n", n);
- exit(1);
- }
-
- /* prepare the pool */
- struct pollfd p[2];
-
- p[0].fd = connect_fd;
- p[0].events = POLLIN;
- p[1].fd = data_in_fd;
- p[1].events = POLLIN;
-
- /* setup the signal handler for CTRL-C */
- if(signal(SIGINT, sig_handler) < 0)
- perror("Setting handler for SIGINT");
-
- /* setup the signal handler for closed pipe by reader */
- if(signal(SIGPIPE, sig_handler) < 0)
- perror("Setting handler for SIGPIPE");
-
- /* writing pcap header to stdout */
- int w = fwrite(pcap_file_header, sizeof(unsigned char),
- sizeof(pcap_file_header), stdout);
-
- if(w<=0)
- perror("error when writing cap header to stdout");
-
- struct packet packet;
-
- /* the main loop */
- while(1) {
-
- /* waiting */
- n = poll(p, 2, -1);
-
- if(n < 0){
- if(errno == EINTR) continue; /* if poll stop by a signal */
- perror("poll");
- break;
- }
-
- /* check control socket */
- if(p[0].revents) {
- if(p[0].revents & POLLHUP){
- fprintf(stderr,"uml_switch disconnected\n");
- break;
- } else {
- fprintf(stderr,"control packet in excess ?\n");
- exit(1);
- }
- }
-
- /* check data out socket */
- if(p[1].revents) {
-
- n = recv(data_in_fd, &packet, sizeof(packet), 0);
- if(n < 0 && errno != EAGAIN) {
- perror("recv data out socket\n");
- exit(1);
- }
-
- dump_packet(&packet,n);
- }
- }
-
- cleanup();
-
- return 0;
-}
0  src/tools-20070815/uml_router/Makefile.orig
View
No changes.
10 src/tools-20070815/uml_router/Makefile.rej
View
@@ -1,10 +0,0 @@
---- uml_router/Makefile 2003-02-19 01:16:27.000000000 +0100
-+++ uml_router/Makefile 2009-05-01 23:31:20.088977298 +0200
-@@ -1,6 +1,6 @@
- TUNTAP = $(shell [ -e /usr/include/linux/if_tun.h ] && echo -DTUNTAP)
-
--OBJS = hash.o port.o uml_switch.o
-+OBJS = hash.o port.o uml_switch.o
- BIN = uml_switch
- CFLAGS = -g -Wall $(TUNTAP)
-
0  src/tools-20070815/uml_router/port.c.orig
View
No changes.
102 src/tools-20070815/uml_router/port.c.rej
View
@@ -1,102 +0,0 @@
---- uml_router/port.c 2003-03-12 17:35:03.000000000 +0100
-+++ uml_router/port.c 2009-05-01 23:31:20.593666238 +0200
-@@ -8,25 +8,6 @@
- #include "hash.h"
- #include "port.h"
-
--struct packet {
-- struct {
-- unsigned char dest[ETH_ALEN];
-- unsigned char src[ETH_ALEN];
-- unsigned char proto[2];
-- } header;
-- unsigned char data[1500];
--};
--
--struct port {
-- struct port *next;
-- struct port *prev;
-- int control;
-- void *data;
-- int data_len;
-- unsigned char src[ETH_ALEN];
-- void (*sender)(int fd, void *packet, int len, void *data);
--};
--
- static struct port *head = NULL;
-
- #define IS_BROADCAST(addr) ((addr[0] & 1) == 1)
-@@ -107,7 +88,16 @@
- (*p->sender)(p->control, packet, len, p->data);
- }
- }
-- else (*target->sender)(target->control, packet, len, target->data);
-+ else {
-+
-+ /* looking for dump port */
-+ for(p = head; p != NULL; p = p->next){
-+ if(p == port) continue;
-+ if(p->dump)
-+ (*p->sender)(p->control, packet, len, p->data);
-+ }
-+ (*target->sender)(target->control, packet, len, target->data);
-+ }
- }
-
- static void handle_data(int fd, int hub, struct packet *packet, int len,
-@@ -149,7 +139,7 @@
- }
-
- int setup_port(int fd, void (*sender)(int fd, void *packet, int len,
-- void *data), void *data, int data_len)
-+ void *data), void *data, int data_len, int dump)
- {
- struct port *port;
-
-@@ -165,6 +155,7 @@
- port->data = data;
- port->data_len = data_len;
- port->sender = sender;
-+ port->dump = dump;
- head = port;
- printf("New connection\n");
- return(0);
-@@ -215,7 +206,7 @@
- handle_data(fd, hub, &packet, len, &data, match_sock);
- }
-
--int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd)
-+int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd, int dump)
- {
- struct sock_data *data;
-
-@@ -226,7 +217,7 @@
- }
- *data = ((struct sock_data) { fd : data_fd,
- sock : *name });
-- return(setup_port(fd, send_sock, data, sizeof(*data)));
-+ return(setup_port(fd, send_sock, data, sizeof(*data), dump));
- }
-
- static void service_port(struct port *port)
-@@ -235,9 +226,12 @@
- char c;
-
- n = read(port->control, &c, sizeof(c));
-- if(n < 0) perror("Reading request");
-- else if(n == 0) printf("Disconnect\n");
-- else printf("Bad request\n");
-+ if(n < 0)
-+ perror("Reading request");
-+ else if(n == 0)
-+ printf("Disconnect\n");
-+ else
-+ printf("Bad request\n");
- }
-
- int handle_port(int fd)
-@@ -252,4 +246,3 @@
- }
- return(1);
- }
--
0  src/tools-20070815/uml_router/port.h.orig
View
No changes.
37 src/tools-20070815/uml_router/port.h.rej
View
@@ -1,37 +0,0 @@
---- uml_router/port.h 2002-04-10 22:08:09.000000000 +0200
-+++ uml_router/port.h 2009-05-01 23:31:20.717552166 +0200
-@@ -8,12 +8,32 @@
- #include <sys/socket.h>
- #include <sys/un.h>
-
-+struct packet {
-+ struct {
-+ unsigned char dest[ETH_ALEN];
-+ unsigned char src[ETH_ALEN];
-+ unsigned char proto[2];
-+ } header;
-+ unsigned char data[1500];
-+};
-+
-+struct port {
-+ struct port *next;
-+ struct port *prev;
-+ int control;
-+ void *data;
-+ int data_len;
-+ unsigned char src[ETH_ALEN];
-+ void (*sender)(int fd, void *packet, int len, void *data);
-+ int dump;
-+};
-+
- extern int handle_port(int fd);
- extern void close_port(int fd);
--extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd);
-+extern int setup_sock_port(int fd, struct sockaddr_un *name, int data_fd, int dump);
- extern int setup_port(int fd, void (*sender)(int fd, void *packet, int len,
- void *data), void *data,
-- int data_len);
-+ int data_len, int dump);
- extern void handle_tap_data(int fd, int hub);
- extern void handle_sock_data(int fd, int hub);
-
0  src/tools-20070815/uml_router/tuntap.c.orig
View
No changes.
19 src/tools-20070815/uml_router/tuntap.c.rej
View
@@ -1,19 +0,0 @@
---- uml_router/tuntap.c 2002-04-27 19:02:16.000000000 +0200
-+++ uml_router/tuntap.c 2009-05-01 23:31:21.088773438 +0200
-@@ -6,6 +6,7 @@
- #include <sys/ioctl.h>
- #include <net/if.h>
- #include <linux/if_tun.h>
-+#include "switch.h"
- #include "port.h"
-
- static void send_tap(int fd, void *packet, int len, void *unused)
-@@ -35,7 +36,7 @@
- close(fd);
- return(-1);
- }
-- err = setup_port(fd, send_tap, NULL, 0);
-+ err = setup_port(fd, send_tap, NULL, 0, 0);
- if(err) return(err);
- return(fd);
- }
0  src/tools-20070815/uml_router/uml_switch.c.orig
View
No changes.
141 src/tools-20070815/uml_router/uml_switch.c.rej
View
@@ -1,141 +0,0 @@
---- uml_router/uml_switch.c 2003-09-03 22:16:32.000000000 +0200
-+++ uml_router/uml_switch.c 2009-05-01 23:31:21.665168486 +0200
-@@ -7,9 +7,7 @@
- #include <stdlib.h>
- #include <signal.h>
- #include <fcntl.h>
--#include <stdint.h>
- #include <sys/socket.h>
--#include <sys/un.h>
- #include <sys/poll.h>
- #include <sys/time.h>
- #include <unistd.h>
-@@ -19,6 +17,7 @@
- #ifdef TUNTAP
- #include "tuntap.h"
- #endif
-+#include "uml_switch.h"
-
- #ifdef notdef
- #include <stddef.h>
-@@ -26,58 +25,6 @@
-
- static int hub = 0;
- static int compat_v0 = 0;
--
--enum request_type { REQ_NEW_CONTROL };
--
--struct request_v0 {
-- enum request_type type;
-- union {
-- struct {
-- unsigned char addr[ETH_ALEN];
-- struct sockaddr_un name;
-- } new_control;
-- } u;
--};
--
--#define SWITCH_MAGIC 0xfeedface
--
--struct request_v1 {
-- uint32_t magic;
-- enum request_type type;
-- union {
-- struct {
-- unsigned char addr[ETH_ALEN];
-- struct sockaddr_un name;
-- } new_control;
-- } u;
--};
--
--struct request_v2 {
-- uint32_t magic;
-- uint32_t version;
-- enum request_type type;
-- struct sockaddr_un sock;
--};
--
--struct reply_v2 {
-- unsigned char mac[ETH_ALEN];
-- struct sockaddr_un sock;
--};
--
--struct request_v3 {
-- uint32_t magic;
-- uint32_t version;
-- enum request_type type;
-- struct sockaddr_un sock;
--};
--
--union request {
-- struct request_v0 v0;
-- struct request_v1 v1;
-- struct request_v2 v2;
-- struct request_v3 v3;
--};
--
- static char *ctl_socket = "/tmp/uml.ctl";
-
- static char *data_socket = NULL;
-@@ -149,7 +96,11 @@
- {
- switch(req->type){
- case REQ_NEW_CONTROL:
-- setup_sock_port(fd, &req->u.new_control.name, data_fd);
-+ setup_sock_port(fd, &req->u.new_control.name, data_fd, 0);
-+ break;
-+ case REQ_NEW_DUMP:
-+ printf("REQ_NEW_DUMP for version 0 not supported\n");
-+ close_descriptor(fd);
- break;
- default:
- printf("Bad request type : %d\n", req->type);
-@@ -164,7 +115,8 @@
-
- switch(type){
- case REQ_NEW_CONTROL:
-- err = setup_sock_port(fd, sock, data_fd);
-+ case REQ_NEW_DUMP:
-+ err = setup_sock_port(fd, sock, data_fd, (type == REQ_NEW_DUMP));
- if(err) return;
- n = write(fd, &data_sun, sizeof(data_sun));
- if(n != sizeof(data_sun)){
-@@ -203,14 +155,28 @@
- return;
- }
- if(req.v1.magic == SWITCH_MAGIC){
-- if(req.v2.version == 2) new_port_v2(fd, &req.v2, data_fd);
-+
-+ /* version 2*/
-+ if(req.v2.version == 2)
-+ new_port_v2(fd, &req.v2, data_fd);
-+
-+ /* version 3 */
- if(req.v3.version == 3)
- new_port_v1_v3(fd, req.v3.type, &req.v3.sock, data_fd);
-+
-+ /* version unknow */
- else if(req.v2.version > 2)
- fprintf(stderr, "Request for a version %d port, which this "
- "uml_switch doesn't support\n", req.v2.version);
-+
-+ /* version 1 */
-+ else if(req.v1.type == REQ_NEW_DUMP)
-+ fprintf(stderr, "REQ_NEW_DUMP request for version 1, which this "
-+ "uml_switch doesn't support\n");
- else new_port_v1_v3(fd, req.v1.type, &req.v1.u.new_control.name, data_fd);
- }
-+
-+ /* version 0*/
- else new_port_v0(fd, &req.v0, data_fd);
- }
-
-@@ -528,6 +494,8 @@
- }
- for(i = 0; i < nfds; i++){
- if(fds[i].revents == 0) continue;
-+
-+ /* stdin */
- if(fds[i].fd == 0){
- if(fds[i].revents & POLLHUP){
- printf("EOF on stdin, cleaning up and exiting\n");
67 src/tools-20070815/uml_router/uml_switch.h
View
@@ -1,67 +0,0 @@
-/* Copyright 2008 Jeff Dike & Kartoch
- * Licensed under the GPL
- */
-
-#ifndef __UML_SWITCH_H__
-#define __UML_SWITCH_H__
-
-#include <stdint.h>
-#include <sys/un.h>
-
-enum request_type {
- REQ_NEW_CONTROL,
- REQ_NEW_DUMP
-};
-
-struct request_v0 {
- enum request_type type;
- union {
- struct {
- unsigned char addr[ETH_ALEN];
- struct sockaddr_un name;
- } new_control;
- } u;
-};
-
-#define SWITCH_MAGIC 0xfeedface
-
-struct request_v1 {
- uint32_t magic;
- enum request_type type;
- union {
- struct {
- unsigned char addr[ETH_ALEN];
- struct sockaddr_un name;
- } new_control;
- } u;
-};
-
-struct request_v2 {
- uint32_t magic;
- uint32_t version;
- enum request_type type;
- struct sockaddr_un sock;
-};
-
-struct reply_v2 {
- unsigned char mac[ETH_ALEN];
- struct sockaddr_un sock;
-};
-
-struct request_v3 {
- uint32_t magic;
- uint32_t version;
- enum request_type type;
- struct sockaddr_un sock;
-};
-
-union request {
- struct request_v0 v0;
- struct request_v1 v1;
- struct request_v2 v2;
- struct request_v3 v3;
-};
-
-#endif
-
-
Please sign in to comment.
Something went wrong with that request. Please try again.