Click here to Skip to main content
15,893,487 members
Articles / Desktop Programming / MFC

Enhance netstat

Rate me:
Please Sign up or sign in to vote.
4.64/5 (11 votes)
16 Nov 2003 137.6K   3.8K   36  
This article shows an implementation of the main TCP/UDP functions of the IP Helper API that is used to get info about active connections including the process attached to a connection.
///////////////////////////////////////////////////////////////////////////
// ipmsp.idl : IDL source for IP specific msp interfaces
/////////////////////////////////////////////////////////////////////////////

#ifndef __IPMSP_IDL__
#define __IPMSP_IDL__

import "tapi3if.idl";
import "strmif.idl";

// The maximum length of the info string is 256 bytes inluding EOS.
const unsigned long MAX_PARTICIPANT_TYPED_INFO_LENGTH		= 256; 

const unsigned long MAX_QOS_ID_LEN = 128; 

typedef enum PARTICIPANT_TYPED_INFO
{
    PTI_CANONICALNAME,
    PTI_NAME,
    PTI_EMAILADDRESS,
    PTI_PHONENUMBER,
    PTI_LOCATION,
    PTI_TOOL,
    PTI_NOTES,
    PTI_PRIVATE

} PARTICIPANT_TYPED_INFO;

typedef enum PARTICIPANT_EVENT
{
    PE_NEW_PARTICIPANT,
    PE_INFO_CHANGE,
    PE_PARTICIPANT_LEAVE,

    PE_NEW_SUBSTREAM,
    PE_SUBSTREAM_REMOVED,

    PE_SUBSTREAM_MAPPED,
    PE_SUBSTREAM_UNMAPPED,

    PE_PARTICIPANT_TIMEOUT,
    PE_PARTICIPANT_RECOVERED,

    PE_PARTICIPANT_ACTIVE,
    PE_PARTICIPANT_INACTIVE,

    PE_LOCAL_TALKING,
    PE_LOCAL_SILENT

} PARTICIPANT_EVENT;

[
    uuid(5899b820-5a34-11d2-95a0-00a0244d2298),
    helpstring("ITParticipant Interface"),
    pointer_default(unique),
    dual
]
interface ITParticipant : IDispatch
{
    [propget, id(1), helpstring("propertry ParticipantTypedInfo")]
    HRESULT ParticipantTypedInfo(
        [in] PARTICIPANT_TYPED_INFO InfoType,
        [out, retval] BSTR * ppInfo
        );

    [propget, id(2), helpstring("the media types of the participant")]
    HRESULT MediaTypes(
        [out, retval] long * plMediaType
        );

    [propput, id(3), helpstring("enable or disable a participant")]
    HRESULT Status(
        [in] ITStream * pITStream,
        [in] VARIANT_BOOL   fEnable
        );

    [propget, id(3), helpstring("the status of the participant")]
    HRESULT Status(
        [in] ITStream * pITStream,
        [out, retval] VARIANT_BOOL * pStatus
        );

    [propget, id(4), helpstring("an ITCollection of streams that have the participant")]
    HRESULT Streams(
        [out, retval] VARIANT * pVariant
        );

    [id(6), hidden]
    HRESULT EnumerateStreams(
        [out, retval] IEnumStream ** ppEnumStream
        );
}


cpp_quote("#ifndef STREAM_INTERFACES_DEFINED")
cpp_quote("#define STREAM_INTERFACES_DEFINED")

const DWORD MAX_DESCRIPTION_LEN = 256;

typedef struct _TAPI_AUDIO_STREAM_CONFIG_CAPS
{
	WCHAR Description[MAX_DESCRIPTION_LEN];
	ULONG MinimumChannels;
	ULONG MaximumChannels;
	ULONG ChannelsGranularity;
	ULONG MinimumBitsPerSample;
	ULONG MaximumBitsPerSample;
	ULONG BitsPerSampleGranularity;
	ULONG MinimumSampleFrequency;
	ULONG MaximumSampleFrequency;
	ULONG SampleFrequencyGranularity;
    ULONG MinimumAvgBytesPerSec;
    ULONG MaximumAvgBytesPerSec;
    ULONG AvgBytesPerSecGranularity;
} TAPI_AUDIO_STREAM_CONFIG_CAPS, *PTAPI_AUDIO_STREAM_CONFIG_CAPS;

