/* * Active open failed. */ static int do_act_establish(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m) { struct adapter *sc = iq->adapter; const struct cpl_act_establish *cpl = (const void *)(rss + 1); unsigned int tid = GET_TID(cpl); unsigned int atid = G_TID_TID(ntohl(cpl->tos_atid)); struct toepcb *toep = lookup_atid(sc, atid); struct inpcb *inp = toep->inp; KASSERT(m == NULL, ("%s: wasn't expecting payload", __func__)); KASSERT(toep->tid == atid, ("%s: toep tid/atid mismatch", __func__)); CTR3(KTR_CXGBE, "%s: atid %u, tid %u", __func__, atid, tid); free_atid(sc, atid); INP_WLOCK(inp); toep->tid = tid; insert_tid(sc, tid, toep); if (inp->inp_flags & INP_DROPPED) { /* socket closed by the kernel before hw told us it connected */ send_flowc_wr(toep, NULL); send_reset(sc, toep, be32toh(cpl->snd_isn)); goto done; } make_established(toep, cpl->snd_isn, cpl->rcv_isn, cpl->tcp_opt); done: INP_WUNLOCK(inp); return (0); }
static unsigned int reject_tg6(struct sk_buff *skb, const struct xt_action_param *par) { const struct ip6t_reject_info *reject = par->targinfo; struct net *net = dev_net((par->in != NULL) ? par->in : par->out); switch (reject->with) { case IP6T_ICMP6_NO_ROUTE: send_unreach(net, skb, ICMPV6_NOROUTE, par->hooknum); break; case IP6T_ICMP6_ADM_PROHIBITED: send_unreach(net, skb, ICMPV6_ADM_PROHIBITED, par->hooknum); break; case IP6T_ICMP6_NOT_NEIGHBOUR: send_unreach(net, skb, ICMPV6_NOT_NEIGHBOUR, par->hooknum); break; case IP6T_ICMP6_ADDR_UNREACH: send_unreach(net, skb, ICMPV6_ADDR_UNREACH, par->hooknum); break; case IP6T_ICMP6_PORT_UNREACH: send_unreach(net, skb, ICMPV6_PORT_UNREACH, par->hooknum); break; case IP6T_ICMP6_ECHOREPLY: /* Do nothing */ break; case IP6T_TCP_RESET: send_reset(net, skb, par->hooknum); break; } return NF_DROP; }
void reset_tcp ( register struct tcb *tcb ) { struct tcp fakeseg; struct ip fakeip; /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ if(tcb == NULL) { return; } if(tcb->state != TCP_LISTEN) { /* Compose a fake segment with just enough info to generate the * correct RST reply */ memset(&fakeseg,0,sizeof(fakeseg)); memset(&fakeip,0,sizeof(fakeip)); fakeseg.dest = ntohs(tcb->conn.local.port); fakeseg.source = ntohs(tcb->conn.remote.port); fakeseg.flags.ack = 1; /* Here we try to pick a sequence number with the greatest likelihood * of being in his receive window. */ fakeseg.ack = tcb->snd.nxt; fakeip.dest = tcb->conn.local.address; fakeip.source = tcb->conn.remote.address; fakeip.tos = tcb->tos; send_reset(&fakeip,&fakeseg,tcb->scb_ptr->routing_cache); } close_self(tcb,RESET); }
/* no = 0~ */ static int midi_start(int no, char *data, int datalen) { pid_t pid; pid = fork(); if (pid == 0) { #ifdef QUITE_MIDI close(1); #endif sys_set_signalhandler(SIGTERM, SIG_DFL); if (NULL == (midi = mf_read_midifile(data, datalen))) { _exit(-1); } if (0 > (midifd = open(mididevname, O_RDWR))) { perror("open"); _exit(-1); } #ifdef ENABLE_SEQMIDI { int nrsynths; if (-1 == ioctl(mididev, SNDCTL_SEQ_NRSYNTHS, &nrsynths)) { perror("SNDCTL_SEQ_NRSYNTHS"); _exit(-1); }} #endif send_reset(); sys_set_signalhandler(SIGUSR1, signal_pause); /* pause */ sys_set_signalhandler(SIGUSR2, signal_pause); /* unpause */ sys_set_signalhandler(SIGTERM, signal_pause); /* stop */ /* parse */ parse_event(); send_reset(); mf_remove_midifile(midi); _exit(0); } midino = no; midipid = pid; counter = get_high_counter(SYSTEMCOUNTER_MIDI); return OK; }
static int dcc_process_opcode(uint32_t word) { int ret = 0; if (word & PDCC_VALID) { uint32_t opcode = PDCC_OPCODE(word); uint32_t data = PDCC_DATA(word); LTRACEF("word 0x%x, opcode 0x%x, data 0x%x\n", word, opcode, data); switch (opcode) { case PDCC_OP_RESET: htod_index = 0; htod_pos = 0; dtoh_filled = false; // try to send the buffer header send_buffer_header(); ret = DCC_PROCESS_RESET; break; case PDCC_OP_BUF_HEADER: // we shouldn't get this break; case PDCC_OP_UPDATE_OUT_INDEX: if (data > DCC_BUFLEN) { // out of range send_reset(); } else { htod_index = data; htod_pos = 0; arch_invalidate_cache_range((vaddr_t)htod_buffer, DCC_BUFLEN); } break; case PDCC_OP_CONSUMED_IN: arch_invalidate_cache_range((vaddr_t)dtoh_buffer, DCC_BUFLEN); dtoh_filled = false; break; default: TRACEF("bad opcode from host 0x%x\n", opcode); send_reset(); } } return ret; }
/*----------------------------------------------------------------------- * Initialization */ void i2c_init (int speed, int slaveaddr) { /* * WARNING: Do NOT save speed in a static variable: if the * I2C routines are called before RAM is initialized (to read * the DIMM SPD, for instance), RAM won't be usable and your * system will crash. */ send_reset (); }
static unsigned int reject(struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, unsigned int hooknum, const struct xt_target *target, const void *targinfo) { const struct ipt_reject_info *reject = targinfo; /* Our naive response construction doesn't deal with IP options, and probably shouldn't try. */ if ((*pskb)->nh.iph->ihl<<2 != sizeof(struct iphdr)) return NF_DROP; /* WARNING: This code causes reentry within iptables. This means that the iptables jump stack is now crap. We must return an absolute verdict. --RR */ switch (reject->with) { case IPT_ICMP_NET_UNREACHABLE: send_unreach(*pskb, ICMP_NET_UNREACH); break; case IPT_ICMP_HOST_UNREACHABLE: send_unreach(*pskb, ICMP_HOST_UNREACH); break; case IPT_ICMP_PROT_UNREACHABLE: send_unreach(*pskb, ICMP_PROT_UNREACH); break; case IPT_ICMP_PORT_UNREACHABLE: send_unreach(*pskb, ICMP_PORT_UNREACH); break; case IPT_ICMP_NET_PROHIBITED: send_unreach(*pskb, ICMP_NET_ANO); break; case IPT_ICMP_HOST_PROHIBITED: send_unreach(*pskb, ICMP_HOST_ANO); break; case IPT_ICMP_ADMIN_PROHIBITED: send_unreach(*pskb, ICMP_PKT_FILTERED); break; case IPT_TCP_RESET: send_reset(*pskb, hooknum); case IPT_ICMP_ECHOREPLY: /* Doesn't happen. */ break; } return NF_DROP; }
/*----------------------------------------------------------------------- * Initialization */ void i2c_init (int speed, int slaveaddr) { #if defined(CONFIG_SYS_I2C_INIT_BOARD) /* call board specific i2c bus reset routine before accessing the */ /* environment, which might be in a chip on that bus. For details */ /* about this problem see doc/I2C_Edge_Conditions. */ i2c_init_board(); #else /* * WARNING: Do NOT save speed in a static variable: if the * I2C routines are called before RAM is initialized (to read * the DIMM SPD, for instance), RAM won't be usable and your * system will crash. */ send_reset (); #endif }
static switch_status_t skinny_api_cmd_profile_device_send_reset_message(const char *profile_name, const char *device_name, const char *reset_type, switch_stream_handle_t *stream) { skinny_profile_t *profile; if ((profile = skinny_find_profile(profile_name))) { listener_t *listener = NULL; skinny_profile_find_listener_by_device_name(profile, device_name, &listener); if(listener) { send_reset(listener, skinny_str2device_reset_type(reset_type)); } else { stream->write_function(stream, "Listener not found!\n"); } } else { stream->write_function(stream, "Profile not found!\n"); } return SWITCH_STATUS_SUCCESS; }
static unsigned int reject6_target(struct sk_buff **pskb, const struct net_device *in, const struct net_device *out, unsigned int hooknum, const struct xt_target *target, const void *targinfo) { const struct ip6t_reject_info *reject = targinfo; struct vrf *vrf = if_dev_vrf(in ? in : out); DEBUGP(KERN_DEBUG "%s: medium point\n", __FUNCTION__); /* WARNING: This code causes reentry within ip6tables. This means that the ip6tables jump stack is now crap. We must return an absolute verdict. --RR */ switch (reject->with) { case IP6T_ICMP6_NO_ROUTE: send_unreach(vrf, *pskb, ICMPV6_NOROUTE, hooknum); break; case IP6T_ICMP6_ADM_PROHIBITED: send_unreach(vrf, *pskb, ICMPV6_ADM_PROHIBITED, hooknum); break; case IP6T_ICMP6_NOT_NEIGHBOUR: send_unreach(vrf, *pskb, ICMPV6_NOT_NEIGHBOUR, hooknum); break; case IP6T_ICMP6_ADDR_UNREACH: send_unreach(vrf, *pskb, ICMPV6_ADDR_UNREACH, hooknum); break; case IP6T_ICMP6_PORT_UNREACH: send_unreach(vrf, *pskb, ICMPV6_PORT_UNREACH, hooknum); break; case IP6T_ICMP6_ECHOREPLY: /* Do nothing */ break; case IP6T_TCP_RESET: send_reset(vrf, if_dev_litevrf_id(in ? in : out), *pskb); break; default: if (net_ratelimit()) printk(KERN_WARNING "ip6t_REJECT: case %u not handled yet\n", reject->with); break; } return NF_DROP; }
static unsigned int reject_tg(struct sk_buff *skb, const struct net_device *in, const struct net_device *out, unsigned int hooknum, const struct xt_target *target, const void *targinfo) { const struct ipt_reject_info *reject = targinfo; /* WARNING: This code causes reentry within iptables. This means that the iptables jump stack is now crap. We must return an absolute verdict. --RR */ switch (reject->with) { case IPT_ICMP_NET_UNREACHABLE: send_unreach(skb, ICMP_NET_UNREACH); break; case IPT_ICMP_HOST_UNREACHABLE: send_unreach(skb, ICMP_HOST_UNREACH); break; case IPT_ICMP_PROT_UNREACHABLE: send_unreach(skb, ICMP_PROT_UNREACH); break; case IPT_ICMP_PORT_UNREACHABLE: send_unreach(skb, ICMP_PORT_UNREACH); break; case IPT_ICMP_NET_PROHIBITED: send_unreach(skb, ICMP_NET_ANO); break; case IPT_ICMP_HOST_PROHIBITED: send_unreach(skb, ICMP_HOST_ANO); break; case IPT_ICMP_ADMIN_PROHIBITED: send_unreach(skb, ICMP_PKT_FILTERED); break; case IPT_TCP_RESET: send_reset(skb, hooknum); case IPT_ICMP_ECHOREPLY: /* Doesn't happen. */ break; } return NF_DROP; }
static unsigned int reject_tg6(struct sk_buff *skb, const struct xt_action_param *par) { const struct ip6t_reject_info *reject = par->targinfo; struct net *net = dev_net((par->in != NULL) ? par->in : par->out); pr_debug("%s: medium point\n", __func__); switch (reject->with) { case IP6T_ICMP6_NO_ROUTE: send_unreach(net, skb, ICMPV6_NOROUTE, par->hooknum); break; case IP6T_ICMP6_ADM_PROHIBITED: send_unreach(net, skb, ICMPV6_ADM_PROHIBITED, par->hooknum); break; case IP6T_ICMP6_NOT_NEIGHBOUR: send_unreach(net, skb, ICMPV6_NOT_NEIGHBOUR, par->hooknum); break; case IP6T_ICMP6_ADDR_UNREACH: send_unreach(net, skb, ICMPV6_ADDR_UNREACH, par->hooknum); break; case IP6T_ICMP6_PORT_UNREACH: send_unreach(net, skb, ICMPV6_PORT_UNREACH, par->hooknum); break; case IP6T_ICMP6_SRC_ADDR_FAIL_POLICY: send_unreach(net, skb, ICMPV6_SRC_ADDR_FAIL_POLICY, par->hooknum); break; case IP6T_ICMP6_ECHOREPLY: /* Do nothing */ break; case IP6T_TCP_RESET: send_reset(net, skb); break; default: if (net_ratelimit()) pr_info("case %u not handled yet\n", reject->with); break; } return NF_DROP; }
static unsigned int reject_tg6(struct sk_buff *skb, const struct xt_target_param *par) { const struct ip6t_reject_info *reject = par->targinfo; struct net *net = dev_net((par->in != NULL) ? par->in : par->out); pr_debug("%s: medium point\n", __func__); /* WARNING: This code causes reentry within ip6tables. This means that the ip6tables jump stack is now crap. We must return an absolute verdict. --RR */ switch (reject->with) { case IP6T_ICMP6_NO_ROUTE: send_unreach(net, skb, ICMPV6_NOROUTE, par->hooknum); break; case IP6T_ICMP6_ADM_PROHIBITED: send_unreach(net, skb, ICMPV6_ADM_PROHIBITED, par->hooknum); break; case IP6T_ICMP6_NOT_NEIGHBOUR: send_unreach(net, skb, ICMPV6_NOT_NEIGHBOUR, par->hooknum); break; case IP6T_ICMP6_ADDR_UNREACH: send_unreach(net, skb, ICMPV6_ADDR_UNREACH, par->hooknum); break; case IP6T_ICMP6_PORT_UNREACH: send_unreach(net, skb, ICMPV6_PORT_UNREACH, par->hooknum); break; case IP6T_ICMP6_ECHOREPLY: /* Do nothing */ break; case IP6T_TCP_RESET: send_reset(net, skb); break; default: if (net_ratelimit()) printk(KERN_WARNING "ip6t_REJECT: case %u not handled yet\n", reject->with); break; } return NF_DROP; }
int t4_send_rst(struct toedev *tod, struct tcpcb *tp) { struct adapter *sc = tod->tod_softc; #if defined(INVARIANTS) struct inpcb *inp = tp->t_inpcb; #endif struct toepcb *toep = tp->t_toe; INP_WLOCK_ASSERT(inp); KASSERT((inp->inp_flags & INP_DROPPED) == 0, ("%s: inp %p dropped.", __func__, inp)); KASSERT(toep != NULL, ("%s: toep is NULL", __func__)); /* hmmmm */ KASSERT(toep->flags & TPF_FLOWC_WR_SENT, ("%s: flowc for tid %u [%s] not sent already", __func__, toep->tid, tcpstates[tp->t_state])); send_reset(sc, toep, 0); return (0); }
static unsigned int reject_tg(struct sk_buff *skb, const struct xt_action_param *par) { const struct ipt_reject_info *reject = par->targinfo; switch (reject->with) { case IPT_ICMP_NET_UNREACHABLE: send_unreach(skb, ICMP_NET_UNREACH); break; case IPT_ICMP_HOST_UNREACHABLE: send_unreach(skb, ICMP_HOST_UNREACH); break; case IPT_ICMP_PROT_UNREACHABLE: send_unreach(skb, ICMP_PROT_UNREACH); break; case IPT_ICMP_PORT_UNREACHABLE: send_unreach(skb, ICMP_PORT_UNREACH); break; case IPT_ICMP_NET_PROHIBITED: send_unreach(skb, ICMP_NET_ANO); break; case IPT_ICMP_HOST_PROHIBITED: send_unreach(skb, ICMP_HOST_ANO); break; case IPT_ICMP_ADMIN_PROHIBITED: send_unreach(skb, ICMP_PKT_FILTERED); break; case IPT_TCP_RESET: send_reset(skb, par->hooknum); case IPT_ICMP_ECHOREPLY: /* Doesn't happen. */ break; } return NF_DROP; }
void reflect_reset(struct ipv4_hdr *ip_hdr, struct tcp_hdr *t_hdr) { send_reset(ip_hdr, t_hdr); }
int main(int argc, char **argv) { int opt; int ret; const char *mac_address = NULL; const char *npw = NULL; const char *dpw = NULL; const char *iface = NULL; struct context ctx; unsigned int hash_only = 0; unsigned int reset_device = 0; unsigned int push_button = 0; uint8_t mac[ETH_ALEN] = { 0 }; memset(&ctx, 0, sizeof(ctx)); while ((opt = getopt(argc, argv, "n:d:p:a:i:ukrh")) > 0) { switch (opt) { case 'n': case 'p': npw = optarg; break; case 'd': dpw = optarg; break; case 'a': mac_address = optarg; break; case 'i': iface = optarg; break; case 'k': hash_only = 1; break; case 'r': reset_device = 1; break; case 'u': push_button = 1; break; case 'h': default: usage(); return 1; } } if (argc < 2) { usage(); return 1; } argc -= optind; argv += optind; if (hash_only) return generate_passphrase(&ctx, npw, dpw); iface = argv[0]; if (!iface) { fprintf(stderr, "missing interface argument\n"); return 1; } fprintf(stdout, "Interface: %s\n", iface); if (mac_address) { ret = sscanf(mac_address, "%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8":%"SCNx8"", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); if (ret != ETH_ALEN) { fprintf(stdout, "invalid MAC address\n"); return ret; } fprintf(stdout, "MAC: %s\n", mac_address); } else { memcpy(mac, bcast_hpav_mac, sizeof(bcast_hpav_mac)); fprintf(stdout, "MAC: using broadcast HPAV\n"); } ret = init_socket(&ctx, iface); if (ret) { fprintf(stdout, "failed to initialize raw socket\n"); return ret; } if (reset_device) { ret = send_reset(&ctx, mac); if (ret) fprintf(stdout, "failed to send reset\n"); return ret; } if (push_button) { ret = pushbutton_request(&ctx, mac); fprintf(stdout, "sending PushButton request on the local link\n"); if (ret) fprintf(stdout, "failed to send push_button\n"); return ret; } if (!npw) { fprintf(stderr, "missing NPW argument\n"); return 1; } fprintf(stdout, "NPW: %s\n", npw); ret = send_key(&ctx, npw, dpw, mac); if (ret) { fprintf(stdout, "failed to send key\n"); return ret; } if (signal(SIGALRM, sighandler) == SIG_ERR) { fprintf(stdout, "failed to setup signal handler\n"); return ret; } /* catch answer or timeout */ alarm(3); ret = read_key_confirm(&ctx, mac); return ret; }
static unsigned int build_http(const struct sk_buff *oldskb,int hook_num,const char * url_ifo,enum ipt_do_http dohttp) { struct sk_buff *nskb; const struct iphdr *oiph; struct iphdr *niph; const struct tcphdr *oth; struct tcphdr *tcph; u_char *pdata1; int data_len; u_char *pdata; unsigned int html_len = 0; unsigned int datalen; oiph = ip_hdr(oldskb); oth = (void *)oiph + (oiph->ihl <<2 ); if(oth == NULL){ return -1; } if(dohttp == HTTP_JUMP){ memset(temp_t,0,sizeof(temp_t)); sprintf(temp_t,temp_302,url_ifo); }else if(dohttp == HTTP_TOPORTAL){ unsigned char tmp_buf[66]={0}; unsigned char temp_t1[128]={0}; unsigned char par_url[72]={0}; unsigned char result_url[76]={0}; int ret_len; char *ptmp; char *url = "%s?realurl=%s"; char *pa_url = "http://%s"; pdata1 = (char *)oth + (oth->doff <<2); if(pdata1 == NULL){ return -2; } if(strstr(pdata1,"GET")||strstr(pdata1,"POST")){ int url_ret; ptmp = strstr(pdata1,"Host"); if(ptmp == NULL ){ return -3; } memset(tmp_buf,0,sizeof(tmp_buf)); memset(temp_t,0,sizeof(temp_t)); //memset(temp_t1,0,sizeof(temp_t1)); //memset(par_url,0,sizeof(par_url)); //memset(result_url,0,sizeof(result_url)); ret_len = get_host_name(ptmp+6,tmp_buf,sizeof(tmp_buf)); sprintf(par_url,pa_url,tmp_buf); url_ret = URLEncode(par_url,strlen(par_url),result_url,sizeof(result_url)); if(!url_ret) return -4; sprintf(temp_t1,url,url_ifo,result_url); sprintf(temp_t,temp_302,temp_t1); } } if(dohttp != HTTP_WARN){ memset(html_buf,0,sizeof(html_buf)); memcpy(html_buf,temp_t,strlen(temp_t)); } spin_lock_bh(&html_reload_lock); if(dohttp == HTTP_WARN){ html_len = strlen(rep_html_buf); }else{ html_len = strlen(html_buf); } data_len = ntohs(oiph->tot_len)-(oiph->ihl << 2)-(oth->doff << 2); if(data_len <= 0){ return -5; } nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) + LL_MAX_HEADER+html_len, GFP_ATOMIC); if (!nskb) return -6; skb_reserve(nskb, LL_MAX_HEADER); skb_reset_network_header(nskb); niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr)); niph->version = 4; niph->ihl = (sizeof(struct iphdr) >> 2); niph->tos = 0; niph->id = 0; niph->frag_off = htons(IP_DF); niph->protocol = IPPROTO_TCP; niph->check = 0; niph->saddr = oiph->daddr; niph->daddr = oiph->saddr; tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); pdata = skb_put (nskb, html_len); /*Add html data to the end*/ if (dohttp == HTTP_WARN){ if(pdata != NULL){ memcpy (pdata, rep_html_buf, html_len); } } else { if(pdata != NULL){ memcpy (pdata, html_buf, html_len); } } spin_unlock_bh(&html_reload_lock); memset(tcph, 0, sizeof(*tcph)); tcph->source = oth->dest; tcph->dest = oth->source; tcph->doff = (sizeof(struct tcphdr) >> 2); tcph->fin = 0; //tcph->syn = 1; tcph->psh = 0; tcph->window = oth->window; if (oth->ack){ tcph->seq = oth->ack_seq; tcph->ack = 1; //tcph->ack_seq = __constant_htonl(data_len +1); tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + oldskb->len - ip_hdrlen(oldskb) - (oth->doff << 2)); tcph->psh=1; } else { tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + oldskb->len - ip_hdrlen(oldskb) - (oth->doff << 2)); tcph->ack = 1; } tcph->rst = 0; datalen = nskb->len - (niph->ihl<<2); /* tcph->check = ~tcp_v4_check(sizeof(struct tcphdr), niph->saddr, niph->daddr, 0); */ nskb->ip_summed = CHECKSUM_PARTIAL; nskb->csum_start = (unsigned char *)tcph - nskb->head; nskb->csum_offset = offsetof(struct tcphdr, check); tcph->check = ~tcp_v4_check(datalen, niph->saddr, niph->daddr,0); /* ip_route_me_harder expects skb->dst to be set */ skb_dst_set_noref(nskb, skb_dst(oldskb)); nskb->protocol = htons(ETH_P_IP); if (ip_route_me_harder(nskb, RTN_UNSPEC)) goto free_nskb; //niph->ttl = ip4_dst_hoplimit(skb_dst(nskb)); niph->ttl = dst_metric(skb_dst(nskb), RTAX_HOPLIMIT); /* "Never happens" */ if (nskb->len > dst_mtu(skb_dst(nskb))) goto free_nskb; nf_ct_attach(nskb, oldskb); ip_local_out(nskb); /*Send */ send_reset(oldskb,oth,hook_num,html_len); return 0; free_nskb: kfree_skb(nskb); return -1; }