static void imprimir_caminho(void) { char *path = stack_content(caminho); int i; raw_err("Coluna: %d\n\tTrecho:\t%s", coluna, path); raw_err("\033[31;1m%c\033[0m\n\t\t", token_errada); for (i = caminho->top; i--; ) raw_err(" "); raw_err(" ^\n"); free(path); }
void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info) { int hash; struct sock *raw_sk; const struct iphdr *iph; struct net *net; hash = protocol & (RAW_HTABLE_SIZE - 1); read_lock(&raw_v4_hashinfo.lock); raw_sk = sk_head(&raw_v4_hashinfo.ht[hash]); if (raw_sk != NULL) { iph = (const struct iphdr *)skb->data; net = dev_net(skb->dev); while ((raw_sk = __raw_v4_lookup(net, raw_sk, protocol, iph->daddr, iph->saddr, skb->dev->ifindex)) != NULL) { raw_err(raw_sk, skb, info); raw_sk = sk_next(raw_sk); iph = (const struct iphdr *)skb->data; } } read_unlock(&raw_v4_hashinfo.lock); }
void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info) { int hash; struct sock *raw_sk; struct iphdr *iph; struct vrf *vrf; hash = protocol & (RAW_HTABLE_SIZE - 1); read_lock(&raw_v4_hashinfo.lock); raw_sk = sk_head(&raw_v4_hashinfo.ht[hash]); if (raw_sk != NULL) { iph = (struct iphdr *)skb->data; vrf = if_dev_vrf(skb->dev); while ((raw_sk = __raw_v4_lookup(vrf, skb->litevrf_id, raw_sk, protocol, iph->daddr, iph->saddr, skb->dev->ifindex,ip_hdr(skb))) != NULL) { raw_err(raw_sk, skb, info); raw_sk = sk_next(raw_sk); iph = (struct iphdr *)skb->data; } } read_unlock(&raw_v4_hashinfo.lock); }
static int icmp_notify_an_error(const struct icmphdr *icmph, const void *msg, size_t msg_sz, uint16_t extra_info, int only_raw, struct sk_buff *skb) { const struct iphdr *emb_iph; uint32_t error_info; emb_iph = msg; assert(emb_iph != NULL); if ((msg_sz < IP_MIN_HEADER_SIZE) || (IP_HEADER_SIZE(emb_iph) < IP_MIN_HEADER_SIZE) || (ntohs(emb_iph->tot_len) < IP_HEADER_SIZE(emb_iph)) || (msg_sz < IP_HEADER_SIZE(emb_iph))) { log_error("invalid length"); skb_free(skb); return 0; /* error: invalid length */ } if (!ip_check_version(emb_iph)) { log_error("not ipv4"); skb_free(skb); return 0; /* error: not ipv4 */ } if (ip_hdr(skb)->daddr != emb_iph->saddr) { log_error("not my embedded packet"); skb_free(skb); return 0; /* error: not my embedded packet */ } error_info = extra_info << 16 | icmph->code << 8 | icmph->type; raw_err(skb, error_info); if (!only_raw) { const struct net_proto *nproto; nproto = net_proto_lookup(ETH_P_IP, emb_iph->proto); if (nproto != NULL) { assert(nproto->handle_error != NULL); nproto->handle_error(skb, error_info); } } return 0; }
void raw_icmp_error(struct sk_buff *skb, int protocol, u32 info) { int hash; struct sock *raw_sk; struct iphdr *iph; hash = protocol & (RAWV4_HTABLE_SIZE - 1); read_lock(&raw_v4_lock); raw_sk = sk_head(&raw_v4_htable[hash]); if (raw_sk != NULL) { iph = (struct iphdr *)skb->data; while ((raw_sk = __raw_v4_lookup(raw_sk, protocol, iph->daddr, iph->saddr, skb->dev->ifindex)) != NULL) { raw_err(raw_sk, skb, info); raw_sk = sk_next(raw_sk); iph = (struct iphdr *)skb->data; } } read_unlock(&raw_v4_lock); }
static void icmp_unreach(struct icmphdr *icmph, struct sk_buff *skb, int len) { struct iphdr *iph; int hash; struct inet_protocol *ipprot; unsigned char *dp; struct sock *raw_sk; /* * Incomplete header ? * Only checks for the IP header, there should be an * additional check for longer headers in upper levels. */ if(len<sizeof(struct iphdr)) { icmp_statistics.IcmpInErrors++; return; } iph = (struct iphdr *) (icmph + 1); dp = (unsigned char*)iph; if(icmph->type==ICMP_TIME_EXCEEDED) { /* ABD */ play_that_funky_music (icmph); } if(icmph->type==ICMP_DEST_UNREACH) { switch(icmph->code & 15) { case ICMP_NET_UNREACH: break; case ICMP_HOST_UNREACH: break; case ICMP_PORT_UNREACH: play_that_funky_music (icmph); /* ABD */ break; case ICMP_PROT_UNREACH: break; case ICMP_FRAG_NEEDED: if (ipv4_config.no_pmtu_disc) { if (sysctl_ip_always_defrag == 0 && net_ratelimit()) printk(KERN_INFO "ICMP: %s: fragmentation needed and DF set.\n", in_ntoa(iph->daddr)); } else { unsigned short new_mtu; new_mtu = ip_rt_frag_needed(iph, ntohs(icmph->un.frag.mtu)); if (!new_mtu) return; icmph->un.frag.mtu = htons(new_mtu); } break; case ICMP_SR_FAILED: if (sysctl_ip_always_defrag == 0 && net_ratelimit()) printk(KERN_INFO "ICMP: %s: Source Route Failed.\n", in_ntoa(iph->daddr)); break; default: break; } if (icmph->code>NR_ICMP_UNREACH) return; } /* * Throw it at our lower layers * * RFC 1122: 3.2.2 MUST extract the protocol ID from the passed header. * RFC 1122: 3.2.2.1 MUST pass ICMP unreach messages to the transport layer. * RFC 1122: 3.2.2.2 MUST pass ICMP time expired messages to transport layer. */ /* * Check the other end isnt violating RFC 1122. Some routers send * bogus responses to broadcast frames. If you see this message * first check your netmask matches at both ends, if it does then * get the other vendor to fix their kit. */ if (!sysctl_icmp_ignore_bogus_error_responses) { if (inet_addr_type(iph->daddr) == RTN_BROADCAST) { if (sysctl_ip_always_defrag == 0 && net_ratelimit()) printk(KERN_WARNING "%s sent an invalid ICMP error to a broadcast.\n", in_ntoa(skb->nh.iph->saddr)); return; } } /* * Deliver ICMP message to raw sockets. Pretty useless feature? */ /* Note: See raw.c and net/raw.h, RAWV4_HTABLE_SIZE==MAX_INET_PROTOS */ hash = iph->protocol & (MAX_INET_PROTOS - 1); if ((raw_sk = raw_v4_htable[hash]) != NULL) { while ((raw_sk = raw_v4_lookup(raw_sk, iph->protocol, iph->saddr, iph->daddr, skb->dev->ifindex)) != NULL) { raw_err(raw_sk, skb); raw_sk = raw_sk->next; } } /* * This can't change while we are doing it. */ ipprot = (struct inet_protocol *) inet_protos[hash]; while(ipprot != NULL) { struct inet_protocol *nextip; nextip = (struct inet_protocol *) ipprot->next; /* * Pass it off to everyone who wants it. */ /* RFC1122: OK. Passes appropriate ICMP errors to the */ /* appropriate protocol layer (MUST), as per 3.2.2. */ if (iph->protocol == ipprot->protocol && ipprot->err_handler) ipprot->err_handler(skb, dp, len); ipprot = nextip; } }