Changeset View
Changeset View
Standalone View
Standalone View
sys/netlink/route/base.h
- This file was added.
#ifndef _NETLINK_ROUTE_ROUTE_BASE_H_ | |||||
#define _NETLINK_ROUTE_ROUTE_BASE_H_ | |||||
/* | |||||
* Messages defined by the NETLINK_ROUTE subsystem | |||||
*/ | |||||
enum { | |||||
NL_RTM_BASE = 16, | |||||
#define NL_RTM_BASE NL_RTM_BASE | |||||
NL_RTM_NEWLINK = 16, | |||||
#define NL_RTM_NEWLINK NL_RTM_NEWLINK | |||||
NL_RTM_DELLINK, | |||||
#define NL_RTM_DELLINK NL_RTM_DELLINK | |||||
NL_RTM_GETLINK, | |||||
#define NL_RTM_GETLINK NL_RTM_GETLINK | |||||
NL_RTM_SETLINK, | |||||
#define NL_RTM_SETLINK NL_RTM_SETLINK | |||||
NL_RTM_NEWADDR = 20, | |||||
#define NL_RTM_NEWADDR NL_RTM_NEWADDR | |||||
NL_RTM_DELADDR, | |||||
#define NL_RTM_DELADDR NL_RTM_DELADDR | |||||
NL_RTM_GETADDR, | |||||
#define NL_RTM_GETADDR NL_RTM_GETADDR | |||||
NL_RTM_NEWROUTE = 24, | |||||
#define NL_RTM_NEWROUTE NL_RTM_NEWROUTE | |||||
NL_RTM_DELROUTE, | |||||
#define NL_RTM_DELROUTE NL_RTM_DELROUTE | |||||
NL_RTM_GETROUTE, | |||||
#define NL_RTM_GETROUTE NL_RTM_GETROUTE | |||||
NL_RTM_NEWNEIGH = 28, | |||||
#define NL_RTM_NEWNEIGH NL_RTM_NEWNEIGH | |||||
NL_RTM_DELNEIGH, | |||||
#define NL_RTM_DELNEIGH NL_RTM_DELNEIGH | |||||
NL_RTM_GETNEIGH, | |||||
#define NL_RTM_GETNEIGH NL_RTM_GETNEIGH | |||||
NL_RTM_NEWRULE = 32, | |||||
#define NL_RTM_NEWRULE NL_RTM_NEWRULE | |||||
NL_RTM_DELRULE, | |||||
#define NL_RTM_DELRULE NL_RTM_DELRULE | |||||
NL_RTM_GETRULE, | |||||
#define NL_RTM_GETRULE NL_RTM_GETRULE | |||||
NL_RTM_NEWQDISC = 36, | |||||
#define NL_RTM_NEWQDISC NL_RTM_NEWQDISC | |||||
NL_RTM_DELQDISC, | |||||
#define NL_RTM_DELQDISC NL_RTM_DELQDISC | |||||
NL_RTM_GETQDISC, | |||||
#define NL_RTM_GETQDISC NL_RTM_GETQDISC | |||||
NL_RTM_NEWTCLASS = 40, | |||||
#define NL_RTM_NEWTCLASS NL_RTM_NEWTCLASS | |||||
NL_RTM_DELTCLASS, | |||||
#define NL_RTM_DELTCLASS NL_RTM_DELTCLASS | |||||
NL_RTM_GETTCLASS, | |||||
#define NL_RTM_GETTCLASS NL_RTM_GETTCLASS | |||||
NL_RTM_NEWTFILTER = 44, | |||||
#define NL_RTM_NEWTFILTER NL_RTM_NEWTFILTER | |||||
NL_RTM_DELTFILTER, | |||||
#define NL_RTM_DELTFILTER NL_RTM_DELTFILTER | |||||
NL_RTM_GETTFILTER, | |||||
#define NL_RTM_GETTFILTER NL_RTM_GETTFILTER | |||||
NL_RTM_NEWACTION = 48, | |||||
#define NL_RTM_NEWACTION NL_RTM_NEWACTION | |||||
NL_RTM_DELACTION, | |||||
#define NL_RTM_DELACTION NL_RTM_DELACTION | |||||
NL_RTM_GETACTION, | |||||
#define NL_RTM_GETACTION NL_RTM_GETACTION | |||||
NL_RTM_NEWPREFIX = 52, | |||||
#define NL_RTM_NEWPREFIX NL_RTM_NEWPREFIX | |||||
NL_RTM_GETMULTICAST = 58, | |||||
#define NL_RTM_GETMULTICAST NL_RTM_GETMULTICAST | |||||
NL_RTM_GETANYCAST = 62, | |||||
#define NL_RTM_GETANYCAST NL_RTM_GETANYCAST | |||||
NL_RTM_NEWNEIGHTBL = 64, | |||||
#define NL_RTM_NEWNEIGHTBL NL_RTM_NEWNEIGHTBL | |||||
NL_RTM_GETNEIGHTBL = 66, | |||||
#define NL_RTM_GETNEIGHTBL NL_RTM_GETNEIGHTBL | |||||
NL_RTM_SETNEIGHTBL, | |||||
#define NL_RTM_SETNEIGHTBL NL_RTM_SETNEIGHTBL | |||||
NL_RTM_NEWNDUSEROPT = 68, | |||||
#define NL_RTM_NEWNDUSEROPT NL_RTM_NEWNDUSEROPT | |||||
NL_RTM_NEWADDRLABEL = 72, | |||||
#define NL_RTM_NEWADDRLABEL NL_RTM_NEWADDRLABEL | |||||
NL_RTM_DELADDRLABEL, | |||||
#define NL_RTM_DELADDRLABEL NL_RTM_DELADDRLABEL | |||||
NL_RTM_GETADDRLABEL, | |||||
#define NL_RTM_GETADDRLABEL NL_RTM_GETADDRLABEL | |||||
NL_RTM_GETDCB = 78, | |||||
#define NL_RTM_GETDCB NL_RTM_GETDCB | |||||
NL_RTM_SETDCB, | |||||
#define NL_RTM_SETDCB NL_RTM_SETDCB | |||||
NL_RTM_NEWNETCONF = 80, | |||||
#define NL_RTM_NEWNETCONF NL_RTM_NEWNETCONF | |||||
NL_RTM_GETNETCONF = 82, | |||||
#define NL_RTM_GETNETCONF NL_RTM_GETNETCONF | |||||
NL_RTM_NEWMDB = 84, | |||||
#define NL_RTM_NEWMDB NL_RTM_NEWMDB | |||||
NL_RTM_DELMDB = 85, | |||||
#define NL_RTM_DELMDB NL_RTM_DELMDB | |||||
NL_RTM_GETMDB = 86, | |||||
#define NL_RTM_GETMDB NL_RTM_GETMDB | |||||
NL_RTM_NEWNSID = 88, | |||||
#define NL_RTM_NEWNSID NL_RTM_NEWNSID | |||||
NL_RTM_DELNSID = 89, | |||||
#define NL_RTM_DELNSID NL_RTM_DELNSID | |||||
NL_RTM_GETNSID = 90, | |||||
#define NL_RTM_GETNSID NL_RTM_GETNSID | |||||
NL_RTM_NEWSTATS = 92, | |||||
#define NL_RTM_NEWSTATS NL_RTM_NEWSTATS | |||||
NL_RTM_GETSTATS = 94, | |||||
#define NL_RTM_GETSTATS NL_RTM_GETSTATS | |||||
NL_RTM_NEWNEXTHOP = 104, | |||||
#define NL_RTM_NEWNEXTHOP NL_RTM_NEWNEXTHOP | |||||
NL_RTM_DELNEXTHOP, | |||||
#define NL_RTM_DELNEXTHOP NL_RTM_DELNEXTHOP | |||||
NL_RTM_GETNEXTHOP, | |||||
#define NL_RTM_GETNEXTHOP NL_RTM_GETNEXTHOP | |||||
__NL_RTM_MAX, | |||||
#define NL_RTM_MAX (((__NL_RTM_MAX + 3) & ~3) - 1) | |||||
}; | |||||
#ifndef _KERNEL | |||||
/* | |||||
* RTM_* namespace clashes with BSD rtsock namespace. | |||||
* Use NL_RTM_ prefix in the kernel and map it to RTM_ | |||||
* for userland. | |||||
*/ | |||||
#define RTM_BASE NL_RTM_BASE | |||||
#define RTM_NEWLINK NL_RTM_NEWLINK | |||||
#define RTM_DELLINK NL_RTM_DELLINK | |||||
#define RTM_GETLINK NL_RTM_GETLINK | |||||
#define RTM_SETLINK NL_RTM_SETLINK | |||||
#define RTM_NEWADDR NL_RTM_NEWADDR | |||||
#define RTM_DELADDR NL_RTM_DELADDR | |||||
#define RTM_GETADDR NL_RTM_GETADDR | |||||
#define RTM_NEWROUTE NL_RTM_NEWROUTE | |||||
#define RTM_DELROUTE NL_RTM_DELROUTE | |||||
#define RTM_GETROUTE NL_RTM_GETROUTE | |||||
#endif | |||||
/* | |||||
* route attribute header | |||||
*/ | |||||
struct rtattr { | |||||
unsigned short rta_len; | |||||
unsigned short rta_type; | |||||
}; | |||||
#ifndef _roundup2 | |||||
#define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ | |||||
#endif | |||||
#define NL_RTA_ALIGN_SIZE sizeof(uint32_t) | |||||
#define NL_RTA_ALIGN(_len) _roundup2(_len, NL_RTA_ALIGN_SIZE) | |||||
#define _NL_RTA_BASE_LEN NL_RTA_ALIGN(sizeof(struct rtattr)) | |||||
#define NL_RTA_DATA_LEN(_rta) ((int)((_rta)->rta_len - _NL_RTA_BASE_LEN)) | |||||
#define NL_RTA_DATA(_rta) ((void *)((char *)(_rta) + _NL_RTA_BASE_LEN)) | |||||
#define NL_RTA_DATA_CONST(_rta) ((const void *)((const char *)(_rta) + _NL_RTA_BASE_LEN)) | |||||
/* Compatibility attribute handling helpers */ | |||||
#ifndef _KERNEL | |||||
#define RTA_ALIGNTO NL_RTA_ALIGN_SIZE | |||||
#define RTA_ALIGN(_len) NL_RTA_ALIGN(_len) | |||||
#define _RTA_ALIGNED_LEN(_rta) RTA_ALIGN((_rta)->rta_len) | |||||
#define _RTA_OK(_rta, _len, _sz) \ | |||||
(((_len) >= (_sz)) && ((_rta)->rta_len >= (_sz)) && ((_rta)->rta_len <= (_len))) | |||||
#define RTA_OK(_rta, _len) _RTA_OK(_rta, _len, sizeof(struct rtattr)) | |||||
#define RTA_NEXT(_rta, _len) \ | |||||
((_len) -= RTA_ALIGNED_LEN, (_rta) = (struct rtattr *)((char *)(_rta) + RTA_ALIGNED_LEN)) | |||||
#define RTA_LENGTH(_len) (sizeof(struct rtattr) + (_len)) | |||||
#define RTA_SPACE(_len) RTA_ALIGN(RTA_LENGTH(_len)) | |||||
#define RTA_DATA(_rta) NL_RTA_DATA(_rta) | |||||
#define RTA_PAYLOAD(_rta) ((int)((_rta)->rta_len) - sizeof(struct rtattr)) | |||||
#define RTM_RTA(_rtm) \ | |||||
((struct rtattr *)(((char *)(_rtm)) + NLMSG_ALIGN(sizeof(struct rtmsg)))) | |||||
#define RTM_PAYLOAD(_msg) NLMSG_PAYLOAD((_msg), sizeof(struct rtmsg)) | |||||
#endif | |||||
enum rtattr_type_t { | |||||
NL_RTA_UNSPEC, | |||||
NL_RTA_DST, | |||||
NL_RTA_SRC, | |||||
NL_RTA_IIF, | |||||
NL_RTA_OIF, | |||||
NL_RTA_GATEWAY, | |||||
NL_RTA_PRIORITY, | |||||
NL_RTA_PREFSRC, | |||||
NL_RTA_METRICS, | |||||
NL_RTA_MULTIPATH, | |||||
NL_RTA_PROTOINFO, /* not used / deprecated */ | |||||
NL_RTA_FLOW, | |||||
NL_RTA_CACHEINFO, /* not used */ | |||||
NL_RTA_SESSION, /* not used / deprecated */ | |||||
NL_RTA_MP_ALGO, /* not used / deprecated */ | |||||
NL_RTA_TABLE, | |||||
NL_RTA_MARK, /* not used */ | |||||
NL_RTA_MFC_STATS, | |||||
NL_RTA_VIA, | |||||
NL_RTA_NEWDST, | |||||
NL_RTA_PREF, | |||||
NL_RTA_ENCAP_TYPE, | |||||
NL_RTA_ENCAP, | |||||
NL_RTA_EXPIRES, | |||||
NL_RTA_PAD, | |||||
NL_RTA_UID, | |||||
NL_RTA_TTL_PROPAGATE, | |||||
NL_RTA_IP_PROTO, | |||||
NL_RTA_SPORT, | |||||
NL_RTA_DPORT, | |||||
NL_RTA_NH_ID, | |||||
__RTA_MAX | |||||
}; | |||||
#define NL_RTA_MAX (__RTA_MAX - 1) | |||||
#ifndef _KERNEL | |||||
/* | |||||
* RTA_* space has clashes with rtsock namespace. | |||||
* Use NL_RTA_ prefix in the kernel and map to | |||||
* RTA_ for userland. | |||||
*/ | |||||
#define RTA_UNSPEC NL_RTA_UNSPEC | |||||
#define RTA_DST NL_RTA_DST | |||||
#define RTA_SRC NL_RTA_SRC | |||||
#define RTA_IIF NL_RTA_IIF | |||||
#define RTA_OIF NL_RTA_OIF | |||||
#define RTA_GATEWAY NL_RTA_GATEWAY | |||||
#define RTA_PRIORITY NL_RTA_PRIORITY | |||||
#define RTA_PREFSRC NL_RTA_PREFSRC | |||||
#define RTA_METRICS NL_RTA_METRICS | |||||
#define RTA_MULTIPATH NL_RTA_MULTIPATH | |||||
#define RTA_PROTOINFO NL_RTA_PROTOINFO | |||||
#define RTA_FLOW NL_RTA_FLOW | |||||
#define RTA_CACHEINFO NL_RTA_CACHEINFO | |||||
#define RTA_SESSION NL_RTA_SESSION | |||||
#define RTA_MP_ALGO NL_RTA_MP_ALGO | |||||
#define RTA_TABLE NL_RTA_TABLE | |||||
#define RTA_MARK NL_RTA_MARK | |||||
#define RTA_MFC_STATS NL_RTA_MFC_STATS | |||||
#define RTA_VIA NL_RTA_VIA | |||||
#define RTA_NEWDST NL_RTA_NEWDST | |||||
#define RTA_PREF NL_RTA_PREF | |||||
#define RTA_ENCAP_TYPE NL_RTA_ENCAP_TYPE | |||||
#define RTA_ENCAP NL_RTA_ENCAP | |||||
#define RTA_EXPIRES NL_RTA_EXPIRES | |||||
#define RTA_PAD NL_RTA_PAD | |||||
#define RTA_UID NL_RTA_UID | |||||
#define RTA_TTL_PROPAGATE NL_RTA_TTL_PROPAGATE | |||||
#define RTA_IP_PROTO NL_RTA_IP_PROTO | |||||
#define RTA_SPORT NL_RTA_SPORT | |||||
#define RTA_DPORT NL_RTA_DPORT | |||||
#define RTA_NH_ID NL_RTA_NH_ID | |||||
#define RTA_MAX NL_RTA_MAX | |||||
#endif | |||||
#endif | |||||
No newline at end of file |