Пример #1
0
static void
init(void)
{
    struct hostent *addr;
    char *eth_addr;

    if ((addr=gethostbyname(host)) == NULL) {
	perror("bad hostname");
	exit(1);
    }
    memcpy((char*)&ip_dstaddr, addr->h_addr, addr->h_length);

    if ((addr=gethostbyname(myhost)) == NULL) {
	perror("bad local hostname");
	exit(1);
    }
    memcpy((char*)&ip_myaddr, addr->h_addr, addr->h_length);

    eth_addr = get_ether_from_ip((char *)&ip_dstaddr, 1);
    memcpy(&eth_dstaddr, eth_addr, 6);

    eth_addr = get_ether_from_ip((char *)&ip_myaddr, 1);
    memcpy(&eth_myaddr, eth_addr, 6);

    printf("me: %x ", ip_myaddr);
    ip_print((char *)&ip_myaddr);
    eth_print((char *)&eth_myaddr);

    printf("dst: %x ", ip_dstaddr);
    ip_print((char *)&ip_dstaddr);
    eth_print((char *)&eth_dstaddr);

    fflush(stdout);
}
Пример #2
0
/* Display the contents of the Ethernet MAC header. */
void
eth_dump(struct ethhdr *eth)
{
  if (inet_debug != DBG_ETH) return;

  printk("eth: SRC = %s ", eth_print(eth->h_source));
  printk("DST = %s ", eth_print(eth->h_dest));
  printk("TYPE = %04X\n", ntohs(eth->h_proto));
}
Пример #3
0
static void
pkt_handler_en10mb(u_char *usr, const struct pcap_pkthdr *pkt,
		   const u_char *d)
{
	struct machdr *mac = mac_hdr(d);

	sb_reset(&sb);
	eth_print(mac, &sb);
	sb_append_str(&sb, "; ");
	etherframe_print(usr, pkt, d + ETH_HLEN, mac->type);
	fprintf(stdout, "pkt: %s\n", sb.buf);
}
Пример #4
0
int elplus_probe(struct device *dev)

{
    elp_device adapter;
    int            i;

    CHECK_NULL(dev);

    /*
     *  setup adapter structure
     */

    adapter.io_addr = dev->base_addr = elp_autodetect(dev);
    if ( !adapter.io_addr )
        return -ENODEV;

    /*
     *  As we enter here from bootup, the adapter should have IRQs enabled,
     *  but we can as well enable them anyway.
     */
    OUTB(INB(dev->base_addr+PORT_CONTROL) | CONTROL_CMDE,
         dev->base_addr+PORT_CONTROL);
    autoirq_setup(0);

    /*
     * use ethernet address command to probe for board in polled mode
     * (this also makes us the IRQ that we need for automatic detection)
     */
    adapter.tx_pcb.command = CMD_STATION_ADDRESS;
    adapter.tx_pcb.length  = 0;
    if (!send_pcb   (&adapter, &adapter.tx_pcb) ||
            !receive_pcb(&adapter, &adapter.rx_pcb) ||
            (adapter.rx_pcb.command != CMD_ADDRESS_RESPONSE) ||
            (adapter.rx_pcb.length != 6)) {
        printk("%s: not responding to first PCB\n", dev->name);
        return -ENODEV;
    }
    if (dev->irq) { /* Is there a preset IRQ? */
        if (dev->irq != autoirq_report(0)) {
            printk("%s: Detected IRQ doesn't match user-defined one.\n",dev->name);
            return -ENODEV;
        }
        /* if dev->irq == autoirq_report(0), all is well */
    } else /* No preset IRQ; just use what we can detect */
        dev->irq=autoirq_report(0);
    switch (dev->irq) { /* Legal, sane? */
    case 0:
        printk("%s: No IRQ reported by autoirq_report().\n",dev->name);
        printk("%s: Check the jumpers of your 3c505 board.\n",dev->name);
        return -ENODEV;
    case 1:
    case 6:
    case 8:
    case 13:
        printk("%s: Impossible IRQ %d reported by autoirq_report().\n",
               dev->name,
               dev->irq);
        return -ENODEV;
    }
    /*
     *  Now we have the IRQ number so we can disable the interrupts from
     *  the board until the board is opened.
     */
    OUTB(INB(dev->base_addr+PORT_CONTROL) & ~CONTROL_CMDE,
         dev->base_addr+PORT_CONTROL);

    /*
     * copy ethernet address into structure
     */
    for (i = 0; i < 6; i++)
        dev->dev_addr[i] = adapter.rx_pcb.data.eth_addr[i];

    /*
     * print remainder of startup message
     */
#if (ELP_KERNEL_TYPE < 2)
    printk("%s: 3c505 card found at I/O 0x%x using IRQ%d has address %s\n",
           dev->name, dev->base_addr, dev->irq, eth_print(dev->dev_addr));
#else
    printk("%s: 3c505 card found at I/O 0x%x using IRQ%d has address %02x:%02x:%02x:%02x:%02x:%02x\n",
           dev->name, dev->base_addr, dev->irq,
           dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
           dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
#endif

    /*
     * initialise the device
     */
    elp_init(dev);
    return 0;
}