The Management API What it is (and isn’t) Defining variables Accessing “singleton” variables Accessing Table variables.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Pointers.
Dynamic Allocation and Linked Lists. Dynamic memory allocation in C C uses the functions malloc() and free() to implement dynamic allocation. malloc is.
Linked Lists.
Algorithms and data structures Protected by
Computer Programming for Engineering Applications ECE 175 Intro to Programming.
SEE C GO Provisional Title. Syntax Types int, float, double, char, void Identifiers foo Operators + - * / ^ Delimiters ; {} () “” ‘’ Keywords return,
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
Processing Data in Collections Chapter Object Wrappers Collections can only hold objects. Primitive types ( int, double, float, etc.) are not objects.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
CS 450 Module R4. R4 Overview Due on March 11 th along with R3. R4 is a small yet critical part of the MPX system. In this module, you will add the functionality.
Unions The storage referenced by a union variable can hold data of different types subject to the restriction that at any one time, the storage holds data.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
1 ITCS 5/4145 Parallel computing, B. Wilkinson, April 11, CUDAMultiDimBlocks.ppt CUDA Grids, Blocks, and Threads These notes will introduce: One.
Hashing as a Dictionary Implementation
Arrays and ArrayLists Ananda Gunawardena. Introduction Array is a useful and powerful aggregate data structure presence in modern programming languages.
Discussion: Week 3/26. Structs: Used to hold associated data together Used to group together different types of variables under the same name struct Telephone{
Informática II Prof. Dr. Gustavo Patiño MJ
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
Introduction to Structured Query Language (SQL)
Pointers. Addresses in Memory When a variable is declared, enough memory to hold a value of that type is allocated for it at an unused memory location.
Linked Lists Chained nodes of information create what are called linked lists, with each node providing a link to the next node. A useful feature of linked.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
1.1 CAS CS 460/660 Introduction to Database Systems File Organization Slides from UC Berkeley.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
C++ for Engineers and Scientists Third Edition
Introduction to Structured Query Language (SQL)
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
1 Procedural Concept The main program coordinates calls to procedures and hands over appropriate data as parameters.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
17. ADVANCED USES OF POINTERS. Dynamic Storage Allocation Many programs require dynamic storage allocation: the ability to allocate storage as needed.
Dynamic Memory Allocation Conventional array and other data declarations An incorrect attempt to size memory dynamically Requirement for dynamic allocation.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting.
Internet Information Systems Writing to Databases and Amending Data.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
CPSC 252 Concrete Data Types Page 1 Overview of Concrete Data Types There are two kinds of data types: Simple (or atomic) – represents a single data item.
CSE 501N Fall ‘09 11: Data Structures: Stacks, Queues, and Maps Nick Leidenfrost October 6, 2009.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
ECE 103 Engineering Programming Chapter 47 Dynamic Memory Alocation Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103.
Dynamic Memory Allocation. Domain A subset of the total domain name space. A domain represents a level of the hierarchy in the Domain Name Space, and.
Dynamic memory allocation and Pointers Lecture 4.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
FTP Server API Implementing the FTP Server Registering FTP Command Callbacks Data and Control Port Close Callbacks Other Server Calls.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
CNG 140 C Programming (Lecture set 12) Spring Chapter 13 Dynamic Data Structures.
Constraints Review. What is a constraint? Unique – forbids duplicate values Referencial – Foreign key Check Constraint – sets restrictions on data added.
Visual C# 2005 Using Arrays. Visual C# Objectives Declare an array and assign values to array elements Initialize an array Use subscripts to access.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
C Tutorial - Pointers CS 537 – Introduction to Operating Systems.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Chapter 6: Using Arrays.
Chapter 12 – Data Structures
Stacks and Queues.
C Basics.
Hash Tables in C James Goerke.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
Pointers, Dynamic Data, and Reference Types
Review & Lab assignments
Programming Language C Language.
Symbol Table 薛智文 (textbook ch#2.7 and 6.5) 薛智文 96 Spring.
Pointers, Dynamic Data, and Reference Types
EECE.2160 ECE Application Programming
Presentation transcript:

The Management API What it is (and isn’t) Defining variables Accessing “singleton” variables Accessing Table variables

What it is… An API that allows you to… Create a list of all management variables such as those used in SNMP on the system Protect management variables from concurrent access by multiple threads Read and write management variables Register functions that will be called when a variable is written to Check values that are written to variables (to make sure the values are within the valid ranges)

What it’s not… An prepackaged SNMP Management station parallel to the SNMP Agent

Variables are centralized A common interface Easy access to variables –Location is transparent Easy integration with extensions –Advanced Web Server –SNMP Agent Advantages

Access Data –State –Connections –System up time –Location –Physical Address –Jobs –Statistics Netsilicon Management Interface SNMP BrowserWeb Browser NET+OS Application Overview

typedef struct { MAN_ID_TYPE id void*varPointer; intisFunction; intsize; inttype intdimensions; intnumberDimensions; MAN_SEMAPHORE *semaphores; intnumberSemaphores; void*rangeFn; void*rangeInfo manTableInfoType *tableInfo; void*callbackFn; } manVarType ; Define a variable ID Type Size Dimension Memory Range Semaphore Callback Function Table Variable Properties

String value –Unlimited length (memory constraint) char *snmpInPktsVar = “ ” char *serlNoVar = “SerialNumber” Variable Properties: id

Memory Address –Causes allocation of a new variable of the specified type –isFunction set to variable INT8 ipAddress[4] var -> type = MAN_INT8 var -> isFunction = MAN_VAR var -> dimensions = {4} var -> numberDimensions = 1 INT32 inMsgCount; var -> type = MAN_INT32 var -> isFunction = MAN_VAR var->size = sizeof (INT32) var->varPointer = malloc (size) var->size = sizeof (INT8) memSize = var->size * var->dimensions[0] var->varPointer = malloc (memSize) Variable Properties: varPointer/isFunction = 0

Function Address –Specifies function to access existing variable –Defined as manAccessFunctionType or manTableAccessFunctionType –isFunction set as MAN_FN manAccessFunctionType inMsgCountAccessFn ( ); varPointer = inMsgCountAccessFn ; isFunction = MAN_FN; inMsgCountAccessFn (var, buffer, indices, isWrite, timeout) static INT32 inMsgCount = 0; memcpy (buffer, inMsgCount, sizeof (INT32)); Variable Properties: varPointer/isFunction = MAN_FN

Define the variable size –Dependent on variable type –Automatically calculated internally when submitted –Requires manual setting for MAN_UNKNOWN INT32 inMsgCount; size = NULL struct FOO entry ; type = MAN_UNKNOWN size = sizeof (struct FOO ); size = sizeof (INT32) = 4 Variable Properties: size

Character MAN_CHAR Integer MAN_INT8 MAN_INT16 MAN_INT32 MAN_INT64 Word MAN_WORD8 MAN_WORD16 MAN_WORD32 MAN_WORD64 Float (4 bytes) (unsupported) MAN_FLOAT Double (8 bytes) (unsupported) MAN_DOUBLE Unknown (structure) MAN_UNKNOWN Octet String MAN_OCTET_STRING Table MAN_SNMP_TABLE Variable Properties: type

Number of dimensions –Maximum is 10 Coordinates for each dimension INT8 ipAddress[4] numberDimensions = 1 dimensions[] = {4} INT8 port[4][2] numberDimensions = 2 dimensions[] = {4, 2} Variable Properties: dimension

Controls access to variable –Prevents collision when accessed by multiple applications –Lock before variable is accessed –Unlock after variable is accessed Supports multiple semaphores –FIFO order when locking –LIFO order when unlocking Sem 1 Sem 2Sem 3 Sem 4Sem 5 Access Variable Variable Properties: semaphores

User defined function – MAN_ERROR_TYPE (*manTestFn) (manVarType *var, void *buffer) Validate values –Legal states Control boundary of variable –Minimum and maximum range Called when before variable is updated –Return MAN_SUCCESS to allow update Variable Properties: rangeFn

User defined function – MAN_ERROR_TYPE (*manCallbackFunctionType) (MAN_ID_TYPE *var, void *buffer, int buflen, void* fnd) Notification –variable is changed Called after variable is updated –Singleton variable –Table –Each entry in dimensional variable Supports multiple callbacks, executed in the order registered *var -> varPointer = 5; (callbackFn) (var) Variable Properties: callbackFn

Table Properties Field information Size Type typedef struct { int numberFields; int *fieldType; int *fieldSize; void *indexFn; void *indexInfo; } manTableInfoType; Index information Compare index fields Data information

tcpConnStatetcpConnLocalAddrtcpConnLocalPorttcpConnRemPort Listen (2) Established (5) Closed (1) Established (5) tcpConnRemAddr Example Variable Table

Structures are transparent to the APIs –Number of fields in each entry –List of types for each field –List of sizes for each field tcpConnState tcpConnLocalAddr tcpConnLocalPort tcpConnRemAddr tcpConnRemPort MAN_INT32 MAN_WORD8 MAN_INT32 MAN_WORD8 MAN_INT32 1 * sizeof (INT32) 4 * sizeof (WORD8) 1 * sizeof (INT32) 4 * sizeof (WORD8) 1 * sizeof (INT32) Fields fieldType fieldSize typedef struct { int numberFields; int *fieldType; int *fieldSize; void *indexFn; void *indexInfo; } manTableInfoType; fieldType fieldSize Table Properties: fieldType/fieldSize

User defined function used to locate entry in table Current row is compared with index passed by application Return results –-1 if index of entry is less than index in current row – 0 if index of entry is equal to index in current row – 1 if index of entry is greater than index in current row int ( *manIndexFunctionType ) ( void *index, void *row, void *indexInfo ) { tcpConnTableIndexTyp e *index = indexInfo; tcpConnTableType *currentRow = (tcpConnTableType*) row; value = memcmp (currentRow->tcpConnLocalPort, index->tcpConnLocalPort, 4) return (value); } Table Properties: indexFn

Register a list of variables Access variable property Retrieve a variable value Update a variable value Add callback routine Register change function Un-register variable list Access a table Management API Capabilities

MAN_ERROR_TYPE manAddVariableList (manVarType *varList, int numberVars) –Registers custom variable list to master list –Supports one or more different lists –Verifies the properties of each variable –Calculates size and allocates memory –Each variable is hashed for faster access –No duplicate variables allowed Register Variable List

MAN_ERROR_TYPE manDeleteVariableList (manVarType *varList ) –Unregisters variable list from Master list –Frees memory –Causes rehashing of table Unregister Variable List

MAN_ERROR_TYPE manGetVariableInfo ( MAN_ID_TYPE id, int *type, int *size, int *dimensions, int *numberDimensions) Access Variable Properties

MAN_ERROR_TYPE manGetWORD* (MAN_ID_TYPE id, void *buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manGetChar (MAN_ID_TYPE id, void *buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manGetOctetString (MAN_ID_TYPE id, void *buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manGetUnknown (MAN_ID_TYPE id, void *buffer, int size, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manGetINT* (MAN_ID_TYPE id, void *buffer, int *indices MAN_TIMEOUT_TYPE timeout) –Reads a value from variable memory into buffer –Index allows an entry to be accessed from dimensional variable –Double and float not supported INT32 getValue = 0; man G et INT32 (“ inMsgCount ”, &getValue, NULL, 10) totalSize = var -> size; memcpy (getValue, var -> varPointer, totalSize); Retrieve Singleton Variable

MAN_ERROR_TYPE manGetArray (MAN_ID_TYPE id, void *buffer, int size, MAN_TIMEOUT_TYPE timeout) –Not valid for MAN_OCTET_STRING and MAN_SNMP_TABLE type –Reads all entries from dimensional variable into buffer –Buffer size must be equal to or greater than dimensional INT8 getValue[4] = 0; man G et Array (“ ipAddress ”, getValue, 4, 10) totalSize = var -> size * ( var -> dimensions) memcpy (getValue, var -> varPointer, totalSize); Retrieve Dimensional Variable

MAN_ERROR_TYPE manSetWORD* (MAN_ID_TYPE id, void buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manSetChar (MAN_ID_TYPE id, void buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manSetOctetString (MAN_ID_TYPE id, void *buffer, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manSetUnknown (MAN_ID_TYPE id, void *buffer, int size, int *indices MAN_TIMEOUT_TYPE timeout) MAN_ERROR_TYPE manSetINT* (MAN_ID_TYPE id, void buffer, int *indices MAN_TIMEOUT_TYPE timeout) –Writes value from buffer into variable memory –Index allows an entry to be accessed from dimensional variable –Double and float not supported INT32 setValue = 50; man S et INT32 (“ inMsgCount ”, &setValue, NULL, 10) totalSize = var -> size; memcpy (var -> varPointer, setValue, totalSize); Update Singleton Variable

MAN_ERROR_TYPE manSetArray (MAN_ID_TYPE id, void *buffer, int size, MAN_TIMEOUT_TYPE timeout) –Not valid for MAN_OCTET_STRING_TYPE and MAN_SNMP_TABLE –Writes buffer into dimensional variable –Buffer size must equal dimensional size INT8 setValue[4] = {10,32,52,70}; man S et Array (“ ipAddress ”, setValue, 4, 10) totalSize = var -> size * ( var -> dimensions) memcpy (var -> varPointer, setValue, totalSize); Update a Dimensional Variable

MAN_ERROR_TYPE manAddVariableCallback (MAN_ID_TYPE id, int*indices, manCallbackFunctionType *fn, void *fnd) –User defined function executed when variable is updated –Routine must be defined as manCallbackFunctionType –Sets one or more callback routines per variable –Sets a callback for an entry in dimensional variable –Multiple functions are executed in the order added Add a Callback Function

MAN_ERROR_TYPE manDeleteVariableCallback (MAN_ID_TYPE id, int*indices, manCallbackFunctionType *fn, void *fnd) –Removes user defined function when variable is updated –One callback is removed if multiple set Remove a Callback Function

MAN_ERROR_TYPE manRegisterChangeFn (manVariableChangeFnType *fn) –User defined function executed when variable is accessed –Sets one routine for all variables Set Variable Change Function

MAN_ERROR_TYPE manUnregisterChangeFn (void) –Removes the user defined function executed when a variable is accessed Remove Variable Change Function

Update table entry Retrieve table entry Retrieve table entry position Delete table entry Add new table entry Access Tables

Table Index An entry requires a unique identifier Distinguish between entries Sorting and searching entries in table Defined as manTableIndexType typedef struct { int numericIndex; int wantExact; void *snmpIndex; } manTableIndexType; typedef struct { WORD8 tcpConnLocalAddr[4] INT32 tcpConnLocalPort WORD8 tcpConnRemAddr[4] INT32 tcpConnRemPort } tcpConnTableIndexType;

MAN_ERROR_TYPE manSetSnmpRow (MAN_ID_TYPE id, manTableIndexType *index, manTableIndexType *newIndex, void *buffer, MAN_TIMEOUT_TYPE timeout) –Updates entry that matches index when exact –Updates first entry greater or equal to index when not exact –Relocates entry in table if index is changed Update Table Entry

MAN_ERROR_TYPE manGetSnmpRow (MAN_ID_TYPE id, manTableIndexType *index, void *buffer, MAN_TIMEOUT_TYPE timeout) –Retrieves entry that matches index when exact –Retrieves first entry greater or equal to index when not exact Retrieve a Table Entry

MAN_ERROR_TYPE manGetSnmpRowPos (MAN_ID_TYPE id, manTableIndexType *index, int *pos, MAN_TIMEOUT_TYPE timeout) –Get position of entry that matches index when exact –Get position of first entry greater or equal to index when not exact Retrieve Table Entry Position

MAN_ERROR_TYPE manDeleteSnmpRow (MAN_ID_TYPE id, manTableIndexType *index, MAN_TIMEOUT_TYPE timeout) –Deletes entry that matches index when exact –Deletes first entry greater or equal to index when not exact –Releases memory allocated for entry Remove a Table Entry

MAN_ERROR_TYPE manInsertSnmpRow (MAN_ID_TYPE id, manTableIndexType *index, void *buffer, MAN_TIMEOUT_TYPE timeout) –Inserts before entry which matches index when exact –Inserts before first entry greater or equal to index when not exact –Allocates memory for new entry Add a Table Entry