static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) { struct ctl_table_header *head = grab_header(dir); struct ctl_table *table = PROC_I(dir)->sysctl_entry; struct ctl_table_header *h = NULL; struct qstr *name = &dentry->d_name; struct ctl_table *p; struct inode *inode; struct dentry *err = ERR_PTR(-ENOENT); if (IS_ERR(head)) return ERR_CAST(head); if (table && !table->child) { WARN_ON(1); goto out; } table = table ? table->child : head->ctl_table; p = find_in_table(table, name); if (!p) { for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) { if (h->attached_to != table) continue; p = find_in_table(h->attached_by, name); if (p) break; } } if (!p) goto out; if (gr_handle_sysctl(p, MAY_EXEC)) goto out; err = ERR_PTR(-ENOMEM); inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p); if (h) sysctl_head_finish(h); if (!inode) goto out; err = NULL; d_set_d_op(dentry, &proc_sys_dentry_operations); d_add(dentry, inode); out: sysctl_head_finish(head); return err; }
static void instantiate_widget_instance (widget_instance *instance) { widget_creation_function function = NULL; #if defined (USE_LUCID) if (!function) function = find_in_table (instance->info->type, xlw_creation_table); #endif #if defined(USE_MOTIF) if (!function) function = find_in_table (instance->info->type, xm_creation_table); #endif #if defined (USE_XAW) if (!function) function = find_in_table (instance->info->type, xaw_creation_table); #endif if (!function) { if (dialog_spec_p (instance->info->type)) { #if defined (USE_LUCID) /* not yet */ #endif #if defined(USE_MOTIF) if (!function) function = xm_create_dialog; #endif #if defined (USE_XAW) if (!function) function = xaw_create_dialog; #endif } } if (!function) { printf ("No creation function for widget type %s\n", instance->info->type); abort (); } instance->widget = (*function) (instance); if (!instance->widget) abort (); /* XtRealizeWidget (instance->widget);*/ }
static enum mtk_plmn_type get_plmn_type(const char *code) { /* China Mobile (CMCC) MCC/MNC codes */ const char *table_type1[] = { "46000", "46002", "46007" }; /* China Unicom (CU) and China Telecom MCC/MNC codes */ const char *table_type3[] = { "46001", "46006", "46009", "45407", "46005", "45502" }; if (find_in_table(code, table_type1, G_N_ELEMENTS(table_type1))) return MTK_PLMN_TYPE_1; if (find_in_table(code, table_type3, G_N_ELEMENTS(table_type3))) return MTK_PLMN_TYPE_3; return MTK_PLMN_TYPE_2; }
static int verify_hash_table(struct hash_table *t) { unsigned int i; struct hash_elem *e; #if 0 static int count = 0; count++; if((count % 128) == 0) dprintf("verify_hash_table: count %d\n", count); #endif // do a quick spin through the table, making sure the same element isn't double entered for(i = 0; i < t->table_size; i++) { for(e = t->table[i]; e != NULL; e = NEXT(t, e)) { if(find_in_table(t, e, i, NEXT(t, e)) == true) { hash_dump(t); panic("element %p double inserted into hash table %p\n", e, t); } } } return 0; }
VOID GetPacketInfo(unsigned short ptype, unsigned char *szBuffer, int size_framehdr, char *src, char *dst, char *type, char *info) { int size_iphdr; unsigned short src_port, dst_port; char *service; struct ethernet_802_3 *eth; struct iphdr *ip; struct udphdr *udp; struct icmphdr *icmp; struct tcphdr *tcp; struct arppkt *arp; if (ptype == 0x0800) //'tis IP packet { ip = (struct iphdr *) &szBuffer[size_framehdr]; size_iphdr = (ip->verlen & 0x0f) * 4; lstrcpy(src, IpToString(ip->sourceip)); lstrcpy(dst, IpToString(ip->destip)); if (ip->prot == R_UDP) { udp = (struct udphdr *) &szBuffer[size_framehdr + size_iphdr]; lstrcpy(type, "udp"); src_port = ntohs(udp->srcport); dst_port = ntohs(udp->dstport); if (service = find_in_table(src_port, 0)) lstrcpy(info, service); else if (service = find_in_table(dst_port, 0)) lstrcpy(info, service); else wsprintf(info, "port: %d --> %d", src_port, dst_port); } else if (ip->prot == R_ICMP) { lstrcpy(type, "icmp"); icmp = (struct icmphdr *) &szBuffer[size_framehdr + size_iphdr]; if (icmp->type <= 16) lstrcpy(info, ICMP_type[icmp->type]); } else if (ip->prot == R_TCP) { lstrcpy(type, "tcp"); tcp = (struct tcphdr *) &szBuffer[size_framehdr + size_iphdr]; src_port = ntohs(tcp->srcport); dst_port = ntohs(tcp->dstport); if (service = find_in_table(src_port, 1)) lstrcpy(info, service); else if (service = find_in_table(dst_port, 1)) lstrcpy(info, service); else wsprintf(info, "port: %d --> %d", src_port, dst_port); } else if (ip->prot == R_IGMP) { lstrcpy(type, "igmp"); } else return; } else if (ptype == 0x0806) // ARP { arp = (struct arppkt *) &szBuffer[size_framehdr]; wsprintf(src, "%d.%d.%d.%d", arp->sender_ip[0], arp->sender_ip[1],arp->sender_ip[2],arp->sender_ip[3]); if (ntohs(arp->operation) == 1) { wsprintf(type, "arp req."); wsprintf(dst, "Broadcast"); wsprintf(info, "%d.%d.%d.%d = ?", arp->target_ip[0], arp->target_ip[1],arp->target_ip[2],arp->target_ip[3]); } else if (ntohs(arp->operation) == 2) { wsprintf(type, "arp resp."); wsprintf(dst, "%d.%d.%d.%d", arp->target_ip[0], arp->target_ip[1],arp->target_ip[2],arp->target_ip[3]); wsprintf(info, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", arp->sender_ha[0], arp->sender_ha[1],arp->sender_ha[2],arp->sender_ha[3],arp->sender_ha[4],arp->sender_ha[5]); } } else if (ptype == 0x8035) // RARP { arp = (struct arppkt *) &szBuffer[size_framehdr]; wsprintf(src, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X = ?", arp->sender_ha[0], arp->sender_ha[1],arp->sender_ha[2],arp->sender_ha[3],arp->sender_ha[4],arp->sender_ha[5]); if (ntohs(arp->operation) == 3) { wsprintf(type, "rarp req."); wsprintf(dst, "Broadcast"); wsprintf(info, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X = ?", arp->sender_ha[0], arp->sender_ha[1],arp->sender_ha[2],arp->sender_ha[3],arp->sender_ha[4],arp->sender_ha[5]); } else if (ntohs(arp->operation) == 4) { wsprintf(type, "rarp resp."); wsprintf(dst, "%d.%d.%d.%d", arp->target_ip[0], arp->target_ip[1],arp->target_ip[2],arp->target_ip[3]); wsprintf(info, "%d.%d.%d.%d", arp->target_ip[0], arp->target_ip[1],arp->target_ip[2],arp->target_ip[3]); } } else // unknown type of packet { eth = (struct ethernet_802_3 *) szBuffer; wsprintf(src, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", szBuffer[6], szBuffer[7], szBuffer[8], szBuffer[9], szBuffer[10], szBuffer[11]); wsprintf(dst, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", szBuffer[0], szBuffer[1], szBuffer[2], szBuffer[3], szBuffer[4], szBuffer[5]); if (size_framehdr == 14) { wsprintf(type, "ethernet_II frame"); wsprintf(info, "type = 0x%.4x%", ptype); } else if ((eth->dsap == 0xf0) && (eth->ssap == 0xf0)) { wsprintf(type, "netbeui"); wsprintf(info, "type = 0x%.4x", ptype); } else if ((eth->dsap == 0xff) && (eth->ssap == 0xff)) { wsprintf(type, "ipx"); lstrcpy(info, "novell"); } else { wsprintf(type, "802.3 frame"); wsprintf(info, "type = 0x%.4x", ptype); } } }