|
|
39bd546 |
--- net-tools-1.60/netstat.c.sctp-addrs 2008-06-18 14:41:29.000000000 +0200
|
|
|
39bd546 |
+++ net-tools-1.60/netstat.c 2008-06-18 14:12:03.000000000 +0200
|
|
|
39bd546 |
@@ -1299,23 +1299,21 @@ static void sctp_eps_do_one(int lnr, cha
|
|
|
39bd546 |
const char *lport_str;
|
|
|
39bd546 |
const char *uid_str;
|
|
|
39bd546 |
const char *inode_str;
|
|
|
39bd546 |
- const char *pladdr_str;
|
|
|
39bd546 |
char *laddrs_str;
|
|
|
39bd546 |
|
|
|
39bd546 |
if(lnr == 0) {
|
|
|
39bd546 |
- /* ENDPT SOCK STY SST HBKT LPORT uid inode pladdr LADDRS*/
|
|
|
39bd546 |
+ /* ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS */
|
|
|
39bd546 |
return;
|
|
|
39bd546 |
}
|
|
|
39bd546 |
|
|
|
39bd546 |
- strtok(line," \t\n"); /*skip ptr*/
|
|
|
39bd546 |
- strtok(0," \t\n"); /*skip ptr*/
|
|
|
39bd546 |
+ strtok(line," \t\n"); /*skip endpt*/
|
|
|
39bd546 |
+ strtok(0," \t\n"); /*skip sock*/
|
|
|
39bd546 |
sty_str = strtok(0," \t\n");
|
|
|
39bd546 |
sst_str = strtok(0," \t\n");
|
|
|
39bd546 |
strtok(0," \t\n"); /*skip hash bucket*/
|
|
|
39bd546 |
lport_str=strtok(0," \t\n");
|
|
|
39bd546 |
uid_str = strtok(0," \t\n");
|
|
|
39bd546 |
inode_str = strtok(0," \t\n");
|
|
|
39bd546 |
- pladdr_str = strtok(0," \t\n");
|
|
|
39bd546 |
laddrs_str=strtok(0,"\t\n");
|
|
|
39bd546 |
|
|
|
39bd546 |
type = atoi(sty_str);
|
|
|
39bd546 |
@@ -1323,61 +1321,35 @@ static void sctp_eps_do_one(int lnr, cha
|
|
|
39bd546 |
port = atoi(lport_str);
|
|
|
39bd546 |
uid = atoi(uid_str);
|
|
|
39bd546 |
inode = strtoul(inode_str,0,0);
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- if(flag_sctp<=1) {
|
|
|
39bd546 |
- /* only print the primary address */
|
|
|
39bd546 |
- char local_addr[64];
|
|
|
39bd546 |
- char local_port[16];
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(local_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &localaddr, flag_not),
|
|
|
39bd546 |
- sizeof(local_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(port), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- printf("sctp ");
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
- printf("%-47s", buffer);
|
|
|
39bd546 |
- printf(" %-12s", sctp_socket_state_str(state));
|
|
|
39bd546 |
- } else {
|
|
|
39bd546 |
- /*print all addresses*/
|
|
|
39bd546 |
- const char *this_local_addr;
|
|
|
39bd546 |
- int first=1;
|
|
|
39bd546 |
- char local_port[16];
|
|
|
39bd546 |
- snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(port), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
- for(this_local_addr=strtok(laddrs_str," \t\n");
|
|
|
39bd546 |
- this_local_addr;
|
|
|
39bd546 |
- this_local_addr=strtok(0," \t\n"))
|
|
|
39bd546 |
- {
|
|
|
39bd546 |
- char local_addr[64];
|
|
|
39bd546 |
- ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(local_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &localaddr, flag_not),
|
|
|
39bd546 |
- sizeof(local_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
|
|
|
39bd546 |
- if(!first) printf("\n");
|
|
|
39bd546 |
- if(first)
|
|
|
39bd546 |
- printf("sctp ");
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- printf(" ");
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
- printf("%-47s", buffer);
|
|
|
39bd546 |
- printf(" %-12s", first?sctp_socket_state_str(state):"");
|
|
|
39bd546 |
- first = 0;
|
|
|
39bd546 |
- }
|
|
|
39bd546 |
+ const char *this_local_addr;
|
|
|
39bd546 |
+ int first=1;
|
|
|
39bd546 |
+ char local_port[16];
|
|
|
39bd546 |
+ snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
+ get_sname(htons(port), "sctp", flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
+ for(this_local_addr=strtok(laddrs_str," \t\n");
|
|
|
39bd546 |
+ this_local_addr;
|
|
|
39bd546 |
+ this_local_addr=strtok(0," \t\n"))
|
|
|
39bd546 |
+ {
|
|
|
39bd546 |
+ char local_addr[64];
|
|
|
39bd546 |
+ ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
+ if(ap)
|
|
|
39bd546 |
+ safe_strncpy(local_addr,
|
|
|
39bd546 |
+ ap->sprint((struct sockaddr *) &localaddr, flag_not),
|
|
|
39bd546 |
+ sizeof(local_addr));
|
|
|
39bd546 |
+ else
|
|
|
39bd546 |
+ sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ if(!first) printf("\n");
|
|
|
39bd546 |
+ if(first)
|
|
|
39bd546 |
+ printf("sctp ");
|
|
|
39bd546 |
+ else
|
|
|
39bd546 |
+ printf(" ");
|
|
|
39bd546 |
+ sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
+ printf("%-55s", buffer);
|
|
|
39bd546 |
+ printf(" %-12s", first?sctp_socket_state_str(state):"");
|
|
|
39bd546 |
+ first = 0;
|
|
|
39bd546 |
}
|
|
|
39bd546 |
-
|
|
|
39bd546 |
finish_this_one(uid,inode,"");
|
|
|
39bd546 |
}
|
|
|
39bd546 |
|
|
|
39bd546 |
@@ -1403,32 +1375,29 @@ static void sctp_assoc_do_one(int lnr, c
|
|
|
39bd546 |
const char *lport_str,*rport_str;
|
|
|
39bd546 |
const char *uid_str;
|
|
|
39bd546 |
const char *inode_str;
|
|
|
39bd546 |
- const char *pladdr_str;
|
|
|
39bd546 |
char *laddrs_str;
|
|
|
39bd546 |
- const char *praddr_str;
|
|
|
39bd546 |
char *raddrs_str;
|
|
|
39bd546 |
-
|
|
|
39bd546 |
+
|
|
|
39bd546 |
if(lnr == 0) {
|
|
|
39bd546 |
- /* ASSOC SOCK STY SST ST HBKT tx_queue rx_queue uid inode LPORT RPORT pladdr praddr LADDRS <-> RADDRS*/
|
|
|
39bd546 |
+ /* ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS */
|
|
|
39bd546 |
return;
|
|
|
39bd546 |
}
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- strtok(line," \t\n"); /*skip ptr*/
|
|
|
39bd546 |
- strtok(0," \t\n"); /*skip ptr*/
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ strtok(line," \t\n"); /*skip assoc*/
|
|
|
39bd546 |
+ strtok(0," \t\n"); /*skip sock*/
|
|
|
39bd546 |
sty_str = strtok(0," \t\n");
|
|
|
39bd546 |
sst_str = strtok(0," \t\n");
|
|
|
39bd546 |
st_str = strtok(0," \t\n");
|
|
|
39bd546 |
strtok(0," \t\n"); /*skip hash bucket*/
|
|
|
39bd546 |
+ strtok(0," \t\n"); /*skip hash assoc-id*/
|
|
|
39bd546 |
txqueue_str = strtok(0," \t\n");
|
|
|
39bd546 |
rxqueue_str = strtok(0," \t\n");
|
|
|
39bd546 |
uid_str = strtok(0," \t\n");
|
|
|
39bd546 |
inode_str = strtok(0," \t\n");
|
|
|
39bd546 |
lport_str=strtok(0," \t\n");
|
|
|
39bd546 |
rport_str=strtok(0," \t\n");
|
|
|
39bd546 |
- pladdr_str = strtok(0," \t\n");
|
|
|
39bd546 |
- praddr_str = strtok(0," \t\n");
|
|
|
39bd546 |
- laddrs_str=strtok(0,"<->\t\n");
|
|
|
39bd546 |
- raddrs_str=strtok(0,"<->\t\n");
|
|
|
39bd546 |
+ laddrs_str = strtok(0,"<->\t\n");
|
|
|
39bd546 |
+ raddrs_str = strtok(0,"<->\t\n");
|
|
|
39bd546 |
|
|
|
39bd546 |
type = atoi(sty_str);
|
|
|
39bd546 |
state = atoi(sst_str);
|
|
|
39bd546 |
@@ -1439,116 +1408,81 @@ static void sctp_assoc_do_one(int lnr, c
|
|
|
39bd546 |
inode = strtoul(inode_str,0,0);
|
|
|
39bd546 |
lport = atoi(lport_str);
|
|
|
39bd546 |
rport = atoi(rport_str);
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- if(flag_sctp<=1) {
|
|
|
39bd546 |
- /* only print the primary addresses */
|
|
|
39bd546 |
- char local_addr[64];
|
|
|
39bd546 |
- char local_port[16];
|
|
|
39bd546 |
- char remote_addr[64];
|
|
|
39bd546 |
- char remote_port[16];
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- ap = process_sctp_addr_str(pladdr_str, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(local_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &localaddr, flag_not),
|
|
|
39bd546 |
- sizeof(local_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(lport), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- ap = process_sctp_addr_str(praddr_str, (struct sockaddr*)&remoteaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(remote_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &remoteaddr, flag_not),
|
|
|
39bd546 |
- sizeof(remote_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family);
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- snprintf(remote_port, sizeof(remote_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(rport), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- printf("sctp");
|
|
|
39bd546 |
- printf(" %6u %6u ", rxqueue, txqueue);
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
- printf("%-23s", buffer);
|
|
|
39bd546 |
- printf(" ");
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", remote_addr, remote_port);
|
|
|
39bd546 |
- printf("%-23s", buffer);
|
|
|
39bd546 |
- printf(" %-12s", sctp_socket_state_str(state));
|
|
|
39bd546 |
- } else {
|
|
|
39bd546 |
- /*print all addresses*/
|
|
|
39bd546 |
- const char *this_local_addr;
|
|
|
39bd546 |
- const char *this_remote_addr;
|
|
|
39bd546 |
- char *ss1,*ss2;
|
|
|
39bd546 |
- int first=1;
|
|
|
39bd546 |
- char local_port[16];
|
|
|
39bd546 |
- char remote_port[16];
|
|
|
39bd546 |
- snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(lport), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
- snprintf(remote_port, sizeof(remote_port), "%s",
|
|
|
39bd546 |
- get_sname(htons(rport), "sctp",
|
|
|
39bd546 |
- flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- this_local_addr=strtok_r(laddrs_str," \t\n",&ss1;;
|
|
|
39bd546 |
- this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2;;
|
|
|
39bd546 |
- while(this_local_addr || this_remote_addr) {
|
|
|
39bd546 |
- char local_addr[64];
|
|
|
39bd546 |
- char remote_addr[64];
|
|
|
39bd546 |
- if(this_local_addr) {
|
|
|
39bd546 |
- ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(local_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &localaddr, flag_not),
|
|
|
39bd546 |
- sizeof(local_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
- }
|
|
|
39bd546 |
- if(this_remote_addr) {
|
|
|
39bd546 |
- ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr);
|
|
|
39bd546 |
- if(ap)
|
|
|
39bd546 |
- safe_strncpy(remote_addr,
|
|
|
39bd546 |
- ap->sprint((struct sockaddr *) &remoteaddr, flag_not),
|
|
|
39bd546 |
- sizeof(remote_addr));
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family);
|
|
|
39bd546 |
- }
|
|
|
39bd546 |
|
|
|
39bd546 |
- if(!first) printf("\n");
|
|
|
39bd546 |
- if(first)
|
|
|
39bd546 |
- printf("sctp %6u %6u ", rxqueue, txqueue);
|
|
|
39bd546 |
- else
|
|
|
39bd546 |
- printf(" ");
|
|
|
39bd546 |
- if(this_local_addr) {
|
|
|
39bd546 |
- if(first)
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
+ /*print all addresses*/
|
|
|
39bd546 |
+ const char *this_local_addr;
|
|
|
39bd546 |
+ const char *this_remote_addr;
|
|
|
39bd546 |
+ char *ss1,*ss2;
|
|
|
39bd546 |
+ int first=1;
|
|
|
39bd546 |
+ char local_port[16];
|
|
|
39bd546 |
+ char remote_port[16];
|
|
|
39bd546 |
+ snprintf(local_port, sizeof(local_port), "%s",
|
|
|
39bd546 |
+ get_sname(htons(lport), "sctp",
|
|
|
39bd546 |
+ flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
+ snprintf(remote_port, sizeof(remote_port), "%s",
|
|
|
39bd546 |
+ get_sname(htons(rport), "sctp",
|
|
|
39bd546 |
+ flag_not & FLAG_NUM_PORT));
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ this_local_addr=strtok_r(laddrs_str," \t\n",&ss1;;
|
|
|
39bd546 |
+ this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2;;
|
|
|
39bd546 |
+ while(this_local_addr || this_remote_addr) {
|
|
|
39bd546 |
+ char local_addr[64];
|
|
|
39bd546 |
+ char remote_addr[64];
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ if(this_local_addr) {
|
|
|
39bd546 |
+ if (this_local_addr[0] == '*') {
|
|
|
39bd546 |
+ /* skip * */
|
|
|
39bd546 |
+ this_local_addr++;
|
|
|
39bd546 |
+ }
|
|
|
39bd546 |
+ ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr);
|
|
|
39bd546 |
+ if(ap)
|
|
|
39bd546 |
+ safe_strncpy(local_addr,
|
|
|
39bd546 |
+ ap->sprint((struct sockaddr *) &localaddr, flag_not), sizeof(local_addr));
|
|
|
39bd546 |
else
|
|
|
39bd546 |
- sprintf(buffer,"%s", local_addr);
|
|
|
39bd546 |
- printf("%-23s", buffer);
|
|
|
39bd546 |
- } else
|
|
|
39bd546 |
- printf("%-23s", "");
|
|
|
39bd546 |
- printf(" ");
|
|
|
39bd546 |
- if(this_remote_addr) {
|
|
|
39bd546 |
- if(first)
|
|
|
39bd546 |
- sprintf(buffer,"%s:%s", remote_addr, remote_port);
|
|
|
39bd546 |
+ sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family);
|
|
|
39bd546 |
+ }
|
|
|
39bd546 |
+ if(this_remote_addr) {
|
|
|
39bd546 |
+ if (this_remote_addr[0] == '*') {
|
|
|
39bd546 |
+ /* skip * */
|
|
|
39bd546 |
+ this_remote_addr++;
|
|
|
39bd546 |
+ }
|
|
|
39bd546 |
+ ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr);
|
|
|
39bd546 |
+ if(ap)
|
|
|
39bd546 |
+ safe_strncpy(remote_addr,
|
|
|
39bd546 |
+ ap->sprint((struct sockaddr *) &remoteaddr, flag_not), sizeof(remote_addr));
|
|
|
39bd546 |
else
|
|
|
39bd546 |
- sprintf(buffer,"%s", remote_addr);
|
|
|
39bd546 |
- printf("%-23s", buffer);
|
|
|
39bd546 |
- } else
|
|
|
39bd546 |
- printf("%-23s", "");
|
|
|
39bd546 |
-
|
|
|
39bd546 |
- printf(" %-12s", first?sctp_socket_state_str(state):"");
|
|
|
39bd546 |
+ sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family);
|
|
|
39bd546 |
+ }
|
|
|
39bd546 |
|
|
|
39bd546 |
- first = 0;
|
|
|
39bd546 |
- this_local_addr=strtok_r(0," \t\n",&ss1;;
|
|
|
39bd546 |
- this_remote_addr=strtok_r(0," \t\n",&ss2;;
|
|
|
39bd546 |
- }
|
|
|
39bd546 |
+ if(!first) printf("\n");
|
|
|
39bd546 |
+ if(first)
|
|
|
39bd546 |
+ printf("sctp %6u %6u ", rxqueue, txqueue);
|
|
|
39bd546 |
+ else
|
|
|
39bd546 |
+ printf(" ");
|
|
|
39bd546 |
+ if(this_local_addr) {
|
|
|
39bd546 |
+ if(first)
|
|
|
39bd546 |
+ sprintf(buffer,"%s:%s", local_addr, local_port);
|
|
|
39bd546 |
+ else
|
|
|
39bd546 |
+ sprintf(buffer,"%s", local_addr);
|
|
|
39bd546 |
+ printf("%-27s", buffer);
|
|
|
39bd546 |
+ } else
|
|
|
39bd546 |
+ printf("%-27s", "");
|
|
|
39bd546 |
+ printf(" ");
|
|
|
39bd546 |
+ if(this_remote_addr) {
|
|
|
39bd546 |
+ if(first)
|
|
|
39bd546 |
+ sprintf(buffer,"%s:%s", remote_addr, remote_port);
|
|
|
39bd546 |
+ else
|
|
|
39bd546 |
+ sprintf(buffer,"%s", remote_addr);
|
|
|
39bd546 |
+ printf("%-27s", buffer);
|
|
|
39bd546 |
+ } else
|
|
|
39bd546 |
+ printf("%-27s", "");
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ printf(" %-12s", first?sctp_socket_state_str(state):"");
|
|
|
39bd546 |
+
|
|
|
39bd546 |
+ first = 0;
|
|
|
39bd546 |
+ this_local_addr=strtok_r(0," \t\n",&ss1;;
|
|
|
39bd546 |
+ this_remote_addr=strtok_r(0," \t\n",&ss2;;
|
|
|
39bd546 |
}
|
|
|
39bd546 |
-
|
|
|
39bd546 |
finish_this_one(uid,inode,"");
|
|
|
39bd546 |
}
|
|
|
39bd546 |
|