typedef struct _TAPI_VIDEO_STREAM_CONFIG_CAPS
{
	WCHAR Description[MAX_DESCRIPTION_LEN];
	ULONG VideoStandard;
	SIZE InputSize;
	SIZE MinCroppingSize;
	SIZE MaxCroppingSize;
	int CropGranularityX;
	int CropGranularityY;
	int CropAlignX;
	int CropAlignY;
	SIZE MinOutputSize;
	SIZE MaxOutputSize;
	int OutputGranularityX;
	int OutputGranularityY;
	int StretchTapsX;
	int StretchTapsY;
	int ShrinkTapsX;
	int ShrinkTapsY;
	LONGLONG MinFrameInterval;
	LONGLONG MaxFrameInterval;
	LONG MinBitsPerSecond;
	LONG MaxBitsPerSecond;
} TAPI_VIDEO_STREAM_CONFIG_CAPS, *PTAPI_VIDEO_STREAM_CONFIG_CAPS;


typedef enum tagStreamConfigCapsType
{
	AudioStreamConfigCaps,
	VideoStreamConfigCaps
} StreamConfigCapsType;

typedef struct tagTAPI_STREAM_CONFIG_CAPS
{
	StreamConfigCapsType CapsType;
	union
	{
		TAPI_VIDEO_STREAM_CONFIG_CAPS VideoCap;
		TAPI_AUDIO_STREAM_CONFIG_CAPS AudioCap;
	};
} TAPI_STREAM_CONFIG_CAPS, *PTAPI_STREAM_CONFIG_CAPS;

typedef enum tagTAPIControlFlags
{
    TAPIControl_Flags_None   = 0x0000,
    TAPIControl_Flags_Auto   = 0x0001,
    TAPIControl_Flags_Manual = 0x0002

} TAPIControlFlags;

[
    object,
    local,
    uuid(6c0ab6c1-21e3-11d3-a577-00c04f8ef6e3),
    pointer_default(unique),
    hidden
]
interface ITFormatControl : IUnknown
{
    HRESULT GetCurrentFormat(
        [out] AM_MEDIA_TYPE **ppMediaType
        );

    HRESULT ReleaseFormat (
        [in] AM_MEDIA_TYPE *pMediaType
        );

    HRESULT GetNumberOfCapabilities(
        [out] DWORD *pdwCount
        );

    HRESULT GetStreamCaps(
        [in] DWORD dwIndex, 
        [out] AM_MEDIA_TYPE **ppMediaType, 
        [out] TAPI_STREAM_CONFIG_CAPS *pStreamConfigCaps, 
        [out] BOOL *pfEnabled
        );

    HRESULT ReOrderCapabilities(
        [in] DWORD *pdwIndices, 
        [in] BOOL *pfEnabled, 
        [in] BOOL *pfPublicize, 
        [in] DWORD dwNumIndices
        );
}

typedef enum tagStreamQualityProperty
{
    StreamQuality_MaxBitrate,
    StreamQuality_CurrBitrate,         // Read-Only
    StreamQuality_MinFrameInterval,
    StreamQuality_AvgFrameInterval, // Read-Only

} StreamQualityProperty;

