resolv.h
Go to the documentation of this file.00001 #ifndef _GPXE_RESOLV_H
00002 #define _GPXE_RESOLV_H
00003
00004
00005
00006
00007
00008
00009
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011
00012 #include <gpxe/refcnt.h>
00013 #include <gpxe/interface.h>
00014 #include <gpxe/tables.h>
00015 #include <gpxe/socket.h>
00016
00017 struct resolv_interface;
00018
00019
00020 struct resolv_interface_operations {
00021
00022
00023
00024
00025
00026
00027 void ( * done ) ( struct resolv_interface *resolv,
00028 struct sockaddr *sa, int rc );
00029 };
00030
00031
00032 struct resolv_interface {
00033
00034 struct interface intf;
00035
00036 struct resolv_interface_operations *op;
00037 };
00038
00039 extern struct resolv_interface null_resolv;
00040 extern struct resolv_interface_operations null_resolv_ops;
00041
00042
00043
00044
00045
00046
00047
00048
00049 static inline void resolv_init ( struct resolv_interface *resolv,
00050 struct resolv_interface_operations *op,
00051 struct refcnt *refcnt ) {
00052 resolv->intf.dest = &null_resolv.intf;
00053 resolv->intf.refcnt = refcnt;
00054 resolv->op = op;
00055 }
00056
00057
00058
00059
00060
00061
00062
00063 static inline __attribute__ (( always_inline )) struct resolv_interface *
00064 intf_to_resolv ( struct interface *intf ) {
00065 return container_of ( intf, struct resolv_interface, intf );
00066 }
00067
00068
00069
00070
00071
00072
00073
00074 static inline __attribute__ (( always_inline )) struct resolv_interface *
00075 resolv_get_dest ( struct resolv_interface *resolv ) {
00076 return intf_to_resolv ( intf_get ( resolv->intf.dest ) );
00077 }
00078
00079
00080
00081
00082
00083
00084 static inline __attribute__ (( always_inline )) void
00085 resolv_put ( struct resolv_interface *resolv ) {
00086 intf_put ( &resolv->intf );
00087 }
00088
00089
00090
00091
00092
00093
00094
00095 static inline __attribute__ (( always_inline )) void
00096 resolv_plug ( struct resolv_interface *resolv, struct resolv_interface *dest ) {
00097 plug ( &resolv->intf, &dest->intf );
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 static inline __attribute__ (( always_inline )) void
00107 resolv_plug_plug ( struct resolv_interface *a, struct resolv_interface *b ) {
00108 plug_plug ( &a->intf, &b->intf );
00109 }
00110
00111
00112
00113
00114
00115
00116 static inline __attribute__ (( always_inline )) void
00117 resolv_unplug ( struct resolv_interface *resolv ) {
00118 plug ( &resolv->intf, &null_resolv.intf );
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 static inline void resolv_nullify ( struct resolv_interface *resolv ) {
00130 resolv->op = &null_resolv_ops;
00131 };
00132
00133
00134 struct resolver {
00135
00136 const char *name;
00137
00138
00139
00140
00141
00142
00143
00144 int ( * resolv ) ( struct resolv_interface *resolv, const char *name,
00145 struct sockaddr *sa );
00146 };
00147
00148
00149 #define RESOLV_NUMERIC 01
00150
00151
00152 #define RESOLV_NORMAL 02
00153
00154
00155 #define RESOLVERS __table ( struct resolver, "resolvers" )
00156
00157
00158 #define __resolver( resolv_order ) __table_entry ( RESOLVERS, resolv_order )
00159
00160 extern void resolv_done ( struct resolv_interface *resolv,
00161 struct sockaddr *sa, int rc );
00162 extern void ignore_resolv_done ( struct resolv_interface *resolv,
00163 struct sockaddr *sa, int rc );
00164 extern struct resolv_interface_operations null_resolv_ops;
00165 extern struct resolv_interface null_resolv;
00166
00167 extern int resolv ( struct resolv_interface *resolv, const char *name,
00168 struct sockaddr *sa );
00169
00170 #endif