Skip to content

GetAvailableDevicesAtSpecificEthernetInterface should return details even when NewDevice fails #55

@shaunco

Description

@shaunco

Many ONVIF devices respond to unauthenticated discovery requests with quite a bit of useful information (make, model, profiles, etc) but require authentication to list device_services or capabilities. The current GetAvailableDevicesAtSpecificEthernetInterface code calls NewDevice for each device that responded to the discovery request, but this immediately fails if the device requires auth and causes the device to not be included in the response.

The fix is to properly parse the XML response rather than just grabbing the address and calling NewDevice at:

onvif/Device.go

Lines 135 to 140 in 67386c9

if err != nil {
// TODO(jfsmig) print a warning
} else {
nvtDevicesSeen[xaddr] = true
nvtDevices = append(nvtDevices, *dev)
}

for example, this response has very useful information in the Types and Scopes:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<SOAP-ENV:Envelope
    xmlns:SOAP-ENV=\"http://www.w3.org/2003/05/soap-envelope\"
    xmlns:SOAP-ENC=\"http://www.w3.org/2003/05/soap-encoding\"
    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
    xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"
    xmlns:wsdd=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\"
    xmlns:tdn=\"http://www.onvif.org/ver10/network/wsdl\"
    xmlns:tds=\"http://www.onvif.org/ver10/device/wsdl\">
    <SOAP-ENV:Header>
        <wsa:MessageID>urn:uuid:91fc71a4-9d7d-435f-b425-430ad5eda5f6</wsa:MessageID>
        <wsa:RelatesTo>uuid:f01cfa1c-66f5-42cf-8f04-60cd7dab9a78</wsa:RelatesTo>
        <wsa:ReplyTo SOAP-ENV:mustUnderstand=\"true\">
            <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
        </wsa:ReplyTo>
        <wsa:To SOAP-ENV:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
        <wsa:Action SOAP-ENV:mustUnderstand=\"true\">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action>
        <wsdd:AppSequence InstanceId=\"1737371380\" MessageNumber=\"3406\"></wsdd:AppSequence>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <wsdd:ProbeMatches>
            <wsdd:ProbeMatch>
                <wsa:EndpointReference>
                    <wsa:Address>urn:uuid:98190dc2-0890-4ef8-ac9a-0003c5161834</wsa:Address>
                </wsa:EndpointReference>
                <wsdd:Types>tdn:NetworkVideoTransmitter tds:Device</wsdd:Types>
                <wsdd:Scopes>onvif://www.onvif.org/location/Unknown onvif://www.onvif.org/manufacturer/MOBOTIX onvif://www.onvif.org/hardware/S16D-Sec onvif://www.onvif.org/name/MOBOTIX%20S16D-Sec onvif://www.onvif.org/Profile/Streaming onvif://www.onvif.org/Profile/T onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/audio_decoder onvif://www.onvif.org/type/Network_Video_Transmitter</wsdd:Scopes>
                <wsdd:XAddrs>https://172.16.50.6:443/onvif/device_service</wsdd:XAddrs>
                <wsdd:MetadataVersion>1</wsdd:MetadataVersion>
            </wsdd:ProbeMatch>
        </wsdd:ProbeMatches>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>"

It would actually be quite useful to have a discovery method that only parses/returns the XML data without ever trying to call NewDevice

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions