From 5fd515c7a4eed5990b74706d2c52391a7c337c3a Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Sun, 20 Apr 2003 20:43:57 +0000 Subject: bitkeeper revision 1.184 (3ea3068dWnCzvBRYV1RTpoVK29FlDg) Many files: Removed the system-wide VIF list -- we now find VIFs via the task hashtable. Fixed a few synchronisation problems. --- .../arch/xeno/drivers/dom0/dom0_core.c | 8 +- .../arch/xeno/drivers/dom0/vfr.c | 327 +++++++++++---------- 2 files changed, 173 insertions(+), 162 deletions(-) (limited to 'xenolinux-2.4.21-pre4-sparse') diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c index c36ab02e96..d3e4752eb3 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/dom0_core.c @@ -75,15 +75,11 @@ static int cmd_read_proc(char *page, char **start, off_t off, static ssize_t dom_vif_read(struct file * file, char * buff, size_t size, loff_t * off) { - char hyp_buf[128]; // Hypervisor is going to write its reply here. + char hyp_buf[128]; network_op_t op; static int finished = 0; - // This seems to be the only way to make the OS stop making read requests - // to the file. When we use the fileoperations version of read, offset - // seems to be ignored altogether. - - if (finished) + if ( finished ) { finished = 0; return 0; diff --git a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c index 13fe25ec9c..852f6943e2 100644 --- a/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c +++ b/xenolinux-2.4.21-pre4-sparse/arch/xeno/drivers/dom0/vfr.c @@ -26,7 +26,7 @@ u16 antous(const char *buff, int len); int anton(const char *buff, int len); static int vfr_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) + int count, int *eof, void *data) { strcpy(page, readbuf); *readbuf = '\0'; @@ -60,147 +60,163 @@ static int vfr_read_proc(char *page, char **start, off_t off, ((_x)=='\f') || ((_x)=='\r') || ((_x)=='\n') ) static int vfr_write_proc(struct file *file, const char *buffer, - u_long count, void *data) + u_long count, void *data) { - network_op_t op; - int ret, len; - int ts, te, tl; // token start, end, and length - int fs, fe, fl; // field. - - len = count; - ts = te = 0; - - memset(&op, 0, sizeof(network_op_t)); - - // get the command: - while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces. - te = ts; - while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end - if ( te <= ts ) goto bad; - tl = te - ts; - - if ( strncmp(&buffer[ts], "ADD", tl) == 0 ) - { - op.cmd = NETWORK_OP_ADDRULE; - } - else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 ) - { - op.cmd = NETWORK_OP_DELETERULE; - } - else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 ) - { - op.cmd = NETWORK_OP_GETRULELIST; - goto doneparsing; - } - - ts = te; - - // get the action - while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces. - te = ts; - while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end - if ( te <= ts ) goto bad; - tl = te - ts; - - if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 ) - { - op.u.net_rule.action = NETWORK_ACTION_ACCEPT; - goto keyval; - } - if ( strncmp(&buffer[ts], "COUNT", tl) == 0 ) - { - op.u.net_rule.action = NETWORK_ACTION_COUNT; - goto keyval; - } - - // default case; - return (len); - + network_op_t op; + int ret, len; + int ts, te, tl; // token start, end, and length + int fs, fe, fl; // field. - // get the key=val pairs. - keyval: - while (count) - { - //get field - ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; } - te = ts; - while ( count && !isspace(buffer[te]) && (buffer[te] != '=') ) - { te++; count--; } - if ( te <= ts ) - goto doneparsing; - tl = te - ts; - fs = ts; fe = te; fl = tl; // save the field markers. - // skip " = " (ignores extra equals.) - while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) ) - { te++; count--; } - ts = te; - while ( count && !isspace(buffer[te]) ) { te++; count--; } - tl = te - ts; + len = count; + ts = te = 0; - if ( (fl <= 0) || (tl <= 0) ) goto bad; + memset(&op, 0, sizeof(network_op_t)); - if (strncmp(&buffer[fs], "srcaddr", fl) == 0) - { - op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl); - } - else if (strncmp(&buffer[fs], "dstaddr", fl) == 0) - { - op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl); - } - else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0) - { - op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl); - } - else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0) - { - op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl); - } - else if (strncmp(&buffer[fs], "srcport", fl) == 0) + // get the command: + while ( count && isspace(buffer[ts]) ) { ts++; count--; } // skip spaces. + te = ts; + while ( count && !isspace(buffer[te]) ) { te++; count--; } // command end + if ( te <= ts ) goto bad; + tl = te - ts; + + if ( strncmp(&buffer[ts], "ADD", tl) == 0 ) { - op.u.net_rule.src_port = antous(&buffer[ts], tl); + op.cmd = NETWORK_OP_ADDRULE; } - else if (strncmp(&buffer[fs], "dstport", fl) == 0) + else if ( strncmp(&buffer[ts], "DELETE", tl) == 0 ) { - op.u.net_rule.dst_port = antous(&buffer[ts], tl); + op.cmd = NETWORK_OP_DELETERULE; } - else if (strncmp(&buffer[fs], "srcportmask", fl) == 0) + else if ( strncmp(&buffer[ts], "PRINT", tl) == 0 ) { - op.u.net_rule.src_port_mask = antous(&buffer[ts], tl); + op.cmd = NETWORK_OP_GETRULELIST; + goto doneparsing; } - else if (strncmp(&buffer[fs], "dstportmask", fl) == 0) + + ts = te; + + // get the action + while ( count && (buffer[ts] == ' ') ) { ts++; count--; } // skip spaces. + te = ts; + while ( count && (buffer[te] != ' ') ) { te++; count--; } // command end + if ( te <= ts ) goto bad; + tl = te - ts; + + if ( strncmp(&buffer[ts], "ACCEPT", tl) == 0 ) { - op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl); + op.u.net_rule.action = NETWORK_ACTION_ACCEPT; + goto keyval; } - else if (strncmp(&buffer[fs], "srcint", fl) == 0) + if ( strncmp(&buffer[ts], "COUNT", tl) == 0 ) { - op.u.net_rule.src_interface = anton(&buffer[ts], tl); + op.u.net_rule.action = NETWORK_ACTION_COUNT; + goto keyval; } - else if (strncmp(&buffer[fs], "dstint", fl) == 0) + + // default case; + return (len); + + + // get the key=val pairs. + keyval: + while (count) { - op.u.net_rule.dst_interface = anton(&buffer[ts], tl); - } - else if ( (strncmp(&buffer[fs], "proto", fl) == 0)) - { - if (strncmp(&buffer[ts], "any", tl) == 0) - op.u.net_rule.proto = NETWORK_PROTO_ANY; - if (strncmp(&buffer[ts], "ip", tl) == 0) - op.u.net_rule.proto = NETWORK_PROTO_IP; - if (strncmp(&buffer[ts], "tcp", tl) == 0) - op.u.net_rule.proto = NETWORK_PROTO_TCP; - if (strncmp(&buffer[ts], "udp", tl) == 0) - op.u.net_rule.proto = NETWORK_PROTO_UDP; - if (strncmp(&buffer[ts], "arp", tl) == 0) - op.u.net_rule.proto = NETWORK_PROTO_ARP; - + //get field + ts = te; while ( count && isspace(buffer[ts]) ) { ts++; count--; } + te = ts; + while ( count && !isspace(buffer[te]) && (buffer[te] != '=') ) + { te++; count--; } + if ( te <= ts ) + goto doneparsing; + tl = te - ts; + fs = ts; fe = te; fl = tl; // save the field markers. + // skip " = " (ignores extra equals.) + while ( count && (isspace(buffer[te]) || (buffer[te] == '=')) ) + { te++; count--; } + ts = te; + while ( count && !isspace(buffer[te]) ) { te++; count--; } + tl = te - ts; + + if ( (fl <= 0) || (tl <= 0) ) goto bad; + + /* NB. Prefix matches must go first! */ + if (strncmp(&buffer[fs], "src", fl) == 0) + { + op.u.net_rule.src_vif = VIF_ANY_INTERFACE; + } + else if (strncmp(&buffer[fs], "dst", fl) == 0) + { + op.u.net_rule.dst_vif = VIF_PHYSICAL_INTERFACE; + } + else if (strncmp(&buffer[fs], "srcaddr", fl) == 0) + { + op.u.net_rule.src_addr = getipaddr(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "dstaddr", fl) == 0) + { + op.u.net_rule.dst_addr = getipaddr(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "srcaddrmask", fl) == 0) + { + op.u.net_rule.src_addr_mask = getipaddr(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "dstaddrmask", fl) == 0) + { + op.u.net_rule.dst_addr_mask = getipaddr(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "srcport", fl) == 0) + { + op.u.net_rule.src_port = antous(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "dstport", fl) == 0) + { + op.u.net_rule.dst_port = antous(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "srcportmask", fl) == 0) + { + op.u.net_rule.src_port_mask = antous(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "dstportmask", fl) == 0) + { + op.u.net_rule.dst_port_mask = antous(&buffer[ts], tl); + } + else if (strncmp(&buffer[fs], "srcdom", fl) == 0) + { + op.u.net_rule.src_vif |= anton(&buffer[ts], tl)<= '0') && (c <= '9') ) - { - ret *= 10; - ret += c - '0'; - buff++; len--; - } + while ( (len) && ((c = *buff) >= '0') && (c <= '9') ) + { + ret *= 10; + ret += c - '0'; + buff++; len--; + } - return ret; + return ret; } u32 getipaddr(const char *buff, unsigned int len) { - int i; - char c; - u32 ret, val; + char c; + u32 ret, val; - ret = 0; val = 0; + ret = 0; val = 0; - while ( len ) - { - if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) ) + while ( len ) { - return(0); // malformed. + if (!((((c = *buff) >= '0') && ( c <= '9')) || ( c == '.' ) ) ) + { + return(0); // malformed. + } + + if ( c == '.' ) { + if (val > 255) return (0); //malformed. + ret = ret << 8; + ret += val; + val = 0; + len--; buff++; + continue; + } + val *= 10; + val += c - '0'; + buff++; len--; } + ret = ret << 8; + ret += val; - if ( c == '.' ) { - if (val > 255) return (0); //malformed. - ret = ret << 8; - ret += val; - val = 0; - len--; buff++; - continue; - } - val *= 10; - val += c - '0'; - buff++; len--; - } - ret = ret << 8; - ret += val; - - return (ret); + return (ret); } -- cgit v1.2.3