[
    object,
    local,
    uuid(6c0ab6c2-21e3-11d3-a577-00c04f8ef6e3),
    pointer_default(unique),
    hidden
]
interface ITStreamQualityControl : IUnknown
{
    HRESULT GetRange(
        [in] StreamQualityProperty Property, 
        [out] long *plMin, 
        [out] long *plMax, 
        [out] long *plSteppingDelta, 
        [out] long *plDefault, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Get(
        [in] StreamQualityProperty Property, 
        [out] long *plValue, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Set(
        [in] StreamQualityProperty Property, 
        [in] long lValue, 
        [in] TAPIControlFlags lFlags
        );
}

typedef enum tagCallQualityProperty
{
    CallQuality_ControlInterval,
    CallQuality_ConfBitrate,            // confmsp and read-only
    CallQuality_MaxInputBitrate,        // read only
    CallQuality_CurrInputBitrate,       // Read-Only
    CallQuality_MaxOutputBitrate,
    CallQuality_CurrOutputBitrate,      // Read-Only
    CallQuality_MaxCPULoad,
    CallQuality_CurrCPULoad             // Read-Only

} CallQualityProperty;

[
    object,
    local,
    uuid(fe1d8ae0-edc4-49b5-8f8c-4de40f9cdfaf),
    pointer_default(unique),
    hidden
]
interface ITCallQualityControl : IUnknown
{
    HRESULT GetRange(
        [in] CallQualityProperty Property, 
        [out] long *plMin, 
        [out] long *plMax, 
        [out] long *plSteppingDelta, 
        [out] long *plDefault, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Get(
        [in] CallQualityProperty Property, 
        [out] long *plValue, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Set(
        [in] CallQualityProperty Property, 
        [in] long lValue, 
        [in] TAPIControlFlags lFlags
        );
}

typedef enum tagAudioDeviceProperty
{
    AudioDevice_DuplexMode,
    AudioDevice_AutomaticGainControl,
    AudioDevice_AcousticEchoCancellation

} AudioDeviceProperty;

[
    object,
    local,
    uuid(6c0ab6c5-21e3-11d3-a577-00c04f8ef6e3),
    pointer_default(unique),
    hidden
]
interface ITAudioDeviceControl : IUnknown
{
    HRESULT GetRange(
        [in] AudioDeviceProperty Property, 
        [out] long *plMin, 
        [out] long *plMax, 
        [out] long *plSteppingDelta, 
        [out] long *plDefault, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Get(
            [in] AudioDeviceProperty Property, 
        [out] long *plValue, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Set(
        [in] AudioDeviceProperty Property, 
        [in] long lValue, 
        [in] TAPIControlFlags lFlags
        );
}

typedef enum tagAudioSettingsProperty
{
    AudioSettings_SignalLevel,    // Read-Only
    AudioSettings_SilenceThreshold,
    AudioSettings_Volume,
    AudioSettings_Balance,
    AudioSettings_Loudness,
    AudioSettings_Treble,
    AudioSettings_Bass,
    AudioSettings_Mono

} AudioSettingsProperty;

[
    object,
    local,
    uuid(6c0ab6c6-21e3-11d3-a577-00c04f8ef6e3),
    pointer_default(unique),
    hidden
]
interface ITAudioSettings  : IUnknown
{
    HRESULT GetRange(
        [in] AudioSettingsProperty Property, 
        [out] long *plMin, 
        [out] long *plMax, 
        [out] long *plSteppingDelta, 
        [out] long *plDefault, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Get(
        [in] AudioSettingsProperty Property, 
        [out] long *plValue, 
        [out] TAPIControlFlags *plFlags
        );

    HRESULT Set(
        [in] AudioSettingsProperty Property, 
        [in] long lValue, 
        [in] TAPIControlFlags lFlags
        );
}

[
    uuid(e8c89d27-a3bd-47d5-a6fc-d2ae40cdbc6e),
    helpstring("ITQOSApplicationID interface"),
    pointer_default(unique),
    dual
]
interface ITQOSApplicationID : IDispatch
{
    HRESULT SetQOSApplicationID(
        [in] BSTR pApplicationID,
        [in] BSTR pApplicationGUID,
        [in] BSTR pSubIDs
        );
}


cpp_quote("#endif // STREAM_INTERFACES_DEFINED")

cpp_quote("#ifndef RTP_MEDIATYPE_DEFINED")
cpp_quote("#define RTP_MEDIATYPE_DEFINED")
cpp_quote("struct DECLSPEC_UUID(\"14099BC0-787B-11d0-9CD3-00A0C9081C19\") MEDIATYPE_RTP_Single_Stream;")
cpp_quote("#endif //RTP_MEDIATYPE_DEFINED")

#endif // __H323_PRIVATE_IDL__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions