Skip to content

bpo-30987 - Support for ISO-TP protocol in SocketCAN #2956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added implementation for getsockname + unit tests
  • Loading branch information
pylessard committed Aug 3, 2017
commit 17c58d70c307ce8383a821cd6c954d5b561d49b0
15 changes: 11 additions & 4 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,10 @@ def testBCM(self):
@unittest.skipUnless(HAVE_SOCKET_CAN_ISOTP, 'CAN ISOTP required for this test.')
class ISOTPTest(unittest.TestCase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.interface = "vcan0"

def testCrucialConstants(self):
socket.AF_CAN
socket.PF_CAN
Expand All @@ -1749,14 +1753,17 @@ def testTooLongInterfaceName(self):
def testBind(self):
try:
with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_ISOTP) as s:
s.bind(("vcan0",1,2))

addr = (self.interface,0x123,0x456)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit pick: addr = self.interface, 0x123, 0x456

s.bind(addr)
self.assertEqual(s.getsockname(), addr)
except OSError as e:
if e.errno not in [errno.ENODEV, errno.EPROTONOSUPPORT]:
if e.errno == errno.ENODEV:
self.skipTest('network interface `%s` does not exist' %
self.interface)
else:
raise



@unittest.skipUnless(HAVE_SOCKET_RDS, 'RDS sockets required for this test.')
class BasicRDSTest(unittest.TestCase):

Expand Down
19 changes: 16 additions & 3 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,9 +1373,22 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
ifname = ifr.ifr_name;
}

return Py_BuildValue("O&h", PyUnicode_DecodeFSDefault,
ifname,
a->can_family);
switch (proto) {
#ifdef CAN_ISOTP
case CAN_ISOTP:
{
return Py_BuildValue("O&kk", PyUnicode_DecodeFSDefault,
ifname,
a->can_addr.tp.rx_id,
a->can_addr.tp.tx_id);
}
#endif
default:
{
return Py_BuildValue("O&", PyUnicode_DecodeFSDefault,
ifname);
}
}
}
#endif

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy