\doxysection{icmpv6.\+h}
\label{icmpv6_8h_source}\index{include/osmocom/netif/icmpv6.h@{include/osmocom/netif/icmpv6.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{3 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{4 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{5 \textcolor{preprocessor}{\#include <netinet/in.h>}}
\DoxyCodeLine{6 }
\DoxyCodeLine{7 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{8 \textcolor{preprocessor}{\#include <osmocom/core/endian.h>}}
\DoxyCodeLine{9 }
\DoxyCodeLine{10 \textcolor{preprocessor}{\#define ICMPv6\_OPT\_TYPE\_PREFIX\_INFO 0x03}}
\DoxyCodeLine{11 }
\DoxyCodeLine{12 \textcolor{keyword}{struct }osmo\_icmpv6\_hdr \{}
\DoxyCodeLine{13         uint8\_t type;}
\DoxyCodeLine{14         uint8\_t code;}
\DoxyCodeLine{15         uint16\_t csum;}
\DoxyCodeLine{16 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{17 }
\DoxyCodeLine{18 \textcolor{keyword}{struct }osmo\_icmpv6\_echo\_hdr \{}
\DoxyCodeLine{19         \textcolor{keyword}{struct }osmo\_icmpv6\_hdr hdr;}
\DoxyCodeLine{20         uint16\_t ident;         \textcolor{comment}{/* Identifier */}}
\DoxyCodeLine{21         uint16\_t seq;           \textcolor{comment}{/* Sequence number */}}
\DoxyCodeLine{22         uint8\_t data[0];        \textcolor{comment}{/* Data */}}
\DoxyCodeLine{23 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{comment}{/* RFC4861 Section 4.1 */}}
\DoxyCodeLine{26 \textcolor{keyword}{struct }osmo\_icmpv6\_rsol\_hdr \{}
\DoxyCodeLine{27         \textcolor{keyword}{struct }osmo\_icmpv6\_hdr hdr;}
\DoxyCodeLine{28         uint32\_t reserved;}
\DoxyCodeLine{29         uint8\_t options[0];}
\DoxyCodeLine{30 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{31 }
\DoxyCodeLine{32 \textcolor{comment}{/* RFC4861 Section 4.2 */}}
\DoxyCodeLine{33 \textcolor{keyword}{struct }osmo\_icmpv6\_radv\_hdr \{}
\DoxyCodeLine{34         \textcolor{keyword}{struct }osmo\_icmpv6\_hdr hdr;}
\DoxyCodeLine{35         uint8\_t cur\_ho\_limit;}
\DoxyCodeLine{36 \textcolor{preprocessor}{\#if OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{37         uint8\_t res:6,}
\DoxyCodeLine{38                 m:1,}
\DoxyCodeLine{39                 o:1;}
\DoxyCodeLine{40 \textcolor{preprocessor}{\#elif OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{41 \textcolor{comment}{/* auto-\/generated from the little endian part above (libosmocore/contrib/struct\_endianness.py) */}}
\DoxyCodeLine{42         uint8\_t o:1, m:1, res:6;}
\DoxyCodeLine{43 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{44         uint16\_t router\_lifetime;}
\DoxyCodeLine{45         uint32\_t reachable\_time;}
\DoxyCodeLine{46         uint32\_t retrans\_timer;}
\DoxyCodeLine{47         uint8\_t options[0];}
\DoxyCodeLine{48 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{49 }
\DoxyCodeLine{50 }
\DoxyCodeLine{51 \textcolor{comment}{/* RFC4861 Section 4.6 */}}
\DoxyCodeLine{52 \textcolor{keyword}{struct }osmo\_icmpv6\_opt\_hdr \{}
\DoxyCodeLine{53         uint8\_t type;}
\DoxyCodeLine{54         \textcolor{comment}{/* length in units of 8 octets, including type+len! */}}
\DoxyCodeLine{55         uint8\_t len;}
\DoxyCodeLine{56         uint8\_t data[0];}
\DoxyCodeLine{57 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{58 }
\DoxyCodeLine{59 \textcolor{comment}{/* RFC4861 Section 4.6.2 */}}
\DoxyCodeLine{60 \textcolor{keyword}{struct }osmo\_icmpv6\_opt\_prefix \{}
\DoxyCodeLine{61         \textcolor{keyword}{struct }osmo\_icmpv6\_opt\_hdr hdr;}
\DoxyCodeLine{62         uint8\_t prefix\_len;}
\DoxyCodeLine{63 \textcolor{preprocessor}{\#if OSMO\_IS\_LITTLE\_ENDIAN}}
\DoxyCodeLine{64         uint8\_t res:6,}
\DoxyCodeLine{65                 a:1,}
\DoxyCodeLine{66                 l:1;}
\DoxyCodeLine{67 \textcolor{preprocessor}{\#elif OSMO\_IS\_BIG\_ENDIAN}}
\DoxyCodeLine{68 \textcolor{comment}{/* auto-\/generated from the little endian part above (libosmocore/contrib/struct\_endianness.py) */}}
\DoxyCodeLine{69         uint8\_t l:1, a:1, res:6;}
\DoxyCodeLine{70 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{71         uint32\_t valid\_lifetime;}
\DoxyCodeLine{72         uint32\_t preferred\_lifetime;}
\DoxyCodeLine{73         uint32\_t res2;}
\DoxyCodeLine{74         uint8\_t prefix[16];}
\DoxyCodeLine{75 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{comment}{/* RFC4861 Section 4.6.4 */}}
\DoxyCodeLine{78 \textcolor{keyword}{struct }osmo\_icmpv6\_opt\_mtu \{}
\DoxyCodeLine{79         \textcolor{keyword}{struct }osmo\_icmpv6\_opt\_hdr hdr;}
\DoxyCodeLine{80         uint16\_t reserved;}
\DoxyCodeLine{81         uint32\_t mtu;}
\DoxyCodeLine{82 \} \_\_attribute\_\_ ((packed));}
\DoxyCodeLine{83 }
\DoxyCodeLine{84 uint16\_t osmo\_icmpv6\_prepend\_ip6hdr(\textcolor{keyword}{struct} msgb *msg, \textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *saddr,}
\DoxyCodeLine{85                                     \textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *daddr);}
\DoxyCodeLine{86 }
\DoxyCodeLine{87 \textcolor{keyword}{struct }msgb *osmo\_icmpv6\_construct\_rs(\textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *saddr);}
\DoxyCodeLine{88 \textcolor{keyword}{struct }msgb *osmo\_icmpv6\_construct\_ra(\textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *saddr,}
\DoxyCodeLine{89                                       \textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *daddr,}
\DoxyCodeLine{90                                       \textcolor{keyword}{const} \textcolor{keyword}{struct} in6\_addr *prefix,}
\DoxyCodeLine{91                                       uint32\_t mtu);}
\DoxyCodeLine{92 }
\DoxyCodeLine{93 \textcolor{keywordtype}{bool} osmo\_icmpv6\_validate\_router\_solicit(\textcolor{keyword}{const} uint8\_t *pack, \textcolor{keywordtype}{unsigned} len);}
\DoxyCodeLine{94 \textcolor{keyword}{struct }osmo\_icmpv6\_radv\_hdr *osmo\_icmpv6\_validate\_router\_adv(\textcolor{keyword}{const} uint8\_t *pack, \textcolor{keywordtype}{unsigned} len);}
\DoxyCodeLine{95 }
\DoxyCodeLine{96 \textcolor{preprocessor}{\#define foreach\_icmpv6\_opt(icmpv6\_pkt, icmpv6\_len, opt\_hdr) \(\backslash\)}}
\DoxyCodeLine{97 \textcolor{preprocessor}{        for (opt\_hdr = (struct osmo\_icmpv6\_opt\_hdr *)(icmpv6\_pkt)-\/>options; \(\backslash\)}}
\DoxyCodeLine{98 \textcolor{preprocessor}{             (uint8\_t *)(opt\_hdr) + sizeof(struct osmo\_icmpv6\_opt\_hdr) <= (((uint8\_t *)(icmpv6\_pkt)) + (icmpv6\_len)); \(\backslash\)}}
\DoxyCodeLine{99 \textcolor{preprocessor}{             opt\_hdr = (struct osmo\_icmpv6\_opt\_hdr *)((uint8\_t *)(opt\_hdr) + (opt\_hdr)-\/>len) \(\backslash\)}}
\DoxyCodeLine{100 \textcolor{preprocessor}{            )}}
\DoxyCodeLine{101 }
\DoxyCodeLine{102 \textcolor{comment}{/* RFC3307 link-\/local scope multicast address */}}
\DoxyCodeLine{103 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }in6\_addr osmo\_icmpv6\_all\_router\_mcast\_addr;}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint8\_t osmo\_icmpv6\_solicited\_node\_mcast\_addr\_prefix[13];}

\end{DoxyCode}
