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("reassembled unit is too large")]
341 ErrReassembledUnitTooLarge,
342 #[error("too many spatial layers")]
344 ErrTooManySpatialLayers,
345 #[error("NALU Type is unhandled")]
347 ErrUnhandledNaluType,
348
349 #[error("corrupted h265 packet")]
351 ErrH265CorruptedPacket,
352 #[error("invalid h265 packet type")]
354 ErrInvalidH265PacketType,
355
356 #[error("payload is too small for OBU extension header")]
358 ErrPayloadTooSmallForObuExtensionHeader,
359 #[error("payload is too small for OBU payload size")]
361 ErrPayloadTooSmallForObuPayloadSize,
362
363 #[error("extension_payload must be in 32-bit words")]
365 HeaderExtensionPayloadNot32BitWords,
366 #[error("audio level overflow")]
368 AudioLevelOverflow,
369 #[error("playout delay overflow")]
371 PlayoutDelayOverflow,
372 #[error("payload is not large enough")]
374 PayloadIsNotLargeEnough,
375 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
377 StapASizeLargerThanBuffer(usize, usize),
378 #[error("nalu type {0} is currently not handled")]
380 NaluTypeIsNotHandled(u8),
381
382 #[error("duplicated packet")]
385 ErrDuplicated,
386 #[error("SRTP master key is not long enough")]
388 ErrShortSrtpMasterKey,
389 #[error("SRTP master salt is not long enough")]
391 ErrShortSrtpMasterSalt,
392 #[error("no such SRTP Profile")]
394 ErrNoSuchSrtpProfile,
395 #[error("indexOverKdr > 0 is not supported yet")]
397 ErrNonZeroKdrNotSupported,
398 #[error("exporter called with wrong label")]
400 ErrExporterWrongLabel,
401 #[error("no config provided")]
403 ErrNoConfig,
404 #[error("no conn provided")]
406 ErrNoConn,
407 #[error("failed to verify auth tag")]
409 ErrFailedToVerifyAuthTag,
410 #[error("packet is too short to be RTP packet")]
412 ErrTooShortRtp,
413 #[error("packet is too short to be RTCP packet")]
415 ErrTooShortRtcp,
416 #[error("payload differs")]
418 ErrPayloadDiffers,
419 #[error("started channel used incorrectly, should only be closed")]
421 ErrStartedChannelUsedIncorrectly,
422 #[error("stream has not been inited, unable to close")]
424 ErrStreamNotInited,
425 #[error("stream is already closed")]
427 ErrStreamAlreadyClosed,
428 #[error("stream is already inited")]
430 ErrStreamAlreadyInited,
431 #[error("failed to cast child")]
433 ErrFailedTypeAssertion,
434 #[error("exceeded the maximum number of packets")]
436 ErrExceededMaxPackets,
437
438 #[error("index_over_kdr > 0 is not supported yet")]
440 UnsupportedIndexOverKdr,
441 #[error("invalid master key length for aes_256_cm")]
443 InvalidMasterKeyLength,
444 #[error("invalid master salt length for aes_256_cm")]
446 InvalidMasterSaltLength,
447 #[error("out_len > 32 is not supported for aes_256_cm")]
449 UnsupportedOutLength,
450 #[error("SRTP Master Key must be len {0}, got {1}")]
452 SrtpMasterKeyLength(usize, usize),
453 #[error("SRTP Salt must be len {0}, got {1}")]
455 SrtpSaltLength(usize, usize),
456 #[error("SyntaxError: {0}")]
458 ExtMapParse(String),
459 #[error("ssrc {0} not exist in srtp_ssrc_state")]
461 SsrcMissingFromSrtp(u32),
462 #[error("srtp ssrc={0} index={1}: duplicated")]
464 SrtpSsrcDuplicated(u32, u16),
465 #[error("srtcp ssrc={0} index={1}: duplicated")]
467 SrtcpSsrcDuplicated(u32, usize),
468 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
470 SsrcMissingFromSrtcp(u32),
471 #[error("Stream with ssrc {0} exists")]
473 StreamWithSsrcExists(u32),
474 #[error("Session RTP/RTCP type must be same as input buffer")]
476 SessionRtpRtcpTypeMismatch,
477 #[error("Session EOF")]
479 SessionEof,
480 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
482 SrtpTooSmall(usize, usize),
483 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
485 SrtcpTooSmall(usize, usize),
486 #[error("failed to verify rtp auth tag")]
488 RtpFailedToVerifyAuthTag,
489 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
491 RtcpInvalidLengthAuthTag(usize, usize),
492 #[error("failed to verify rtcp auth tag")]
494 RtcpFailedToVerifyAuthTag,
495 #[error("SessionSRTP has been closed")]
497 SessionSrtpAlreadyClosed,
498 #[error("this stream is not a RTPStream")]
500 InvalidRtpStream,
501 #[error("this stream is not a RTCPStream")]
503 InvalidRtcpStream,
504
505 #[error("attribute not found")]
508 ErrAttributeNotFound,
509 #[error("transaction is stopped")]
511 ErrTransactionStopped,
512 #[error("transaction not exists")]
514 ErrTransactionNotExists,
515 #[error("transaction exists with same id")]
517 ErrTransactionExists,
518 #[error("agent is closed")]
520 ErrAgentClosed,
521 #[error("transaction is timed out")]
523 ErrTransactionTimeOut,
524 #[error("no default reason for ErrorCode")]
526 ErrNoDefaultReason,
527 #[error("unexpected EOF")]
529 ErrUnexpectedEof,
530 #[error("attribute size is invalid")]
532 ErrAttributeSizeInvalid,
533 #[error("attribute size overflow")]
535 ErrAttributeSizeOverflow,
536 #[error("attempt to decode to nil message")]
538 ErrDecodeToNil,
539 #[error("unexpected EOF: not enough bytes to read header")]
541 ErrUnexpectedHeaderEof,
542 #[error("integrity check failed")]
544 ErrIntegrityMismatch,
545 #[error("fingerprint check failed")]
547 ErrFingerprintMismatch,
548 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
550 ErrFingerprintBeforeIntegrity,
551 #[error("bad UNKNOWN-ATTRIBUTES size")]
553 ErrBadUnknownAttrsSize,
554 #[error("invalid length of IP value")]
556 ErrBadIpLength,
557 #[error("no connection provided")]
559 ErrNoConnection,
560 #[error("client is closed")]
562 ErrClientClosed,
563 #[error("no agent is set")]
565 ErrNoAgent,
566 #[error("collector is closed")]
568 ErrCollectorClosed,
569 #[error("unsupported network")]
571 ErrUnsupportedNetwork,
572 #[error("invalid url")]
574 ErrInvalidUrl,
575 #[error("unknown scheme type")]
577 ErrSchemeType,
578 #[error("invalid hostname")]
580 ErrHost,
581
582 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
585 ErrRelayAddressInvalid,
586 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
588 ErrNoAvailableConns,
589 #[error("turn: PacketConnConfig must have a non-nil Conn")]
591 ErrConnUnset,
592 #[error("turn: ListenerConfig must have a non-nil Listener")]
594 ErrListenerUnset,
595 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
597 ErrListeningAddressInvalid,
598 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
600 ErrRelayAddressGeneratorUnset,
601 #[error("turn: max retries exceeded")]
603 ErrMaxRetriesExceeded,
604 #[error("turn: MaxPort must be not 0")]
606 ErrMaxPortNotZero,
607 #[error("turn: MaxPort must be not 0")]
609 ErrMinPortNotZero,
610 #[error("turn: MaxPort less than MinPort")]
612 ErrMaxPortLessThanMinPort,
613 #[error("turn: relay_conn cannot not be nil")]
615 ErrNilConn,
616 #[error("turn: TODO")]
618 ErrTodo,
619 #[error("turn: already listening")]
621 ErrAlreadyListening,
622 #[error("turn: Server failed to close")]
624 ErrFailedToClose,
625 #[error("turn: failed to retransmit transaction")]
627 ErrFailedToRetransmitTransaction,
628 #[error("all retransmissions failed")]
630 ErrAllRetransmissionsFailed,
631 #[error("no binding found for channel")]
633 ErrChannelBindNotFound,
634 #[error("STUN server address is not set for the client")]
636 ErrStunserverAddressNotSet,
637 #[error("only one Allocate() caller is allowed")]
639 ErrOneAllocateOnly,
640 #[error("already allocated")]
642 ErrAlreadyAllocated,
643 #[error("non-STUN message from STUN server")]
645 ErrNonStunmessage,
646 #[error("failed to decode STUN message")]
648 ErrFailedToDecodeStun,
649 #[error("unexpected STUN request message")]
651 ErrUnexpectedStunrequestMessage,
652 #[error("channel number not in [0x4000, 0x7FFF]")]
654 ErrInvalidChannelNumber,
655 #[error("channelData length != len(Data)")]
657 ErrBadChannelDataLength,
658 #[error("invalid value for requested family attribute")]
660 ErrInvalidRequestedFamilyValue,
661 #[error("fake error")]
663 ErrFakeErr,
664 #[error("use of closed network connection")]
666 ErrClosed,
667 #[error("addr is not a net.UDPAddr")]
669 ErrUdpaddrCast,
670 #[error("try-lock is already locked")]
672 ErrDoubleLock,
673 #[error("transaction closed")]
675 ErrTransactionClosed,
676 #[error("wait_for_result called on non-result transaction")]
678 ErrWaitForResultOnNonResultTransaction,
679 #[error("failed to build refresh request")]
681 ErrFailedToBuildRefreshRequest,
682 #[error("failed to refresh allocation")]
684 ErrFailedToRefreshAllocation,
685 #[error("failed to get lifetime from refresh response")]
687 ErrFailedToGetLifetime,
688 #[error("too short buffer")]
690 ErrShortBuffer,
691 #[error("unexpected response type")]
693 ErrUnexpectedResponse,
694 #[error("AllocatePacketConn must be set")]
696 ErrAllocatePacketConnMustBeSet,
697 #[error("AllocateConn must be set")]
699 ErrAllocateConnMustBeSet,
700 #[error("LeveledLogger must be set")]
702 ErrLeveledLoggerMustBeSet,
703 #[error("you cannot use the same channel number with different peer")]
705 ErrSameChannelDifferentPeer,
706 #[error("allocations must not be created with nil FivTuple")]
708 ErrNilFiveTuple,
709 #[error("allocations must not be created with nil FiveTuple.src_addr")]
711 ErrNilFiveTupleSrcAddr,
712 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
714 ErrNilFiveTupleDstAddr,
715 #[error("allocations must not be created with nil turnSocket")]
717 ErrNilTurnSocket,
718 #[error("allocations must not be created with a lifetime of 0")]
720 ErrLifetimeZero,
721 #[error("allocation attempt created with duplicate FiveTuple")]
723 ErrDupeFiveTuple,
724 #[error("failed to cast net.Addr to *net.UDPAddr")]
726 ErrFailedToCastUdpaddr,
727 #[error("failed to generate nonce")]
729 ErrFailedToGenerateNonce,
730 #[error("failed to send error message")]
732 ErrFailedToSendError,
733 #[error("duplicated Nonce generated, discarding request")]
735 ErrDuplicatedNonce,
736 #[error("no such user exists")]
738 ErrNoSuchUser,
739 #[error("unexpected class")]
741 ErrUnexpectedClass,
742 #[error("unexpected method")]
744 ErrUnexpectedMethod,
745 #[error("failed to handle")]
747 ErrFailedToHandle,
748 #[error("unhandled STUN packet")]
750 ErrUnhandledStunpacket,
751 #[error("unable to handle ChannelData")]
753 ErrUnableToHandleChannelData,
754 #[error("failed to create stun message from packet")]
756 ErrFailedToCreateStunpacket,
757 #[error("failed to create channel data from packet")]
759 ErrFailedToCreateChannelData,
760 #[error("relay already allocated for 5-TUPLE")]
762 ErrRelayAlreadyAllocatedForFiveTuple,
763 #[error("RequestedTransport must be UDP")]
765 ErrRequestedTransportMustBeUdp,
766 #[error("no support for DONT-FRAGMENT")]
768 ErrNoDontFragmentSupport,
769 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
771 ErrRequestWithReservationTokenAndEvenPort,
772 #[error("no allocation found")]
774 ErrNoAllocationFound,
775 #[error("unable to handle send-indication, no permission added")]
777 ErrNoPermission,
778 #[error("packet write smaller than packet")]
780 ErrShortWrite,
781 #[error("no such channel bind")]
783 ErrNoSuchChannelBind,
784 #[error("failed writing to socket")]
786 ErrFailedWriteSocket,
787
788 #[error("Unknown type")]
791 ErrUnknownType,
792
793 #[error("queries not supported in stun address")]
795 ErrStunQuery,
796
797 #[error("invalid query")]
799 ErrInvalidQuery,
800
801 #[error("url parse: invalid port number")]
803 ErrPort,
804
805 #[error("local username fragment is less than 24 bits long")]
808 ErrLocalUfragInsufficientBits,
809
810 #[error("local password is less than 128 bits long")]
813 ErrLocalPwdInsufficientBits,
814
815 #[error("invalid transport protocol type")]
817 ErrProtoType,
818
819 #[error("no candidate pairs available")]
821 ErrNoCandidatePairs,
822
823 #[error("connecting canceled by caller")]
825 ErrCanceledByCaller,
826
827 #[error("attempted to start agent twice")]
829 ErrMultipleStart,
830
831 #[error("remote ufrag is empty")]
833 ErrRemoteUfragEmpty,
834
835 #[error("remote pwd is empty")]
837 ErrRemotePwdEmpty,
838
839 #[error("no on_candidate provided")]
841 ErrNoOnCandidateHandler,
842
843 #[error("attempting to gather candidates during gathering state")]
845 ErrMultipleGatherAttempted,
846
847 #[error("username is empty")]
849 ErrUsernameEmpty,
850
851 #[error("password is empty")]
853 ErrPasswordEmpty,
854
855 #[error("failed to parse address")]
857 ErrAddressParseFailed,
858
859 #[error("lite agents must only use host candidates")]
861 ErrLiteUsingNonHostCandidates,
862
863 #[error("lite support only")]
865 ErrLiteSupportOnly,
866
867 #[error("agent does not need URL with selected candidate types")]
869 ErrUselessUrlsProvided,
870
871 #[error("unsupported 1:1 NAT IP candidate type")]
873 ErrUnsupportedNat1to1IpCandidateType,
874
875 #[error("invalid 1:1 NAT IP mapping")]
877 ErrInvalidNat1to1IpMapping,
878
879 #[error("external mapped IP not found")]
881 ErrExternalMappedIpNotFound,
882
883 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
886 ErrMulticastDnsWithNat1to1IpMapping,
887
888 #[error("1:1 NAT IP mapping for host candidate ineffective")]
891 ErrIneffectiveNat1to1IpMappingHost,
892
893 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
896 ErrIneffectiveNat1to1IpMappingSrflx,
897
898 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
900 ErrInvalidMulticastDnshostName,
901
902 #[error("mdns is not supported")]
904 ErrMulticastDnsNotSupported,
905
906 #[error("ICE Agent can not be restarted when gathering")]
908 ErrRestartWhenGathering,
909
910 #[error("run was canceled by done")]
912 ErrRunCanceled,
913
914 #[error("TCPMux is not initialized")]
916 ErrTcpMuxNotInitialized,
917
918 #[error("conn with same remote addr already exists")]
920 ErrTcpRemoteAddrAlreadyExists,
921
922 #[error("failed to send packet")]
924 ErrSendPacket,
925 #[error("attribute not long enough to be ICE candidate")]
927 ErrAttributeTooShortIceCandidate,
928 #[error("could not parse component")]
930 ErrParseComponent,
931 #[error("could not parse priority")]
933 ErrParsePriority,
934 #[error("could not parse port")]
936 ErrParsePort,
937 #[error("could not parse related addresses")]
939 ErrParseRelatedAddr,
940 #[error("could not parse type")]
942 ErrParseType,
943 #[error("unknown candidate type")]
945 ErrUnknownCandidateType,
946 #[error("failed to get XOR-MAPPED-ADDRESS response")]
948 ErrGetXorMappedAddrResponse,
949 #[error("connection with same remote address already exists")]
951 ErrConnectionAddrAlreadyExist,
952 #[error("error reading streaming packet")]
954 ErrReadingStreamingPacket,
955 #[error("error writing to")]
957 ErrWriting,
958 #[error("error closing connection")]
960 ErrClosingConnection,
961 #[error("unable to determine networkType")]
963 ErrDetermineNetworkType,
964 #[error("missing protocol scheme")]
966 ErrMissingProtocolScheme,
967 #[error("too many colons in address")]
969 ErrTooManyColonsAddr,
970 #[error("unexpected error trying to read")]
972 ErrRead,
973 #[error("unknown role")]
975 ErrUnknownRole,
976 #[error("username mismatch")]
978 ErrMismatchUsername,
979 #[error("the ICE conn can't write STUN messages")]
981 ErrIceWriteStunMessage,
982 #[error("url parse: relative URL without a base")]
984 ErrUrlParse,
985 #[error("Candidate IP could not be found")]
987 ErrCandidateIpNotFound,
988
989 #[error("conn is closed")]
992 ErrConnClosed,
993 #[error("read/write timeout")]
995 ErrDeadlineExceeded,
996 #[error("context is not supported for export_keying_material")]
998 ErrContextUnsupported,
999 #[error("packet is too short")]
1001 ErrDtlspacketInvalidLength,
1002 #[error("handshake is in progress")]
1004 ErrHandshakeInProgress,
1005 #[error("invalid content type")]
1007 ErrInvalidContentType,
1008 #[error("invalid mac")]
1010 ErrInvalidMac,
1011 #[error("packet length and declared length do not match")]
1013 ErrInvalidPacketLength,
1014 #[error("export_keying_material can not be used with a reserved label")]
1016 ErrReservedExportKeyingMaterial,
1017 #[error("client sent certificate verify but we have no certificate to verify")]
1019 ErrCertificateVerifyNoCertificate,
1020 #[error("client+server do not support any shared cipher suites")]
1022 ErrCipherSuiteNoIntersection,
1023 #[error("server hello can not be created without a cipher suite")]
1025 ErrCipherSuiteUnset,
1026 #[error("client sent certificate but did not verify it")]
1028 ErrClientCertificateNotVerified,
1029 #[error("server required client verification, but got none")]
1031 ErrClientCertificateRequired,
1032 #[error("server responded with SRTP Profile we do not support")]
1034 ErrClientNoMatchingSrtpProfile,
1035 #[error("client required Extended Master Secret extension, but server does not support it")]
1037 ErrClientRequiredButNoServerEms,
1038 #[error("server hello can not be created without a compression method")]
1040 ErrCompressionMethodUnset,
1041 #[error("client+server cookie does not match")]
1043 ErrCookieMismatch,
1044 #[error("cookie must not be longer then 255 bytes")]
1046 ErrCookieTooLong,
1047 #[error("PSK Identity Hint provided but PSK is nil")]
1049 ErrIdentityNoPsk,
1050 #[error("no certificate provided")]
1052 ErrInvalidCertificate,
1053 #[error("cipher spec invalid")]
1055 ErrInvalidCipherSpec,
1056 #[error("invalid or unknown cipher suite")]
1058 ErrInvalidCipherSuite,
1059 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
1061 ErrInvalidClientKeyExchange,
1062 #[error("invalid or unknown compression method")]
1064 ErrInvalidCompressionMethod,
1065 #[error("ECDSA signature contained zero or negative values")]
1067 ErrInvalidEcdsasignature,
1068 #[error("invalid or unknown elliptic curve type")]
1070 ErrInvalidEllipticCurveType,
1071 #[error("invalid extension type")]
1073 ErrInvalidExtensionType,
1074 #[error("invalid hash algorithm")]
1076 ErrInvalidHashAlgorithm,
1077 #[error("invalid named curve")]
1079 ErrInvalidNamedCurve,
1080 #[error("invalid private key type")]
1082 ErrInvalidPrivateKey,
1083 #[error("named curve and private key type does not match")]
1085 ErrNamedCurveAndPrivateKeyMismatch,
1086 #[error("invalid server name format")]
1088 ErrInvalidSniFormat,
1089 #[error("invalid signature algorithm")]
1091 ErrInvalidSignatureAlgorithm,
1092 #[error("expected and actual key signature do not match")]
1094 ErrKeySignatureMismatch,
1095 #[error("Conn can not be created with a nil nextConn")]
1097 ErrNilNextConn,
1098 #[error("connection can not be created, no CipherSuites satisfy this Config")]
1100 ErrNoAvailableCipherSuites,
1101 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
1103 ErrNoAvailableSignatureSchemes,
1104 #[error("no certificates configured")]
1106 ErrNoCertificates,
1107 #[error("no config provided")]
1109 ErrNoConfigProvided,
1110 #[error("client requested zero or more elliptic curves that are not supported by the server")]
1112 ErrNoSupportedEllipticCurves,
1113 #[error("unsupported protocol version")]
1115 ErrUnsupportedProtocolVersion,
1116 #[error("Certificate and PSK provided")]
1118 ErrPskAndCertificate,
1119 #[error("PSK and PSK Identity Hint must both be set for client")]
1121 ErrPskAndIdentityMustBeSetForClient,
1122 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
1124 ErrRequestedButNoSrtpExtension,
1125 #[error("Certificate is mandatory for server")]
1127 ErrServerMustHaveCertificate,
1128 #[error("client requested SRTP but we have no matching profiles")]
1130 ErrServerNoMatchingSrtpProfile,
1131 #[error(
1133 "server requires the Extended Master Secret extension, but the client does not support it"
1134 )]
1135 ErrServerRequiredButNoClientEms,
1136 #[error("expected and actual verify data does not match")]
1138 ErrVerifyDataMismatch,
1139 #[error("handshake message unset, unable to marshal")]
1141 ErrHandshakeMessageUnset,
1142 #[error("invalid flight number")]
1144 ErrInvalidFlight,
1145 #[error("unable to generate key signature, unimplemented")]
1147 ErrKeySignatureGenerateUnimplemented,
1148 #[error("unable to verify key signature, unimplemented")]
1150 ErrKeySignatureVerifyUnimplemented,
1151 #[error("data length and declared length do not match")]
1153 ErrLengthMismatch,
1154 #[error("buffer not long enough to contain nonce")]
1156 ErrNotEnoughRoomForNonce,
1157 #[error("feature has not been implemented yet")]
1159 ErrNotImplemented,
1160 #[error("sequence number overflow")]
1162 ErrSequenceNumberOverflow,
1163 #[error("unable to marshal fragmented handshakes")]
1165 ErrUnableToMarshalFragmented,
1166 #[error("invalid state machine transition")]
1168 ErrInvalidFsmTransition,
1169 #[error("ApplicationData with epoch of 0")]
1171 ErrApplicationDataEpochZero,
1172 #[error("unhandled contentType")]
1174 ErrUnhandledContextType,
1175 #[error("context canceled")]
1177 ErrContextCanceled,
1178 #[error("empty fragment")]
1180 ErrEmptyFragment,
1181 #[error("Alert is Fatal or Close Notify")]
1183 ErrAlertFatalOrClose,
1184 #[error(
1186 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
1187 )]
1188 ErrFragmentBufferOverflow {
1189 new_size: usize,
1191 max_size: usize,
1193 },
1194 #[error("Client transport is not set yet")]
1196 ErrClientTransportNotSet,
1197
1198 #[error("endpoint stopping")]
1202 EndpointStopping,
1203 #[error("too many connections")]
1207 TooManyConnections,
1208 #[error("invalid DNS name: {0}")]
1210 InvalidDnsName(String),
1211 #[error("invalid remote address: {0}")]
1215 InvalidRemoteAddress(SocketAddr),
1216 #[error("no client config")]
1218 NoClientConfig,
1219 #[error("no server config")]
1221 NoServerConfig,
1222
1223 #[error("raw is too small for a SCTP chunk")]
1226 ErrChunkHeaderTooSmall,
1227 #[error("not enough data left in SCTP packet to satisfy requested length")]
1229 ErrChunkHeaderNotEnoughSpace,
1230 #[error("chunk PADDING is non-zero at offset")]
1232 ErrChunkHeaderPaddingNonZero,
1233 #[error("chunk has invalid length")]
1235 ErrChunkHeaderInvalidLength,
1236
1237 #[error("ChunkType is not of type ABORT")]
1239 ErrChunkTypeNotAbort,
1240 #[error("failed build Abort Chunk")]
1242 ErrBuildAbortChunkFailed,
1243 #[error("ChunkType is not of type COOKIEACK")]
1245 ErrChunkTypeNotCookieAck,
1246 #[error("ChunkType is not of type COOKIEECHO")]
1248 ErrChunkTypeNotCookieEcho,
1249 #[error("ChunkType is not of type ctError")]
1251 ErrChunkTypeNotCt,
1252 #[error("failed build Error Chunk")]
1254 ErrBuildErrorChunkFailed,
1255 #[error("failed to marshal stream")]
1257 ErrMarshalStreamFailed,
1258 #[error("chunk too short")]
1260 ErrChunkTooShort,
1261 #[error("ChunkType is not of type ForwardTsn")]
1263 ErrChunkTypeNotForwardTsn,
1264 #[error("ChunkType is not of type HEARTBEAT")]
1266 ErrChunkTypeNotHeartbeat,
1267 #[error("ChunkType is not of type HEARTBEATACK")]
1269 ErrChunkTypeNotHeartbeatAck,
1270 #[error("heartbeat is not long enough to contain Heartbeat Info")]
1272 ErrHeartbeatNotLongEnoughInfo,
1273 #[error("failed to parse param type")]
1275 ErrParseParamTypeFailed,
1276 #[error("heartbeat should only have HEARTBEAT param")]
1278 ErrHeartbeatParam,
1279 #[error("failed unmarshalling param in Heartbeat Chunk")]
1281 ErrHeartbeatChunkUnmarshal,
1282 #[error("unimplemented")]
1284 ErrUnimplemented,
1285 #[error("heartbeat Ack must have one param")]
1287 ErrHeartbeatAckParams,
1288 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
1290 ErrHeartbeatAckNotHeartbeatInfo,
1291 #[error("unable to marshal parameter for Heartbeat Ack")]
1293 ErrHeartbeatAckMarshalParam,
1294
1295 #[error("raw is too small for error cause")]
1297 ErrErrorCauseTooSmall,
1298
1299 #[error("unhandled ParamType: {typ}")]
1301 ErrParamTypeUnhandled {
1302 typ: u16,
1304 },
1305
1306 #[error("unexpected ParamType")]
1308 ErrParamTypeUnexpected,
1309
1310 #[error("param header too short")]
1312 ErrParamHeaderTooShort,
1313 #[error("param self reported length is shorter than header length")]
1315 ErrParamHeaderSelfReportedLengthShorter,
1316 #[error("param self reported length is longer than header length")]
1318 ErrParamHeaderSelfReportedLengthLonger,
1319 #[error("failed to parse param type")]
1321 ErrParamHeaderParseFailed,
1322
1323 #[error("packet to short")]
1325 ErrParamPacketTooShort,
1326 #[error("outgoing SSN reset request parameter too short")]
1328 ErrSsnResetRequestParamTooShort,
1329 #[error("failed unmarshalling SSN reset request parameter in RE-CONFIG chunk")]
1331 ErrUnmarshalSsnResetRequestParam,
1332 #[error("reconfig response parameter too short")]
1334 ErrReconfigRespParamTooShort,
1335 #[error("failed unmarshalling re-configuration response parameter in RE-CONFIG chunk")]
1337 ErrUnmarshalReconfigRespParam,
1338 #[error("invalid algorithm type")]
1340 ErrInvalidAlgorithmType,
1341
1342 #[error("failed to parse param type")]
1344 ErrInitChunkParseParamTypeFailed,
1345 #[error("failed unmarshalling param in Init Chunk")]
1347 ErrInitChunkUnmarshalParam,
1348 #[error("unable to marshal parameter for INIT/INITACK")]
1350 ErrInitAckMarshalParam,
1351
1352 #[error("ChunkType is not of type INIT")]
1354 ErrChunkTypeNotTypeInit,
1355 #[error("chunk Value isn't long enough for mandatory parameters exp")]
1357 ErrChunkValueNotLongEnough,
1358 #[error("ChunkType of type INIT flags must be all 0")]
1360 ErrChunkTypeInitFlagZero,
1361 #[error("failed to unmarshal INIT body")]
1363 ErrChunkTypeInitUnmarshalFailed,
1364 #[error("failed marshaling INIT common data")]
1366 ErrChunkTypeInitMarshalFailed,
1367 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
1369 ErrChunkTypeInitInitiateTagZero,
1370 #[error("INIT ACK inbound stream request must be > 0")]
1372 ErrInitInboundStreamRequestZero,
1373 #[error("INIT ACK outbound stream request must be > 0")]
1375 ErrInitOutboundStreamRequestZero,
1376 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
1378 ErrInitAdvertisedReceiver1500,
1379
1380 #[error("packet is smaller than the header size")]
1382 ErrChunkPayloadSmall,
1383 #[error("ChunkType is not of type PayloadData")]
1385 ErrChunkTypeNotPayloadData,
1386 #[error("failed unmarshalling payload data chunk")]
1388 ErrChunkUnmarshalPayloadData,
1389 #[error("ChunkType is not of type Reconfig")]
1391 ErrChunkTypeNotReconfig,
1392 #[error("ChunkReconfig has invalid ParamA")]
1394 ErrChunkReconfigInvalidParamA,
1395
1396 #[error("failed to parse param type")]
1398 ErrChunkParseParamTypeFailed,
1399 #[error("unable to marshal parameter A for reconfig")]
1401 ErrChunkMarshalParamAReconfigFailed,
1402 #[error("unable to marshal parameter B for reconfig")]
1404 ErrChunkMarshalParamBReconfigFailed,
1405
1406 #[error("ChunkType is not of type SACK")]
1408 ErrChunkTypeNotSack,
1409 #[error("SACK Chunk size is not large enough to contain header")]
1411 ErrSackSizeNotLargeEnoughInfo,
1412 #[error("failed unmarshalling SACK chunk")]
1414 ErrChunkUnmarshalSack,
1415
1416 #[error("invalid chunk size")]
1418 ErrInvalidChunkSize,
1419 #[error("ChunkType is not of type SHUTDOWN")]
1421 ErrChunkTypeNotShutdown,
1422 #[error("failed unmarshalling shutdown chunk")]
1424 ErrChunkUnmarshalShutdown,
1425
1426 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1428 ErrChunkTypeNotShutdownAck,
1429 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1431 ErrChunkTypeNotShutdownComplete,
1432
1433 #[error("raw is smaller than the minimum length for a SCTP packet")]
1435 ErrPacketRawTooSmall,
1436 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1438 ErrParseSctpChunkNotEnoughData,
1439 #[error("failed to unmarshal, contains unknown chunk type")]
1441 ErrUnmarshalUnknownChunkType,
1442 #[error("checksum mismatch theirs")]
1444 ErrChecksumMismatch,
1445
1446 #[error("unexpected chunk popped (unordered)")]
1448 ErrUnexpectedChuckPoppedUnordered,
1449 #[error("unexpected chunk popped (ordered)")]
1451 ErrUnexpectedChuckPoppedOrdered,
1452 #[error("unexpected q state (should've been selected)")]
1454 ErrUnexpectedQState,
1455 #[error("try again")]
1457 ErrTryAgain,
1458
1459 #[error("abort chunk, with following errors: {0}")]
1461 ErrAbortChunk(String),
1462 #[error("shutdown called in non-Established state")]
1464 ErrShutdownNonEstablished,
1465 #[error("association closed before connecting")]
1467 ErrAssociationClosedBeforeConn,
1468 #[error("association init failed")]
1470 ErrAssociationInitFailed,
1471 #[error("association handshake closed")]
1473 ErrAssociationHandshakeClosed,
1474 #[error("silently discard")]
1476 ErrSilentlyDiscard,
1477 #[error("the init not stored to send")]
1479 ErrInitNotStoredToSend,
1480 #[error("cookieEcho not stored to send")]
1482 ErrCookieEchoNotStoredToSend,
1483 #[error("sctp packet must not have a source port of 0")]
1485 ErrSctpPacketSourcePortZero,
1486 #[error("sctp packet must not have a destination port of 0")]
1488 ErrSctpPacketDestinationPortZero,
1489 #[error("init chunk must not be bundled with any other chunk")]
1491 ErrInitChunkBundled,
1492 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1494 ErrInitChunkVerifyTagNotZero,
1495 #[error("todo: handle Init when in state")]
1497 ErrHandleInitState,
1498 #[error("no cookie in InitAck")]
1500 ErrInitAckNoCookie,
1501 #[error("there already exists a stream with identifier")]
1503 ErrStreamAlreadyExist,
1504 #[error("Failed to create a stream with identifier")]
1506 ErrStreamCreateFailed,
1507 #[error("unable to be popped from inflight queue TSN")]
1509 ErrInflightQueueTsnPop,
1510 #[error("requested non-existent TSN")]
1512 ErrTsnRequestNotExist,
1513 #[error("sending reset packet in non-Established state")]
1515 ErrResetPacketInStateNotExist,
1516 #[error("unexpected parameter type")]
1518 ErrParameterType,
1519 #[error("sending payload data in non-Established state")]
1521 ErrPayloadDataStateNotExist,
1522 #[error("unhandled chunk type")]
1524 ErrChunkTypeUnhandled,
1525 #[error("handshake failed (INIT ACK)")]
1527 ErrHandshakeInitAck,
1528 #[error("handshake failed (COOKIE ECHO)")]
1530 ErrHandshakeCookieEcho,
1531
1532 #[error("outbound packet larger than maximum message size")]
1534 ErrOutboundPacketTooLarge,
1535 #[error("Stream closed")]
1537 ErrStreamClosed,
1538 #[error("Stream not existed")]
1540 ErrStreamNotExisted,
1541 #[error("Association not existed")]
1543 ErrAssociationNotExisted,
1544 #[error("Transport not existed")]
1546 ErrTransportNoExisted,
1547 #[error("Io EOF")]
1549 ErrEof,
1550 #[error("Invalid SystemTime")]
1552 ErrInvalidSystemTime,
1553 #[error("Net Conn read error")]
1555 ErrNetConnRead,
1556 #[error("Max Data Channel ID")]
1558 ErrMaxDataChannelID,
1559
1560 #[error(
1563 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1564 )]
1565 UnexpectedEndOfBuffer {
1566 expected: usize,
1568 actual: usize,
1570 },
1571 #[error("Unknown MessageType {0}")]
1573 InvalidMessageType(u8),
1574 #[error("Unknown ChannelType {0}")]
1576 InvalidChannelType(u8),
1577 #[error("Unknown PayloadProtocolIdentifier {0}")]
1579 InvalidPayloadProtocolIdentifier(u8),
1580 #[error("Unknow Protocol")]
1582 UnknownProtocol,
1583
1584 #[error("stream is nil")]
1587 ErrNilStream,
1588 #[error("incomplete frame header")]
1590 ErrIncompleteFrameHeader,
1591 #[error("incomplete frame data")]
1593 ErrIncompleteFrameData,
1594 #[error("incomplete file header")]
1596 ErrIncompleteFileHeader,
1597 #[error("IVF signature mismatch")]
1599 ErrSignatureMismatch,
1600 #[error("IVF version unknown, parser may not parse correctly")]
1602 ErrUnknownIVFVersion,
1603
1604 #[error("file not opened")]
1606 ErrFileNotOpened,
1607 #[error("invalid nil packet")]
1609 ErrInvalidNilPacket,
1610
1611 #[error("bad header signature")]
1613 ErrBadIDPageSignature,
1614 #[error("wrong header, expected beginning of stream")]
1616 ErrBadIDPageType,
1617 #[error("payload for id page must be 19 bytes")]
1619 ErrBadIDPageLength,
1620 #[error("bad payload signature")]
1622 ErrBadIDPagePayloadSignature,
1623 #[error("not enough data for payload header")]
1625 ErrShortPageHeader,
1626 #[error("bad OpusTags signature")]
1628 ErrBadOpusTagsSignature,
1629 #[error("unsupported channel mapping family")]
1631 ErrUnsupportedChannelMappingFamily,
1632
1633 #[error("data is not a H264 bitstream")]
1635 ErrDataIsNotH264Stream,
1636 #[error("data is not a H265 bitstream")]
1638 ErrDataIsNotH265Stream,
1639 #[error("Io EOF")]
1641 ErrIoEOF,
1642
1643 #[error("mDNS: port not support, only 5353 is supported")]
1646 ErrMDNSPortNotSupported,
1647 #[error("mDNS: connection is closed")]
1649 ErrMDNSConnectionClosed,
1650 #[error("mDNS: query not found")]
1652 ErrMDNSQueryNotFound,
1653 #[error("mDNS: parsing/packing of this type isn't available yet")]
1655 ErrNotStarted,
1656 #[error("mDNS: parsing/packing of this section has completed")]
1658 ErrSectionDone,
1659 #[error("mDNS: parsing/packing of this section is header")]
1661 ErrSectionHeader,
1662 #[error("mDNS: insufficient data for base length type")]
1664 ErrBaseLen,
1665 #[error("mDNS: insufficient data for calculated length type")]
1667 ErrCalcLen,
1668 #[error("mDNS: segment prefix is reserved")]
1670 ErrReserved,
1671 #[error("mDNS: too many pointers (>10)")]
1673 ErrTooManyPtr,
1674 #[error("mDNS: invalid pointer")]
1676 ErrInvalidPtr,
1677 #[error("mDNS: nil resource body")]
1679 ErrNilResourceBody,
1680 #[error("mDNS: insufficient data for resource body length")]
1682 ErrResourceLen,
1683 #[error("mDNS: segment length too long")]
1685 ErrSegTooLong,
1686 #[error("mDNS: zero length segment")]
1688 ErrZeroSegLen,
1689 #[error("mDNS: resource length too long")]
1691 ErrResTooLong,
1692 #[error("mDNS: too many Questions to pack (>65535)")]
1694 ErrTooManyQuestions,
1695 #[error("mDNS: too many Answers to pack (>65535)")]
1697 ErrTooManyAnswers,
1698 #[error("mDNS: too many Authorities to pack (>65535)")]
1700 ErrTooManyAuthorities,
1701 #[error("mDNS: too many Additionals to pack (>65535)")]
1703 ErrTooManyAdditionals,
1704 #[error("mDNS: name is not in canonical format (it must end with a .)")]
1706 ErrNonCanonicalName,
1707 #[error("mDNS: character string exceeds maximum length (255)")]
1709 ErrStringTooLong,
1710 #[error("mDNS: compressed name in SRV resource data")]
1712 ErrCompressedSrv,
1713 #[error("mDNS: empty builder msg")]
1715 ErrEmptyBuilderMsg,
1716
1717 #[error("connection closed")]
1721 ErrConnectionClosed,
1722
1723 #[error("data channel closed")]
1726 ErrDataChannelClosed,
1727
1728 #[error("data channel is not open yet")]
1732 ErrDataChannelNotOpen,
1733
1734 #[error("data channel stream identifier has not been assigned yet")]
1742 ErrDataChannelStreamIdNotAssigned,
1743
1744 #[error("data channel not existed")]
1747 ErrDataChannelNotExisted,
1748
1749 #[error("data channel send buffer full")]
1753 ErrSendBufferFull,
1754
1755 #[error("x509Cert expired")]
1757 ErrCertificateExpired,
1758
1759 #[error("turn server credentials required")]
1762 ErrNoTurnCredentials,
1763
1764 #[error("invalid turn server credentials")]
1767 ErrTurnCredentials,
1768
1769 #[error("track already exists")]
1771 ErrExistingTrack,
1772
1773 #[error("track not existed")]
1775 ErrTrackNotExisted,
1776
1777 #[error("private key type not supported")]
1780 ErrPrivateKeyType,
1781
1782 #[error("peerIdentity cannot be modified")]
1785 ErrModifyingPeerIdentity,
1786
1787 #[error("certificates cannot be modified")]
1790 ErrModifyingCertificates,
1791
1792 #[error("no certificate")]
1794 ErrNonCertificate,
1795
1796 #[error("bundle policy cannot be modified")]
1799 ErrModifyingBundlePolicy,
1800
1801 #[error("rtcp mux policy cannot be modified")]
1804 ErrModifyingRTCPMuxPolicy,
1805
1806 #[error("ice candidate pool size cannot be modified")]
1809 ErrModifyingICECandidatePoolSize,
1810
1811 #[error("data channel label exceeds size limit")]
1814 ErrStringSizeLimit,
1815
1816 #[error("negotiated set without channel id")]
1820 ErrNegotiatedWithoutID,
1821
1822 #[error("both max_packet_life_time and max_retransmits was set")]
1827 ErrRetransmitsOrPacketLifeTime,
1828
1829 #[error("codec not found")]
1831 ErrCodecNotFound,
1832
1833 #[error("remote description is not set")]
1836 ErrNoRemoteDescription,
1837
1838 #[error("offer SDP semantics does not match configuration")]
1841 ErrIncorrectSDPSemantics,
1842
1843 #[error("operation can not be run in current signaling state")]
1845 ErrIncorrectSignalingState,
1846
1847 #[error("protocol is larger then 65535 bytes")]
1850 ErrProtocolTooLarge,
1851
1852 #[error("RtpSender not created by this PeerConnection")]
1855 ErrSenderNotCreatedByConnection,
1856
1857 #[error("RtpSender's initial_track_id has already been set")]
1860 ErrSenderInitialTrackIdAlreadySet,
1861
1862 #[error("set_remote_description called with no fingerprint")]
1865 ErrSessionDescriptionNoFingerprint,
1866
1867 #[error("set_remote_description called with an invalid fingerprint")]
1870 ErrSessionDescriptionInvalidFingerprint,
1871
1872 #[error("set_remote_description called with multiple conflicting fingerprint")]
1875 ErrSessionDescriptionConflictingFingerprints,
1876
1877 #[error("set_remote_description called with no ice-ufrag")]
1880 ErrSessionDescriptionMissingIceUfrag,
1881
1882 #[error("set_remote_description called with no ice-pwd")]
1885 ErrSessionDescriptionMissingIcePwd,
1886
1887 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
1890 ErrSessionDescriptionConflictingIceUfrag,
1891
1892 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
1895 ErrSessionDescriptionConflictingIcePwd,
1896
1897 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
1899 ErrNoSRTPProtectionProfile,
1900
1901 #[error("failed to generate certificate fingerprint")]
1903 ErrFailedToGenerateCertificateFingerprint,
1904
1905 #[error("operation failed no codecs are available")]
1907 ErrNoCodecsAvailable,
1908
1909 #[error("unable to start track, codec is not supported by remote")]
1911 ErrUnsupportedCodec,
1912
1913 #[error("Invalid state error")]
1915 InvalidStateError,
1916
1917 #[error("Invalid modification error")]
1919 InvalidModificationError,
1920
1921 #[error("Range error {0}")]
1923 RangeError(String),
1924
1925 #[error("unable to populate media section, RTPSender created with no codecs")]
1928 ErrSenderWithNoCodecs,
1929
1930 #[error("unable to populate media section, RTPSender created with no ssrcs")]
1933 ErrSenderWithNoSSRCs,
1934
1935 #[error("new track must be of the same kind as previous")]
1937 ErrRTPSenderNewTrackHasIncorrectKind,
1938
1939 #[error("new track has incorrect envelope")]
1941 ErrRTPSenderNewTrackHasIncorrectEnvelope,
1942
1943 #[error("Sequence number transformer must be enabled before sending data")]
1945 ErrRTPSenderDataSent,
1946
1947 #[error("Sequence number transformer has been already enabled")]
1949 ErrRTPSenderSeqTransEnabled,
1950
1951 #[error("failed to unbind TrackLocal from PeerConnection")]
1953 ErrUnbindFailed,
1954
1955 #[error("the requested codec does not have a payloader")]
1957 ErrNoPayloaderForCodec,
1958
1959 #[error("a header extension must be registered with the same direction each time")]
1962 ErrRegisterHeaderExtensionInvalidDirection,
1963
1964 #[error("invalid direction")]
1966 ErrInvalidDirection,
1967
1968 #[error(
1971 "no header extension ID was free to use(this means the maximum of 15 extensions have been registered)"
1972 )]
1973 ErrRegisterHeaderExtensionNoFreeID,
1974
1975 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
1977 ErrSimulcastProbeOverflow,
1978
1979 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
1981 ErrDetachNotEnabled,
1982 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
1984 ErrDetachBeforeOpened,
1985 #[error("the DTLS transport has not started yet")]
1987 ErrDtlsTransportNotStarted,
1988 #[error("failed extracting keys from DTLS for SRTP")]
1990 ErrDtlsKeyExtractionFailed,
1991 #[error("failed to start SRTP")]
1993 ErrFailedToStartSRTP,
1994 #[error("failed to start SRTCP")]
1996 ErrFailedToStartSRTCP,
1997 #[error("attempted to start DTLSTransport that is not in new state")]
1999 ErrInvalidDTLSStart,
2000 #[error("peer didn't provide certificate via DTLS")]
2002 ErrNoRemoteCertificate,
2003 #[error("identity provider is not implemented")]
2005 ErrIdentityProviderNotImplemented,
2006 #[error("remote certificate does not match any fingerprint")]
2008 ErrNoMatchingCertificateFingerprint,
2009 #[error("unsupported fingerprint algorithm")]
2011 ErrUnsupportedFingerprintAlgorithm,
2012 #[error("ICE connection not started")]
2014 ErrICEConnectionNotStarted,
2015 #[error("unknown candidate type")]
2017 ErrICECandidateTypeUnknown,
2018 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
2020 ErrICEInvalidConvertCandidateType,
2021 #[error("ICEAgent does not exist")]
2023 ErrICEAgentNotExist,
2024 #[error("unable to convert ICE candidates to ICECandidates")]
2026 ErrICECandidatesConversionFailed,
2027 #[error("unknown ICE Role")]
2029 ErrICERoleUnknown,
2030 #[error("unknown protocol")]
2032 ErrICEProtocolUnknown,
2033 #[error("gatherer not started")]
2035 ErrICEGathererNotStarted,
2036 #[error("unknown network type")]
2038 ErrNetworkTypeUnknown,
2039 #[error("new sdp does not match previous offer")]
2041 ErrSDPDoesNotMatchOffer,
2042 #[error("new sdp does not match previous answer")]
2044 ErrSDPDoesNotMatchAnswer,
2045 #[error("provided value is not a valid enum value of type SDPType")]
2047 ErrPeerConnSDPTypeInvalidValue,
2048 #[error("invalid state change op")]
2050 ErrPeerConnStateChangeInvalid,
2051 #[error("unhandled state change op")]
2053 ErrPeerConnStateChangeUnhandled,
2054 #[error("invalid SDP type supplied to SetLocalDescription()")]
2056 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
2057 #[error("remoteDescription contained media section without mid value")]
2059 ErrPeerConnRemoteDescriptionWithoutMidValue,
2060 #[error("localDescription contained media section without mid value")]
2062 ErrPeerConnLocalDescriptionWithoutMidValue,
2063 #[error("remoteDescription has not been set yet")]
2065 ErrPeerConnRemoteDescriptionNil,
2066 #[error("localDescription has not been set yet")]
2068 ErrPeerConnLocalDescriptionNil,
2069 #[error("single media section has an explicit SSRC")]
2071 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
2072 #[error("could not add transceiver for remote SSRC")]
2074 ErrPeerConnRemoteSSRCAddTransceiver,
2075 #[error("mid RTP Extensions required for Simulcast")]
2077 ErrPeerConnSimulcastMidRTPExtensionRequired,
2078 #[error("stream id RTP Extensions required for Simulcast")]
2080 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
2081 #[error("incoming SSRC failed Simulcast probing")]
2083 ErrPeerConnSimulcastIncomingSSRCFailed,
2084 #[error("failed collecting stats")]
2086 ErrPeerConnStatsCollectionFailed,
2087 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
2089 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
2090 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
2092 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
2093 #[error("add_transceiver_from_kind currently only supports recvonly")]
2095 ErrPeerConnAddTransceiverFromKindSupport,
2096 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
2098 ErrPeerConnAddTransceiverFromTrackSupport,
2099 #[error("TODO set_identity_provider")]
2101 ErrPeerConnSetIdentityProviderNotImplemented,
2102 #[error("write_rtcp failed to open write_stream")]
2104 ErrPeerConnWriteRTCPOpenWriteStream,
2105 #[error("cannot find transceiver with mid")]
2107 ErrPeerConnTransceiverMidNil,
2108 #[error("DTLSTransport must not be nil")]
2110 ErrRTPReceiverDTLSTransportNil,
2111 #[error("Receive has already been called")]
2113 ErrRTPReceiverReceiveAlreadyCalled,
2114 #[error("unable to find stream for Track with SSRC")]
2116 ErrRTPReceiverWithSSRCTrackStreamNotFound,
2117 #[error("no trackStreams found for SSRC")]
2119 ErrRTPReceiverForSSRCTrackStreamNotFound,
2120 #[error("no trackStreams found for RID")]
2122 ErrRTPReceiverForRIDTrackStreamNotFound,
2123 #[error("invalid RTP Receiver transition")]
2125 ErrRTPReceiverStateChangeInvalid,
2126 #[error("Track must not be nil")]
2128 ErrRTPSenderTrackNil,
2129 #[error("RTPSender not existed")]
2131 ErrRTPSenderNotExisted,
2132 #[error("Sender Track has been removed or replaced to nil")]
2134 ErrRTPSenderTrackRemoved,
2135 #[error("Sender cannot add encoding as rid is empty")]
2137 ErrRTPSenderRidNil,
2138 #[error("Sender cannot add encoding as there is no base track")]
2140 ErrRTPSenderNoBaseEncoding,
2141 #[error("Sender cannot add encoding as provided track does not match base track")]
2143 ErrRTPSenderBaseEncodingMismatch,
2144 #[error("Sender cannot encoding due to RID collision")]
2146 ErrRTPSenderRIDCollision,
2147 #[error("Sender does not have track for RID")]
2149 ErrRTPSenderNoTrackForRID,
2150 #[error("RTPReceiver not existed")]
2152 ErrRTPReceiverNotExisted,
2153 #[error("DTLSTransport must not be nil")]
2155 ErrRTPSenderDTLSTransportNil,
2156 #[error("Send has already been called")]
2158 ErrRTPSenderSendAlreadyCalled,
2159 #[error("RTPTransceiver not existed")]
2161 ErrRTPTransceiverNotExisted,
2162 #[error("SCTPTransport not existed")]
2164 ErrSCTPTransportNotExisted,
2165 #[error("DTLSTransport not existed")]
2167 ErrDTLSTransportNotExisted,
2168 #[error("errRTPSenderTrackNil")]
2170 ErrRTPTransceiverCannotChangeMid,
2171 #[error("invalid state change in RTPTransceiver.setSending")]
2173 ErrRTPTransceiverSetSendingInvalidState,
2174 #[error("unsupported codec type by this transceiver")]
2176 ErrRTPTransceiverCodecUnsupported,
2177 #[error("DTLS not established")]
2179 ErrSCTPTransportDTLS,
2180 #[error("add_transceiver_sdp() called with 0 transceivers")]
2182 ErrSDPZeroTransceivers,
2183 #[error("invalid Media Section. Media + DataChannel both enabled")]
2185 ErrSDPMediaSectionMediaDataChanInvalid,
2186 #[error("invalid Media Section Track Index")]
2188 ErrSDPMediaSectionTrackInvalid,
2189 #[error("can't rollback from stable state")]
2191 ErrSignalingStateCannotRollback,
2192 #[error("invalid proposed signaling state transition: {0}")]
2194 ErrSignalingStateProposedTransitionInvalid(String),
2195 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
2197 ErrStatsICECandidateStateInvalid,
2198 #[error("ICETransport can only be called in ICETransportStateNew")]
2200 ErrICETransportNotInNew,
2201 #[error("bad Certificate PEM format")]
2203 ErrCertificatePEMFormatError,
2204 #[error("SCTP is not established")]
2206 ErrSCTPNotEstablished,
2207
2208 #[error("DataChannel is not opened")]
2210 ErrClosedPipe,
2211 #[error("Interceptor is not bind")]
2213 ErrInterceptorNotBind,
2214 #[error("excessive retries in CreateOffer")]
2216 ErrExcessiveRetries,
2217
2218 #[error("not long enough to be a RTP Packet")]
2220 ErrRTPTooShort,
2221
2222 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
2224 SimulcastRidParseErrorSyntaxIdDirSplit,
2225 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
2227 SimulcastRidParseErrorUnknownDirection,
2228
2229 #[error("codec not found")]
2232 CodecNotFound,
2233 #[error("missing whitespace")]
2235 MissingWhitespace,
2236 #[error("missing colon")]
2238 MissingColon,
2239 #[error("payload type not found")]
2241 PayloadTypeNotFound,
2242 #[error("SdpInvalidSyntax: {0}")]
2244 SdpInvalidSyntax(String),
2245 #[error("SdpInvalidValue: {0}")]
2247 SdpInvalidValue(String),
2248 #[error("sdp: empty time_descriptions")]
2250 SdpEmptyTimeDescription,
2251 #[error("parse extmap: {0}")]
2253 ParseExtMap(String),
2254 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
2256 )]
2257 SyntaxError {
2258 s: String,
2260 p: usize,
2262 },
2263
2264 #[error("invalid PEM: {0}")]
2267 InvalidPEM(String),
2268 #[error("parse ip: {0}")]
2270 ParseIp(#[from] net::AddrParseError),
2271 #[error("parse int: {0}")]
2273 ParseInt(#[from] ParseIntError),
2274 #[error("{0}")]
2276 Io(#[source] IoError),
2277 #[error("url parse: {0}")]
2279 Url(#[from] url::ParseError),
2280 #[error("utf8: {0}")]
2282 Utf8(#[from] FromUtf8Error),
2283 #[error("{0}")]
2285 Std(#[source] StdError),
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("crypto: {0}")]
2331 Crypto(String),
2332 #[error("{0}")]
2333 Other(String),
2335}
2336
2337impl Error {
2338 pub fn from_std<T>(error: T) -> Self
2341 where
2342 T: std::error::Error + Send + Sync + 'static,
2343 {
2344 Error::Std(StdError(Box::new(error)))
2345 }
2346
2347 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
2352 if let Error::Std(s) = self {
2353 return s.0.downcast_ref();
2354 }
2355
2356 None
2357 }
2358}
2359
2360#[derive(Debug, Error)]
2366#[error("io error: {0}")]
2367pub struct IoError(#[from] pub io::Error);
2368
2369impl PartialEq for IoError {
2371 fn eq(&self, other: &Self) -> bool {
2372 self.0.kind() == other.0.kind()
2373 }
2374}
2375
2376impl From<io::Error> for Error {
2377 fn from(e: io::Error) -> Self {
2378 Error::Io(IoError(e))
2379 }
2380}
2381
2382#[derive(Debug, Error)]
2392#[error("{0}")]
2393pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
2394
2395impl PartialEq for StdError {
2396 fn eq(&self, _: &Self) -> bool {
2397 false
2398 }
2399}
2400
2401impl<T> From<std::sync::PoisonError<T>> for Error {
2402 fn from(e: std::sync::PoisonError<T>) -> Self {
2403 Error::PoisonError(e.to_string())
2404 }
2405}
2406
2407impl From<SystemTimeError> for Error {
2408 fn from(e: SystemTimeError) -> Self {
2409 Error::Other(e.to_string())
2410 }
2411}
2412
2413pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
2417 if errs.is_empty() {
2418 Ok(())
2419 } else {
2420 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
2421 Err(Error::Other(errs_strs.join("\n")))
2422 }
2423}