1#![allow(dead_code)]
8
9use std::io;
10use std::net;
11use std::net::SocketAddr;
12use std::num::ParseIntError;
13use std::string::FromUtf8Error;
14use std::time::SystemTimeError;
15use substring::Substring;
16use thiserror::Error;
17
18pub type Result<T> = std::result::Result<T, Error>;
20
21#[derive(Error, Debug, PartialEq)]
31#[non_exhaustive]
32pub enum Error {
33 #[error("buffer: full")]
35 ErrBufferFull,
36 #[error("buffer: closed")]
38 ErrBufferClosed,
39 #[error("buffer: short")]
41 ErrBufferShort,
42 #[error("packet too big")]
44 ErrPacketTooBig,
45 #[error("i/o timeout")]
47 ErrTimeout,
48 #[error("udp: listener closed")]
50 ErrClosedListener,
51 #[error("udp: listen queue exceeded")]
53 ErrListenQueueExceeded,
54 #[error("udp: listener accept ch closed")]
56 ErrClosedListenerAcceptCh,
57 #[error("obs cannot be nil")]
59 ErrObsCannotBeNil,
60 #[error("se of closed network connection")]
62 ErrUseClosedNetworkConn,
63 #[error("addr is not a net.UDPAddr")]
65 ErrAddrNotUdpAddr,
66 #[error("something went wrong with locAddr")]
68 ErrLocAddr,
69 #[error("already closed")]
71 ErrAlreadyClosed,
72 #[error("no remAddr defined")]
74 ErrNoRemAddr,
75 #[error("address already in use")]
77 ErrAddressAlreadyInUse,
78 #[error("no such UDPConn")]
80 ErrNoSuchUdpConn,
81 #[error("cannot remove unspecified IP by the specified IP")]
83 ErrCannotRemoveUnspecifiedIp,
84 #[error("no address assigned")]
86 ErrNoAddressAssigned,
87 #[error("1:1 NAT requires more than one mapping")]
89 ErrNatRequriesMapping,
90 #[error("length mismtach between mappedIPs and localIPs")]
92 ErrMismatchLengthIp,
93 #[error("non-udp translation is not supported yet")]
95 ErrNonUdpTranslationNotSupported,
96 #[error("no associated local address")]
98 ErrNoAssociatedLocalAddress,
99 #[error("no NAT binding found")]
101 ErrNoNatBindingFound,
102 #[error("has no permission")]
104 ErrHasNoPermission,
105 #[error("host name must not be empty")]
107 ErrHostnameEmpty,
108 #[error("failed to parse IP address")]
110 ErrFailedToParseIpaddr,
111 #[error("no interface is available")]
113 ErrNoInterface,
114 #[error("not found")]
116 ErrNotFound,
117 #[error("unexpected network")]
119 ErrUnexpectedNetwork,
120 #[error("can't assign requested address")]
122 ErrCantAssignRequestedAddr,
123 #[error("unknown network")]
125 ErrUnknownNetwork,
126 #[error("no router linked")]
128 ErrNoRouterLinked,
129 #[error("invalid port number")]
131 ErrInvalidPortNumber,
132 #[error("unexpected type-switch failure")]
134 ErrUnexpectedTypeSwitchFailure,
135 #[error("bind failed")]
137 ErrBindFailed,
138 #[error("end port is less than the start")]
140 ErrEndPortLessThanStart,
141 #[error("port space exhausted")]
143 ErrPortSpaceExhausted,
144 #[error("vnet is not enabled")]
146 ErrVnetDisabled,
147 #[error("invalid local IP in static_ips")]
149 ErrInvalidLocalIpInStaticIps,
150 #[error("mapped in static_ips is beyond subnet")]
152 ErrLocalIpBeyondStaticIpsSubset,
153 #[error("all static_ips must have associated local IPs")]
155 ErrLocalIpNoStaticsIpsAssociated,
156 #[error("router already started")]
158 ErrRouterAlreadyStarted,
159 #[error("router already stopped")]
161 ErrRouterAlreadyStopped,
162 #[error("static IP is beyond subnet")]
164 ErrStaticIpIsBeyondSubnet,
165 #[error("address space exhausted")]
167 ErrAddressSpaceExhausted,
168 #[error("no IP address is assigned for eth0")]
170 ErrNoIpaddrEth0,
171 #[error("Invalid mask")]
173 ErrInvalidMask,
174
175 #[error("tls handshake is in progress")]
178 HandshakeInProgress,
179 #[error("context is not supported for export_keying_material")]
181 ContextUnsupported,
182 #[error("export_keying_material can not be used with a reserved label")]
184 ReservedExportKeyingMaterial,
185 #[error("no cipher suite for export_keying_material")]
187 CipherSuiteUnset,
188 #[error("export_keying_material hash: {0}")]
190 Hash(String),
191 #[error("mutex poison: {0}")]
193 PoisonError(String),
194
195 #[error("Wrong marshal size")]
198 WrongMarshalSize,
199 #[error("Invalid total lost count")]
202 InvalidTotalLost,
203 #[error("Invalid header")]
205 InvalidHeader,
206 #[error("Empty compound packet")]
208 EmptyCompound,
209 #[error("First packet in compound must be SR or RR")]
212 BadFirstPacket,
213 #[error("Compound missing SourceDescription with CNAME")]
215 MissingCname,
216 #[error("Feedback packet seen before CNAME")]
218 PacketBeforeCname,
219 #[error("Too many reports")]
221 TooManyReports,
222 #[error("Too many chunks")]
224 TooManyChunks,
225 #[error("too many sources")]
227 TooManySources,
228 #[error("Packet too short to be read")]
230 PacketTooShort,
231 #[error("Buffer too short to be written")]
233 BufferTooShort,
234 #[error("Wrong packet type")]
236 WrongType,
237 #[error("SDES must be < 255 octets long")]
239 SdesTextTooLong,
240 #[error("SDES item missing type")]
242 SdesMissingType,
243 #[error("Reason must be < 255 octets long")]
245 ReasonTooLong,
246 #[error("Invalid packet version")]
248 BadVersion,
249 #[error("Invalid padding value")]
251 WrongPadding,
252 #[error("Wrong feedback message type")]
254 WrongFeedbackType,
255 #[error("Wrong payload type")]
257 WrongPayloadType,
258 #[error("Header length is too small")]
260 HeaderTooSmall,
261 #[error("Media SSRC must be 0")]
263 SsrcMustBeZero,
264 #[error("Missing REMB identifier")]
266 MissingRembIdentifier,
267 #[error("SSRC num and length do not match")]
269 SsrcNumAndLengthMismatch,
270 #[error("Invalid size or startIndex")]
272 InvalidSizeOrStartIndex,
273 #[error("Delta exceed limit")]
275 DeltaExceedLimit,
276 #[error("Packet status chunk must be 2 bytes")]
278 PacketStatusChunkLength,
279 #[error("Invalid bitrate")]
281 InvalidBitrate,
282 #[error("Wrong chunk type")]
284 WrongChunkType,
285 #[error("Struct contains unexpected member type")]
287 BadStructMemberType,
288 #[error("Cannot read into non-pointer")]
290 BadReadParameter,
291 #[error("Invalid block size")]
293 InvalidBlockSize,
294
295 #[error("RTP header size insufficient")]
298 ErrHeaderSizeInsufficient,
299 #[error("RTP header size insufficient for extension")]
301 ErrHeaderSizeInsufficientForExtension,
302 #[error("buffer too small")]
304 ErrBufferTooSmall,
305 #[error("extension not enabled")]
307 ErrHeaderExtensionsNotEnabled,
308 #[error("extension not found")]
310 ErrHeaderExtensionNotFound,
311
312 #[error("header extension id must be between 1 and 14 for RFC 5285 extensions")]
314 ErrRfc8285oneByteHeaderIdrange,
315 #[error("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")]
317 ErrRfc8285oneByteHeaderSize,
318
319 #[error("header extension id must be between 1 and 255 for RFC 5285 extensions")]
321 ErrRfc8285twoByteHeaderIdrange,
322 #[error("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")]
324 ErrRfc8285twoByteHeaderSize,
325
326 #[error("header extension id must be 0 for none RFC 5285 extensions")]
328 ErrRfc3550headerIdrange,
329
330 #[error("packet is not large enough")]
332 ErrShortPacket,
333 #[error("invalid nil packet")]
335 ErrNilPacket,
336 #[error("too many PDiff")]
338 ErrTooManyPDiff,
339 #[error("too many spatial layers")]
341 ErrTooManySpatialLayers,
342 #[error("NALU Type is unhandled")]
344 ErrUnhandledNaluType,
345
346 #[error("corrupted h265 packet")]
348 ErrH265CorruptedPacket,
349 #[error("invalid h265 packet type")]
351 ErrInvalidH265PacketType,
352
353 #[error("payload is too small for OBU extension header")]
355 ErrPayloadTooSmallForObuExtensionHeader,
356 #[error("payload is too small for OBU payload size")]
358 ErrPayloadTooSmallForObuPayloadSize,
359
360 #[error("extension_payload must be in 32-bit words")]
362 HeaderExtensionPayloadNot32BitWords,
363 #[error("audio level overflow")]
365 AudioLevelOverflow,
366 #[error("playout delay overflow")]
368 PlayoutDelayOverflow,
369 #[error("payload is not large enough")]
371 PayloadIsNotLargeEnough,
372 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
374 StapASizeLargerThanBuffer(usize, usize),
375 #[error("nalu type {0} is currently not handled")]
377 NaluTypeIsNotHandled(u8),
378
379 #[error("duplicated packet")]
382 ErrDuplicated,
383 #[error("SRTP master key is not long enough")]
385 ErrShortSrtpMasterKey,
386 #[error("SRTP master salt is not long enough")]
388 ErrShortSrtpMasterSalt,
389 #[error("no such SRTP Profile")]
391 ErrNoSuchSrtpProfile,
392 #[error("indexOverKdr > 0 is not supported yet")]
394 ErrNonZeroKdrNotSupported,
395 #[error("exporter called with wrong label")]
397 ErrExporterWrongLabel,
398 #[error("no config provided")]
400 ErrNoConfig,
401 #[error("no conn provided")]
403 ErrNoConn,
404 #[error("failed to verify auth tag")]
406 ErrFailedToVerifyAuthTag,
407 #[error("packet is too short to be RTP packet")]
409 ErrTooShortRtp,
410 #[error("packet is too short to be RTCP packet")]
412 ErrTooShortRtcp,
413 #[error("payload differs")]
415 ErrPayloadDiffers,
416 #[error("started channel used incorrectly, should only be closed")]
418 ErrStartedChannelUsedIncorrectly,
419 #[error("stream has not been inited, unable to close")]
421 ErrStreamNotInited,
422 #[error("stream is already closed")]
424 ErrStreamAlreadyClosed,
425 #[error("stream is already inited")]
427 ErrStreamAlreadyInited,
428 #[error("failed to cast child")]
430 ErrFailedTypeAssertion,
431 #[error("exceeded the maximum number of packets")]
433 ErrExceededMaxPackets,
434
435 #[error("index_over_kdr > 0 is not supported yet")]
437 UnsupportedIndexOverKdr,
438 #[error("invalid master key length for aes_256_cm")]
440 InvalidMasterKeyLength,
441 #[error("invalid master salt length for aes_256_cm")]
443 InvalidMasterSaltLength,
444 #[error("out_len > 32 is not supported for aes_256_cm")]
446 UnsupportedOutLength,
447 #[error("SRTP Master Key must be len {0}, got {1}")]
449 SrtpMasterKeyLength(usize, usize),
450 #[error("SRTP Salt must be len {0}, got {1}")]
452 SrtpSaltLength(usize, usize),
453 #[error("SyntaxError: {0}")]
455 ExtMapParse(String),
456 #[error("ssrc {0} not exist in srtp_ssrc_state")]
458 SsrcMissingFromSrtp(u32),
459 #[error("srtp ssrc={0} index={1}: duplicated")]
461 SrtpSsrcDuplicated(u32, u16),
462 #[error("srtcp ssrc={0} index={1}: duplicated")]
464 SrtcpSsrcDuplicated(u32, usize),
465 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
467 SsrcMissingFromSrtcp(u32),
468 #[error("Stream with ssrc {0} exists")]
470 StreamWithSsrcExists(u32),
471 #[error("Session RTP/RTCP type must be same as input buffer")]
473 SessionRtpRtcpTypeMismatch,
474 #[error("Session EOF")]
476 SessionEof,
477 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
479 SrtpTooSmall(usize, usize),
480 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
482 SrtcpTooSmall(usize, usize),
483 #[error("failed to verify rtp auth tag")]
485 RtpFailedToVerifyAuthTag,
486 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
488 RtcpInvalidLengthAuthTag(usize, usize),
489 #[error("failed to verify rtcp auth tag")]
491 RtcpFailedToVerifyAuthTag,
492 #[error("SessionSRTP has been closed")]
494 SessionSrtpAlreadyClosed,
495 #[error("this stream is not a RTPStream")]
497 InvalidRtpStream,
498 #[error("this stream is not a RTCPStream")]
500 InvalidRtcpStream,
501
502 #[error("attribute not found")]
505 ErrAttributeNotFound,
506 #[error("transaction is stopped")]
508 ErrTransactionStopped,
509 #[error("transaction not exists")]
511 ErrTransactionNotExists,
512 #[error("transaction exists with same id")]
514 ErrTransactionExists,
515 #[error("agent is closed")]
517 ErrAgentClosed,
518 #[error("transaction is timed out")]
520 ErrTransactionTimeOut,
521 #[error("no default reason for ErrorCode")]
523 ErrNoDefaultReason,
524 #[error("unexpected EOF")]
526 ErrUnexpectedEof,
527 #[error("attribute size is invalid")]
529 ErrAttributeSizeInvalid,
530 #[error("attribute size overflow")]
532 ErrAttributeSizeOverflow,
533 #[error("attempt to decode to nil message")]
535 ErrDecodeToNil,
536 #[error("unexpected EOF: not enough bytes to read header")]
538 ErrUnexpectedHeaderEof,
539 #[error("integrity check failed")]
541 ErrIntegrityMismatch,
542 #[error("fingerprint check failed")]
544 ErrFingerprintMismatch,
545 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
547 ErrFingerprintBeforeIntegrity,
548 #[error("bad UNKNOWN-ATTRIBUTES size")]
550 ErrBadUnknownAttrsSize,
551 #[error("invalid length of IP value")]
553 ErrBadIpLength,
554 #[error("no connection provided")]
556 ErrNoConnection,
557 #[error("client is closed")]
559 ErrClientClosed,
560 #[error("no agent is set")]
562 ErrNoAgent,
563 #[error("collector is closed")]
565 ErrCollectorClosed,
566 #[error("unsupported network")]
568 ErrUnsupportedNetwork,
569 #[error("invalid url")]
571 ErrInvalidUrl,
572 #[error("unknown scheme type")]
574 ErrSchemeType,
575 #[error("invalid hostname")]
577 ErrHost,
578
579 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
582 ErrRelayAddressInvalid,
583 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
585 ErrNoAvailableConns,
586 #[error("turn: PacketConnConfig must have a non-nil Conn")]
588 ErrConnUnset,
589 #[error("turn: ListenerConfig must have a non-nil Listener")]
591 ErrListenerUnset,
592 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
594 ErrListeningAddressInvalid,
595 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
597 ErrRelayAddressGeneratorUnset,
598 #[error("turn: max retries exceeded")]
600 ErrMaxRetriesExceeded,
601 #[error("turn: MaxPort must be not 0")]
603 ErrMaxPortNotZero,
604 #[error("turn: MaxPort must be not 0")]
606 ErrMinPortNotZero,
607 #[error("turn: MaxPort less than MinPort")]
609 ErrMaxPortLessThanMinPort,
610 #[error("turn: relay_conn cannot not be nil")]
612 ErrNilConn,
613 #[error("turn: TODO")]
615 ErrTodo,
616 #[error("turn: already listening")]
618 ErrAlreadyListening,
619 #[error("turn: Server failed to close")]
621 ErrFailedToClose,
622 #[error("turn: failed to retransmit transaction")]
624 ErrFailedToRetransmitTransaction,
625 #[error("all retransmissions failed")]
627 ErrAllRetransmissionsFailed,
628 #[error("no binding found for channel")]
630 ErrChannelBindNotFound,
631 #[error("STUN server address is not set for the client")]
633 ErrStunserverAddressNotSet,
634 #[error("only one Allocate() caller is allowed")]
636 ErrOneAllocateOnly,
637 #[error("already allocated")]
639 ErrAlreadyAllocated,
640 #[error("non-STUN message from STUN server")]
642 ErrNonStunmessage,
643 #[error("failed to decode STUN message")]
645 ErrFailedToDecodeStun,
646 #[error("unexpected STUN request message")]
648 ErrUnexpectedStunrequestMessage,
649 #[error("channel number not in [0x4000, 0x7FFF]")]
651 ErrInvalidChannelNumber,
652 #[error("channelData length != len(Data)")]
654 ErrBadChannelDataLength,
655 #[error("invalid value for requested family attribute")]
657 ErrInvalidRequestedFamilyValue,
658 #[error("fake error")]
660 ErrFakeErr,
661 #[error("use of closed network connection")]
663 ErrClosed,
664 #[error("addr is not a net.UDPAddr")]
666 ErrUdpaddrCast,
667 #[error("try-lock is already locked")]
669 ErrDoubleLock,
670 #[error("transaction closed")]
672 ErrTransactionClosed,
673 #[error("wait_for_result called on non-result transaction")]
675 ErrWaitForResultOnNonResultTransaction,
676 #[error("failed to build refresh request")]
678 ErrFailedToBuildRefreshRequest,
679 #[error("failed to refresh allocation")]
681 ErrFailedToRefreshAllocation,
682 #[error("failed to get lifetime from refresh response")]
684 ErrFailedToGetLifetime,
685 #[error("too short buffer")]
687 ErrShortBuffer,
688 #[error("unexpected response type")]
690 ErrUnexpectedResponse,
691 #[error("AllocatePacketConn must be set")]
693 ErrAllocatePacketConnMustBeSet,
694 #[error("AllocateConn must be set")]
696 ErrAllocateConnMustBeSet,
697 #[error("LeveledLogger must be set")]
699 ErrLeveledLoggerMustBeSet,
700 #[error("you cannot use the same channel number with different peer")]
702 ErrSameChannelDifferentPeer,
703 #[error("allocations must not be created with nil FivTuple")]
705 ErrNilFiveTuple,
706 #[error("allocations must not be created with nil FiveTuple.src_addr")]
708 ErrNilFiveTupleSrcAddr,
709 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
711 ErrNilFiveTupleDstAddr,
712 #[error("allocations must not be created with nil turnSocket")]
714 ErrNilTurnSocket,
715 #[error("allocations must not be created with a lifetime of 0")]
717 ErrLifetimeZero,
718 #[error("allocation attempt created with duplicate FiveTuple")]
720 ErrDupeFiveTuple,
721 #[error("failed to cast net.Addr to *net.UDPAddr")]
723 ErrFailedToCastUdpaddr,
724 #[error("failed to generate nonce")]
726 ErrFailedToGenerateNonce,
727 #[error("failed to send error message")]
729 ErrFailedToSendError,
730 #[error("duplicated Nonce generated, discarding request")]
732 ErrDuplicatedNonce,
733 #[error("no such user exists")]
735 ErrNoSuchUser,
736 #[error("unexpected class")]
738 ErrUnexpectedClass,
739 #[error("unexpected method")]
741 ErrUnexpectedMethod,
742 #[error("failed to handle")]
744 ErrFailedToHandle,
745 #[error("unhandled STUN packet")]
747 ErrUnhandledStunpacket,
748 #[error("unable to handle ChannelData")]
750 ErrUnableToHandleChannelData,
751 #[error("failed to create stun message from packet")]
753 ErrFailedToCreateStunpacket,
754 #[error("failed to create channel data from packet")]
756 ErrFailedToCreateChannelData,
757 #[error("relay already allocated for 5-TUPLE")]
759 ErrRelayAlreadyAllocatedForFiveTuple,
760 #[error("RequestedTransport must be UDP")]
762 ErrRequestedTransportMustBeUdp,
763 #[error("no support for DONT-FRAGMENT")]
765 ErrNoDontFragmentSupport,
766 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
768 ErrRequestWithReservationTokenAndEvenPort,
769 #[error("no allocation found")]
771 ErrNoAllocationFound,
772 #[error("unable to handle send-indication, no permission added")]
774 ErrNoPermission,
775 #[error("packet write smaller than packet")]
777 ErrShortWrite,
778 #[error("no such channel bind")]
780 ErrNoSuchChannelBind,
781 #[error("failed writing to socket")]
783 ErrFailedWriteSocket,
784
785 #[error("Unknown type")]
788 ErrUnknownType,
789
790 #[error("queries not supported in stun address")]
792 ErrStunQuery,
793
794 #[error("invalid query")]
796 ErrInvalidQuery,
797
798 #[error("url parse: invalid port number")]
800 ErrPort,
801
802 #[error("local username fragment is less than 24 bits long")]
805 ErrLocalUfragInsufficientBits,
806
807 #[error("local password is less than 128 bits long")]
810 ErrLocalPwdInsufficientBits,
811
812 #[error("invalid transport protocol type")]
814 ErrProtoType,
815
816 #[error("no candidate pairs available")]
818 ErrNoCandidatePairs,
819
820 #[error("connecting canceled by caller")]
822 ErrCanceledByCaller,
823
824 #[error("attempted to start agent twice")]
826 ErrMultipleStart,
827
828 #[error("remote ufrag is empty")]
830 ErrRemoteUfragEmpty,
831
832 #[error("remote pwd is empty")]
834 ErrRemotePwdEmpty,
835
836 #[error("no on_candidate provided")]
838 ErrNoOnCandidateHandler,
839
840 #[error("attempting to gather candidates during gathering state")]
842 ErrMultipleGatherAttempted,
843
844 #[error("username is empty")]
846 ErrUsernameEmpty,
847
848 #[error("password is empty")]
850 ErrPasswordEmpty,
851
852 #[error("failed to parse address")]
854 ErrAddressParseFailed,
855
856 #[error("lite agents must only use host candidates")]
858 ErrLiteUsingNonHostCandidates,
859
860 #[error("lite support only")]
862 ErrLiteSupportOnly,
863
864 #[error("agent does not need URL with selected candidate types")]
866 ErrUselessUrlsProvided,
867
868 #[error("unsupported 1:1 NAT IP candidate type")]
870 ErrUnsupportedNat1to1IpCandidateType,
871
872 #[error("invalid 1:1 NAT IP mapping")]
874 ErrInvalidNat1to1IpMapping,
875
876 #[error("external mapped IP not found")]
878 ErrExternalMappedIpNotFound,
879
880 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
883 ErrMulticastDnsWithNat1to1IpMapping,
884
885 #[error("1:1 NAT IP mapping for host candidate ineffective")]
888 ErrIneffectiveNat1to1IpMappingHost,
889
890 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
893 ErrIneffectiveNat1to1IpMappingSrflx,
894
895 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
897 ErrInvalidMulticastDnshostName,
898
899 #[error("mdns is not supported")]
901 ErrMulticastDnsNotSupported,
902
903 #[error("ICE Agent can not be restarted when gathering")]
905 ErrRestartWhenGathering,
906
907 #[error("run was canceled by done")]
909 ErrRunCanceled,
910
911 #[error("TCPMux is not initialized")]
913 ErrTcpMuxNotInitialized,
914
915 #[error("conn with same remote addr already exists")]
917 ErrTcpRemoteAddrAlreadyExists,
918
919 #[error("failed to send packet")]
921 ErrSendPacket,
922 #[error("attribute not long enough to be ICE candidate")]
924 ErrAttributeTooShortIceCandidate,
925 #[error("could not parse component")]
927 ErrParseComponent,
928 #[error("could not parse priority")]
930 ErrParsePriority,
931 #[error("could not parse port")]
933 ErrParsePort,
934 #[error("could not parse related addresses")]
936 ErrParseRelatedAddr,
937 #[error("could not parse type")]
939 ErrParseType,
940 #[error("unknown candidate type")]
942 ErrUnknownCandidateType,
943 #[error("failed to get XOR-MAPPED-ADDRESS response")]
945 ErrGetXorMappedAddrResponse,
946 #[error("connection with same remote address already exists")]
948 ErrConnectionAddrAlreadyExist,
949 #[error("error reading streaming packet")]
951 ErrReadingStreamingPacket,
952 #[error("error writing to")]
954 ErrWriting,
955 #[error("error closing connection")]
957 ErrClosingConnection,
958 #[error("unable to determine networkType")]
960 ErrDetermineNetworkType,
961 #[error("missing protocol scheme")]
963 ErrMissingProtocolScheme,
964 #[error("too many colons in address")]
966 ErrTooManyColonsAddr,
967 #[error("unexpected error trying to read")]
969 ErrRead,
970 #[error("unknown role")]
972 ErrUnknownRole,
973 #[error("username mismatch")]
975 ErrMismatchUsername,
976 #[error("the ICE conn can't write STUN messages")]
978 ErrIceWriteStunMessage,
979 #[error("url parse: relative URL without a base")]
981 ErrUrlParse,
982 #[error("Candidate IP could not be found")]
984 ErrCandidateIpNotFound,
985
986 #[error("conn is closed")]
989 ErrConnClosed,
990 #[error("read/write timeout")]
992 ErrDeadlineExceeded,
993 #[error("context is not supported for export_keying_material")]
995 ErrContextUnsupported,
996 #[error("packet is too short")]
998 ErrDtlspacketInvalidLength,
999 #[error("handshake is in progress")]
1001 ErrHandshakeInProgress,
1002 #[error("invalid content type")]
1004 ErrInvalidContentType,
1005 #[error("invalid mac")]
1007 ErrInvalidMac,
1008 #[error("packet length and declared length do not match")]
1010 ErrInvalidPacketLength,
1011 #[error("export_keying_material can not be used with a reserved label")]
1013 ErrReservedExportKeyingMaterial,
1014 #[error("client sent certificate verify but we have no certificate to verify")]
1016 ErrCertificateVerifyNoCertificate,
1017 #[error("client+server do not support any shared cipher suites")]
1019 ErrCipherSuiteNoIntersection,
1020 #[error("server hello can not be created without a cipher suite")]
1022 ErrCipherSuiteUnset,
1023 #[error("client sent certificate but did not verify it")]
1025 ErrClientCertificateNotVerified,
1026 #[error("server required client verification, but got none")]
1028 ErrClientCertificateRequired,
1029 #[error("server responded with SRTP Profile we do not support")]
1031 ErrClientNoMatchingSrtpProfile,
1032 #[error("client required Extended Master Secret extension, but server does not support it")]
1034 ErrClientRequiredButNoServerEms,
1035 #[error("server hello can not be created without a compression method")]
1037 ErrCompressionMethodUnset,
1038 #[error("client+server cookie does not match")]
1040 ErrCookieMismatch,
1041 #[error("cookie must not be longer then 255 bytes")]
1043 ErrCookieTooLong,
1044 #[error("PSK Identity Hint provided but PSK is nil")]
1046 ErrIdentityNoPsk,
1047 #[error("no certificate provided")]
1049 ErrInvalidCertificate,
1050 #[error("cipher spec invalid")]
1052 ErrInvalidCipherSpec,
1053 #[error("invalid or unknown cipher suite")]
1055 ErrInvalidCipherSuite,
1056 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
1058 ErrInvalidClientKeyExchange,
1059 #[error("invalid or unknown compression method")]
1061 ErrInvalidCompressionMethod,
1062 #[error("ECDSA signature contained zero or negative values")]
1064 ErrInvalidEcdsasignature,
1065 #[error("invalid or unknown elliptic curve type")]
1067 ErrInvalidEllipticCurveType,
1068 #[error("invalid extension type")]
1070 ErrInvalidExtensionType,
1071 #[error("invalid hash algorithm")]
1073 ErrInvalidHashAlgorithm,
1074 #[error("invalid named curve")]
1076 ErrInvalidNamedCurve,
1077 #[error("invalid private key type")]
1079 ErrInvalidPrivateKey,
1080 #[error("named curve and private key type does not match")]
1082 ErrNamedCurveAndPrivateKeyMismatch,
1083 #[error("invalid server name format")]
1085 ErrInvalidSniFormat,
1086 #[error("invalid signature algorithm")]
1088 ErrInvalidSignatureAlgorithm,
1089 #[error("expected and actual key signature do not match")]
1091 ErrKeySignatureMismatch,
1092 #[error("Conn can not be created with a nil nextConn")]
1094 ErrNilNextConn,
1095 #[error("connection can not be created, no CipherSuites satisfy this Config")]
1097 ErrNoAvailableCipherSuites,
1098 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
1100 ErrNoAvailableSignatureSchemes,
1101 #[error("no certificates configured")]
1103 ErrNoCertificates,
1104 #[error("no config provided")]
1106 ErrNoConfigProvided,
1107 #[error("client requested zero or more elliptic curves that are not supported by the server")]
1109 ErrNoSupportedEllipticCurves,
1110 #[error("unsupported protocol version")]
1112 ErrUnsupportedProtocolVersion,
1113 #[error("Certificate and PSK provided")]
1115 ErrPskAndCertificate,
1116 #[error("PSK and PSK Identity Hint must both be set for client")]
1118 ErrPskAndIdentityMustBeSetForClient,
1119 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
1121 ErrRequestedButNoSrtpExtension,
1122 #[error("Certificate is mandatory for server")]
1124 ErrServerMustHaveCertificate,
1125 #[error("client requested SRTP but we have no matching profiles")]
1127 ErrServerNoMatchingSrtpProfile,
1128 #[error(
1130 "server requires the Extended Master Secret extension, but the client does not support it"
1131 )]
1132 ErrServerRequiredButNoClientEms,
1133 #[error("expected and actual verify data does not match")]
1135 ErrVerifyDataMismatch,
1136 #[error("handshake message unset, unable to marshal")]
1138 ErrHandshakeMessageUnset,
1139 #[error("invalid flight number")]
1141 ErrInvalidFlight,
1142 #[error("unable to generate key signature, unimplemented")]
1144 ErrKeySignatureGenerateUnimplemented,
1145 #[error("unable to verify key signature, unimplemented")]
1147 ErrKeySignatureVerifyUnimplemented,
1148 #[error("data length and declared length do not match")]
1150 ErrLengthMismatch,
1151 #[error("buffer not long enough to contain nonce")]
1153 ErrNotEnoughRoomForNonce,
1154 #[error("feature has not been implemented yet")]
1156 ErrNotImplemented,
1157 #[error("sequence number overflow")]
1159 ErrSequenceNumberOverflow,
1160 #[error("unable to marshal fragmented handshakes")]
1162 ErrUnableToMarshalFragmented,
1163 #[error("invalid state machine transition")]
1165 ErrInvalidFsmTransition,
1166 #[error("ApplicationData with epoch of 0")]
1168 ErrApplicationDataEpochZero,
1169 #[error("unhandled contentType")]
1171 ErrUnhandledContextType,
1172 #[error("context canceled")]
1174 ErrContextCanceled,
1175 #[error("empty fragment")]
1177 ErrEmptyFragment,
1178 #[error("Alert is Fatal or Close Notify")]
1180 ErrAlertFatalOrClose,
1181 #[error(
1183 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
1184 )]
1185 ErrFragmentBufferOverflow {
1186 new_size: usize,
1188 max_size: usize,
1190 },
1191 #[error("Client transport is not set yet")]
1193 ErrClientTransportNotSet,
1194
1195 #[error("endpoint stopping")]
1199 EndpointStopping,
1200 #[error("too many connections")]
1204 TooManyConnections,
1205 #[error("invalid DNS name: {0}")]
1207 InvalidDnsName(String),
1208 #[error("invalid remote address: {0}")]
1212 InvalidRemoteAddress(SocketAddr),
1213 #[error("no client config")]
1215 NoClientConfig,
1216 #[error("no server config")]
1218 NoServerConfig,
1219
1220 #[error("raw is too small for a SCTP chunk")]
1223 ErrChunkHeaderTooSmall,
1224 #[error("not enough data left in SCTP packet to satisfy requested length")]
1226 ErrChunkHeaderNotEnoughSpace,
1227 #[error("chunk PADDING is non-zero at offset")]
1229 ErrChunkHeaderPaddingNonZero,
1230 #[error("chunk has invalid length")]
1232 ErrChunkHeaderInvalidLength,
1233
1234 #[error("ChunkType is not of type ABORT")]
1236 ErrChunkTypeNotAbort,
1237 #[error("failed build Abort Chunk")]
1239 ErrBuildAbortChunkFailed,
1240 #[error("ChunkType is not of type COOKIEACK")]
1242 ErrChunkTypeNotCookieAck,
1243 #[error("ChunkType is not of type COOKIEECHO")]
1245 ErrChunkTypeNotCookieEcho,
1246 #[error("ChunkType is not of type ctError")]
1248 ErrChunkTypeNotCt,
1249 #[error("failed build Error Chunk")]
1251 ErrBuildErrorChunkFailed,
1252 #[error("failed to marshal stream")]
1254 ErrMarshalStreamFailed,
1255 #[error("chunk too short")]
1257 ErrChunkTooShort,
1258 #[error("ChunkType is not of type ForwardTsn")]
1260 ErrChunkTypeNotForwardTsn,
1261 #[error("ChunkType is not of type HEARTBEAT")]
1263 ErrChunkTypeNotHeartbeat,
1264 #[error("ChunkType is not of type HEARTBEATACK")]
1266 ErrChunkTypeNotHeartbeatAck,
1267 #[error("heartbeat is not long enough to contain Heartbeat Info")]
1269 ErrHeartbeatNotLongEnoughInfo,
1270 #[error("failed to parse param type")]
1272 ErrParseParamTypeFailed,
1273 #[error("heartbeat should only have HEARTBEAT param")]
1275 ErrHeartbeatParam,
1276 #[error("failed unmarshalling param in Heartbeat Chunk")]
1278 ErrHeartbeatChunkUnmarshal,
1279 #[error("unimplemented")]
1281 ErrUnimplemented,
1282 #[error("heartbeat Ack must have one param")]
1284 ErrHeartbeatAckParams,
1285 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
1287 ErrHeartbeatAckNotHeartbeatInfo,
1288 #[error("unable to marshal parameter for Heartbeat Ack")]
1290 ErrHeartbeatAckMarshalParam,
1291
1292 #[error("raw is too small for error cause")]
1294 ErrErrorCauseTooSmall,
1295
1296 #[error("unhandled ParamType: {typ}")]
1298 ErrParamTypeUnhandled {
1299 typ: u16,
1301 },
1302
1303 #[error("unexpected ParamType")]
1305 ErrParamTypeUnexpected,
1306
1307 #[error("param header too short")]
1309 ErrParamHeaderTooShort,
1310 #[error("param self reported length is shorter than header length")]
1312 ErrParamHeaderSelfReportedLengthShorter,
1313 #[error("param self reported length is longer than header length")]
1315 ErrParamHeaderSelfReportedLengthLonger,
1316 #[error("failed to parse param type")]
1318 ErrParamHeaderParseFailed,
1319
1320 #[error("packet to short")]
1322 ErrParamPacketTooShort,
1323 #[error("outgoing SSN reset request parameter too short")]
1325 ErrSsnResetRequestParamTooShort,
1326 #[error("failed unmarshalling SSN reset request parameter in RE-CONFIG chunk")]
1328 ErrUnmarshalSsnResetRequestParam,
1329 #[error("reconfig response parameter too short")]
1331 ErrReconfigRespParamTooShort,
1332 #[error("failed unmarshalling re-configuration response parameter in RE-CONFIG chunk")]
1334 ErrUnmarshalReconfigRespParam,
1335 #[error("invalid algorithm type")]
1337 ErrInvalidAlgorithmType,
1338
1339 #[error("failed to parse param type")]
1341 ErrInitChunkParseParamTypeFailed,
1342 #[error("failed unmarshalling param in Init Chunk")]
1344 ErrInitChunkUnmarshalParam,
1345 #[error("unable to marshal parameter for INIT/INITACK")]
1347 ErrInitAckMarshalParam,
1348
1349 #[error("ChunkType is not of type INIT")]
1351 ErrChunkTypeNotTypeInit,
1352 #[error("chunk Value isn't long enough for mandatory parameters exp")]
1354 ErrChunkValueNotLongEnough,
1355 #[error("ChunkType of type INIT flags must be all 0")]
1357 ErrChunkTypeInitFlagZero,
1358 #[error("failed to unmarshal INIT body")]
1360 ErrChunkTypeInitUnmarshalFailed,
1361 #[error("failed marshaling INIT common data")]
1363 ErrChunkTypeInitMarshalFailed,
1364 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
1366 ErrChunkTypeInitInitiateTagZero,
1367 #[error("INIT ACK inbound stream request must be > 0")]
1369 ErrInitInboundStreamRequestZero,
1370 #[error("INIT ACK outbound stream request must be > 0")]
1372 ErrInitOutboundStreamRequestZero,
1373 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
1375 ErrInitAdvertisedReceiver1500,
1376
1377 #[error("packet is smaller than the header size")]
1379 ErrChunkPayloadSmall,
1380 #[error("ChunkType is not of type PayloadData")]
1382 ErrChunkTypeNotPayloadData,
1383 #[error("failed unmarshalling payload data chunk")]
1385 ErrChunkUnmarshalPayloadData,
1386 #[error("ChunkType is not of type Reconfig")]
1388 ErrChunkTypeNotReconfig,
1389 #[error("ChunkReconfig has invalid ParamA")]
1391 ErrChunkReconfigInvalidParamA,
1392
1393 #[error("failed to parse param type")]
1395 ErrChunkParseParamTypeFailed,
1396 #[error("unable to marshal parameter A for reconfig")]
1398 ErrChunkMarshalParamAReconfigFailed,
1399 #[error("unable to marshal parameter B for reconfig")]
1401 ErrChunkMarshalParamBReconfigFailed,
1402
1403 #[error("ChunkType is not of type SACK")]
1405 ErrChunkTypeNotSack,
1406 #[error("SACK Chunk size is not large enough to contain header")]
1408 ErrSackSizeNotLargeEnoughInfo,
1409 #[error("failed unmarshalling SACK chunk")]
1411 ErrChunkUnmarshalSack,
1412
1413 #[error("invalid chunk size")]
1415 ErrInvalidChunkSize,
1416 #[error("ChunkType is not of type SHUTDOWN")]
1418 ErrChunkTypeNotShutdown,
1419 #[error("failed unmarshalling shutdown chunk")]
1421 ErrChunkUnmarshalShutdown,
1422
1423 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1425 ErrChunkTypeNotShutdownAck,
1426 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1428 ErrChunkTypeNotShutdownComplete,
1429
1430 #[error("raw is smaller than the minimum length for a SCTP packet")]
1432 ErrPacketRawTooSmall,
1433 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1435 ErrParseSctpChunkNotEnoughData,
1436 #[error("failed to unmarshal, contains unknown chunk type")]
1438 ErrUnmarshalUnknownChunkType,
1439 #[error("checksum mismatch theirs")]
1441 ErrChecksumMismatch,
1442
1443 #[error("unexpected chunk popped (unordered)")]
1445 ErrUnexpectedChuckPoppedUnordered,
1446 #[error("unexpected chunk popped (ordered)")]
1448 ErrUnexpectedChuckPoppedOrdered,
1449 #[error("unexpected q state (should've been selected)")]
1451 ErrUnexpectedQState,
1452 #[error("try again")]
1454 ErrTryAgain,
1455
1456 #[error("abort chunk, with following errors: {0}")]
1458 ErrAbortChunk(String),
1459 #[error("shutdown called in non-Established state")]
1461 ErrShutdownNonEstablished,
1462 #[error("association closed before connecting")]
1464 ErrAssociationClosedBeforeConn,
1465 #[error("association init failed")]
1467 ErrAssociationInitFailed,
1468 #[error("association handshake closed")]
1470 ErrAssociationHandshakeClosed,
1471 #[error("silently discard")]
1473 ErrSilentlyDiscard,
1474 #[error("the init not stored to send")]
1476 ErrInitNotStoredToSend,
1477 #[error("cookieEcho not stored to send")]
1479 ErrCookieEchoNotStoredToSend,
1480 #[error("sctp packet must not have a source port of 0")]
1482 ErrSctpPacketSourcePortZero,
1483 #[error("sctp packet must not have a destination port of 0")]
1485 ErrSctpPacketDestinationPortZero,
1486 #[error("init chunk must not be bundled with any other chunk")]
1488 ErrInitChunkBundled,
1489 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1491 ErrInitChunkVerifyTagNotZero,
1492 #[error("todo: handle Init when in state")]
1494 ErrHandleInitState,
1495 #[error("no cookie in InitAck")]
1497 ErrInitAckNoCookie,
1498 #[error("there already exists a stream with identifier")]
1500 ErrStreamAlreadyExist,
1501 #[error("Failed to create a stream with identifier")]
1503 ErrStreamCreateFailed,
1504 #[error("unable to be popped from inflight queue TSN")]
1506 ErrInflightQueueTsnPop,
1507 #[error("requested non-existent TSN")]
1509 ErrTsnRequestNotExist,
1510 #[error("sending reset packet in non-Established state")]
1512 ErrResetPacketInStateNotExist,
1513 #[error("unexpected parameter type")]
1515 ErrParameterType,
1516 #[error("sending payload data in non-Established state")]
1518 ErrPayloadDataStateNotExist,
1519 #[error("unhandled chunk type")]
1521 ErrChunkTypeUnhandled,
1522 #[error("handshake failed (INIT ACK)")]
1524 ErrHandshakeInitAck,
1525 #[error("handshake failed (COOKIE ECHO)")]
1527 ErrHandshakeCookieEcho,
1528
1529 #[error("outbound packet larger than maximum message size")]
1531 ErrOutboundPacketTooLarge,
1532 #[error("Stream closed")]
1534 ErrStreamClosed,
1535 #[error("Stream not existed")]
1537 ErrStreamNotExisted,
1538 #[error("Association not existed")]
1540 ErrAssociationNotExisted,
1541 #[error("Transport not existed")]
1543 ErrTransportNoExisted,
1544 #[error("Io EOF")]
1546 ErrEof,
1547 #[error("Invalid SystemTime")]
1549 ErrInvalidSystemTime,
1550 #[error("Net Conn read error")]
1552 ErrNetConnRead,
1553 #[error("Max Data Channel ID")]
1555 ErrMaxDataChannelID,
1556
1557 #[error(
1560 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1561 )]
1562 UnexpectedEndOfBuffer {
1563 expected: usize,
1565 actual: usize,
1567 },
1568 #[error("Unknown MessageType {0}")]
1570 InvalidMessageType(u8),
1571 #[error("Unknown ChannelType {0}")]
1573 InvalidChannelType(u8),
1574 #[error("Unknown PayloadProtocolIdentifier {0}")]
1576 InvalidPayloadProtocolIdentifier(u8),
1577 #[error("Unknow Protocol")]
1579 UnknownProtocol,
1580
1581 #[error("stream is nil")]
1584 ErrNilStream,
1585 #[error("incomplete frame header")]
1587 ErrIncompleteFrameHeader,
1588 #[error("incomplete frame data")]
1590 ErrIncompleteFrameData,
1591 #[error("incomplete file header")]
1593 ErrIncompleteFileHeader,
1594 #[error("IVF signature mismatch")]
1596 ErrSignatureMismatch,
1597 #[error("IVF version unknown, parser may not parse correctly")]
1599 ErrUnknownIVFVersion,
1600
1601 #[error("file not opened")]
1603 ErrFileNotOpened,
1604 #[error("invalid nil packet")]
1606 ErrInvalidNilPacket,
1607
1608 #[error("bad header signature")]
1610 ErrBadIDPageSignature,
1611 #[error("wrong header, expected beginning of stream")]
1613 ErrBadIDPageType,
1614 #[error("payload for id page must be 19 bytes")]
1616 ErrBadIDPageLength,
1617 #[error("bad payload signature")]
1619 ErrBadIDPagePayloadSignature,
1620 #[error("not enough data for payload header")]
1622 ErrShortPageHeader,
1623 #[error("bad OpusTags signature")]
1625 ErrBadOpusTagsSignature,
1626 #[error("unsupported channel mapping family")]
1628 ErrUnsupportedChannelMappingFamily,
1629
1630 #[error("data is not a H264 bitstream")]
1632 ErrDataIsNotH264Stream,
1633 #[error("data is not a H265 bitstream")]
1635 ErrDataIsNotH265Stream,
1636 #[error("Io EOF")]
1638 ErrIoEOF,
1639
1640 #[error("mDNS: port not support, only 5353 is supported")]
1643 ErrMDNSPortNotSupported,
1644 #[error("mDNS: connection is closed")]
1646 ErrMDNSConnectionClosed,
1647 #[error("mDNS: query not found")]
1649 ErrMDNSQueryNotFound,
1650 #[error("mDNS: parsing/packing of this type isn't available yet")]
1652 ErrNotStarted,
1653 #[error("mDNS: parsing/packing of this section has completed")]
1655 ErrSectionDone,
1656 #[error("mDNS: parsing/packing of this section is header")]
1658 ErrSectionHeader,
1659 #[error("mDNS: insufficient data for base length type")]
1661 ErrBaseLen,
1662 #[error("mDNS: insufficient data for calculated length type")]
1664 ErrCalcLen,
1665 #[error("mDNS: segment prefix is reserved")]
1667 ErrReserved,
1668 #[error("mDNS: too many pointers (>10)")]
1670 ErrTooManyPtr,
1671 #[error("mDNS: invalid pointer")]
1673 ErrInvalidPtr,
1674 #[error("mDNS: nil resource body")]
1676 ErrNilResourceBody,
1677 #[error("mDNS: insufficient data for resource body length")]
1679 ErrResourceLen,
1680 #[error("mDNS: segment length too long")]
1682 ErrSegTooLong,
1683 #[error("mDNS: zero length segment")]
1685 ErrZeroSegLen,
1686 #[error("mDNS: resource length too long")]
1688 ErrResTooLong,
1689 #[error("mDNS: too many Questions to pack (>65535)")]
1691 ErrTooManyQuestions,
1692 #[error("mDNS: too many Answers to pack (>65535)")]
1694 ErrTooManyAnswers,
1695 #[error("mDNS: too many Authorities to pack (>65535)")]
1697 ErrTooManyAuthorities,
1698 #[error("mDNS: too many Additionals to pack (>65535)")]
1700 ErrTooManyAdditionals,
1701 #[error("mDNS: name is not in canonical format (it must end with a .)")]
1703 ErrNonCanonicalName,
1704 #[error("mDNS: character string exceeds maximum length (255)")]
1706 ErrStringTooLong,
1707 #[error("mDNS: compressed name in SRV resource data")]
1709 ErrCompressedSrv,
1710 #[error("mDNS: empty builder msg")]
1712 ErrEmptyBuilderMsg,
1713
1714 #[error("connection closed")]
1718 ErrConnectionClosed,
1719
1720 #[error("data channel closed")]
1723 ErrDataChannelClosed,
1724
1725 #[error("data channel is not open yet")]
1729 ErrDataChannelNotOpen,
1730
1731 #[error("data channel not existed")]
1734 ErrDataChannelNotExisted,
1735
1736 #[error("data channel send buffer full")]
1740 ErrSendBufferFull,
1741
1742 #[error("x509Cert expired")]
1744 ErrCertificateExpired,
1745
1746 #[error("turn server credentials required")]
1749 ErrNoTurnCredentials,
1750
1751 #[error("invalid turn server credentials")]
1754 ErrTurnCredentials,
1755
1756 #[error("track already exists")]
1758 ErrExistingTrack,
1759
1760 #[error("track not existed")]
1762 ErrTrackNotExisted,
1763
1764 #[error("private key type not supported")]
1767 ErrPrivateKeyType,
1768
1769 #[error("peerIdentity cannot be modified")]
1772 ErrModifyingPeerIdentity,
1773
1774 #[error("certificates cannot be modified")]
1777 ErrModifyingCertificates,
1778
1779 #[error("no certificate")]
1781 ErrNonCertificate,
1782
1783 #[error("bundle policy cannot be modified")]
1786 ErrModifyingBundlePolicy,
1787
1788 #[error("rtcp mux policy cannot be modified")]
1791 ErrModifyingRTCPMuxPolicy,
1792
1793 #[error("ice candidate pool size cannot be modified")]
1796 ErrModifyingICECandidatePoolSize,
1797
1798 #[error("data channel label exceeds size limit")]
1801 ErrStringSizeLimit,
1802
1803 #[error("negotiated set without channel id")]
1807 ErrNegotiatedWithoutID,
1808
1809 #[error("both max_packet_life_time and max_retransmits was set")]
1814 ErrRetransmitsOrPacketLifeTime,
1815
1816 #[error("codec not found")]
1818 ErrCodecNotFound,
1819
1820 #[error("remote description is not set")]
1823 ErrNoRemoteDescription,
1824
1825 #[error("offer SDP semantics does not match configuration")]
1828 ErrIncorrectSDPSemantics,
1829
1830 #[error("operation can not be run in current signaling state")]
1832 ErrIncorrectSignalingState,
1833
1834 #[error("protocol is larger then 65535 bytes")]
1837 ErrProtocolTooLarge,
1838
1839 #[error("RtpSender not created by this PeerConnection")]
1842 ErrSenderNotCreatedByConnection,
1843
1844 #[error("RtpSender's initial_track_id has already been set")]
1847 ErrSenderInitialTrackIdAlreadySet,
1848
1849 #[error("set_remote_description called with no fingerprint")]
1852 ErrSessionDescriptionNoFingerprint,
1853
1854 #[error("set_remote_description called with an invalid fingerprint")]
1857 ErrSessionDescriptionInvalidFingerprint,
1858
1859 #[error("set_remote_description called with multiple conflicting fingerprint")]
1862 ErrSessionDescriptionConflictingFingerprints,
1863
1864 #[error("set_remote_description called with no ice-ufrag")]
1867 ErrSessionDescriptionMissingIceUfrag,
1868
1869 #[error("set_remote_description called with no ice-pwd")]
1872 ErrSessionDescriptionMissingIcePwd,
1873
1874 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
1877 ErrSessionDescriptionConflictingIceUfrag,
1878
1879 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
1882 ErrSessionDescriptionConflictingIcePwd,
1883
1884 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
1886 ErrNoSRTPProtectionProfile,
1887
1888 #[error("failed to generate certificate fingerprint")]
1890 ErrFailedToGenerateCertificateFingerprint,
1891
1892 #[error("operation failed no codecs are available")]
1894 ErrNoCodecsAvailable,
1895
1896 #[error("unable to start track, codec is not supported by remote")]
1898 ErrUnsupportedCodec,
1899
1900 #[error("Invalid state error")]
1902 InvalidStateError,
1903
1904 #[error("Invalid modification error")]
1906 InvalidModificationError,
1907
1908 #[error("Range error {0}")]
1910 RangeError(String),
1911
1912 #[error("unable to populate media section, RTPSender created with no codecs")]
1915 ErrSenderWithNoCodecs,
1916
1917 #[error("unable to populate media section, RTPSender created with no ssrcs")]
1920 ErrSenderWithNoSSRCs,
1921
1922 #[error("new track must be of the same kind as previous")]
1924 ErrRTPSenderNewTrackHasIncorrectKind,
1925
1926 #[error("new track has incorrect envelope")]
1928 ErrRTPSenderNewTrackHasIncorrectEnvelope,
1929
1930 #[error("Sequence number transformer must be enabled before sending data")]
1932 ErrRTPSenderDataSent,
1933
1934 #[error("Sequence number transformer has been already enabled")]
1936 ErrRTPSenderSeqTransEnabled,
1937
1938 #[error("failed to unbind TrackLocal from PeerConnection")]
1940 ErrUnbindFailed,
1941
1942 #[error("the requested codec does not have a payloader")]
1944 ErrNoPayloaderForCodec,
1945
1946 #[error("a header extension must be registered with the same direction each time")]
1949 ErrRegisterHeaderExtensionInvalidDirection,
1950
1951 #[error("invalid direction")]
1953 ErrInvalidDirection,
1954
1955 #[error(
1958 "no header extension ID was free to use(this means the maximum of 15 extensions have been registered)"
1959 )]
1960 ErrRegisterHeaderExtensionNoFreeID,
1961
1962 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
1964 ErrSimulcastProbeOverflow,
1965
1966 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
1968 ErrDetachNotEnabled,
1969 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
1971 ErrDetachBeforeOpened,
1972 #[error("the DTLS transport has not started yet")]
1974 ErrDtlsTransportNotStarted,
1975 #[error("failed extracting keys from DTLS for SRTP")]
1977 ErrDtlsKeyExtractionFailed,
1978 #[error("failed to start SRTP")]
1980 ErrFailedToStartSRTP,
1981 #[error("failed to start SRTCP")]
1983 ErrFailedToStartSRTCP,
1984 #[error("attempted to start DTLSTransport that is not in new state")]
1986 ErrInvalidDTLSStart,
1987 #[error("peer didn't provide certificate via DTLS")]
1989 ErrNoRemoteCertificate,
1990 #[error("identity provider is not implemented")]
1992 ErrIdentityProviderNotImplemented,
1993 #[error("remote certificate does not match any fingerprint")]
1995 ErrNoMatchingCertificateFingerprint,
1996 #[error("unsupported fingerprint algorithm")]
1998 ErrUnsupportedFingerprintAlgorithm,
1999 #[error("ICE connection not started")]
2001 ErrICEConnectionNotStarted,
2002 #[error("unknown candidate type")]
2004 ErrICECandidateTypeUnknown,
2005 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
2007 ErrICEInvalidConvertCandidateType,
2008 #[error("ICEAgent does not exist")]
2010 ErrICEAgentNotExist,
2011 #[error("unable to convert ICE candidates to ICECandidates")]
2013 ErrICECandidatesConversionFailed,
2014 #[error("unknown ICE Role")]
2016 ErrICERoleUnknown,
2017 #[error("unknown protocol")]
2019 ErrICEProtocolUnknown,
2020 #[error("gatherer not started")]
2022 ErrICEGathererNotStarted,
2023 #[error("unknown network type")]
2025 ErrNetworkTypeUnknown,
2026 #[error("new sdp does not match previous offer")]
2028 ErrSDPDoesNotMatchOffer,
2029 #[error("new sdp does not match previous answer")]
2031 ErrSDPDoesNotMatchAnswer,
2032 #[error("provided value is not a valid enum value of type SDPType")]
2034 ErrPeerConnSDPTypeInvalidValue,
2035 #[error("invalid state change op")]
2037 ErrPeerConnStateChangeInvalid,
2038 #[error("unhandled state change op")]
2040 ErrPeerConnStateChangeUnhandled,
2041 #[error("invalid SDP type supplied to SetLocalDescription()")]
2043 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
2044 #[error("remoteDescription contained media section without mid value")]
2046 ErrPeerConnRemoteDescriptionWithoutMidValue,
2047 #[error("localDescription contained media section without mid value")]
2049 ErrPeerConnLocalDescriptionWithoutMidValue,
2050 #[error("remoteDescription has not been set yet")]
2052 ErrPeerConnRemoteDescriptionNil,
2053 #[error("localDescription has not been set yet")]
2055 ErrPeerConnLocalDescriptionNil,
2056 #[error("single media section has an explicit SSRC")]
2058 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
2059 #[error("could not add transceiver for remote SSRC")]
2061 ErrPeerConnRemoteSSRCAddTransceiver,
2062 #[error("mid RTP Extensions required for Simulcast")]
2064 ErrPeerConnSimulcastMidRTPExtensionRequired,
2065 #[error("stream id RTP Extensions required for Simulcast")]
2067 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
2068 #[error("incoming SSRC failed Simulcast probing")]
2070 ErrPeerConnSimulcastIncomingSSRCFailed,
2071 #[error("failed collecting stats")]
2073 ErrPeerConnStatsCollectionFailed,
2074 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
2076 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
2077 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
2079 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
2080 #[error("add_transceiver_from_kind currently only supports recvonly")]
2082 ErrPeerConnAddTransceiverFromKindSupport,
2083 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
2085 ErrPeerConnAddTransceiverFromTrackSupport,
2086 #[error("TODO set_identity_provider")]
2088 ErrPeerConnSetIdentityProviderNotImplemented,
2089 #[error("write_rtcp failed to open write_stream")]
2091 ErrPeerConnWriteRTCPOpenWriteStream,
2092 #[error("cannot find transceiver with mid")]
2094 ErrPeerConnTransceiverMidNil,
2095 #[error("DTLSTransport must not be nil")]
2097 ErrRTPReceiverDTLSTransportNil,
2098 #[error("Receive has already been called")]
2100 ErrRTPReceiverReceiveAlreadyCalled,
2101 #[error("unable to find stream for Track with SSRC")]
2103 ErrRTPReceiverWithSSRCTrackStreamNotFound,
2104 #[error("no trackStreams found for SSRC")]
2106 ErrRTPReceiverForSSRCTrackStreamNotFound,
2107 #[error("no trackStreams found for RID")]
2109 ErrRTPReceiverForRIDTrackStreamNotFound,
2110 #[error("invalid RTP Receiver transition")]
2112 ErrRTPReceiverStateChangeInvalid,
2113 #[error("Track must not be nil")]
2115 ErrRTPSenderTrackNil,
2116 #[error("RTPSender not existed")]
2118 ErrRTPSenderNotExisted,
2119 #[error("Sender Track has been removed or replaced to nil")]
2121 ErrRTPSenderTrackRemoved,
2122 #[error("Sender cannot add encoding as rid is empty")]
2124 ErrRTPSenderRidNil,
2125 #[error("Sender cannot add encoding as there is no base track")]
2127 ErrRTPSenderNoBaseEncoding,
2128 #[error("Sender cannot add encoding as provided track does not match base track")]
2130 ErrRTPSenderBaseEncodingMismatch,
2131 #[error("Sender cannot encoding due to RID collision")]
2133 ErrRTPSenderRIDCollision,
2134 #[error("Sender does not have track for RID")]
2136 ErrRTPSenderNoTrackForRID,
2137 #[error("RTPReceiver not existed")]
2139 ErrRTPReceiverNotExisted,
2140 #[error("DTLSTransport must not be nil")]
2142 ErrRTPSenderDTLSTransportNil,
2143 #[error("Send has already been called")]
2145 ErrRTPSenderSendAlreadyCalled,
2146 #[error("RTPTransceiver not existed")]
2148 ErrRTPTransceiverNotExisted,
2149 #[error("errRTPSenderTrackNil")]
2151 ErrRTPTransceiverCannotChangeMid,
2152 #[error("invalid state change in RTPTransceiver.setSending")]
2154 ErrRTPTransceiverSetSendingInvalidState,
2155 #[error("unsupported codec type by this transceiver")]
2157 ErrRTPTransceiverCodecUnsupported,
2158 #[error("DTLS not established")]
2160 ErrSCTPTransportDTLS,
2161 #[error("add_transceiver_sdp() called with 0 transceivers")]
2163 ErrSDPZeroTransceivers,
2164 #[error("invalid Media Section. Media + DataChannel both enabled")]
2166 ErrSDPMediaSectionMediaDataChanInvalid,
2167 #[error("invalid Media Section Track Index")]
2169 ErrSDPMediaSectionTrackInvalid,
2170 #[error("set_answering_dtlsrole must DTLSRoleClient or DTLSRoleServer")]
2172 ErrSettingEngineSetAnsweringDTLSRole,
2173 #[error("can't rollback from stable state")]
2175 ErrSignalingStateCannotRollback,
2176 #[error("invalid proposed signaling state transition: {0}")]
2178 ErrSignalingStateProposedTransitionInvalid(String),
2179 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
2181 ErrStatsICECandidateStateInvalid,
2182 #[error("ICETransport can only be called in ICETransportStateNew")]
2184 ErrICETransportNotInNew,
2185 #[error("bad Certificate PEM format")]
2187 ErrCertificatePEMFormatError,
2188 #[error("SCTP is not established")]
2190 ErrSCTPNotEstablished,
2191
2192 #[error("DataChannel is not opened")]
2194 ErrClosedPipe,
2195 #[error("Interceptor is not bind")]
2197 ErrInterceptorNotBind,
2198 #[error("excessive retries in CreateOffer")]
2200 ErrExcessiveRetries,
2201
2202 #[error("not long enough to be a RTP Packet")]
2204 ErrRTPTooShort,
2205
2206 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
2208 SimulcastRidParseErrorSyntaxIdDirSplit,
2209 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
2211 SimulcastRidParseErrorUnknownDirection,
2212
2213 #[error("codec not found")]
2216 CodecNotFound,
2217 #[error("missing whitespace")]
2219 MissingWhitespace,
2220 #[error("missing colon")]
2222 MissingColon,
2223 #[error("payload type not found")]
2225 PayloadTypeNotFound,
2226 #[error("SdpInvalidSyntax: {0}")]
2228 SdpInvalidSyntax(String),
2229 #[error("SdpInvalidValue: {0}")]
2231 SdpInvalidValue(String),
2232 #[error("sdp: empty time_descriptions")]
2234 SdpEmptyTimeDescription,
2235 #[error("parse extmap: {0}")]
2237 ParseExtMap(String),
2238 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
2240 )]
2241 SyntaxError {
2242 s: String,
2244 p: usize,
2246 },
2247
2248 #[error("{0}")]
2251 Sec1(#[source] sec1::Error),
2252 #[error("{0}")]
2254 P256(#[source] P256Error),
2255 #[error("{0}")]
2257 RcGen(#[from] rcgen::Error),
2258 #[error("invalid PEM: {0}")]
2260 InvalidPEM(String),
2261 #[error("aes gcm: {0}")]
2263 AesGcm(#[from] aes_gcm::Error),
2264 #[error("parse ip: {0}")]
2266 ParseIp(#[from] net::AddrParseError),
2267 #[error("parse int: {0}")]
2269 ParseInt(#[from] ParseIntError),
2270 #[error("{0}")]
2272 Io(#[source] IoError),
2273 #[error("url parse: {0}")]
2275 Url(#[from] url::ParseError),
2276 #[error("utf8: {0}")]
2278 Utf8(#[from] FromUtf8Error),
2279 #[error("{0}")]
2281 Std(#[source] StdError),
2282 #[error("{0}")]
2284 Aes(#[from] aes::cipher::InvalidLength),
2285
2286 #[error("Other RTCP Err: {0}")]
2289 OtherRtcpErr(String),
2290 #[error("Other RTP Err: {0}")]
2292 OtherRtpErr(String),
2293 #[error("Other SRTP Err: {0}")]
2295 OtherSrtpErr(String),
2296 #[error("Other STUN Err: {0}")]
2298 OtherStunErr(String),
2299 #[error("Other TURN Err: {0}")]
2301 OtherTurnErr(String),
2302 #[error("Other ICE Err: {0}")]
2304 OtherIceErr(String),
2305 #[error("Other DTLS Err: {0}")]
2307 OtherDtlsErr(String),
2308 #[error("Other SCTP Err: {0}")]
2310 OtherSctpErr(String),
2311 #[error("Other DataChannel Err: {0}")]
2313 OtherDataChannelErr(String),
2314 #[error("Other Interceptor Err: {0}")]
2316 OtherInterceptorErr(String),
2317 #[error("Other Media Err: {0}")]
2319 OtherMediaErr(String),
2320 #[error("Other mDNS Err: {0}")]
2322 OtherMdnsErr(String),
2323 #[error("Other SDP Err: {0}")]
2325 OtherSdpErr(String),
2326 #[error("Other PeerConnection Err: {0}")]
2328 OtherPeerConnectionErr(String),
2329 #[error("{0}")]
2330 Other(String),
2332}
2333
2334impl Error {
2335 pub fn from_std<T>(error: T) -> Self
2338 where
2339 T: std::error::Error + Send + Sync + 'static,
2340 {
2341 Error::Std(StdError(Box::new(error)))
2342 }
2343
2344 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
2349 if let Error::Std(s) = self {
2350 return s.0.downcast_ref();
2351 }
2352
2353 None
2354 }
2355}
2356
2357#[derive(Debug, Error)]
2363#[error("io error: {0}")]
2364pub struct IoError(#[from] pub io::Error);
2365
2366impl PartialEq for IoError {
2368 fn eq(&self, other: &Self) -> bool {
2369 self.0.kind() == other.0.kind()
2370 }
2371}
2372
2373impl From<io::Error> for Error {
2374 fn from(e: io::Error) -> Self {
2375 Error::Io(IoError(e))
2376 }
2377}
2378
2379#[derive(Debug, Error)]
2389#[error("{0}")]
2390pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
2391
2392impl PartialEq for StdError {
2393 fn eq(&self, _: &Self) -> bool {
2394 false
2395 }
2396}
2397
2398impl<T> From<std::sync::PoisonError<T>> for Error {
2399 fn from(e: std::sync::PoisonError<T>) -> Self {
2400 Error::PoisonError(e.to_string())
2401 }
2402}
2403
2404impl From<sec1::Error> for Error {
2405 fn from(e: sec1::Error) -> Self {
2406 Error::Sec1(e)
2407 }
2408}
2409
2410#[derive(Debug, Error)]
2417#[error("{0}")]
2418pub struct P256Error(#[source] p256::elliptic_curve::Error);
2419
2420impl PartialEq for P256Error {
2421 fn eq(&self, _: &Self) -> bool {
2422 false
2423 }
2424}
2425
2426impl From<p256::elliptic_curve::Error> for Error {
2427 fn from(e: p256::elliptic_curve::Error) -> Self {
2428 Error::P256(P256Error(e))
2429 }
2430}
2431
2432impl From<SystemTimeError> for Error {
2433 fn from(e: SystemTimeError) -> Self {
2434 Error::Other(e.to_string())
2435 }
2436}
2437
2438pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
2442 if errs.is_empty() {
2443 Ok(())
2444 } else {
2445 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
2446 Err(Error::Other(errs_strs.join("\n")))
2447 }
2448}