NetView plug-ins


Interraction with hostlist


The functions of the work with hostlist can be divided into the following parts:

Working with hosts - adding, deleting, getting information about all or only selected by user hosts- all this possible by using of message NMPN_OBJECT. All hostnames should be in lower case. For operations with host lParam points to NVHOST sctucteure, wParam can be used with next bitmask flags:

NVOBJ_GETHOST - You should specify id field in NVHOST to the host id of the existing host to get information about it, or 0 - in this case you'll get information about 1st host in hostlist

If combine NVOBJ_GETHOST | NVOBJ_SELECTED then you'll get info about next (after id) selected by user host (or 1st selected if id==0). nextid returns id of the next host, allowing enumeration all or selected onlyhosts. Follow you can see sample code of the selected hosts enumeration passing name of every host to yourstuff(NVHOST *):

NVHOST hst;ZeroMemory(&hst,sizeof(hst));
SendMessage(plgi->nvwnd,NMPN_OBJECT,NVOBJ_SELECTED|NVOBJ_GETHOST,(DWORD)&hst);
while(hst.id)
{
yourstuff(&hst);

hst.id=hst.nextid;
if(hst.id)SendMessage(plgi->nvwnd,NMPN_OBJECT,NVOBJ_SELECTED|NVOBJ_GETHOST,(DWORD)&hst);
}

NVOBJ_SETHOST - In NVHOST you shoud specify id of the existing host or 0 to add new host to hostlist.

NVOBJ_DELHOST - Host with specified in NVHOST id will be deleted.

NVOBJ_HOSTBYTEXT - lParam points to NULL-terminated string - host's name or IP. Can be combined with NVOBJ_FORCENEW - in this case NetView will add new host, if can't find in hostlist by specified text. Returns ID of found\added host or NULL. If combine also with NVOBJ_HOSTNOIP then host will be added with empty IP without tring to determine its IP address.

 

Work with hostlists. lParam points to NVLIST structure. wParam can have the following bitmask flags:

NVOBJ_GETLIST - the same as NVOBJ_GETHOST for hosts, except that NVOBJ_SELECTED cannot be used

NVOBJ_SETLIST - same as NVOBJ_SETHOST

NVOBJ_DELLIST - delete hostlist, lParam = hostlist id

NVOBJ_LISTBYTEXT - the same as NVOBJ_HOSTBYTEXT

 

 Working with visual map\plan lines. NetView stores all lines information internally as array of structures so all access to lines is based on the lines indexes, wich can changes during NetView work.

NVOBJ_GETLINE - lParam points to NVLINE, with specified index, message returns all lines count.

NVOBJ_SETLINE - lParam points to NVLINE, with specified index (you can set index to -1 to create new line), message returns all lines count.

NVOBJ_DELLINE - lParam =index of line to be deleted

 

Working with areas - colored rectangles on Visual map/plan. The same as work with hosts and hostlists:
NVOBJ_GETAREA - lParam points to NVAREA with specified id. You can specify id=0 to get 1st area.
NVOBJ_SETAREA - lParam points to NVAREA with specified id. You can specify id=0 to create new area
NVOBJ_DELAREA - lParam = od of area to be deleted

 

Working with host's metavariables. Metavariable - is a string, associated with host and having unique within this host name. It is not recommended to store long strings in metavariables - this will cause NetView to eat much memory. The name of variable is case-sensitive. Working with they it is realized by message NMPN_METAVAR, lParam points to structure NVMETAVAR and plug-in shoud allocate enough memory to store variable string. wParam can be:

NVMETAVAR_GET - before calling set host.name or host.id (in this case specify also NVMETAVAR_USEID in wParam) and varname in NVMETAVAR. If variable does not exist will is returned empty line. If maximum length of the string unknown, it is necessary to set vallen to zero, after calling the message NetView will set vallen to necessities value. Then allocate the necessary amount to memory for structure and send the message once again. The Approximite code of this deal:

 LPNVMETAVAR mv=(LPNVMETAVAR)malloc(256);
ZeroMemory(mv,256);
mv->host.id=HostId;
strcpy(mv->varname,"abcd_myvar");
mv->vallen=0;
SendMessage(plgi->nvwnd,NMPN_METAVAR,NVMETAVAR_GET|NVMETAVAR_USEID,(DWORD)mv);
mv=(LPNVMETAVAR)realloc(mv,256+mv->vallen);
ZeroMemory(mv->val,mv->vallen+1);

SendMessage(plgi->nvwnd,NMPN_METAVAR,NVMETAVAR_GET|NVMETAVAR_USEID,(DWORD)mv);
//do something...

free(mv);

NVMETAVAR_SET - set all fields of NVMETAVAR. (NVMETAVAR_USEID also can be used with  host.id specified) Example:

LPNVMETAVAR mv=(LPNVMETAVAR)malloc(256+val.Length());
strcpy(mv->host.name,"coolhost");
strcpy(mv->varname,"abcd_myvar");
strcpy(mv->val,"my metavar string");
mv->vallen=val.Length();
SendMessage(plgi->nvwnd,NMPN_METAVAR,NVMETAVAR_SET,(DWORD)mv);
free(mv);

NetView stores all hosts information and setting in metavariables.

 

List of the main metavariables can be found  здесь

For applying changes in internal metavariables plug-in usually should call NMPN_ACTION with flag NVACTION_SETSTATE and lParam = host id.

On top


© 2001-2004 Killer{R}   © 2003 VoVaN