Sponsored Content
Operating Systems Solaris Getting interface names using code Post 302213732 by jlliagre on Thursday 10th of July 2008 08:24:33 PM
Old 07-10-2008
Mine's smaller Smilie

Code:
cc -lkstat  -o knet knet.c

Code:
#include <kstat.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv) {
  kstat_ctl_t *kc;
  kstat_t *ksp;
  kc=kstat_open();
  for(ksp=kc->kc_chain; ksp != NULL; ksp=ksp->ks_next) {
    if((strcmp(ksp->ks_class, "net")==0) && (strcmp(ksp->ks_module, "link")==0)) {
      printf("%s\n", ksp->ks_name);
    }
  }
  kstat_close(kc);
}

 

9 More Discussions You Might Find Interesting

1. Programming

How to modify this c code to get full GUI interface for Unix Linux ?

Hi, the following code comes from Unix Linux dialog utility project. Unfortunately, this project is no more actively maintained. Unix Linux dialog utility is made of widget boxes. One of them is mixedgauge.c In the following example I would like to get rid of flickering when run in... (0 Replies)
Discussion started by: jack2
0 Replies

2. Shell Programming and Scripting

Shell Script to display function names (called & defined) in a C++ Source Code

Hello to all, I am looking for a way to display only the names of function (calls & definition) of a C++ source code.There is already a post related to this, but the script is to find the functions using a specific variable, and the replies are not that convincing since they cannot be used for... (2 Replies)
Discussion started by: frozensmilz
2 Replies

3. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

4. Solaris

Command line Interface or GUI Interface not shown on solaris

Dear all, I am a newbie in solaris and I need your advice. I have a Solaris version 5.9 installed on Sunfire V240. I am able to ssh the machine from putty remotely. My problem is that I cannot see the display from KVM switch I have connected to it. I need also to be able to see the GUI... (2 Replies)
Discussion started by: mbouster
2 Replies

5. SCO

Change SCO - GUI or Desktop interface to DOS based interface

Hi all I have installed a demo version of SCO OpenServer 5.0.2, I finally found it is Desktop Interface, I would like to know how to change its interface to dos based interface? If you have any ideas, please tell me then. Thank you (2 Replies)
Discussion started by: TinhNhi
2 Replies

6. IP Networking

Need a bridge from an ethernet interface to a serial interface

This is my situation DOS pc serial cable (sl0) Linux Pc eth1 192.168.0.10 <-------------------->192.168.0.2 <------------>192.168.0.1 (router) I connected the linux pc and the dos pc with a SLIP (serial line internet protocol), so they can communicate in the sl0 interface. ... (3 Replies)
Discussion started by: mghis
3 Replies

7. UNIX for Dummies Questions & Answers

Adding a network interface to a bonded interface

I have a RHEL 5 system with a bonded interface configure using only one network port (eth0). So I have config file for ifcfg-bond0 and ifcfg-eth. I'd like to configure eth5 to be the second SLAVE in the bond. My question is, after I modify ifcfg-eth5, can I add eth5 to the bond0 interface without... (1 Reply)
Discussion started by: westmoreland
1 Replies

8. Solaris

Haed code nxge0 nic interface with full duplex & 1000mbps

Hi All I would need to do hard code of nxge0 nic to full duplex & 1000mbps. So that whenever solaris server come up after reboot. it will show full duplex & 1000mbps setting only. Please also let me know how to do it online through command. regards (0 Replies)
Discussion started by: amity
0 Replies

9. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies
ks_snapshot(9E) 						Driver Entry Points						   ks_snapshot(9E)

NAME
ks_snapshot - take a snapshot of kstat data SYNOPSIS
#include <sys/types.h> #include <sys/kstat.h> #include <sys/ddi.h> #include <sys/sunddi.h> int prefix_ks_snapshot(kstat_t *ksp, void *buf, int rw); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI). PARAMETERS
ksp Pointer to a kstat(9S) structure. buf Pointer to a buffer to copy the snapshot into. rw Read/Write flag. Possible values are: KSTAT_READ Copy driver statistics from the driver to the buffer. KSTAT_WRITE Copy statistics from the buffer to the driver. DESCRIPTION
The kstat mechanism allows for an optional ks_snapshot() function to copy kstat data. This is the routine that is called to marshall the kstat data to be copied to user-land. A driver can opt to use a custom snapshot routine rather than the default snapshot routine; to take advantage of this feature, set the ks_snapshot field before calling kstat_install(9F). The ks_snapshot() function must have the following structure: static int xx_kstat_snapshot(kstat_t *ksp, void *buf, int rw) { if (rw == KSTAT_WRITE) { /* set the native stats to the values in buf */ /* return EACCES if you don't support this */ } else { /* copy the kstat-specific data into buf */ } return(0); } In general, the ks_snapshot() routine might need to refer to provider-private data; for example, it might need a pointer to the provider's raw statistics. The ks_private field is available for this purpose. Its use is entirely at the provider's discretion. No kstat locking should be done inside the ks_update() routine. The caller will already be holding the kstat's ks_lock (to ensure consis- tent data) and will prevent the kstat from being removed. 1. ks_snaptime must be set (via gethrtime(9F)) to timestamp the data. 2. Data gets copied from the kstat to the buffer on KSTAT_READ, and from the buffer to the kstat on KSTAT_WRITE. RETURN VALUES
0 Success EACCES If KSTAT_WRITE is not allowed EIO For any other error CONTEXT
This function is called from user context only. EXAMPLES
Example 1 Named kstats with Long Strings (KSTAT_DATA_STRING) static int xxx_kstat_snapshot(kstat_t *ksp, void *buf, int rw) { if (rw == KSTAT_WRITE) { return (EACCES); } else { kstat_named_t *knp = buf; char *end = knp + ksp->ks_ndata; uint_t i; bcopy(ksp->ks_data, buf, sizeof (kstat_named_t) * ksp->ks_ndata); /* * Now copy the strings to the end of the buffer, and * update the pointers appropriately. */ for (i = 0; i < ksp->ks_ndata; i++, knp++) if (knp->data_type == KSTAT_DATA_STRING && KSTAT_NAMED_STR_PTR(knp) != NULL) { bcopy(KSTAT_NAMED_STR_PTR(knp), end, KSTAT_NAMED_STR_BUFLEN(knp)); KSTAT_NAMED_STR_PTR(knp) = end; end += KSTAT_NAMED_STR_BUFLEN(knp); } } return(0); } SEE ALSO
ks_update(9E), kstat_create(9F), kstat_install(9F), kstat(9S) Writing Device Drivers SunOS 5.11 4 Dec 2002 ks_snapshot(9E)
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy