From owner-freebsd-isdn Sat Oct 30 10:17:30 1999 Delivered-To: freebsd-isdn@freebsd.org Received: from MedIS.DE (medis33.medis.de [193.141.96.33]) by hub.freebsd.org (Postfix) with ESMTP id 7A77414A0E for ; Sat, 30 Oct 1999 10:17:14 -0700 (PDT) (envelope-from Christian.Wolf@medis.de) Received: from tick.medis.de (tick.medis.de [193.141.96.36] (may be forged)) by MedIS.DE (8.9.3/8.9.3) with SMTP id TAA17846 for ; Sat, 30 Oct 1999 19:17:11 +0200 (MET DST) Date: Sat, 30 Oct 1999 19:17:10 +0200 (MET DST) From: Christian Wolf To: freebsd-isdn@freebsd.org Subject: Update of first-packet-log for i4b-00.83.00-beta-300799 Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-isdn@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Hi! I updated the ``first-packet-log'' patch for i4b-00.83.00-beta-300799. The patch in the contrib is out of date (i4b-00.63-alpha-100798). With this patch the first I4BIPRLOGFIRST (e.g. 32) packets are logged by isdnd, like this: isdnd[65]: CHD 00003 MEDIS rate 150 sec/unit (aocd, rate) isdnd[65]: CHD 00003 MEDIS dialing out from 77110510 to 76696951 isdnd[65]: PKT MEDIS send 44 TCP 193.141.96.1:1023 -> 193.141.96.36:513 SYN isdnd[65]: CHD 00003 MEDIS outgoing call proceeding (ctl 0, ch 0) isdnd[65]: PKT MEDIS send 44 TCP 193.141.96.1:1023 -> 193.141.96.36:513 SYN isdnd[65]: CHD 00004 MEDIS accepting: incoming call from 4076696951 to 77110510 isdnd[65]: CHD 00004 MEDIS incoming call active (ctl 0, ch 1, ipr0) isdnd[65]: PKT MEDIS recv 44 TCP 193.141.96.36:513 -> 193.141.96.1:1023 SYN ACK isdnd[65]: PKT MEDIS send 40 TCP 193.141.96.1:1023 -> 193.141.96.36:513 ACK isdnd[65]: PKT MEDIS send 41 TCP 193.141.96.1:1023 -> 193.141.96.36:513 PUSH ACK isdnd[65]: PKT MEDIS recv 44 TCP 193.141.96.36:513 -> 193.141.96.1:1023 SYN ACK Regards, Chris diff -rbBc i4b-00.83/driver/i4b_ipr.c i4b/driver/i4b_ipr.c *** i4b-00.83/driver/i4b_ipr.c Thu Jul 22 20:30:15 1999 --- i4b/driver/i4b_ipr.c Sat Oct 30 19:03:29 1999 *************** *** 161,166 **** --- 161,167 ---- #define I4BIPRACCT 1 /* enable accounting messages */ #define I4BIPRACCTINTVL 2 /* accounting msg interval in secs */ #define I4BIPRADJFRXP 1 /* adjust 1st rxd packet */ + #define I4BIPRLOGFIRST 32 /* log the first 32 packets */ /* initialized by L4 */ *************** *** 194,199 **** --- 195,203 ---- #ifdef I4BIPRADJFRXP int sc_first_pkt; /* flag, first rxd packet */ #endif + #if I4BIPRLOGFIRST + int sc_log_first; /* log first n packets */ + #endif #ifdef IPR_VJ struct slcompress sc_compr; /* tcp compression data */ *************** *** 330,335 **** --- 333,341 ---- sc->sc_loutb = 0; sc->sc_fn = 1; #endif + #if I4BIPRLOGFIRST + sc->sc_log_first = I4BIPRLOGFIRST; + #endif #ifdef IPR_VJ #ifdef __FreeBSD__ *************** *** 456,461 **** --- 462,475 ---- sc->sc_state = ST_DIALING; } + #if I4BIPRLOGFIRST + if(sc->sc_log_first > 0) + { + --(sc->sc_log_first); + i4b_l4_packet_ind(BDRV_IPR, unit, 1, m ); + } + #endif + /* update access time */ microtime(&sc->sc_if.if_lastchange); *************** *** 801,806 **** --- 815,824 ---- #if I4BIPRACCT sc->sc_if.if_timer = 0; #endif + #if I4BIPRLOGFIRST + /* show next I4BIPRLOGFIRST packets again */ + sc->sc_log_first = I4BIPRLOGFIRST; + #endif i4b_l4_accounting(BDRV_IPR, cd->driver_unit, ACCT_FINAL, sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb); *************** *** 996,1001 **** --- 1014,1026 ---- #if I4BIPRACCT /* NB. do the accounting after decompression! */ sc->sc_inb += m->m_pkthdr.len; + #endif + #if I4BIPRLOGFIRST + if(sc->sc_log_first > 0) + { + --(sc->sc_log_first); + i4b_l4_packet_ind(BDRV_IPR, unit, 0, m ); + } #endif #if NBPFILTER > 0 || NBPF > 0 diff -rbBc i4b-00.83/isdnd/isdnd.h i4b/isdnd/isdnd.h *** i4b-00.83/isdnd/isdnd.h Thu May 20 15:30:36 1999 --- i4b/isdnd/isdnd.h Sat Oct 30 18:13:01 1999 *************** *** 162,168 **** LL_WRN, /* warning conditions - nonfatal abnormal conditions */ LL_DMN, /* normal but significant condition - status of daemon */ LL_CHD, /* informational - everything regarding call handling */ ! LL_DBG /* debug messages - everything which helps debugging */ }; /*---------------------------------------------------------------------------* --- 162,169 ---- LL_WRN, /* warning conditions - nonfatal abnormal conditions */ LL_DMN, /* normal but significant condition - status of daemon */ LL_CHD, /* informational - everything regarding call handling */ ! LL_DBG, /* debug messages - everything which helps debugging */ ! LL_PKT /* packet logging - log the first few packets */ }; /*---------------------------------------------------------------------------* *************** *** 689,694 **** --- 690,696 ---- void msg_l12stat_ind(msg_l12stat_ind_t *ml); void msg_teiasg_ind(msg_teiasg_ind_t *mt); void msg_proceeding_ind ( msg_proceeding_ind_t *mp ); + void msg_packet_ind( msg_packet_ind_t *mp ); const char * name_of_controller(int ctrl_type, int card_type); void next_state ( cfg_entry_t *cep, int event ); char * print_i4b_cause( cause_t code ); diff -rbBc i4b-00.83/isdnd/log.c i4b/isdnd/log.c *** i4b-00.83/isdnd/log.c Sun Feb 14 10:44:56 1999 --- i4b/isdnd/log.c Sat Oct 30 18:13:57 1999 *************** *** 67,73 **** {"WRN", LOG_WARNING}, /* warning conditions, nonfatal */ {"DMN", LOG_NOTICE}, /* normal but significant condition, daemon*/ {"CHD", LOG_INFO}, /* informational, call handling */ ! {"DBG", LOG_DEBUG} /* debug messages */ }; /*---------------------------------------------------------------------------* --- 67,74 ---- {"WRN", LOG_WARNING}, /* warning conditions, nonfatal */ {"DMN", LOG_NOTICE}, /* normal but significant condition, daemon*/ {"CHD", LOG_INFO}, /* informational, call handling */ ! {"DBG", LOG_DEBUG}, /* debug messages */ ! {"PKT", LOG_INFO} /* packet logging */ }; /*---------------------------------------------------------------------------* diff -rbBc i4b-00.83/isdnd/main.c i4b/isdnd/main.c *** i4b-00.83/isdnd/main.c Fri Jul 30 08:51:13 1999 --- i4b/isdnd/main.c Sat Oct 30 18:14:55 1999 *************** *** 637,642 **** --- 637,646 ---- msg_dialoutnumber((msg_dialoutnumber_ind_t *)msg_rd_buf); break; + case MSG_PACKET_IND: + msg_packet_ind((msg_packet_ind_t *)msg_rd_buf); + break; + default: log(LL_WRN, "ERROR, unknown message received from /dev/isdn (0x%x)", msg_rd_buf[0]); break; diff -rbBc i4b-00.83/isdnd/msghdl.c i4b/isdnd/msghdl.c *** i4b-00.83/isdnd/msghdl.c Mon Jul 26 13:58:46 1999 --- i4b/isdnd/msghdl.c Sat Oct 30 18:39:35 1999 *************** *** 34,39 **** --- 34,50 ---- *---------------------------------------------------------------------------*/ #include "isdnd.h" + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include /*---------------------------------------------------------------------------* * handle incoming CONNECT_IND (=SETUP) message *************** *** 846,851 **** --- 857,957 ---- DBGL(DL_DRVR, (log(LL_DBG, "msg_idle_timeout_ind: idletimeout, kernel sent disconnect!"))); check_and_kill(cep); + } + + /*---------------------------------------------------------------------------* + * handle incoming MSG_PACKET_IND message + *---------------------------------------------------------------------------*/ + static char* + strapp( char* buf, const char* txt ) + { + while( *txt ) *buf++ = *txt++; + *buf = '\0'; + return buf; + } + + static char* + ipapp( char* buf, unsigned long a ) + { + unsigned long ma = ntohl( a ); + + buf += sprintf( buf, "%lu.%lu.%lu.%lu", + (ma>>24)&0xFF, (ma>>16)&0xFF, (ma>>8)&0xFF, (ma)&0xFF ); + return buf; + } + + void + msg_packet_ind( msg_packet_ind_t *mp) + { + cfg_entry_t *cep; + struct ip* ip; + u_char* proto_hdr; + char tmp[ 80 ]; + char* cptr = tmp; + char* name = "???"; + int i; + + for(i=0; i < nentries; i++) + { + cep = &cfg_entry_tab[i]; /* ptr to config entry */ + + if( cep->usrdevicename == mp->driver && + cep->usrdeviceunit == mp->driver_unit ) + { + name = cep->name; + break; + } + } + + ip = (struct ip*)mp->pktdata; + proto_hdr = mp->pktdata + ((ip->ip_hl)<<2); + + if( ip->ip_p == IPPROTO_TCP ) + { + struct tcphdr* tcp = (struct tcphdr*)proto_hdr; + + cptr = strapp( cptr, "TCP " ); + cptr = ipapp( cptr, ip->ip_src.s_addr ); + cptr += sprintf( cptr, ":%u -> ", ntohs( tcp->th_sport ) ); + cptr = ipapp( cptr, ip->ip_dst.s_addr ); + cptr += sprintf( cptr, ":%u", ntohs( tcp->th_dport ) ); + + if(tcp->th_flags & TH_FIN) cptr = strapp( cptr, " FIN" ); + if(tcp->th_flags & TH_SYN) cptr = strapp( cptr, " SYN" ); + if(tcp->th_flags & TH_RST) cptr = strapp( cptr, " RST" ); + if(tcp->th_flags & TH_PUSH) cptr = strapp( cptr, " PUSH" ); + if(tcp->th_flags & TH_ACK) cptr = strapp( cptr, " ACK" ); + if(tcp->th_flags & TH_URG) cptr = strapp( cptr, " URG" ); + } + else if( ip->ip_p == IPPROTO_UDP ) + { + struct udphdr* udp = (struct udphdr*)proto_hdr; + + cptr = strapp( cptr, "UDP " ); + cptr = ipapp( cptr, ip->ip_src.s_addr ); + cptr += sprintf( cptr, ":%u -> ", ntohs( udp->uh_sport ) ); + cptr = ipapp( cptr, ip->ip_dst.s_addr ); + cptr += sprintf( cptr, ":%u", ntohs( udp->uh_dport ) ); + } + else if( ip->ip_p == IPPROTO_ICMP ) + { + struct icmp* icmp = (struct icmp*)proto_hdr; + + cptr += sprintf( cptr, "ICMP:%u.%u", icmp->icmp_type, icmp->icmp_code); + cptr = ipapp( cptr, ip->ip_src.s_addr ); + cptr = strapp( cptr, " -> " ); + cptr = ipapp( cptr, ip->ip_dst.s_addr ); + } + else + { + cptr += sprintf( cptr, "PROTO=%u ", ip->ip_p); + cptr = ipapp( cptr, ip->ip_src.s_addr); + cptr = strapp( cptr, " -> " ); + cptr = ipapp( cptr, ip->ip_dst.s_addr); + } + + log( LL_PKT, "%s %s %u %s", + name, mp->direction?"send":"recv", ntohs( ip->ip_len ), tmp ); } /*---------------------------------------------------------------------------* diff -rbBc i4b-00.83/layer4/i4b_l4.c i4b/layer4/i4b_l4.c *** i4b-00.83/layer4/i4b_l4.c Thu Apr 8 18:37:56 1999 --- i4b/layer4/i4b_l4.c Sat Oct 30 18:22:00 1999 *************** *** 554,559 **** --- 554,584 ---- } /*---------------------------------------------------------------------------* + * send MSG_PACKET_IND message to userland + *---------------------------------------------------------------------------*/ + void + i4b_l4_packet_ind(int driver, int driver_unit, int dir, struct mbuf *pkt) + { + struct mbuf *m; + int len = pkt->m_pkthdr.len; + unsigned char* ip = pkt->m_data; + + if((m = i4b_Dgetmbuf(sizeof(msg_packet_ind_t))) != NULL) + { + msg_packet_ind_t *mp = (msg_packet_ind_t *)m->m_data; + + mp->header.type = MSG_PACKET_IND; + mp->header.cdid = -1; + mp->driver = driver; + mp->driver_unit = driver_unit; + mp->direction = dir; + memcpy( mp->pktdata, ip, len