Lines Matching refs:strip_info
523 static void DumpData(char *msg, struct strip *strip_info, __u8 *ptr, __u8 *end) in DumpData() argument
559 printk(KERN_INFO "%s: %-13s%s\n", strip_info->dev.name, msg, pkt_text); in DumpData()
563 static void HexDump(char *msg, struct strip *strip_info, __u8 *start, __u8 *end)
566 printk(KERN_INFO "%s: %s: %d bytes\n", strip_info->dev.name, msg, end-ptr);
579 printk(KERN_INFO "%s: %4lX %s\n", strip_info->dev.name, offset, text);
930 static int allocate_buffers(struct strip *strip_info) in allocate_buffers() argument
932 struct net_device *dev = &strip_info->dev; in allocate_buffers()
940 strip_info->rx_buff = r; in allocate_buffers()
941 strip_info->sx_buff = s; in allocate_buffers()
942 strip_info->tx_buff = t; in allocate_buffers()
943 strip_info->sx_size = sx_size; in allocate_buffers()
944 strip_info->tx_size = tx_size; in allocate_buffers()
945 strip_info->mtu = dev->mtu; in allocate_buffers()
960 static void strip_changedmtu(struct strip *strip_info) in strip_changedmtu() argument
962 int old_mtu = strip_info->mtu; in strip_changedmtu()
963 struct net_device *dev = &strip_info->dev; in strip_changedmtu()
964 unsigned char *orbuff = strip_info->rx_buff; in strip_changedmtu()
965 unsigned char *osbuff = strip_info->sx_buff; in strip_changedmtu()
966 unsigned char *otbuff = strip_info->tx_buff; in strip_changedmtu()
972 strip_info->dev.name, MAX_SEND_MTU); in strip_changedmtu()
986 if (!allocate_buffers(strip_info)) in strip_changedmtu()
990 strip_info->dev.name); in strip_changedmtu()
995 if (strip_info->sx_count) in strip_changedmtu()
997 if (strip_info->sx_count <= strip_info->sx_size) in strip_changedmtu()
998 memcpy(strip_info->sx_buff, osbuff, strip_info->sx_count); in strip_changedmtu()
1001 strip_info->discard = strip_info->sx_count; in strip_changedmtu()
1002 strip_info->rx_over_errors++; in strip_changedmtu()
1006 if (strip_info->tx_left) in strip_changedmtu()
1008 if (strip_info->tx_left <= strip_info->tx_size) in strip_changedmtu()
1009 memcpy(strip_info->tx_buff, strip_info->tx_head, strip_info->tx_left); in strip_changedmtu()
1012 strip_info->tx_left = 0; in strip_changedmtu()
1013 strip_info->tx_dropped++; in strip_changedmtu()
1016 strip_info->tx_head = strip_info->tx_buff; in strip_changedmtu()
1021 strip_info->dev.name, old_mtu, strip_info->mtu); in strip_changedmtu()
1028 static void strip_unlock(struct strip *strip_info) in strip_unlock() argument
1033 strip_info->idle_timer.expires = jiffies + 1*HZ; in strip_unlock()
1034 add_timer(&strip_info->idle_timer); in strip_unlock()
1035 netif_wake_queue(&strip_info->dev); in strip_unlock()
1157 sprintf_status_info(char *buffer, struct strip *strip_info) in sprintf_status_info() argument
1166 int tx_left = strip_info->tx_left; in sprintf_status_info()
1167 unsigned long rx_average_pps = strip_info->rx_average_pps; in sprintf_status_info()
1168 unsigned long tx_average_pps = strip_info->tx_average_pps; in sprintf_status_info()
1169 unsigned long sx_average_pps = strip_info->sx_average_pps; in sprintf_status_info()
1170 int working = strip_info->working; in sprintf_status_info()
1171 int firmware_level = strip_info->firmware_level; in sprintf_status_info()
1172 long watchdog_doprobe = strip_info->watchdog_doprobe; in sprintf_status_info()
1173 long watchdog_doreset = strip_info->watchdog_doreset; in sprintf_status_info()
1174 long gratuitous_arp = strip_info->gratuitous_arp; in sprintf_status_info()
1175 long arp_interval = strip_info->arp_interval; in sprintf_status_info()
1176 FirmwareVersion firmware_version = strip_info->firmware_version; in sprintf_status_info()
1177 SerialNumber serial_number = strip_info->serial_number; in sprintf_status_info()
1178 BatteryVoltage battery_voltage = strip_info->battery_voltage; in sprintf_status_info()
1179 char* if_name = strip_info->dev.name; in sprintf_status_info()
1180 MetricomAddress true_dev_addr = strip_info->true_dev_addr; in sprintf_status_info()
1181 MetricomAddress dev_dev_addr = *(MetricomAddress*)strip_info->dev.dev_addr; in sprintf_status_info()
1182 int manual_dev_addr = strip_info->manual_dev_addr; in sprintf_status_info()
1184 unsigned long rx_bytes = strip_info->rx_bytes; in sprintf_status_info()
1185 unsigned long tx_bytes = strip_info->tx_bytes; in sprintf_status_info()
1186 unsigned long rx_rbytes = strip_info->rx_rbytes; in sprintf_status_info()
1187 unsigned long tx_rbytes = strip_info->tx_rbytes; in sprintf_status_info()
1188 unsigned long rx_sbytes = strip_info->rx_sbytes; in sprintf_status_info()
1189 unsigned long tx_sbytes = strip_info->tx_sbytes; in sprintf_status_info()
1190 unsigned long rx_ebytes = strip_info->rx_ebytes; in sprintf_status_info()
1191 unsigned long tx_ebytes = strip_info->tx_ebytes; in sprintf_status_info()
1219 if (!memcmp(strip_info->dev.dev_addr, zero_address.c, sizeof(zero_address))) in sprintf_status_info()
1236 p += sprintf_neighbours(p, &strip_info->poletops, "Poletops:"); in sprintf_status_info()
1237 p += sprintf_neighbours(p, &strip_info->portables, "Portables:"); in sprintf_status_info()
1251 struct strip *strip_info = struct_strip_list; in get_status_info() local
1257 while (strip_info != NULL) in get_status_info()
1259 buf += sprintf_status_info(buf, strip_info); in get_status_info()
1261 strip_info = strip_info->next; in get_status_info()
1270 static void ResetRadio(struct strip *strip_info) in ResetRadio() argument
1272 struct tty_struct *tty = strip_info->tty; in ResetRadio()
1280 if (strip_info->working) in ResetRadio()
1282 printk(KERN_INFO "%s: No response: Resetting radio.\n", strip_info->dev.name); in ResetRadio()
1283 strip_info->firmware_version.c[0] = '\0'; in ResetRadio()
1284 strip_info->serial_number.c[0] = '\0'; in ResetRadio()
1285 strip_info->battery_voltage.c[0] = '\0'; in ResetRadio()
1286 strip_info->portables.num_nodes = 0; in ResetRadio()
1287 do_gettimeofday(&strip_info->portables.timestamp); in ResetRadio()
1288 strip_info->poletops.num_nodes = 0; in ResetRadio()
1289 do_gettimeofday(&strip_info->poletops.timestamp); in ResetRadio()
1292 strip_info->pps_timer = jiffies; in ResetRadio()
1293 strip_info->rx_pps_count = 0; in ResetRadio()
1294 strip_info->tx_pps_count = 0; in ResetRadio()
1295 strip_info->sx_pps_count = 0; in ResetRadio()
1296 strip_info->rx_average_pps = 0; in ResetRadio()
1297 strip_info->tx_average_pps = 0; in ResetRadio()
1298 strip_info->sx_average_pps = 0; in ResetRadio()
1301 *(MetricomAddress*)&strip_info->true_dev_addr = zero_address; in ResetRadio()
1302 if (!strip_info->manual_dev_addr) in ResetRadio()
1303 *(MetricomAddress*)strip_info->dev.dev_addr = zero_address; in ResetRadio()
1304 strip_info->working = FALSE; in ResetRadio()
1305 strip_info->firmware_level = NoStructure; in ResetRadio()
1306 strip_info->next_command = CompatibilityCommand; in ResetRadio()
1307 strip_info->watchdog_doprobe = jiffies + 10 * HZ; in ResetRadio()
1308 strip_info->watchdog_doreset = jiffies + 1 * HZ; in ResetRadio()
1311 if (strip_info->user_baud > B38400) in ResetRadio()
1322 if (strip_info->user_baud == get_baud(tty)) in ResetRadio()
1329 if (strip_info->user_baud == B57600 ) s = baudstring[0]; in ResetRadio()
1330 else if (strip_info->user_baud == B115200) s = baudstring[1]; in ResetRadio()
1333 else set_baud(tty, strip_info->user_baud); in ResetRadio()
1338 strip_info->tx_ebytes += s.length; in ResetRadio()
1349 struct strip *strip_info = (struct strip *) tty->disc_data; in strip_write_some_more() local
1352 if (!strip_info || strip_info->magic != STRIP_MAGIC || in strip_write_some_more()
1353 !netif_running(&strip_info->dev)) in strip_write_some_more()
1356 if (strip_info->tx_left > 0) in strip_write_some_more()
1373 int num_written = tty->driver.write(tty, 0, strip_info->tx_head, strip_info->tx_left); in strip_write_some_more()
1374 strip_info->tx_left -= num_written; in strip_write_some_more()
1375 strip_info->tx_head += num_written; in strip_write_some_more()
1377 strip_info->tx_sbytes += num_written; in strip_write_some_more()
1384 strip_unlock(strip_info); in strip_write_some_more()
1400 static unsigned char *strip_make_packet(unsigned char *buffer, struct strip *strip_info, struct sk_… in strip_make_packet() argument
1416 strip_info->dev.name, ntohs(header->protocol)); in strip_make_packet()
1420 if (len > strip_info->mtu) in strip_make_packet()
1423 strip_info->dev.name, len); in strip_make_packet()
1431 if (!memcmp(haddr.c, strip_info->true_dev_addr.c, sizeof(haddr))) in strip_make_packet()
1433 printk(KERN_ERR "%s: Dropping packet addressed to self\n", strip_info->dev.name); in strip_make_packet()
1444 struct in_device *in_dev = in_dev_get(&strip_info->dev); in strip_make_packet()
1454 if (!arp_query(haddr.c, brd, &strip_info->dev)) in strip_make_packet()
1457 strip_info->dev.name); in strip_make_packet()
1464 if (!memcmp(haddr.c, strip_info->true_dev_addr.c, sizeof(haddr))) return(NULL); in strip_make_packet()
1486 if (strip_info->firmware_level >= ChecksummedMessages) ptr = add_checksum(buffer+1, ptr); in strip_make_packet()
1492 static void strip_send(struct strip *strip_info, struct sk_buff *skb) in strip_send() argument
1495 unsigned char *ptr = strip_info->tx_buff; in strip_send()
1496 int doreset = (long)jiffies - strip_info->watchdog_doreset >= 0; in strip_send()
1497 int doprobe = (long)jiffies - strip_info->watchdog_doprobe >= 0 && !doreset; in strip_send()
1505 char *newptr = strip_make_packet(ptr, strip_info, skb); in strip_send()
1506 strip_info->tx_pps_count++; in strip_send()
1507 if (!newptr) strip_info->tx_dropped++; in strip_send()
1511 strip_info->sx_pps_count++; in strip_send()
1512 strip_info->tx_packets++; /* Count another successful packet */ in strip_send()
1514 strip_info->tx_bytes += skb->len; in strip_send()
1515 strip_info->tx_rbytes += ptr - strip_info->tx_buff; in strip_send()
1527 StringDescriptor ts = CommandString[strip_info->next_command]; in strip_send()
1533 strip_info->next_command, tv.tv_sec % 100, tv.tv_usec); in strip_send()
1536 if (ptr == strip_info->tx_buff) *ptr++ = 0x0D; in strip_send()
1545 if (strip_info->firmware_level < ChecksummedMessages) ptr += ts.length; in strip_send()
1551 if (strip_info->firmware_level >= StructuredMessages) in strip_send()
1552 if (++strip_info->next_command >= ELEMENTS_OF(CommandString)) in strip_send()
1553 strip_info->next_command = 0; in strip_send()
1555 strip_info->tx_ebytes += ts.length; in strip_send()
1557 strip_info->watchdog_doprobe = jiffies + 10 * HZ; in strip_send()
1558 strip_info->watchdog_doreset = jiffies + 1 * HZ; in strip_send()
1565 strip_info->tx_head = strip_info->tx_buff; in strip_send()
1566 strip_info->tx_left = ptr - strip_info->tx_buff; in strip_send()
1567 strip_info->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); in strip_send()
1572 if (strip_info->tx_size - strip_info->tx_left < 20) in strip_send()
1573 printk(KERN_ERR "%s: Sending%5d bytes;%5d bytes free.\n", strip_info->dev.name, in strip_send()
1574 strip_info->tx_left, strip_info->tx_size - strip_info->tx_left); in strip_send()
1580 if (doreset) { ResetRadio(strip_info); return; } in strip_send()
1583 struct in_device *in_dev = in_dev_get(&strip_info->dev); in strip_send()
1611 if (strip_info->working && (long)jiffies - strip_info->gratuitous_arp >= 0 && in strip_send()
1612 memcmp(strip_info->dev.dev_addr, zero_address.c, sizeof(zero_address)) && in strip_send()
1613 arp_query(haddr.c, brd, &strip_info->dev)) in strip_send()
1617 strip_info->gratuitous_arp = jiffies + strip_info->arp_interval; in strip_send()
1618 strip_info->arp_interval *= 2; in strip_send()
1619 if (strip_info->arp_interval > MaxARPInterval) in strip_send()
1620 strip_info->arp_interval = MaxARPInterval; in strip_send()
1625 &strip_info->dev, /* Device to send packet on */ in strip_send()
1628 strip_info->dev.dev_addr, /* Source HW address is our HW address */ in strip_send()
1629 strip_info->dev.dev_addr); /* Target HW address is our HW address (redundant) */ in strip_send()
1635 strip_write_some_more(strip_info->tty); in strip_send()
1641 struct strip *strip_info = (struct strip *)(dev->priv); in strip_xmit() local
1651 del_timer(&strip_info->idle_timer); in strip_xmit()
1654 if (strip_info->mtu != strip_info->dev.mtu) in strip_xmit()
1655 strip_changedmtu(strip_info); in strip_xmit()
1657 if (jiffies - strip_info->pps_timer > HZ) in strip_xmit()
1659 unsigned long t = jiffies - strip_info->pps_timer; in strip_xmit()
1660 unsigned long rx_pps_count = (strip_info->rx_pps_count * HZ * 8 + t/2) / t; in strip_xmit()
1661 unsigned long tx_pps_count = (strip_info->tx_pps_count * HZ * 8 + t/2) / t; in strip_xmit()
1662 unsigned long sx_pps_count = (strip_info->sx_pps_count * HZ * 8 + t/2) / t; in strip_xmit()
1664 strip_info->pps_timer = jiffies; in strip_xmit()
1665 strip_info->rx_pps_count = 0; in strip_xmit()
1666 strip_info->tx_pps_count = 0; in strip_xmit()
1667 strip_info->sx_pps_count = 0; in strip_xmit()
1669 strip_info->rx_average_pps = (strip_info->rx_average_pps + rx_pps_count + 1) / 2; in strip_xmit()
1670 strip_info->tx_average_pps = (strip_info->tx_average_pps + tx_pps_count + 1) / 2; in strip_xmit()
1671 strip_info->sx_average_pps = (strip_info->sx_average_pps + sx_pps_count + 1) / 2; in strip_xmit()
1675 strip_info->dev.name, rx_pps_count / 8); in strip_xmit()
1678 strip_info->dev.name, tx_pps_count / 8); in strip_xmit()
1681 strip_info->dev.name, sx_pps_count / 8); in strip_xmit()
1684 strip_send(strip_info, skb); in strip_xmit()
1716 struct strip *strip_info = (struct strip *)(dev->priv); in strip_header() local
1722 header->src_addr = strip_info->true_dev_addr; in strip_header()
1767 static void get_radio_version(struct strip *strip_info, __u8 *ptr, __u8 *end) in get_radio_version() argument
1787 if (strip_info->firmware_version.c[0] == 0) in get_radio_version()
1789 strip_info->dev.name, len, value_begin); in get_radio_version()
1790 sprintf(strip_info->firmware_version.c, "%.*s", len, value_begin); in get_radio_version()
1799 sprintf(strip_info->serial_number.c, "%.*s", len, p); in get_radio_version()
1811 static void get_radio_voltage(struct strip *strip_info, __u8 *ptr, __u8 *end) in get_radio_voltage() argument
1817 sprintf(strip_info->battery_voltage.c, "%.*s", len, ptr); in get_radio_voltage()
1844 static int get_radio_address(struct strip *strip_info, __u8 *p) in get_radio_address() argument
1851 if (memcmp(strip_info->true_dev_addr.c, addr.c, sizeof(addr))) in get_radio_address()
1855 printk(KERN_INFO "%s: Radio address = %s\n", strip_info->dev.name, addr_string.c); in get_radio_address()
1856 strip_info->true_dev_addr = addr; in get_radio_address()
1857 if (!strip_info->manual_dev_addr) *(MetricomAddress*)strip_info->dev.dev_addr = addr; in get_radio_address()
1859 strip_info->gratuitous_arp = jiffies + 15 * HZ; in get_radio_address()
1860 strip_info->arp_interval = 1 * HZ; in get_radio_address()
1865 static int verify_checksum(struct strip *strip_info) in verify_checksum() argument
1867 __u8 *p = strip_info->sx_buff; in verify_checksum()
1868 __u8 *end = strip_info->sx_buff + strip_info->sx_count - 4; in verify_checksum()
1872 if (sum == 0 && strip_info->firmware_level == StructuredMessages) in verify_checksum()
1874 strip_info->firmware_level = ChecksummedMessages; in verify_checksum()
1875 printk(KERN_INFO "%s: Radio provides message checksums\n", strip_info->dev.name); in verify_checksum()
1880 static void RecvErr(char *msg, struct strip *strip_info) in RecvErr() argument
1882 __u8 *ptr = strip_info->sx_buff; in RecvErr()
1883 __u8 *end = strip_info->sx_buff + strip_info->sx_count; in RecvErr()
1884 DumpData(msg, strip_info, ptr, end); in RecvErr()
1885 strip_info->rx_errors++; in RecvErr()
1888 static void RecvErr_Message(struct strip *strip_info, __u8 *sendername, const __u8 *msg, u_long len) in RecvErr_Message() argument
1892 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1894 strip_info->dev.name, sendername); in RecvErr_Message()
1904 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1906 strip_info->dev.name); in RecvErr_Message()
1911 strip_info->watchdog_doreset = jiffies + LongTime; in RecvErr_Message()
1920 if (!strip_info->working) in RecvErr_Message()
1922 strip_info->working = TRUE; in RecvErr_Message()
1923 printk(KERN_INFO "%s: Radio now in starmode\n", strip_info->dev.name); in RecvErr_Message()
1928 strip_info->watchdog_doprobe = jiffies; in RecvErr_Message()
1930 if (strip_info->firmware_level == NoStructure && sendername) in RecvErr_Message()
1932 strip_info->firmware_level = StructuredMessages; in RecvErr_Message()
1933 strip_info->next_command = 0; /* Try to enable checksums ASAP */ in RecvErr_Message()
1934 printk(KERN_INFO "%s: Radio provides structured messages\n", strip_info->dev.name); in RecvErr_Message()
1936 if (strip_info->firmware_level >= StructuredMessages) in RecvErr_Message()
1943 verify_checksum(strip_info); in RecvErr_Message()
1948 if (!GOT_ALL_RADIO_INFO(strip_info)) strip_info->watchdog_doprobe = jiffies; in RecvErr_Message()
1953 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1956 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1960 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1962 strip_info->dev.name); in RecvErr_Message()
1967 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1969 strip_info->dev.name); in RecvErr_Message()
1973 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1976 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1979 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1982 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1985 RecvErr("Error Msg:", strip_info); in RecvErr_Message()
1988 static void process_AT_response(struct strip *strip_info, __u8 *ptr, __u8 *end) in process_AT_response() argument
2005 if (has_prefix(ptr, len, "ATS300?" )) get_radio_version(strip_info, p, end); in process_AT_response()
2006 else if (has_prefix(ptr, len, "ATS305?" )) get_radio_address(strip_info, p); in process_AT_response()
2007 else if (has_prefix(ptr, len, "ATS311?" )) get_radio_neighbours(&strip_info->poletops, p, end); in process_AT_response()
2008 else if (has_prefix(ptr, len, "ATS319=7")) verify_checksum(strip_info); in process_AT_response()
2009 else if (has_prefix(ptr, len, "ATS325?" )) get_radio_voltage(strip_info, p, end); in process_AT_response()
2010 else if (has_prefix(ptr, len, "AT~LA" )) get_radio_neighbours(&strip_info->portables, p, end); in process_AT_response()
2011 else RecvErr("Unknown AT Response:", strip_info); in process_AT_response()
2014 static void process_ACK(struct strip *strip_info, __u8 *ptr, __u8 *end) in process_ACK() argument
2019 static void process_Info(struct strip *strip_info, __u8 *ptr, __u8 *end) in process_Info() argument
2021 if (ptr+16 > end) RecvErr("Bad Info Msg:", strip_info); in process_Info()
2024 static struct net_device *get_strip_dev(struct strip *strip_info) in get_strip_dev() argument
2029 if (strip_info->manual_dev_addr && in get_strip_dev()
2030 !memcmp(strip_info->dev.dev_addr, zero_address.c, sizeof(zero_address)) && in get_strip_dev()
2031 memcmp(&strip_info->true_dev_addr, zero_address.c, sizeof(zero_address))) in get_strip_dev()
2038 if (dev->type == strip_info->dev.type && in get_strip_dev()
2039 !memcmp(dev->dev_addr, &strip_info->true_dev_addr, sizeof(MetricomAddress))) in get_strip_dev()
2042 strip_info->dev.name, dev->name); in get_strip_dev()
2050 return(&strip_info->dev); in get_strip_dev()
2057 static void deliver_packet(struct strip *strip_info, STRIP_Header *header, __u16 packetlen) in deliver_packet() argument
2062 printk(KERN_ERR "%s: memory squeeze, dropping packet.\n", strip_info->dev.name); in deliver_packet()
2063 strip_info->rx_dropped++; in deliver_packet()
2068 memcpy(skb_put(skb, packetlen), strip_info->rx_buff, packetlen); in deliver_packet()
2069 skb->dev = get_strip_dev(strip_info); in deliver_packet()
2079 strip_info->rx_packets++; in deliver_packet()
2080 strip_info->rx_pps_count++; in deliver_packet()
2082 strip_info->rx_bytes += packetlen; in deliver_packet()
2088 static void process_IP_packet(struct strip *strip_info, STRIP_Header *header, __u8 *ptr, __u8 *end) in process_IP_packet() argument
2093 ptr = UnStuffData(ptr, end, strip_info->rx_buff, 4); in process_IP_packet()
2096 RecvErr("IP Packet too short", strip_info); in process_IP_packet()
2100 packetlen = ((__u16)strip_info->rx_buff[2] << 8) | strip_info->rx_buff[3]; in process_IP_packet()
2105 strip_info->dev.name, packetlen); in process_IP_packet()
2106 strip_info->rx_dropped++; in process_IP_packet()
2113 ptr = UnStuffData(ptr, end, strip_info->rx_buff+4, packetlen-4); in process_IP_packet()
2116 RecvErr("IP Packet too short", strip_info); in process_IP_packet()
2122 RecvErr("IP Packet too long", strip_info); in process_IP_packet()
2128 deliver_packet(strip_info, header, packetlen); in process_IP_packet()
2131 static void process_ARP_packet(struct strip *strip_info, STRIP_Header *header, __u8 *ptr, __u8 *end) in process_ARP_packet() argument
2134 struct arphdr *arphdr = (struct arphdr *)strip_info->rx_buff; in process_ARP_packet()
2137 ptr = UnStuffData(ptr, end, strip_info->rx_buff, 8); in process_ARP_packet()
2140 RecvErr("ARP Packet too short", strip_info); in process_ARP_packet()
2149 strip_info->dev.name, packetlen); in process_ARP_packet()
2150 strip_info->rx_dropped++; in process_ARP_packet()
2159 ptr = UnStuffData(ptr, end, strip_info->rx_buff+8, packetlen-8); in process_ARP_packet()
2162 RecvErr("ARP Packet too short", strip_info); in process_ARP_packet()
2168 RecvErr("ARP Packet too long", strip_info); in process_ARP_packet()
2174 deliver_packet(strip_info, header, packetlen); in process_ARP_packet()
2185 static void process_text_message(struct strip *strip_info) in process_text_message() argument
2187 __u8 *msg = strip_info->sx_buff; in process_text_message()
2188 int len = strip_info->sx_count; in process_text_message()
2192 if (len == 9 && get_radio_address(strip_info, msg) == 0) return; in process_text_message()
2200 if (has_prefix(msg, len, "ERR_")) { RecvErr_Message(strip_info, NULL, &msg[4], len-4); return; } in process_text_message()
2202 RecvErr("No initial *", strip_info); in process_text_message()
2214 static void process_message(struct strip *strip_info) in process_message() argument
2217 __u8 *ptr = strip_info->sx_buff; in process_message()
2218 __u8 *end = strip_info->sx_buff + strip_info->sx_count; in process_message()
2226 else { process_text_message(strip_info); return; } in process_message()
2235 RecvErr("No second *", strip_info); in process_message()
2244 strip_info->firmware_level = NoStructure; in process_message()
2245 strip_info->next_command = CompatibilityCommand; in process_message()
2251 RecvErr("No proto key", strip_info); in process_message()
2262 if (strip_info->firmware_level >= ChecksummedMessages) in process_message()
2267 RecvErr("Missing Checksum", strip_info); in process_message()
2270 if (!verify_checksum(strip_info)) in process_message()
2272 RecvErr("Bad Checksum", strip_info); in process_message()
2284 header.dst_addr = strip_info->true_dev_addr; in process_message()
2289 strip_info->rx_rbytes += (end - ptr); in process_message()
2290 process_IP_packet(strip_info, &header, ptr, end); in process_message()
2292 strip_info->rx_rbytes += (end - ptr); in process_message()
2293 process_ARP_packet(strip_info, &header, ptr, end); in process_message()
2295 strip_info->rx_ebytes += (end - ptr); in process_message()
2296 process_AT_response(strip_info, ptr, end); in process_message()
2298 strip_info->rx_ebytes += (end - ptr); in process_message()
2299 process_ACK(strip_info, ptr, end); in process_message()
2301 strip_info->rx_ebytes += (end - ptr); in process_message()
2302 process_Info(strip_info, ptr, end); in process_message()
2304 strip_info->rx_ebytes += (end - ptr); in process_message()
2305 RecvErr_Message(strip_info, sendername, ptr, end-ptr); in process_message()
2306 } else RecvErr("Unrecognized protocol key", strip_info); in process_message()
2308 if (key.l == SIP0Key.l) process_IP_packet (strip_info, &header, ptr, end); in process_message()
2309 else if (key.l == ARP0Key.l) process_ARP_packet (strip_info, &header, ptr, end); in process_message()
2310 else if (key.l == ATR_Key.l) process_AT_response(strip_info, ptr, end); in process_message()
2311 else if (key.l == ACK_Key.l) process_ACK (strip_info, ptr, end); in process_message()
2312 else if (key.l == INF_Key.l) process_Info (strip_info, ptr, end); in process_message()
2313 else if (key.l == ERR_Key.l) RecvErr_Message (strip_info, sendername, ptr, end-ptr); in process_message()
2314 else RecvErr("Unrecognized protocol key", strip_info); in process_message()
2333 struct strip *strip_info = (struct strip *) tty->disc_data; in strip_receive_buf() local
2336 if (!strip_info || strip_info->magic != STRIP_MAGIC in strip_receive_buf()
2337 || !netif_running(&strip_info->dev)) in strip_receive_buf()
2341 if (strip_info->mtu != strip_info->dev.mtu) in strip_receive_buf()
2342 strip_changedmtu(strip_info); in strip_receive_buf()
2354 strip_info->rx_sbytes += count; in strip_receive_buf()
2360 … if (fp && *fp) printk(KERN_INFO "%s: %s on serial port\n", strip_info->dev.name, TTYERROR(*fp)); in strip_receive_buf()
2361 if (fp && *fp++ && !strip_info->discard) /* If there's a serial error, record it */ in strip_receive_buf()
2364 strip_info->discard = strip_info->sx_count; in strip_receive_buf()
2365 strip_info->rx_errors++; in strip_receive_buf()
2369 if (strip_info->sx_count > 0 || *cp >= ' ') in strip_receive_buf()
2373 if (strip_info->sx_count > 3000) in strip_receive_buf()
2375 strip_info->dev.name, strip_info->sx_count, end-cp-1, in strip_receive_buf()
2376 strip_info->discard ? " (discarded)" : ""); in strip_receive_buf()
2377 if (strip_info->sx_count > strip_info->sx_size) in strip_receive_buf()
2379 strip_info->rx_over_errors++; in strip_receive_buf()
2381 strip_info->dev.name, strip_info->sx_count); in strip_receive_buf()
2383 else if (strip_info->discard) in strip_receive_buf()
2385 strip_info->dev.name, strip_info->discard, strip_info->sx_count); in strip_receive_buf()
2386 else process_message(strip_info); in strip_receive_buf()
2387 strip_info->discard = 0; in strip_receive_buf()
2388 strip_info->sx_count = 0; in strip_receive_buf()
2393 if (strip_info->sx_count < strip_info->sx_size) in strip_receive_buf()
2394 strip_info->sx_buff[strip_info->sx_count] = *cp; in strip_receive_buf()
2395 strip_info->sx_count++; in strip_receive_buf()
2406 static int set_mac_address(struct strip *strip_info, MetricomAddress *addr) in set_mac_address() argument
2414 strip_info->manual_dev_addr = memcmp(addr->c, broadcast_address.c, sizeof(broadcast_address)); in set_mac_address()
2415 if (strip_info->manual_dev_addr) in set_mac_address()
2416 *(MetricomAddress*)strip_info->dev.dev_addr = *addr; in set_mac_address()
2417 else *(MetricomAddress*)strip_info->dev.dev_addr = strip_info->true_dev_addr; in set_mac_address()
2423 struct strip *strip_info = (struct strip *)(dev->priv); in dev_set_mac_address() local
2426 set_mac_address(strip_info, (MetricomAddress *)sa->sa_data); in dev_set_mac_address()
2433 struct strip *strip_info = (struct strip *)(dev->priv); in strip_get_stats() local
2437 stats.rx_packets = strip_info->rx_packets; in strip_get_stats()
2438 stats.tx_packets = strip_info->tx_packets; in strip_get_stats()
2439 stats.rx_dropped = strip_info->rx_dropped; in strip_get_stats()
2440 stats.tx_dropped = strip_info->tx_dropped; in strip_get_stats()
2441 stats.tx_errors = strip_info->tx_errors; in strip_get_stats()
2442 stats.rx_errors = strip_info->rx_errors; in strip_get_stats()
2443 stats.rx_over_errors = strip_info->rx_over_errors; in strip_get_stats()
2477 struct strip *strip_info = (struct strip *)(dev->priv); in strip_open_low() local
2482 if (strip_info->tty == NULL) in strip_open_low()
2485 if (!allocate_buffers(strip_info)) in strip_open_low()
2488 strip_info->sx_count = 0; in strip_open_low()
2489 strip_info->tx_left = 0; in strip_open_low()
2491 strip_info->discard = 0; in strip_open_low()
2492 strip_info->working = FALSE; in strip_open_low()
2493 strip_info->firmware_level = NoStructure; in strip_open_low()
2494 strip_info->next_command = CompatibilityCommand; in strip_open_low()
2495 strip_info->user_baud = get_baud(strip_info->tty); in strip_open_low()
2508 printk(KERN_INFO "%s: Initializing Radio.\n", strip_info->dev.name); in strip_open_low()
2509 ResetRadio(strip_info); in strip_open_low()
2510 strip_info->idle_timer.expires = jiffies + 1*HZ; in strip_open_low()
2511 add_timer(&strip_info->idle_timer); in strip_open_low()
2523 struct strip *strip_info = (struct strip *)(dev->priv); in strip_close_low() local
2525 if (strip_info->tty == NULL) in strip_close_low()
2527 strip_info->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); in strip_close_low()
2534 if (strip_info->rx_buff) in strip_close_low()
2536 kfree(strip_info->rx_buff); in strip_close_low()
2537 strip_info->rx_buff = NULL; in strip_close_low()
2539 if (strip_info->sx_buff) in strip_close_low()
2541 kfree(strip_info->sx_buff); in strip_close_low()
2542 strip_info->sx_buff = NULL; in strip_close_low()
2544 if (strip_info->tx_buff) in strip_close_low()
2546 kfree(strip_info->tx_buff); in strip_close_low()
2547 strip_info->tx_buff = NULL; in strip_close_low()
2549 del_timer(&strip_info->idle_timer); in strip_close_low()
2598 static void strip_free(struct strip *strip_info) in strip_free() argument
2600 *(strip_info->referrer) = strip_info->next; in strip_free()
2601 if (strip_info->next) in strip_free()
2602 strip_info->next->referrer = strip_info->referrer; in strip_free()
2603 strip_info->magic = 0; in strip_free()
2604 kfree(strip_info); in strip_free()
2615 struct strip *strip_info = (struct strip *) in strip_alloc() local
2618 if (!strip_info) in strip_alloc()
2625 memset(strip_info, 0, sizeof(struct strip)); in strip_alloc()
2643 strip_info->next = *s; in strip_alloc()
2645 (*s)->referrer = &strip_info->next; in strip_alloc()
2646 strip_info->referrer = s; in strip_alloc()
2647 *s = strip_info; in strip_alloc()
2649 strip_info->magic = STRIP_MAGIC; in strip_alloc()
2650 strip_info->tty = NULL; in strip_alloc()
2652 strip_info->gratuitous_arp = jiffies + LongTime; in strip_alloc()
2653 strip_info->arp_interval = 0; in strip_alloc()
2654 init_timer(&strip_info->idle_timer); in strip_alloc()
2655 strip_info->idle_timer.data = (long)&strip_info->dev; in strip_alloc()
2656 strip_info->idle_timer.function = strip_IdleTask; in strip_alloc()
2659 sprintf(strip_info->dev.name, "st%d", channel_id); in strip_alloc()
2660 strip_info->dev.base_addr = channel_id; in strip_alloc()
2661 strip_info->dev.priv = (void*)strip_info; in strip_alloc()
2662 strip_info->dev.next = NULL; in strip_alloc()
2663 strip_info->dev.init = strip_dev_init; in strip_alloc()
2665 return(strip_info); in strip_alloc()
2678 struct strip *strip_info = (struct strip *) tty->disc_data; in strip_open() local
2684 if (strip_info && strip_info->magic == STRIP_MAGIC) in strip_open()
2690 if ((strip_info = strip_alloc()) == NULL) in strip_open()
2698 if (register_netdev(&strip_info->dev) != 0) in strip_open()
2701 strip_free(strip_info); in strip_open()
2705 strip_info->tty = tty; in strip_open()
2706 tty->disc_data = strip_info; in strip_open()
2715 strip_info->dev.type = ARPHRD_METRICOM; /* dtang */ in strip_open()
2727 printk(KERN_INFO "STRIP: device \"%s\" activated\n", strip_info->dev.name); in strip_open()
2732 return(strip_info->dev.base_addr); in strip_open()
2744 struct strip *strip_info = (struct strip *) tty->disc_data; in strip_close() local
2750 if (!strip_info || strip_info->magic != STRIP_MAGIC) in strip_close()
2753 unregister_netdev(&strip_info->dev); in strip_close()
2756 strip_info->tty = NULL; in strip_close()
2757 printk(KERN_INFO "STRIP: device \"%s\" closed down\n", strip_info->dev.name); in strip_close()
2758 strip_free(strip_info); in strip_close()
2770 struct strip *strip_info = (struct strip *) tty->disc_data; in strip_ioctl() local
2776 if (!strip_info || strip_info->magic != STRIP_MAGIC) in strip_ioctl()
2782 return copy_to_user((void*)arg, strip_info->dev.name, in strip_ioctl()
2783 strlen(strip_info->dev.name) + 1) ? in strip_ioctl()
2789 printk(KERN_INFO "%s: SIOCSIFHWADDR\n", strip_info->dev.name); in strip_ioctl()
2791 -EFAULT : set_mac_address(strip_info, &addr); in strip_ioctl()