void tfe_init(void) { tfe_log = log_open("TFE"); rawnet_set_should_accept_func(cs8900_should_accept); if (cs8900_init() < 0) { tfe_enabled = 0; tfe_cannot_use = 1; } if (should_activate) { should_activate = 0; if (tfe_activate() < 0) { tfe_enabled = 0; tfe_cannot_use = 1; } } }
void cs8900io_init(void) { if (!cs8900io_init_done) { cs8900io_log = log_open("CS8900 I/O"); rawnet_set_should_accept_func(cs8900_should_accept); if (cs8900_init() < 0) { cs8900io_enabled = 0; cs8900io_cannot_use = 1; } if (should_activate) { should_activate = 0; if (cs8900io_activate() < 0) { cs8900io_enabled = 0; cs8900io_cannot_use = 1; } } cs8900io_init_done = 1; } }
void main_task (void *data) { buf_t *p, *r; unsigned char addr [4], *output; unsigned short port; #if 1 mutex_group_t *g; debug_printf ("\n\n*** Testing SNMP on UART 1 ***\n\n"); arp = arp_init (arp_data, sizeof(arp_data), 0); /* * Create a group of two locks: timer and eth. */ g = mutex_group_init (group, sizeof(group)); mutex_group_add (g, ð.netif.lock); mutex_group_add (g, &timer.decisec); ip = mem_alloc (&pool, sizeof (*ip)); ip_init (ip, &pool, 70, &timer, arp, g); arp->ip = ip; /* * Create interface eth0 144.206.181.251 / 255.255.255.0 */ /* Reset чипа CS8900A заведен на порт G3. * Он в прямой логике, надо подать туда 0. */ outb_far (0x08, DDRG); clearb_far (3, PORTG); /* Добавляем один wait state, т.к. иначе cs8900 не успевает. */ setb (SRW, MCUCR); cs8900_init (ð, "eth0", 80, &pool, arp); route_add_netif (ip, &route, "\220\316\265\373", 24, ð.netif); /* * Add default route to 144.206.181.254 */ route_add_gateway (ip, &default_route, "\0\0\0\0", 0, "\220\316\265\376"); if (! default_route.netif) debug_printf ("test_snmp: no interface for default route!\n"); snmp_init (&snmp, &pool, ip, snmp_tab, sizeof(snmp_tab), SNMP_SERVICE_REPEATER, "Testing SNMP", "1.3.6.1.4.1.20520.1.1"); #endif udp_socket (&sock, ip, 161); debug_printf ("test_snmp: mem available = %u bytes\n", mem_available (&pool)); for (;;) { p = udp_recvfrom (&sock, addr, &port); debug_printf ("test_snmp: mem available = %u bytes\n", mem_available (&pool)); r = buf_alloc (&pool, 1500, 50); if (! r) { debug_printf ("test_snmp: out of memory!\n"); buf_free (p); continue; } output = snmp_execute (&snmp, p->payload, p->len, r->payload, r->len, addr); buf_free (p); if (! output) { buf_free (r); continue; } buf_add_header (r, - (output - r->payload)); udp_sendto (&sock, r, addr, port); } }