diff options
| author | Volodymyr Huti <v.huti@vyos.io> | 2023-11-13 22:47:31 +0200 | 
|---|---|---|
| committer | Dave LeRoy <dleroy@labn.net> | 2024-06-10 16:39:21 -0700 | 
| commit | 51f070028692260ea19b5ef0f489c56de5683bbc (patch) | |
| tree | 98353987ecb6261f9157955c710b44b973909faf /nhrpd/nhrp_packet.c | |
| parent | d5b0c76eddc8c30b8306ed7f53f6c8d94f4b0c37 (diff) | |
nhrp: add `cisco-authentication` password support
Implemented:
- handling 8 char long password, aka Cisco style.
- minimal error inidication routine
- test case, password change affects conection
Signed-off-by: Volodymyr Huti <v.huti@vyos.io>
Diffstat (limited to 'nhrpd/nhrp_packet.c')
| -rw-r--r-- | nhrpd/nhrp_packet.c | 27 | 
1 files changed, 22 insertions, 5 deletions
diff --git a/nhrpd/nhrp_packet.c b/nhrpd/nhrp_packet.c index c6bd3bbbde..71f5c2f007 100644 --- a/nhrpd/nhrp_packet.c +++ b/nhrpd/nhrp_packet.c @@ -115,14 +115,32 @@ uint16_t nhrp_packet_calculate_checksum(const uint8_t *pdu, uint16_t len)  	return (~csum) & 0xffff;  } -void nhrp_packet_complete(struct zbuf *zb, struct nhrp_packet_header *hdr) +void nhrp_packet_complete(struct zbuf *zb, struct nhrp_packet_header *hdr, +			  struct interface *ifp)  { +	nhrp_packet_complete_auth(zb, hdr, ifp, true); +} + +void nhrp_packet_complete_auth(struct zbuf *zb, struct nhrp_packet_header *hdr, +			       struct interface *ifp, bool auth) +{ +	struct nhrp_interface *nifp = ifp->info; +	struct zbuf *auth_token = nifp->auth_token; +	struct nhrp_extension_header *dst;  	unsigned short size; +	if (auth && auth_token) { +		dst = nhrp_ext_push(zb, hdr, +				    NHRP_EXTENSION_AUTHENTICATION | +					    NHRP_EXTENSION_FLAG_COMPULSORY); +		zbuf_copy_peek(zb, auth_token, zbuf_size(auth_token)); +		nhrp_ext_complete(zb, dst); +	} +  	if (hdr->extension_offset)  		nhrp_ext_push(zb, hdr, -			      NHRP_EXTENSION_END -				      | NHRP_EXTENSION_FLAG_COMPULSORY); +			      NHRP_EXTENSION_END | +				      NHRP_EXTENSION_FLAG_COMPULSORY);  	size = zb->tail - (uint8_t *)hdr;  	hdr->packet_size = htons(size); @@ -225,8 +243,7 @@ struct nhrp_extension_header *nhrp_ext_pull(struct zbuf *zb,  	return ext;  } -void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr, -		      struct interface *ifp) +void nhrp_ext_request(struct zbuf *zb, struct nhrp_packet_header *hdr)  {  	/* Place holders for standard extensions */  	nhrp_ext_push(zb, hdr,  | 
