Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
34a070f5
Commit
34a070f5
authored
Nov 30, 2020
by
Max Kellermann
Committed by
Max Kellermann
Nov 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/IPv[46]Address: add Cast(const sockaddr_in&)
parent
ac4975cd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
4 deletions
+22
-4
IPv4Address.cxx
src/net/IPv4Address.cxx
+1
-1
IPv4Address.hxx
src/net/IPv4Address.hxx
+10
-1
IPv6Address.cxx
src/net/IPv6Address.cxx
+1
-1
IPv6Address.hxx
src/net/IPv6Address.hxx
+10
-1
No files found.
src/net/IPv4Address.cxx
View file @
34a070f5
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
src/net/IPv4Address.hxx
View file @
34a070f5
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -158,6 +158,15 @@ public:
}
/**
* Cast a #sockaddr_in6 reference to an IPv6Address reference.
*/
static
constexpr
const
IPv4Address
&
Cast
(
const
struct
sockaddr_in
&
src
)
noexcept
{
/* this reinterpret_cast works because this class is
just a wrapper for struct sockaddr_in6 */
return
*
(
const
IPv4Address
*
)(
const
void
*
)
&
src
;
}
/**
* Return a downcasted reference to the address. This call is
* only legal after verifying SocketAddress::GetFamily().
*/
...
...
src/net/IPv6Address.cxx
View file @
34a070f5
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
src/net/IPv6Address.hxx
View file @
34a070f5
/*
* Copyright 2012-20
19
Max Kellermann <max.kellermann@gmail.com>
* Copyright 2012-20
20
Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -127,6 +127,15 @@ public:
}
/**
* Cast a #sockaddr_in6 reference to an IPv6Address reference.
*/
static
constexpr
const
IPv6Address
&
Cast
(
const
struct
sockaddr_in6
&
src
)
noexcept
{
/* this reinterpret_cast works because this class is
just a wrapper for struct sockaddr_in6 */
return
*
(
const
IPv6Address
*
)(
const
void
*
)
&
src
;
}
/**
* Return a downcasted reference to the address. This call is
* only legal after verifying SocketAddress::GetFamily().
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment